/* DocScan Pro — mobile-first UI */
:root {
  --brand: #1a73e8;
  --brand-600: #1557b0;
  --brand-50: #e8f0fe;
  --accent: #00a37a;
  --danger: #d93025;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1f2430;
  --muted: #667085;
  --border: #e3e7ee;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-h: 56px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --surface: #181c24; --text: #e8eaf0; --muted: #98a2b3; --border: #2a303c;
    --brand-50: #1b2a44; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer;
  transition: background .15s, transform .05s, opacity .15s; text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-success { background: var(--accent); color: #fff; }
.btn-outline { border-color: var(--border); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 16px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: inherit;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:hover { background: rgba(127,127,127,.12); }

/* ---------- layout ---------- */
#app { min-height: 100%; }
.view { min-height: 100vh; min-height: 100dvh; padding-top: calc(var(--header-h) + var(--safe-top)); padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px); }
.appbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: calc(var(--header-h) + var(--safe-top)); padding: var(--safe-top) 8px 0;
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.appbar h1 { font-size: 18px; margin: 0 8px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .brand { display: flex; align-items: center; gap: 8px; color: var(--brand); }
.container { max-width: 1100px; margin: 0 auto; padding: 16px; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  height: calc(var(--nav-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  display: flex; align-items: center; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 12px; min-width: 72px; }
.bottom-nav a.active { color: var(--brand); }
.bottom-nav .scan-fab {
  width: 60px; height: 60px; margin-top: -26px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(26,115,232,.45); border: 4px solid var(--bg);
}
.bottom-nav .scan-fab svg { width: 28px; height: 28px; }

/* ---------- cards & forms ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 18px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; font-weight: 700; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg); outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.field-error { color: var(--danger); font-size: 13px; margin-top: 4px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch input { width: 46px; height: 26px; appearance: none; background: var(--border); border-radius: 13px; position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { left: 23px; }
.segmented { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 3px; }
.segmented button { flex: 1; border: 0; background: transparent; border-radius: 9px; min-height: 38px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.auth-logo .logo { width: 64px; height: 64px; border-radius: 18px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; }
.auth-logo .logo svg { width: 34px; height: 34px; }
.auth-logo h2 { margin: 0; }
.auth-logo p { margin: 0; color: var(--muted); }
.auth-switch { text-align: center; margin-top: 16px; color: var(--muted); }
.auth-switch a { color: var(--brand); font-weight: 600; text-decoration: none; cursor: pointer; }

/* ---------- library ---------- */
.search { position: relative; margin-bottom: 14px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 44px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.doc-card { position: relative; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.doc-card .cover { aspect-ratio: 3 / 4; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; border-bottom: 1px solid var(--border); }
.doc-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.doc-card .cover .placeholder { color: var(--muted); }
.doc-card .meta { padding: 10px 12px 12px; }
.doc-card .title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 26px; }
.doc-card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.doc-card .menu { position: absolute; right: 2px; bottom: 8px; width: 36px; height: 36px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; background: var(--brand-50); color: var(--brand); }
.badge.draft { background: #fff4e5; color: #b26a00; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty svg { width: 64px; height: 64px; margin: 0 auto 12px; color: var(--border); stroke-width: 1.5; }
.empty h3 { color: var(--text); margin: 0 0 6px; }

/* ---------- page manager ---------- */
.pages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
.page-tile { position: relative; background: var(--surface); border: 2px solid transparent; border-radius: 12px; box-shadow: var(--shadow); cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.page-tile.selected { border-color: var(--brand); }
.page-tile .thumb { aspect-ratio: 3 / 4; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 10px 10px 0 0; background: var(--bg); }
.page-tile .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform .25s; }
.page-tile .num { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 6px 10px; font-size: 13px; font-weight: 600; }
.page-tile .handle { width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: grab; touch-action: none; border-radius: 8px; }
.page-tile .check { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; display: none; align-items: center; justify-content: center; }
.page-tile.selected .check { display: flex; }
.page-tile .check svg { width: 16px; height: 16px; stroke-width: 3; }
.page-tile.dragging { opacity: .3; }
.page-tile.ghost { position: fixed; z-index: 1000; pointer-events: none; opacity: .95; transform: scale(1.05) rotate(2deg); box-shadow: 0 16px 40px rgba(0,0,0,.3); }
.add-tile { border: 2px dashed var(--border); background: transparent; box-shadow: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--brand); font-weight: 600; min-height: 180px; }
.page-toolbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + var(--safe-bottom));
}
.page-toolbar .tools { display: flex; justify-content: space-around; margin-bottom: 8px; }
.page-toolbar .tool { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--text); background: none; border: 0; padding: 6px 8px; border-radius: 10px; cursor: pointer; min-width: 58px; }
.page-toolbar .tool:disabled { opacity: .35; }
.page-toolbar .tool.danger { color: var(--danger); }
.pdf-list { margin-top: 24px; }
.pdf-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.pdf-item:last-child { border-bottom: 0; }
.pdf-item .pdf-icon { width: 40px; height: 40px; border-radius: 10px; background: #fde8e7; color: var(--danger); display: flex; align-items: center; justify-content: center; flex: none; }
.pdf-item .info { flex: 1; min-width: 0; }
.pdf-item .info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.pdf-item .info small { color: var(--muted); }

/* ---------- sheets, dialogs, toasts ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(15, 18, 24, .5); z-index: 900; opacity: 0; transition: opacity .2s; }
.backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 901; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 18px calc(18px + var(--safe-bottom));
  transform: translateY(100%); transition: transform .25s ease-out; max-width: 640px; margin: 0 auto;
}
.sheet.show { transform: none; }
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 14px; font-size: 18px; }
.sheet .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.action-list button { width: 100%; display: flex; align-items: center; gap: 14px; padding: 14px 6px; border: 0; background: none; border-bottom: 1px solid var(--border); text-align: left; cursor: pointer; font-weight: 500; }
.action-list button:last-child { border-bottom: 0; }
.action-list button.danger { color: var(--danger); }
.dialog {
  position: fixed; z-index: 902; left: 50%; top: 50%; transform: translate(-50%, -46%) scale(.96); opacity: 0;
  width: calc(100% - 40px); max-width: 400px; background: var(--surface); border-radius: 18px; padding: 22px; transition: all .2s;
}
.dialog.show { opacity: 1; transform: translate(-50%, -50%); }
.dialog h3 { margin: 0 0 8px; }
.dialog p { margin: 0 0 14px; color: var(--muted); }
.dialog .buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px); z-index: 2000; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: #222733; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: toast-in .2s ease-out; max-width: 480px; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.loader { position: fixed; inset: 0; z-index: 3000; background: rgba(15,18,24,.55); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: #fff; font-weight: 600; }
.spinner { width: 44px; height: 44px; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { width: 220px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.25); overflow: hidden; }
.progress > div { height: 100%; background: #fff; width: 0; transition: width .2s; }

/* ---------- scanner (camera) ---------- */
.scanner { position: fixed; inset: 0; z-index: 500; background: #000; color: #fff; display: flex; flex-direction: column; }
.scanner-top, .editor-top { display: flex; align-items: center; justify-content: space-between; padding: calc(8px + var(--safe-top)) 8px 8px; z-index: 2; }
.scanner-top .pill { background: rgba(255,255,255,.14); border-radius: 20px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
.cam-stage { position: relative; flex: 1; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.cam-stage video { width: 100%; height: 100%; object-fit: contain; }
.cam-stage canvas.overlay { position: absolute; pointer-events: none; }
.cam-hint { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.55); padding: 6px 14px; border-radius: 20px; font-size: 13px; white-space: nowrap; transition: background .2s; }
.cam-hint.ok { background: rgba(0,163,122,.85); }
.cam-fallback { text-align: center; padding: 24px; max-width: 360px; }
.cam-fallback p { color: #c9ced8; }
.scanner-bottom { display: flex; align-items: center; justify-content: space-between; padding: 18px 26px calc(22px + var(--safe-bottom)); }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: transparent; padding: 4px; cursor: pointer; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s; }
.shutter:active span { transform: scale(.9); }
.stack-btn { width: 56px; height: 56px; border-radius: 10px; border: 2px solid rgba(255,255,255,.8); background: #222 center/cover no-repeat; position: relative; cursor: pointer; color: #fff; }
.stack-btn .count { position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--brand); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.side-btn { width: 56px; display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; color: #fff; font-size: 11px; cursor: pointer; }
.chip-toggle { background: rgba(255,255,255,.14); border: 0; color: #fff; border-radius: 16px; padding: 6px 12px; font-size: 12px; font-weight: 700; cursor: pointer; }
.chip-toggle.on { background: var(--brand); }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .25s; }
@keyframes flash { 30% { opacity: .8; } }

/* ---------- editor (crop + enhance) ---------- */
.editor { position: fixed; inset: 0; z-index: 510; background: #111418; color: #fff; display: flex; flex-direction: column; }
.editor-top h2 { font-size: 16px; margin: 0; }
.edit-stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 20px; touch-action: none; }
.edit-stage canvas.src { max-width: 100%; max-height: 100%; display: block; }
.edit-stage svg.quad { position: absolute; overflow: visible; pointer-events: none; }
.edit-stage svg.quad polygon { fill: rgba(26,115,232,.18); stroke: #4d9bff; stroke-width: 2; }
.handle-pt { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; touch-action: none; cursor: grab; display: flex; align-items: center; justify-content: center; }
.handle-pt::after { content: ""; width: 22px; height: 22px; border-radius: 50%; background: rgba(26,115,232,.35); border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.5); }
.handle-pt.active::after { background: #1a73e8; }
.loupe { position: absolute; width: 110px; height: 110px; border-radius: 50%; border: 3px solid #fff; overflow: hidden; box-shadow: 0 4px 16px rgba(0,0,0,.5); pointer-events: none; top: 16px; left: 16px; }
.loupe.right { left: auto; right: 16px; }
.loupe::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid #4d9bff; border-radius: 50%; }
.edit-result { max-width: 100%; max-height: 100%; box-shadow: 0 6px 24px rgba(0,0,0,.5); transition: transform .25s; background: #fff; }
.filter-bar { display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-bar button { flex: none; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); color: #fff; border-radius: 18px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.filter-bar button.active { background: var(--brand); border-color: var(--brand); }
.edit-tools { display: flex; justify-content: space-around; padding: 6px 4px; }
.edit-tools button { background: none; border: 0; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; padding: 6px; min-width: 56px; cursor: pointer; border-radius: 10px; }
.edit-tools button:hover { background: rgba(255,255,255,.08); }
.edit-actions { display: flex; gap: 10px; padding: 8px 14px calc(14px + var(--safe-bottom)); }
.edit-actions .btn { flex: 1; }
.edit-actions .btn-outline { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.busy-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.35); }

/* ---------- viewer & result ---------- */
.viewer { position: fixed; inset: 0; z-index: 520; background: #0b0d10; color: #fff; display: flex; flex-direction: column; }
.viewer-stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 12px; }
.viewer-stage img { max-width: 100%; max-height: 100%; transition: transform .25s; background: #fff; }
.viewer-nav { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px calc(12px + var(--safe-bottom)); }
.result { text-align: center; padding-top: 12px; }
.result .ok-icon { width: 84px; height: 84px; border-radius: 50%; background: #e6f6f1; color: var(--accent); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.result .ok-icon svg { width: 44px; height: 44px; stroke-width: 2.5; }
.result h2 { margin: 0 0 4px; }
.result .file { margin: 18px auto; display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px; max-width: 420px; }
.result .buttons { display: grid; gap: 10px; max-width: 420px; margin: 0 auto; }
.result .buttons .row .btn { flex: 1; }
.pdf-frame { width: 100%; height: 70vh; border: 0; border-radius: 12px; background: #fff; }
.page-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.page-chips button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); font-weight: 700; cursor: pointer; }
.page-chips button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; justify-content: space-between; gap: 12px; }
.list li:last-child { border-bottom: 0; }
.list li small { color: var(--muted); white-space: nowrap; }

@media (min-width: 768px) {
  .doc-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
  .pages-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; }
  .sheet { border-radius: 20px; bottom: 24px; }
}

/* =====================================================================
   3D BUTTON THEME
   Raised buttons with a solid "edge" underneath; they press down on tap.
   ===================================================================== */
:root {
  --edge-neutral: #c6cedb;
  --edge-primary: #0f4fa8;
  --edge-success: #007a5a;
  --edge-danger: #a52019;
  --lift: 4px;
}
@media (prefers-color-scheme: dark) {
  :root { --edge-neutral: #07090d; }
}

.btn:not(.btn-ghost) {
  position: relative;
  border: 1px solid var(--edge-neutral);
  background: linear-gradient(180deg, #ffffff 0%, #eef2f7 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .9),
    0 var(--lift) 0 var(--edge-neutral),
    0 calc(var(--lift) + 6px) 14px -6px rgba(16, 24, 40, .35);
  transform: translateY(0);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
  margin-bottom: var(--lift);
}
@media (prefers-color-scheme: dark) {
  .btn:not(.btn-ghost) { background: linear-gradient(180deg, #252b36 0%, #1b2029 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 var(--lift) 0 var(--edge-neutral), 0 calc(var(--lift) + 6px) 14px -6px rgba(0,0,0,.6); }
}
.btn:not(.btn-ghost):hover { filter: brightness(1.04); }
.btn:not(.btn-ghost):active,
.btn:not(.btn-ghost).pressed {
  transform: translateY(calc(var(--lift) - 1px));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 1px 0 var(--edge-neutral), 0 2px 4px -2px rgba(16, 24, 40, .35);
}
.btn-primary:not(.btn-ghost) {
  color: #fff; border-color: var(--edge-primary); text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
  background: linear-gradient(180deg, #5b9cf5 0%, #1a73e8 55%, #1766d6 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 var(--lift) 0 var(--edge-primary), 0 calc(var(--lift) + 8px) 18px -6px rgba(26,115,232,.55);
}
.btn-primary:not(.btn-ghost):active { box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 var(--edge-primary), 0 2px 6px -2px rgba(26,115,232,.5); }
.btn-success:not(.btn-ghost) {
  color: #fff; border-color: var(--edge-success); text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
  background: linear-gradient(180deg, #2fd29f 0%, #00a37a 60%, #009670 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 var(--lift) 0 var(--edge-success), 0 calc(var(--lift) + 8px) 18px -6px rgba(0,163,122,.55);
}
.btn-success:not(.btn-ghost):active { box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 0 var(--edge-success), 0 2px 6px -2px rgba(0,163,122,.5); }
.btn-danger:not(.btn-ghost) {
  color: #fff; border-color: var(--edge-danger); text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
  background: linear-gradient(180deg, #f0645a 0%, #d93025 60%, #c5281e 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 var(--lift) 0 var(--edge-danger), 0 calc(var(--lift) + 8px) 18px -6px rgba(217,48,37,.5);
}
.btn-danger:not(.btn-ghost):active { box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 0 var(--edge-danger), 0 2px 6px -2px rgba(217,48,37,.5); }
.btn-lg { --lift: 5px; }
.btn:disabled { filter: grayscale(.4); }

/* dark editor/camera screens: glassy 3D buttons */
.editor .btn-outline, .edit-actions .btn-outline, .cam-fallback .btn-ghost {
  color: #fff !important; border-color: #000 !important;
  background: linear-gradient(180deg, #3a414e, #262b34) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 var(--lift) 0 #000, 0 10px 16px -6px rgba(0,0,0,.7) !important;
}

/* Scan FAB — 3D orb */
.bottom-nav .scan-fab {
  background: radial-gradient(circle at 35% 28%, #7fb3ff 0%, #1a73e8 55%, #1256b8 100%);
  border: 4px solid var(--bg);
  box-shadow: 0 5px 0 var(--edge-primary), 0 12px 22px -6px rgba(26,115,232,.7), inset 0 2px 3px rgba(255,255,255,.45);
  transition: transform .08s, box-shadow .08s;
}
.bottom-nav .scan-fab:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge-primary), 0 4px 8px -2px rgba(26,115,232,.6), inset 0 2px 3px rgba(255,255,255,.4); }

/* Camera shutter — 3D ring + dome */
.shutter {
  border: 0; padding: 7px;
  background: radial-gradient(circle at 50% 30%, #ffffff, #cfd6e0 70%, #9aa4b3);
  box-shadow: 0 6px 0 #5d6675, 0 12px 20px -4px rgba(0,0,0,.8), inset 0 -3px 5px rgba(0,0,0,.25);
  transition: transform .08s, box-shadow .08s;
}
.shutter span { background: radial-gradient(circle at 40% 30%, #fff 0%, #f1f4f8 55%, #cfd6df 100%); box-shadow: inset 0 -4px 8px rgba(0,0,0,.18), 0 1px 2px rgba(0,0,0,.3); }
.shutter:active { transform: translateY(5px); box-shadow: 0 1px 0 #5d6675, 0 4px 8px rgba(0,0,0,.7), inset 0 -3px 5px rgba(0,0,0,.25); }
.shutter:active span { transform: none; }

/* Chips & small controls */
.filter-bar { padding-bottom: 14px; }
.filter-bar button, .chip-toggle, .scanner-top .pill {
  border: 1px solid #000; background: linear-gradient(180deg, #3b4250, #262b34);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 3px 0 #000;
  transition: transform .08s, box-shadow .08s;
}
.filter-bar button:active, .chip-toggle:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 1px 0 #000; }
.filter-bar button.active, .chip-toggle.on {
  border-color: var(--edge-primary); background: linear-gradient(180deg, #5b9cf5, #1a73e8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 3px 0 var(--edge-primary);
}

/* Tool buttons (page toolbar + editor) as raised tiles */
.page-toolbar .tool, .edit-tools button {
  background: linear-gradient(180deg, var(--surface), var(--bg));
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 3px 0 var(--edge-neutral);
  margin-bottom: 3px; transition: transform .08s, box-shadow .08s;
}
.page-toolbar .tool:active:not(:disabled), .edit-tools button:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 1px 0 var(--edge-neutral); }
.edit-tools button {
  background: linear-gradient(180deg, #353c48, #232830); border-color: #000;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 3px 0 #000;
}
.edit-tools button:active { box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 1px 0 #000; }
.page-toolbar .tools { gap: 6px; }

/* Segmented control — raised active segment */
.segmented { box-shadow: inset 0 2px 4px rgba(16,24,40,.08); }
.segmented button.active { background: linear-gradient(180deg, #fff, #eef3fb); box-shadow: inset 0 1px 0 #fff, 0 2px 0 var(--edge-neutral), 0 4px 8px -4px rgba(16,24,40,.3); }
@media (prefers-color-scheme: dark) { .segmented button.active { background: linear-gradient(180deg, #2b3240, #20252e); box-shadow: 0 2px 0 #000; } }
.page-chips button { box-shadow: 0 3px 0 var(--edge-neutral); transition: transform .08s, box-shadow .08s; }
.page-chips button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge-neutral); }
.page-chips button.on { box-shadow: 0 3px 0 var(--edge-primary); background: linear-gradient(180deg, #5b9cf5, #1a73e8); }

/* Cards get a soft lift */
.doc-card, .page-tile:not(.add-tile) { transition: transform .15s, box-shadow .15s; }
.doc-card:active, .page-tile:not(.add-tile):active { transform: translateY(2px) scale(.99); }
.stack-btn { box-shadow: 0 4px 0 rgba(0,0,0,.8), 0 8px 14px -4px rgba(0,0,0,.8); }

/* =====================================================================
   INSTALL APP banner & guide
   ===================================================================== */
.install-banner {
  display: flex; align-items: center; gap: 14px; padding: 14px; margin-bottom: 16px;
  background: linear-gradient(135deg, #1a73e8, #3b8cf0 60%, #00a37a); color: #fff; border: 0;
  box-shadow: 0 5px 0 var(--edge-primary), 0 14px 24px -10px rgba(26,115,232,.8);
}
.install-banner .app-icon { width: 52px; height: 52px; border-radius: 14px; flex: none; box-shadow: 0 3px 0 rgba(0,0,0,.25); background: #fff center/cover no-repeat; }
.install-banner .txt { flex: 1; min-width: 0; }
.install-banner b { display: block; font-size: 15px; }
.install-banner small { opacity: .9; }
.install-banner .btn { min-height: 40px; padding: 0 14px; margin-bottom: 4px; }
.install-banner .x { color: #fff; width: 32px; height: 32px; flex: none; }
.install-steps { list-style: none; counter-reset: s; padding: 0; margin: 0 0 8px; }
.install-steps li { counter-increment: s; display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.install-steps li:last-child { border-bottom: 0; }
.install-steps li::before {
  content: counter(s); width: 32px; height: 32px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; background: linear-gradient(180deg, #5b9cf5, #1a73e8); box-shadow: 0 3px 0 var(--edge-primary);
}
.install-steps .kbd { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); box-shadow: 0 2px 0 var(--edge-neutral); font-weight: 600; font-size: 13px; white-space: nowrap; }
.install-steps .kbd svg { width: 16px; height: 16px; }
.install-note { font-size: 13px; color: var(--muted); background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.install-note.warn { background: #fff4e5; color: #8a5300; }
@media (prefers-color-scheme: dark) { .install-note.warn { background: #3a2a10; color: #ffcf80; } }
.empty .btn svg { width: 22px; height: 22px; margin: 0; color: inherit; stroke-width: 2; }

/* =====================================================================
   FILE CONVERTER
   ===================================================================== */
.tone-scan { --t1: #5b9cf5; --t2: #1a73e8; --te: #0f4fa8; }
.tone-blue { --t1: #4fb3ff; --t2: #0b84e3; --te: #0660a8; }
.tone-teal { --t1: #3fd0c0; --t2: #0aa296; --te: #077a70; }
.tone-indigo { --t1: #8c8cff; --t2: #5a5ae6; --te: #3d3db0; }
.tone-navy { --t1: #4a7fd6; --t2: #2b579a; --te: #1b3a6b; }
.tone-red { --t1: #ff7a70; --t2: #e0342a; --te: #a8201a; }
.tone-orange { --t1: #ffb057; --t2: #f08a14; --te: #b3650a; }
.tone-pink { --t1: #f57fb9; --t2: #d6388a; --te: #9c2463; }
.tone-green { --t1: #42d69f; --t2: #0ea877; --te: #087a56; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 8px; }
.tool-grid.compact { grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tool-card {
  position: relative; display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer; padding: 14px;
  border-radius: 16px; border: 1px solid var(--border); background: linear-gradient(180deg, var(--surface), var(--bg));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 4px 0 var(--edge-neutral), 0 10px 18px -8px rgba(16,24,40,.3);
  transition: transform .08s, box-shadow .08s; margin-bottom: 4px; color: var(--text); min-height: 76px;
}
.tool-card:active { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 1px 0 var(--edge-neutral); }
@media (prefers-color-scheme: dark) { .tool-card { box-shadow: 0 4px 0 #07090d, 0 10px 18px -8px rgba(0,0,0,.6); } }
.tool-ico {
  width: 46px; height: 46px; flex: none; border-radius: 13px; display: flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(180deg, var(--t1), var(--t2)); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 3px 0 var(--te);
}
.tool-ico svg { width: 24px; height: 24px; }
.tool-txt { display: flex; flex-direction: column; min-width: 0; }
.tool-txt b { font-size: 14px; line-height: 1.25; }
.tool-txt small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tool-flag { position: absolute; top: -7px; right: 8px; background: #fff4e5; color: #8a5300; border: 1px solid #f5c77a; font-size: 10px; font-weight: 800; padding: 1px 7px; border-radius: 10px; }
.tool-grid.compact .tool-card { flex-direction: column; text-align: center; padding: 12px 6px; gap: 8px; min-height: 0; }
.tool-grid.compact .tool-txt b { font-size: 12px; }
.tool-grid.compact .tool-ico { width: 42px; height: 42px; }

.free-banner, .free-pill { display: inline-flex; align-items: center; gap: 8px; color: #0b5c45; background: #e6f6f1; border-radius: 12px; }
.free-banner { display: flex; padding: 12px 14px; margin-bottom: 16px; font-size: 14px; }
.free-banner svg, .free-pill svg { width: 18px; height: 18px; flex: none; stroke-width: 3; }
.free-pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px; margin-top: 8px; }
.free-pill.big { font-size: 13px; padding: 6px 12px; margin-top: 12px; }
@media (prefers-color-scheme: dark) { .free-banner, .free-pill { background: #0f3a2d; color: #8ee6c4; } }

.tool-hero { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.tool-hero .tool-ico { width: 64px; height: 64px; border-radius: 18px; }
.tool-hero .tool-ico svg { width: 34px; height: 34px; }
.tool-hero h2 { margin: 0; font-size: 22px; }
.tool-hero p { margin: 2px 0 0; color: var(--muted); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 34px 18px; cursor: pointer;
  border: 2px dashed #9fc0f3; border-radius: 20px; background: linear-gradient(180deg, var(--brand-50), var(--surface));
  transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--brand); background: var(--brand-50); }
.dropzone .dz-ico { width: 70px; height: 70px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--brand); background: var(--surface); box-shadow: 0 4px 0 var(--edge-neutral); }
.dropzone .dz-ico svg { width: 34px; height: 34px; }
.dropzone b { font-size: 16px; }
.dropzone .dz-or { color: var(--muted); font-size: 13px; }
.dropzone small { color: var(--muted); margin-top: 6px; }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; background: var(--brand-50); }
.notice.warn { background: #fff4e5; color: #6b4200; }
.notice svg { flex: none; margin-top: 1px; }
.notice a { color: inherit; font-weight: 700; }
@media (prefers-color-scheme: dark) { .notice.warn { background: #3a2a10; color: #ffcf80; } }

.conv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.conv-tile { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 3px 0 var(--edge-neutral); overflow: hidden; display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; }
.conv-thumb { aspect-ratio: 3 / 4; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.conv-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform .25s; }
.conv-num { position: absolute; top: 8px; left: 8px; min-width: 24px; height: 24px; border-radius: 12px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 0 var(--edge-primary); }
.conv-meta { padding: 8px 10px 4px; min-width: 0; }
.conv-meta b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta small { color: var(--muted); font-size: 11px; }
.conv-actions { display: flex; justify-content: space-between; padding: 6px 8px 10px; gap: 4px; }
.mini-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border); background: linear-gradient(180deg, var(--surface), var(--bg)); box-shadow: 0 2px 0 var(--edge-neutral); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text); transition: transform .08s, box-shadow .08s; }
.mini-btn svg { width: 16px; height: 16px; }
.mini-btn:active { transform: translateY(2px); box-shadow: none; }
.mini-btn.danger { color: var(--danger); }
.mini-btn.handle { cursor: grab; touch-action: none; }
.conv-tile.dragging { opacity: .3; }
.conv-tile.ghost { position: fixed; z-index: 1000; pointer-events: none; transform: scale(1.05) rotate(2deg); box-shadow: 0 16px 40px rgba(0,0,0,.3); }
.conv-tile.add-more { border: 2px dashed var(--border); box-shadow: none; background: transparent; align-items: center; justify-content: center; gap: 6px; color: var(--brand); font-weight: 700; min-height: 200px; cursor: pointer; }

.detected { display: flex; gap: 14px; align-items: center; }
.detected small { color: var(--muted); display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.detected b { display: block; font-size: 18px; }
.detected span { color: var(--muted); font-size: 13px; word-break: break-all; }
.file-ico { width: 56px; height: 56px; flex: none; border-radius: 14px; display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.file-ico svg { width: 30px; height: 30px; }
.file-ico.kind-image { background: linear-gradient(180deg, #4fb3ff, #0b84e3); }
.file-ico.kind-pdf { background: linear-gradient(180deg, #ff7a70, #e0342a); }
.file-ico.kind-word { background: linear-gradient(180deg, #4a7fd6, #2b579a); }
.target-list { display: grid; gap: 10px; }
.target-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border-radius: 14px; cursor: pointer; font-weight: 700; font-size: 15px;
  border: 1px solid var(--edge-primary); color: #fff; background: linear-gradient(180deg, #5b9cf5, #1a73e8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 4px 0 var(--edge-primary); transition: transform .08s, box-shadow .08s; margin-bottom: 4px;
}
.target-btn span { flex: 1; text-align: left; }
.target-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge-primary); }
.target-btn[data-off] { filter: grayscale(.8); opacity: .75; }
.target-btn small { font-weight: 600; font-size: 11px; }

.info-table { display: flex; gap: 16px; align-items: flex-start; }
.info-table dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.info-table dt { color: var(--muted); font-weight: 600; }
.info-table dd { margin: 0; font-weight: 600; word-break: break-all; }
.hint { color: var(--muted); font-size: 13px; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; --lift: 3px; }
.page-sel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.page-sel-head b { font-size: 16px; }
.page-sel-head span { color: var(--muted); font-size: 13px; flex: 1; }
.page-sel { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; max-height: 320px; overflow-y: auto; padding: 4px 2px 6px; }
.page-check { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; font-size: 13px; font-weight: 600; box-shadow: 0 2px 0 var(--edge-neutral); }
.page-check input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
.page-check:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }

.pdf-icon.img { background: #e3f0fd; color: #0b84e3; }
.hist { overflow: hidden; }
.hist-row { display: grid; grid-template-columns: 2.2fr 1.2fr 1fr .9fr auto; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.hist-row:last-child { border-bottom: 0; }
.hist-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: var(--bg); }
.h-file { min-width: 0; }
.h-file b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-file small, .h-date { color: var(--muted); font-size: 12px; }
.h-act { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.h-act .btn { margin-bottom: 3px; }
.status { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 20px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.status.s-completed { background: #e6f6f1; color: #0b7a57; }
.status.s-failed { background: #fde8e7; color: #b3261e; }
.status.s-processing, .status.s-pending { background: var(--brand-50); color: var(--brand); }
@media (max-width: 640px) {
  .hist-head { display: none; }
  .hist-row { grid-template-columns: 1fr auto; grid-template-areas: "file act" "conv act" "meta act"; row-gap: 2px; }
  .h-file { grid-area: file; } .h-conv { grid-area: conv; font-size: 13px; font-weight: 600; color: var(--brand); }
  .hist-row > span:nth-child(3) { display: none; } .hist-row > span:nth-child(4) { grid-area: meta; }
  .h-act { grid-area: act; } .hide-sm { display: none; }
  .tool-grid:not(.compact) { grid-template-columns: 1fr 1fr; }
}

.dg-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.dg-box { text-align: center; padding: 14px 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 3px 0 var(--edge-neutral); }
.dg-box b { display: block; font-size: 26px; }
.dg-box span { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.dg-box.ok b { color: var(--accent); } .dg-box.warn b { color: #d98200; } .dg-box.err b { color: var(--danger); }
.dg { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 800; flex: none; margin-right: 8px; vertical-align: middle; }
.dg.ok { background: var(--accent); } .dg.warn { background: #f29900; } .dg.err { background: var(--danger); } .dg.opt { background: #98a2b3; }
.dg-list li { align-items: center; }
.dg-main { display: flex; align-items: flex-start; min-width: 0; }
.dg-main b { display: block; font-size: 14px; }
.dg-main small { display: block; color: var(--muted); word-break: break-all; font-size: 12px; }
.dg-state { font-weight: 700; }
.dg-state.s-ok { color: var(--accent); } .dg-state.s-error { color: var(--danger); } .dg-state.s-warn { color: #d98200; }
.help-card { margin-bottom: 12px; }
.help-card h3 { margin: 0 0 8px; font-size: 16px; }
.help-card ol { padding-left: 20px; margin: 0 0 8px; } .help-card li { margin-bottom: 6px; }
.help-card code, .hint code { background: var(--bg); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.bottom-nav a { min-width: 58px; }

/* Designer credit */
.credit { text-align: center; font-size: 12px; color: var(--muted); margin: 22px auto 8px; padding: 10px 14px; letter-spacing: .01em; }
.credit b { color: var(--brand); font-weight: 700; }

/* =====================================================================
   v4 — accounts, dashboard, My Documents
   ===================================================================== */
.container.wide { max-width: 1180px; }
.auth-card.wide { max-width: 560px; }
details.optional { margin: 4px 0 12px; }
details.optional summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 14px; }
textarea.input { resize: vertical; min-height: 70px; font: inherit; }
.hide-sm { }

/* avatar */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #5b9cf5, #1a73e8); color: #fff; font-weight: 800; box-shadow: 0 3px 0 var(--edge-primary); }

/* desktop side navigation (≥ 1024px); phones/tablets keep the bottom bar */
.side-nav { display: none; }
@media (min-width: 1024px) {
  .side-nav {
    display: flex; flex-direction: column; gap: 2px; position: fixed; left: 0; top: 0; bottom: 0; width: 248px; z-index: 30;
    background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; overflow-y: auto;
  }
  .side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; }
  .side-nav a:hover { background: var(--bg); }
  .side-nav a.active { background: var(--brand-50); color: var(--brand); }
  .side-nav .side-brand { display: flex; align-items: center; gap: 10px; color: var(--brand); padding: 4px 10px 14px; font-size: 17px; }
  .side-nav .side-user { background: var(--bg); margin-bottom: 10px; padding: 10px; }
  .side-nav .side-user span { display: flex; flex-direction: column; min-width: 0; }
  .side-nav .side-user b, .side-nav .side-user small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-nav .side-user small { color: var(--muted); font-weight: 500; font-size: 12px; }
  .side-nav .side-scan { margin: 0 0 12px; }
  .side-nav .side-logout { margin-top: auto; color: var(--danger); }
  .bottom-nav { display: none; }
  .view { padding-left: 248px; padding-bottom: 30px; }
  .appbar { left: 248px; }
  .page-toolbar { left: 248px; }
  .select-bar { left: calc(248px + 24px) !important; bottom: 20px !important; }
  .toast-wrap { bottom: 24px; }
}

/* dashboard */
.dash-hello .card-body { display: flex; align-items: center; gap: 16px; }
.dash-hello-txt { flex: 1; min-width: 0; }
.dash-hello-txt small { color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .06em; }
.dash-hello-txt h2 { margin: 2px 0; font-size: 22px; }
.dash-hello-txt span { color: var(--muted); font-size: 13px; }
.dash-hello { margin-bottom: 16px; background: linear-gradient(135deg, var(--surface), var(--brand-50)); }
.journey { display: flex; align-items: center; gap: 4px; overflow-x: auto; padding: 4px 2px 12px; margin-bottom: 8px; scrollbar-width: none; }
.journey::-webkit-scrollbar { display: none; }
.journey-step { flex: none; display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 22px; text-decoration: none; font-weight: 700; font-size: 13px; color: var(--brand);
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 3px 0 var(--edge-neutral); transition: transform .08s, box-shadow .08s; }
.journey-step:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge-neutral); }
.journey-step svg { width: 18px; height: 18px; }
.journey-arrow { color: var(--muted); font-size: 20px; flex: none; }
.dash-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat-card { display: block; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: 0 3px 0 var(--edge-neutral); }
.stat-card b { display: block; font-size: 26px; }
.stat-card span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stat-card.storage { grid-column: span 2; }
.stat-card.storage b { font-size: 20px; margin: 2px 0 8px; }
.stat-card small { color: var(--muted); font-size: 12px; }
.meter { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, #5b9cf5, #1a73e8); border-radius: 4px; }
a.tool-card { text-decoration: none; }
.dash-actions { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* profile */
.profile-photo { display: flex; align-items: center; gap: 18px; }
.profile-photo b { display: block; font-size: 18px; }
.profile-photo small { color: var(--muted); }
.action-list button.danger { color: var(--danger); }

/* My Documents */
.lib-top { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.lib-top .btn { margin-bottom: 4px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 18px; padding: 6px 13px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--muted); box-shadow: 0 2px 0 var(--edge-neutral); }
.chip.on { background: var(--brand); color: #fff; border-color: var(--edge-primary); box-shadow: 0 2px 0 var(--edge-primary); }
.chips .sort { width: auto; min-height: 36px; padding: 4px 10px; margin-left: auto; font-size: 13px; }
.doc-head, .doc-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 130px 130px 96px 84px; gap: 10px; align-items: center; }
.doc-head { padding: 6px 12px; font-size: 11px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.doc-row { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.doc-row:last-child { border-bottom: 0; }
.card:not(.doc-list) > .doc-row, .upload-result .doc-row { grid-template-columns: minmax(0, 1fr) 130px 130px 96px 84px; }
.doc-check input { width: 18px; height: 18px; accent-color: var(--brand); }
.doc-main { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; color: var(--text); }
.doc-info { min-width: 0; display: flex; flex-direction: column; }
.doc-info b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.doc-info small, .doc-cat, .doc-date { color: var(--muted); font-size: 12px; }
.doc-thumb { border-radius: 8px; object-fit: cover; background: var(--bg); border: 1px solid var(--border); flex: none; }
.doc-actions { display: flex; justify-content: flex-end; }
.doc-actions .icon-btn { width: 38px; height: 38px; }
.src-badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 20px; background: var(--bg); color: var(--muted); white-space: nowrap; text-align: center; }
.src-badge.s-upload { background: #e8f0fe; color: #1a73e8; }
.src-badge.s-converted { background: #e6f6f1; color: #0b7a57; }
.src-badge.s-scan { background: #fff4e5; color: #9a5b00; }
.select-bar { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px); z-index: 26; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(16,24,40,.25); max-width: 760px; margin: 0 auto; }
.select-bar b { flex: 1; min-width: 90px; }
.select-bar .btn { margin-bottom: 3px; }
.upload-opts { margin-top: 14px; max-width: 360px; }
.upload-result { margin-top: 16px; }
.upload-ok { display: flex; align-items: center; gap: 10px; color: #0b7a57; margin-bottom: 8px; }
.upload-ok svg { width: 22px; height: 22px; stroke-width: 3; }

/* document detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 24px; align-items: start; }
.detail-preview { display: flex; align-items: center; justify-content: center; min-height: 240px; padding: 14px; background: var(--bg); }
.detail-preview img { max-width: 100%; max-height: 420px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.detail-title { margin: 0 0 8px; word-break: break-word; }
.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 16px 0; font-size: 14px; }
.meta-list dt { color: var(--muted); font-weight: 600; }
.meta-list dd { margin: 0; word-break: break-word; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.link-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.link-row:last-child { border-bottom: 0; }
.link-row span:not(.file-ico) { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.link-row b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-row small { color: var(--muted); font-size: 12px; }
.pdf-item a.info { text-decoration: none; color: var(--text); }

/* picker */
.picker-list { max-height: 52vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; }
.picker-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.picker-row:last-child { border-bottom: 0; }
.picker-row input { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
.picker-row span { display: flex; flex-direction: column; min-width: 0; }
.picker-row b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-row small { color: var(--muted); font-size: 12px; }
.picker-row:has(input:checked) { background: var(--brand-50); }
button.conv-tile.add-more { font: inherit; cursor: pointer; }

@media (max-width: 760px) {
  .hide-sm { display: none !important; }
  .doc-head { display: none; }
  .doc-row, .card:not(.doc-list) > .doc-row, .upload-result .doc-row { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 4px; }
  .card:not(.doc-list) > .doc-row, .upload-result .doc-row { grid-template-columns: minmax(0, 1fr) auto; }
  .doc-row .src-badge { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .stat-card.storage { grid-column: 1 / -1; }
  .dash-stats { grid-template-columns: 1fr 1fr; }
  .dash-actions { grid-template-columns: 1fr 1fr; }
  .dash-hello .card-body { padding: 14px; }
}
