/* ==========================================================================
   OpenQR Studio – app shell (create page). Loaded after style.css and reuses its tokens.
   ========================================================================== */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 16px 18px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.sidebar .brand { padding: 2px 10px 22px; }
.side-nav { display: grid; gap: 4px; }
.side-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  color: var(--muted); font-weight: 500; text-decoration: none;
  transition: background-color .15s, color .15s;
}
.side-link:hover { background: #f3f4f6; color: var(--ink); }
.side-link[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side-link svg.icon { width: 20px; height: 20px; }
.side-sep { height: 1px; background: var(--line); margin: 14px 6px; }
.side-note {
  margin-top: auto; display: flex; gap: 10px; align-items: flex-start;
  background: var(--brand-soft); border-radius: 14px; padding: 14px;
  font-size: 0.8125rem; line-height: 1.45; color: var(--ink);
}
.side-note .ico { color: var(--brand); margin-top: 1px; }
.side-note p { margin: 0; }

/* ---------- Main ---------- */
.app-main { min-width: 0; padding-bottom: 72px; padding-left: 0; }
.app-main .stepper-bar { border-top: 0; }
.app-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 32px 0 8px; }
.app-head h1 { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.02em; }
.step h1 { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.02em; }

.empty {
  margin-top: 24px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 64px 24px;
}
.empty-icon { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); margin-bottom: 18px; }
.empty-icon svg.icon { width: 28px; height: 28px; }
.empty h2 { font-size: 1.25rem; font-weight: 600; }
.empty p { color: var(--muted); margin-top: 6px; }
.mobile-footer { display: none; }

/* ---------- Step 2: content form ---------- */
.step-form { text-align: left; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; margin-top: 32px; align-items: start; }
.content-form { display: grid; gap: 20px; max-width: 620px; }
#content-fields { display: grid; gap: 20px; }
.field label, .field-label { display: block; font-weight: 600; font-size: 0.9375rem; margin-bottom: 6px; }
.field .req { color: #be123c; }
.field input[type="text"], .field input[type="tel"], .field input[type="email"], .field select, .field textarea {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid #7d8492; border-radius: 12px;
}
.field textarea { resize: vertical; min-height: 96px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--brand); }
.field [aria-invalid="true"] { border-color: #be123c; }
.field [aria-invalid="true"]:focus { border-color: #be123c; outline-color: rgba(190, 18, 60, 0.35); }
.field input:disabled { background: #f3f4f6; color: var(--muted); }
.field-msg { color: #be123c; font-size: 0.875rem; margin-top: 6px; }
.field-msg:empty { display: none; }
.field-hint { color: var(--muted); font-size: 0.8125rem; margin-top: 6px; }
.field label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin-bottom: 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-status { min-height: 1.4em; color: #be123c; font-size: 0.9rem; }
.form-actions { display: flex; gap: 12px; justify-content: space-between; }
.preview { position: sticky; top: 24px; }
.preview h2 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.preview-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow); }
#preview-qr > svg { display: block; width: 100%; height: auto; }
.preview-empty { aspect-ratio: 1 / 1; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; color: var(--muted); background: #f3f4f6; border-radius: 12px; padding: 20px; font-size: 0.875rem; }
.preview-empty svg.icon { width: 40px; height: 40px; }
.preview-empty p { margin: 0; }
.stub-box { max-width: 620px; margin: 24px auto 0; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stub-box pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-all; font: 0.875rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- Small screens: sidebar becomes a top bar ---------- */
@media (max-width: 900px) {
  .auth-details { display: none; }
  .auth-bar { background: transparent; padding: 4px 8px; margin: 0; border-radius: 10px; font-size: 0.75rem; }
  .auth-avatar { width: 28px; height: 28px; }
  .auth-name { font-size: 0.75rem; }
  .auth-quota { font-size: 0.7rem; }
  .auth-bar .btn-sm { font-size: 0.7rem; padding: 4px 8px; }
  #auth-sidebar a.side-link { display: none; }
  .code-grid { grid-template-columns: repeat(2, 1fr); }
  .mobile-footer { display: flex; align-items: center; gap: 16px; justify-content: center; padding: 20px 16px 32px; border-top: 1px solid var(--line); font-size: 0.875rem; }
  .mobile-footer a { color: var(--muted); text-decoration: none; font-weight: 500; }
  .mobile-footer a:hover { color: var(--ink); }
  .mobile-footer svg.icon { width: 22px; height: 22px; }
  .side-link[data-donate] { display: none; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .form-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .preview { position: static; }
  .sidebar {
    height: auto; flex-direction: row; align-items: center; gap: 6px;
    padding: 8px 12px; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--line); z-index: 20;
  }
  .sidebar .brand { padding: 0 8px 0 4px; flex: none; }
  .side-nav { display: flex; gap: 2px; }
  .side-link { padding: 9px 12px; white-space: nowrap; }
  .side-sep, .side-note { display: none; }
  nav[aria-label="Help"] { display: none; }
}
@media (max-width: 520px) {
  .app-head { flex-wrap: wrap; }
  .sidebar .brand span { display: none; }
  .side-link { min-height: 44px; min-width: 44px; justify-content: center; padding: 10px 12px; }
  .side-link span { font-size: 0.875rem; }
  /* only the active link keeps a visible label; the others stay readable to screen readers */
  .side-link:not([aria-current="page"]):not(.folder-item):not(.btn-new-folder) span {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
}

/* ---------- Step 3: design ---------- */
.field input[type="color"] { width: 64px; height: 44px; padding: 4px; background: var(--surface); border: 1px solid #7d8492; border-radius: 12px; cursor: pointer; }
.form-actions { flex-wrap: wrap; }
.dl-group { display: flex; gap: 10px; flex-wrap: wrap; }
#design-preview > svg { display: block; width: 100%; height: auto; }


/* ---------- Step 3: pickers ---------- */
.pick { border: 0; padding: 0; margin: 0; min-width: 0; }
.pick legend { padding: 0; margin-bottom: 10px; font-weight: 600; font-size: 0.9375rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; }
.tile { position: relative; display: block; }
.tile input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.tile-art { display: block; width: 68px; height: 68px; padding: 9px; background: var(--surface); border: 1px solid #b6bcc7; border-radius: 12px; }
.tile-art svg { display: block; width: 100%; height: 100%; }
.tile:hover .tile-art { border-color: var(--brand); }
.tile input:checked + .tile-art { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.tile input:focus-visible + .tile-art { outline: 3px solid var(--focus); outline-offset: 2px; }
.seg { display: inline-flex; margin-bottom: 12px; padding: 3px; background: var(--surface); border: 1px solid #7d8492; border-radius: 999px; }
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span { display: block; padding: 7px 18px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; color: var(--muted); }
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.color-row { display: flex; flex-wrap: wrap; gap: 12px; }
.color-field { display: inline-flex; align-items: center; gap: 8px; }
.color-field .hex { width: 128px; padding: 11px 12px; font: 0.95rem ui-monospace, Menlo, Consolas, monospace; color: var(--ink); background: var(--surface); border: 1px solid #7d8492; border-radius: 12px; }
.color-field .hex:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--brand); }
.color-field .hex[aria-invalid="true"] { border-color: #be123c; }
.color-field input[type="color"] { width: 44px; height: 44px; padding: 3px; background: var(--surface); border: 1px solid #7d8492; border-radius: 12px; cursor: pointer; }
.color-field input:disabled { opacity: 0.45; cursor: not-allowed; }
.range-row { display: grid; gap: 6px; margin-top: 14px; font-size: 0.9rem; font-weight: 500; }
.range-row input { width: 100%; accent-color: var(--brand); }
.pick .check { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-weight: 500; cursor: pointer; }
#design-preview.checker { background: repeating-conic-gradient(#d6d9de 0% 25%, #fff 0% 50%) 50% / 16px 16px; border-radius: 8px; }

/* the active step label ("Customize & download") may wrap on phones instead of pushing the page sideways */
@media (max-width: 700px) {
  .stepper li:last-child { min-width: 0; }
  .stepper li.is-active .label { white-space: normal; line-height: 1.25; }
}

/* ---------- Step 3: tabs, logo screen, size ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 10px; }
.pill-tab { padding: 10px 20px; font: inherit; font-weight: 500; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.pill-tab:hover { border-color: #b6bcc7; color: var(--ink); }
.pill-tab[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.panel { display: grid; gap: 20px; }
.dropzone { position: relative; display: grid; justify-items: center; gap: 6px; padding: 28px 16px; text-align: center; color: var(--ink); background: var(--surface); border: 1.5px dashed #9aa1ae; border-radius: 16px; cursor: pointer; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone svg.icon { width: 24px; height: 24px; color: var(--muted); }
.dz-title { font-weight: 500; }
.dz-hint { font-size: 0.8125rem; color: var(--muted); }
.scale-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.scale-row label { font-weight: 600; white-space: nowrap; }
.scale-row input[type="range"] { flex: 1 1 110px; min-width: 0; accent-color: var(--brand); }
.scale-row output { min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.scale-thumb { display: grid; place-items: center; width: 40px; height: 40px; flex: none; overflow: hidden; background: #f3f4f6; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); }
.scale-thumb img { width: 100%; height: 100%; object-fit: contain; }
.scale-thumb svg.icon { width: 20px; height: 20px; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: #eceef2; color: var(--ink); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.size-pick { margin-top: 18px; }
.size-pick .seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: transparent; border: 0; border-radius: 0; margin-bottom: 10px; }
.size-pick .seg label span { border: 1px solid #b6bcc7; border-radius: 12px; text-align: center; font-size: 0.875rem; }
.size-pick .seg input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.preview .dl-group { margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.preview .dl-group .btn { width: 100%; justify-content: center; }
.panel .form-status { min-height: 0; margin: -10px 0; }

/* ---------- My QR codes ---------- */
.app-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lib-toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.lib-search { flex: 1 1 200px; padding: 10px 14px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #7d8492; border-radius: 12px; }
.lib-search:focus { outline: 3px solid var(--focus); border-color: var(--brand); }
.lib-sort { padding: 10px 14px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #7d8492; border-radius: 12px; cursor: pointer; }
.lib-status { font-size: 0.875rem; color: var(--muted); margin-bottom: 16px; min-height: 1.4em; }
.code-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; width: 100%; }
.code-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 1px 4px rgba(0,0,0,.06); transition: box-shadow .15s, border-color .15s; }
.code-card:hover { border-color: var(--brand); box-shadow: 0 4px 16px rgba(79,70,229,.12); }
.card-qr { padding: 12px; background: #fff; aspect-ratio: 1; display: grid; place-items: center; border-bottom: 2px solid var(--brand); }
.card-qr svg { display: block; width: 100%; height: auto; }
.card-qr-err { font-size: 2rem; color: var(--muted); }
.card-body { padding: 10px 12px 6px; flex: 1; }
.card-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0 0 2px; }
.card-type { font-size: 0.75rem; color: var(--muted); margin: 0; text-transform: uppercase; letter-spacing: .04em; }
.card-actions { display: flex; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.card-actions .btn-sm { padding: 5px 8px; font-size: 0.75rem; }
.card-delete { color: #be123c !important; }
.card-delete:hover { background: #fee2e2 !important; color: #be123c !important; }
.btn-sm { padding: 6px 12px; font-size: 0.8125rem; border-radius: 999px; }
.lib-empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.lib-empty .empty-icon { display: block; font-size: 2.5rem; margin-bottom: 12px; }
.lib-pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 24px 0; font-size: 0.9rem; color: var(--muted); }

/* ---------- Dialog ---------- */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 100; padding: 20px; }
.dialog-backdrop[hidden] { display: none; }
.dialog { background: var(--surface); border-radius: var(--radius-lg); box-shadow: 0 8px 40px rgba(0,0,0,.18); padding: 28px; max-width: 400px; width: 100%; }
.dialog h2 { font-size: 1.1rem; font-weight: 650; margin: 0 0 8px; }
.dialog p { color: var(--muted); font-size: 0.9375rem; margin: 0 0 22px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Auth ---------- */
.auth-bar { display: flex; align-items: center; gap: 10px; padding: 11px 12px; background: var(--brand-soft); border-radius: 12px; font-size: 0.8125rem; margin-top: 4px; }
.auth-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.auth-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-quota { font-size: 0.75rem; color: var(--muted); }

/* ---------- Folders ---------- */
.folder-nav-main { margin-bottom: 16px; }
.folder-nav-main #folder-list { display: flex; flex-wrap: wrap; gap: 6px; }
.folder-nav-main .side-link { display: inline-flex; width: auto; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 0.875rem; }
.folder-nav-main .folder-row { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.folder-nav-main .folder-item-named { border: 0; border-radius: 999px 0 0 999px; padding-right: 6px; font-size: 0.875rem; }
.folder-nav-main .folder-count { font-size: 0.75rem; color: var(--muted); padding: 0 6px; }
.is-active-folder { background: var(--brand-soft) !important; color: var(--brand) !important; font-weight: 600 !important; border-color: var(--brand) !important; }
.folder-action-btn { display: grid; place-items: center; width: 26px; height: 30px; flex: none; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.folder-action-btn:last-child { border-radius: 0 999px 999px 0; }
.folder-action-btn:not(.folder-menu-btn):hover { background: #eceef2; color: var(--ink); }
.folder-menu-btn:hover { color: var(--ink); }
.folder-action-btn.folder-delete { color: #be123c; }
.folder-action-btn.folder-delete:hover { background: #fee2e2; }
.folder-action-btn svg.icon { width: 13px; height: 13px; }
.folder-nav-main .btn-new-folder { border-style: dashed; color: var(--muted); }
.folder-nav-main .btn-new-folder:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.folder-picker { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; margin-bottom: 16px; }
.folder-picker .folder-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; font-size: 0.9rem; font-weight: 500; color: var(--ink); cursor: pointer; text-align: left; }
.folder-picker .folder-item:hover { border-color: var(--brand); background: var(--brand-soft); }
.folder-picker .folder-item.is-active-folder { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.folder-picker svg.icon { width: 16px; height: 16px; color: var(--muted); flex: none; }
#folder-dialog .field { margin-bottom: 16px; }
#folder-dialog .field input { width: 100%; padding: 10px 12px; font: inherit; border: 1px solid #7d8492; border-radius: 12px; background: var(--surface); color: var(--ink); box-sizing: border-box; }
#folder-dialog .field input:focus { outline: 3px solid var(--focus); border-color: var(--brand); }

.folder-menu-wrap { position: relative; }
.folder-menu-btn { font-size: 1rem; letter-spacing: 1px; width: 28px; padding: 0; text-align: center; }
.folder-dropdown { position: absolute; right: 0; top: 100%; z-index: 50; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.1); min-width: 120px; overflow: hidden; }
.folder-dropdown-item { display: block; width: 100%; padding: 10px 14px; border: 0; background: transparent; font: inherit; font-size: 0.875rem; font-weight: 500; color: var(--ink); cursor: pointer; text-align: left; }
.folder-dropdown-item:hover { background: #f3f4f6; }
.folder-dropdown-item.folder-delete { color: #be123c; }
.folder-dropdown-item.folder-delete:hover { background: #fee2e2; }