:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f5f9;
  --border: #e3e6ee;
  --text: #121826;
  --muted: #5e6a7f;
  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef0ff;
  --on-accent: #ffffff;
  --success: #15803d;
  --success-soft: #e8f7ee;
  --danger: #c2261c;
  --danger-soft: #fdeceb;
  --shadow: 0 1px 2px rgba(18, 24, 38, .05), 0 4px 16px rgba(18, 24, 38, .06);
  --shadow-lg: 0 24px 64px rgba(18, 24, 38, .22);
  --radius: 14px;
  --radius-sm: 10px;
  --g-organize: #4f46e5;
  --g-optimize: #0d9488;
  --g-convert: #d97706;
  --g-security: #e11d48;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1017;
  --surface: #161a23;
  --surface-2: #1d2230;
  --border: #2a3040;
  --text: #e8ebf2;
  --muted: #97a1b5;
  --accent: #8b93ff;
  --accent-hover: #a5abff;
  --accent-soft: #23264a;
  --on-accent: #0d1017;
  --success: #4ade80;
  --success-soft: #16301f;
  --danger: #f87171;
  --danger-soft: #3a1a1a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
  --g-organize: #818cf8;
  --g-optimize: #2dd4bf;
  --g-convert: #fbbf24;
  --g-security: #fb7185;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2 { margin: 0; line-height: 1.25; }
button, input, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; color: var(--text);
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.big { height: 48px; padding: 0 24px; font-size: 15px; border-radius: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; }
.link:disabled { color: var(--muted); cursor: default; font-weight: 500; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 20px; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; color: var(--text); text-decoration: none; }
.brand svg { width: 32px; height: 32px; stroke-width: 1.6; }
.brand-bg { fill: var(--accent); stroke: none; }
.brand-page { fill: #fff; stroke: none; }
.brand-fold { stroke: var(--accent); fill: none; }
.brand-lock { fill: var(--accent); stroke: none; }
.brand-shackle { stroke: var(--accent); fill: none; stroke-width: 1.5; }
.trust {
  display: flex; align-items: center; gap: 6px; margin: 0;
  font-size: 13px; color: var(--success); background: var(--success-soft);
  padding: 4px 10px 4px 8px; border-radius: 999px; font-weight: 600;
}
.trust svg { width: 16px; height: 16px; }
.account { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.tier {
  font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface-2);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.tier.paid { color: var(--g-convert); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 13px;
}
.user-name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.user-name small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }

/* ---------- layout ---------- */
.layout {
  flex: 1; display: grid; grid-template-columns: 240px minmax(0, 1fr) 300px;
  gap: 24px; padding: 24px; max-width: 1440px; width: 100%; margin: 0 auto; align-items: start;
}

/* ---------- tool list ---------- */
.tools { position: sticky; top: 82px; display: flex; flex-direction: column; gap: 18px; }
.tool-group h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 6px 10px; }
.tool-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.tool-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 0; background: transparent; border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 550; font-size: 14px; text-align: left; color: var(--text);
}
.tool-btn:hover { background: var(--surface-2); }
.tool-btn[aria-current="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 700; }
.tool-btn.off { opacity: .5; }
.tile {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent);
}
.tile svg { width: 17px; height: 17px; }

/* ---------- workspace ---------- */
.workspace {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 20px; outline: none;
}
.tool-head { display: flex; gap: 16px; align-items: center; }
.tool-icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent);
}
.tool-icon svg { width: 26px; height: 26px; }
.tool-head h1 { font-size: 24px; letter-spacing: -.02em; }
.tool-head p { margin: 2px 0 0; color: var(--muted); }
.unavailable { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); }

.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 36px 20px; border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface-2); cursor: pointer; text-align: center; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { border-color: var(--accent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop svg { width: 34px; height: 34px; color: var(--accent); margin-bottom: 6px; }
.drop strong { font-size: 17px; }
.drop span { color: var(--muted); }
.drop small { color: var(--muted); margin-top: 6px; font-size: 12.5px; }
.drop.compact { flex-direction: row; justify-content: center; padding: 14px; gap: 10px; }
.drop.compact svg { width: 22px; height: 22px; margin: 0; }
.drop.compact strong { font-size: 15px; }
.drop.compact small { display: none; }

/* ---------- queue ---------- */
.queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.queue:empty { display: none; }
.q-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 10px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.q-item.dragging { opacity: .4; }
.q-item.drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.q-item[draggable="true"] { cursor: grab; }
.q-index { width: 22px; text-align: center; color: var(--muted); font-weight: 700; font-size: 13px; }
.thumb {
  width: 44px; height: 56px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center; overflow: hidden; flex: none; color: var(--muted);
}
.thumb canvas, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb svg { width: 20px; height: 20px; }
.q-info { flex: 1; min-width: 0; }
.q-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-meta { color: var(--muted); font-size: 12.5px; }
.q-meta .warn { color: var(--danger); font-weight: 600; }
.q-actions { display: flex; gap: 2px; }

/* ---------- page picker ---------- */
.pages-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pages-head h2 { font-size: 15px; }
.pages-actions { display: flex; gap: 16px; font-size: 14px; }
.page-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px;
  max-height: 420px; overflow-y: auto; padding: 4px; margin: -4px;
}
.page {
  position: relative; border: 2px solid transparent; border-radius: 10px; padding: 6px 6px 4px;
  background: var(--surface-2); cursor: pointer; text-align: center; font-size: 12px; color: var(--muted);
}
.page canvas { width: 100%; aspect-ratio: 1 / 1.3; object-fit: contain; display: block; background: #fff; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.page .ph { width: 100%; aspect-ratio: 1 / 1.3; background: var(--border); border-radius: 4px; }
.page[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.page[aria-pressed="true"]::after {
  content: "✓"; position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-size: 13px; display: grid; place-items: center; font-weight: 800;
}
.pages.removing .page[aria-pressed="true"] { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.pages.removing .page[aria-pressed="true"]::after { content: "✕"; background: var(--danger); }
.pages.removing .page[aria-pressed="true"] canvas { opacity: .35; }

/* ---------- options ---------- */
.options { display: flex; flex-direction: column; gap: 16px; }
.options:empty { display: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, label { font-weight: 600; font-size: 13.5px; }
.field small { color: var(--muted); font-size: 12.5px; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; width: fit-content; max-width: 100%; }
.segmented label {
  position: relative; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--muted);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.segmented label small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="tel"], input:not([type]) {
  height: 44px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); width: 100%; max-width: 420px; font-size: 15px;
}
input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- action / progress / result ---------- */
.actionbar { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.progress { flex: 1; min-width: 200px; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .2s; }
.bar.indeterminate span { width: 35% !important; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.progress p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.error { margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-weight: 600; font-size: 14px; }

.result {
  display: flex; gap: 18px; padding: 22px; border-radius: var(--radius);
  background: var(--success-soft); border: 1px solid color-mix(in srgb, var(--success) 25%, transparent);
}
.result-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--success); color: #fff; display: grid; place-items: center; flex: none; }
.result-icon svg { width: 24px; height: 24px; stroke-width: 2.6; }
.result-body { flex: 1; min-width: 0; }
.result h2 { font-size: 18px; }
.result-name { margin: 2px 0 0; font-weight: 600; word-break: break-all; }
.result-note { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.result-note:empty { display: none; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.result-expiry { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; }

/* ---------- files panel ---------- */
.files {
  position: sticky; top: 82px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 18px; box-shadow: var(--shadow);
}
.files-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.files-head h2 { font-size: 16px; }
.usage { font-size: 12px; color: var(--muted); }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 200px); overflow-y: auto; }
.f-item { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.f-item:hover, .f-item:focus-within { background: var(--surface-2); }
.f-kind {
  width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; flex: none;
  font-size: 10px; font-weight: 800; letter-spacing: .02em; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent);
}
.f-info { flex: 1; min-width: 0; }
.f-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-meta { font-size: 12px; color: var(--muted); }
.f-meta .kept { color: var(--success); font-weight: 600; }
/* On desktop the actions float over the row on hover, so names get the full width. */
.f-actions {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: flex; padding: 2px; border-radius: 10px; background: var(--surface);
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .15s;
}
.f-item:hover .f-actions, .f-item:focus-within .f-actions { pointer-events: auto; }
.f-item:hover .f-actions, .f-item:focus-within .f-actions { opacity: 1; }
.f-actions .icon-btn { width: 30px; height: 30px; }
.f-actions svg { width: 17px; height: 17px; }
.files-empty { margin: 0; font-size: 13px; color: var(--muted); }

.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 8px 16px 24px; }
.footer p { margin: 0; }

/* ---------- viewer ---------- */
dialog { border: 0; padding: 0; color: var(--text); }
dialog::backdrop { background: rgba(8, 10, 16, .6); backdrop-filter: blur(3px); }
.viewer {
  width: min(1100px, 100vw - 32px); height: calc(100vh - 32px); max-width: none; max-height: none;
  border-radius: 18px; background: var(--surface-2); box-shadow: var(--shadow-lg); overflow: hidden;
}
.viewer[open] { display: flex; flex-direction: column; }
.viewer-bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.viewer-bar h2 { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-controls { display: flex; align-items: center; gap: 4px; }
.viewer-pages { font-size: 13px; color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }
.zoom-label { min-width: 56px; height: 34px; border: 0; background: transparent; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.zoom-label:hover { background: var(--surface-2); }
.viewer-body { flex: 1; overflow: auto; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.viewer-page { background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); border-radius: 2px; flex: none; }
.viewer-page canvas { display: block; width: 100%; height: 100%; }
.viewer-body img { max-width: 100%; height: auto; box-shadow: 0 2px 10px rgba(0,0,0,.15); background: #fff; }
.viewer-body pre { white-space: pre-wrap; background: var(--surface); padding: 24px; border-radius: 12px; width: 100%; max-width: 820px; margin: 0; font-size: 13px; }
.viewer-msg { margin: auto; text-align: center; color: var(--muted); max-width: 380px; }
.viewer-msg strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }

/* ---------- auth ---------- */
.auth {
  width: min(420px, 100vw - 32px); border-radius: 20px; background: var(--surface);
  box-shadow: var(--shadow-lg); padding: 32px 28px 28px;
}
.auth-close { position: absolute; top: 12px; right: 12px; }
.auth-step { display: flex; flex-direction: column; gap: 10px; }
.auth-step h2 { font-size: 21px; letter-spacing: -.01em; padding-right: 24px; }
.auth-step input { max-width: none; }
.auth-step .btn { margin-top: 8px; width: 100%; }
.muted { color: var(--muted); margin: 0 0 6px; font-size: 14px; }
.perks { list-style: none; padding: 12px 14px; margin: 0 0 8px; background: var(--surface-2); border-radius: 12px; display: grid; gap: 4px; font-size: 13.5px; }
.perks li::before { content: "✓"; color: var(--success); font-weight: 800; margin-right: 8px; }
.code-input { font-size: 26px !important; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; height: 56px !important; }
.resend { align-self: center; font-size: 13.5px; margin-top: 4px; }
.auth .error { margin-top: 12px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px);
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
  .files { grid-column: 2; position: static; }
  .file-list { max-height: none; }
}
@media (max-width: 820px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .trust { display: none; }
  .user-name { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 16px; }
  .files { grid-column: 1; }
  .tools {
    position: static; flex-direction: row; overflow-x: auto; gap: 0; margin: 0 -16px; padding: 0 16px 4px;
    scrollbar-width: none;
  }
  .tools::-webkit-scrollbar { display: none; }
  .tool-group h2 { display: none; }
  .tool-group ul { flex-direction: row; gap: 6px; padding-right: 6px; }
  .tool-btn { white-space: nowrap; padding: 6px 12px 6px 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
  .tool-btn[aria-current="true"] { border-color: var(--accent); }
  .tile { width: 26px; height: 26px; border-radius: 50%; }
  .workspace { padding: 20px 16px; border-radius: 16px; }
  .tool-head h1 { font-size: 20px; }
  .tool-icon { width: 44px; height: 44px; }
  .actionbar .btn.big { width: 100%; }
  .drop.compact span { display: none; }
  .f-actions { position: static; transform: none; opacity: 1; pointer-events: auto; box-shadow: none; background: transparent; }
  .result { flex-direction: column; gap: 12px; padding: 18px; }
  .viewer { width: 100vw; height: 100dvh; border-radius: 0; }
  .viewer-body { padding: 12px; }
  .viewer-pages { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- admin page ---------- */
body.admin .brand img { border-radius: 9px; }
.admin-main { width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.admin-main h1 { font-size: 22px; }
.admin-main code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.admin-main a { color: var(--accent); }
.admin-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin-search { display: flex; gap: 8px; }
.notice { margin: 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--success-soft); color: var(--success); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.tier-form { display: flex; gap: 6px; align-items: center; }
.tier-form select { height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); padding: 0 8px; }
.tier-form .btn { height: 36px; }
.files-cta { margin-top: 12px; width: 100%; }

/* ---------- theme switch ---------- */
.theme-toggle svg { width: 19px; height: 19px; }

/* ---------- plans & payments ---------- */
.tier.warn { color: var(--danger); background: var(--danger-soft); }
.plans-dialog { width: min(560px, 100vw - 32px); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-lg); padding: 28px; }
.plans-dialog h2 { font-size: 21px; padding-right: 28px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin: 14px 0; }
.plan-card { position: relative; border: 2px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.plan-card input { position: absolute; opacity: 0; pointer-events: none; }
.plan-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.plan-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.plan-card b { font-size: 15px; }
.plan-card .size { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.plan-card small { color: var(--muted); font-size: 12.5px; }
.pay-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.pay-row .field { flex: 1; min-width: 140px; }
.pay-row select { height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); padding: 0 10px; width: 100%; }
.pay-total { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.pay-steps { margin: 14px 0; padding: 14px 16px 14px 34px; background: var(--surface-2); border-radius: 12px; font-size: 14px; display: grid; gap: 4px; }
.pay-steps b { font-variant-numeric: tabular-nums; }
.plan-status { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: 14px; margin: 10px 0 0; }
.plan-status.ok { background: var(--success-soft); color: var(--success); font-weight: 600; }
.plan-status.wait { background: var(--accent-soft); }
.plan-status.bad { background: var(--danger-soft); color: var(--danger); }
.plans-dialog form { display: flex; flex-direction: column; gap: 8px; }
.plans-dialog .btn.big { width: 100%; margin-top: 6px; }

/* ---------- contribution ---------- */
.contribute { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--accent-soft); font-size: 13.5px; }
.contribute p { margin: 0 0 8px; }
.contribute .lipa { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface); border-radius: 10px; padding: 8px 10px 8px 12px; }
.contribute .lipa strong { display: block; font-size: 18px; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.contribute .lipa small { color: var(--muted); }

/* ---------- terms ---------- */
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; font-size: 13.5px; margin-top: 4px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.terms-dialog { width: min(720px, 100vw - 32px); max-height: calc(100vh - 48px); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-lg); padding: 0; }
.terms-dialog[open] { display: flex; flex-direction: column; }
.terms-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 12px 28px; border-bottom: 1px solid var(--border); }
.terms-head h2 { font-size: 19px; }
.terms-body { overflow-y: auto; padding: 8px 28px 24px; font-size: 14px; }
.terms-body h3 { font-size: 15px; margin: 18px 0 4px; }
.terms-body p, .terms-body li { color: var(--text); margin: 0 0 6px; }
.terms-body ul { padding-left: 20px; margin: 0 0 6px; }
.footer a, .footer .link { color: var(--muted); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
.footer .sep { margin: 0 6px; }

/* ---------- OCR note ---------- */
.ocr-note { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- admin ---------- */
.admin-main { display: flex; flex-direction: column; gap: 16px; }
.admin-main .workspace { gap: 10px; }
.admin-main h2 { font-size: 17px; }
.admin-main .muted { margin: 0; }
.admin-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.admin-tabs a { padding: 10px 14px; border-radius: 10px 10px 0 0; color: var(--muted); font-weight: 600; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin-tabs a:hover { color: var(--text); }
.admin-tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.admin-tabs .count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11.5px; margin-left: 4px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.kpi span { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi strong { font-size: 28px; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12.5px; }
.kpi.attention { border-color: var(--danger); }
.kpi.attention strong { color: var(--danger); }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 16px; align-items: start; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .grid.base { stroke: var(--muted); }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .value { fill: var(--text); font-size: 12px; font-weight: 700; font-family: var(--font); }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; }
.chart .col:hover .hit { fill: var(--accent-soft); }
.table-view summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13.5px; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hbars li { display: grid; grid-template-columns: 120px 1fr 48px; align-items: center; gap: 10px; font-size: 13.5px; }
.hbar { width: 100%; height: 12px; display: block; }
.hbar rect { fill: var(--accent); }
.hbar-value { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.admin-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table td { vertical-align: top; }
.admin-table input:not([type="checkbox"]) { height: 36px; max-width: 180px; font-size: 14px; }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form select { height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); padding: 0 8px; }
.inline-form .btn { height: 36px; }
.inline-form input { height: 36px; max-width: 170px; }
.status.ok { color: var(--success); font-weight: 700; }
.status.no { color: var(--danger); font-weight: 700; }
.workspace.narrow { max-width: 520px; }
.settings-form { display: flex; flex-direction: column; gap: 6px; }
.settings-form .btn { align-self: flex-start; margin-top: 10px; }
@media (max-width: 640px) {
  .hbars li { grid-template-columns: 96px 1fr 40px; }
  .kpi strong { font-size: 24px; }
}
.topbar > .theme-toggle { margin-left: auto; }
.topbar > .theme-toggle + .account { margin-left: 0; }
.admin-main { max-width: 1200px; }
/* Charts are drawn with fills, not the outline style used by icons. */
svg.chart, svg.hbar { stroke: none; stroke-width: 0; fill: none; }
.chart .grid { stroke-width: 1; }
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .brand span { white-space: nowrap; }
  .topbar > .account { flex-basis: 100%; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
  .topbar > .account:empty { display: none; }
  .account .btn { height: 34px; padding: 0 12px; }
}
button.tier { border: 0; cursor: pointer; font-family: inherit; }
button.tier:hover { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 820px) {
  .account .user-chip { display: none; }
  .account .btn.ghost { padding: 0 8px; }
}
.danger-zone { margin-top: 6px; font-size: 13px; }
.danger-zone summary { cursor: pointer; color: var(--muted); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }

/* ---------- colour per tool group (cards, sidebar, tool header) ---------- */
[data-group="organize"] { --tone: var(--g-organize); }
[data-group="optimize"] { --tone: var(--g-optimize); }
[data-group="convert"] { --tone: var(--g-convert); }
[data-group="security"] { --tone: var(--g-security); }
a.tool-btn { color: var(--text); text-decoration: none; }

/* ---------- views: home (all tools) or one tool ---------- */
#main { flex: 1; outline: none; width: 100%; }
body[data-view="home"] #app { display: none; }
body[data-view="tool"] #home { display: none; }

/* ---------- home ---------- */
.home { max-width: 1180px; margin: 0 auto; padding: 24px 24px 8px; }
.hero { text-align: center; padding: 28px 0 20px; }
.hero-title { font-size: clamp(28px, 5vw, 46px); letter-spacing: -.02em; line-height: 1.1; max-width: 780px; margin: 0 auto; }
.hero-sub { color: var(--muted); font-size: clamp(16px, 2.2vw, 19px); max-width: 640px; margin: 14px auto 0; }
.badges { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 0; margin: 22px 0 0; }
.badges li { padding: 6px 13px 6px 11px; border-radius: 999px; background: var(--surface-2); font-size: 13.5px; font-weight: 600; }
.badges li::before { content: "✓"; color: var(--success); font-weight: 800; margin-right: 6px; }
.tool-section { margin-top: 26px; }
.group-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px 4px; }
.tool-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tool-card {
  display: flex; gap: 14px; align-items: flex-start; height: 100%; padding: 18px;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text);
  text-decoration: none; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s, border-color .12s;
}
.tool-card:hover { transform: translateY(-2px); border-color: var(--tone); box-shadow: 0 10px 28px rgba(18, 24, 38, .10); }
.tool-card:focus-visible { border-color: var(--tone); }
.tool-card .tile { width: 46px; height: 46px; border-radius: 13px; flex: none; }
.tool-card .tile svg { width: 23px; height: 23px; }
.tool-card-text strong { display: block; font-size: 16.5px; margin-bottom: 3px; }
.tool-card-text span { color: var(--muted); font-size: 14px; line-height: 1.45; }
.home-contribute { max-width: 520px; margin: 30px auto 0; }
.home-contribute:empty { display: none; }

/* ---------- tool view ---------- */
.back-link { align-self: flex-start; color: var(--muted); font-weight: 600; font-size: 14px; text-decoration: none; margin-bottom: -6px; }
.back-link:hover { color: var(--accent); }

/* ---------- FAQ ---------- */
.faq { max-width: 820px; margin: 44px auto 0; padding: 0 24px; }
.faq h2 { font-size: 22px; margin-bottom: 8px; letter-spacing: -.01em; }
.faq details { border-bottom: 1px solid var(--border); padding: 14px 4px; }
.faq summary { cursor: pointer; font-weight: 600; font-size: 15.5px; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-size: 20px; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq p { margin: 8px 0 0; color: var(--muted); }

/* ---------- footer ---------- */
.footer { margin-top: 44px; padding: 28px 16px 28px; border-top: 1px solid var(--border); }
.footer p + p { margin-top: 4px; }
.footer-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-bottom: 16px; }
.footer-tools a { color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 500; }
.footer-tools a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- language switch ---------- */
.lang-switch { display: flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; margin-left: auto; }
.lang-switch a { padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: var(--muted); text-decoration: none; }
.lang-switch a:hover { color: var(--text); }
.lang-switch a[aria-current="true"] { background: var(--accent); color: var(--on-accent); }
.topbar > .lang-switch + .theme-toggle { margin-left: 0; }

@media (max-width: 820px) {
  .home { padding: 12px 16px 4px; }
  .hero { padding: 16px 0 8px; }
  .tool-grid { grid-template-columns: 1fr; gap: 10px; }
  .tool-card { padding: 14px; }
  .tool-card .tile { width: 42px; height: 42px; }
  .faq { padding: 0 16px; }
  .back-link { margin-bottom: 0; }
}

/* Home opens straight onto the tools. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.home > .tool-section:first-of-type { margin-top: 8px; }
/* Questions are shown on tool pages, not on the home view. */
body[data-view="home"] .faq { display: none; }

/* Caution on tools whose result needs checking (scans). */
.tool-notice {
  margin: -6px 0 0; padding: 12px 14px 12px 40px; position: relative; border-radius: var(--radius-sm);
  background: #fff7e6; color: #8a4b00; font-size: 13.5px; line-height: 1.45; border: 1px solid #f7d9a4;
}
.tool-notice::before { content: "!"; position: absolute; left: 13px; top: 11px; width: 18px; height: 18px; border-radius: 50%;
  background: #d97706; color: #fff; font-weight: 800; font-size: 12px; display: grid; place-items: center; }
:root[data-theme="dark"] .tool-notice { background: #2e2310; color: #fbd38d; border-color: #5a4318; }

/* Desktop app install box (right column, below sign in). */
.install-box { margin-top: 14px; display: flex; gap: 12px; padding: 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13.5px; }
.install-box img { border-radius: 10px; display: block; }
.install-box b { display: block; font-size: 14px; }
.install-box p { margin: 2px 0 10px; color: var(--muted); }
.install-box .btn { height: 36px; }
