/* GptNotes — a plain desktop-tool look: system font, neutral surfaces,
   an inspector panel, one accent colour (ink blue). No decoration for its own sake. */

:root {
  --bg: #ececea;            /* canvas area behind the paper */
  --panel: #ffffff;
  --panel-2: #f7f7f6;       /* inputs, hover */
  --panel-3: #efefed;       /* pressed, selected */
  --text: #1d1d1f;
  --text-2: #5f5f63;
  --text-3: #8e8e93;
  --line: #e3e3e0;
  --line-2: #d2d2cf;
  --accent: #2a52be;        /* ink blue */
  --accent-hover: #2347a6;
  --accent-soft: #e8eefb;
  --accent-text: #2347a6;
  --danger: #c4372b;
  --ok: #24803c;
  --paper-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.08), 0 12px 28px -12px rgba(0, 0, 0, 0.22);
  --pop-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 10px 30px -8px rgba(0, 0, 0, 0.25);
  --font: system-ui, -apple-system, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
  --guide: #9fb0d4;
  --guide-soft: #e4e6ea;
  --ghost: #9aa0aa;
  --canvas-bg: #ffffff;
  --ink: #000000;
  --bar-h: 48px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #161618;
  --panel: #222224;
  --panel-2: #2a2a2d;
  --panel-3: #333336;
  --text: #ececee;
  --text-2: #a7a7ad;
  --text-3: #76767c;
  --line: #333336;
  --line-2: #424246;
  --accent: #5b82e6;
  --accent-hover: #6d90ec;
  --accent-soft: #24304d;
  --accent-text: #8fadf2;
  --danger: #e2675b;
  --ok: #5fbf77;
  --paper-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 12px 30px -10px rgba(0, 0, 0, 0.7);
  --pop-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 14px 36px -10px rgba(0, 0, 0, 0.7);
  --guide: #56648a;
  --guide-soft: #34353a;
  --ghost: #6c7180;
  --canvas-bg: #1d1d20;
  --ink: #ffffff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--text); background: var(--panel); font-size: 13.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.grow { flex: 1; }
h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
h3 { font-size: 13.5px; margin-bottom: 6px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
a { color: var(--accent-text); }
body.perf * { transition: none !important; animation: none !important; }
.glass { background: var(--panel); }
.grain, .spark-layer { display: none; }

/* ------------------------------------------------ controls */
.ic { width: 16px; height: 16px; flex: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px;
  border: 1px solid var(--line-2); background: var(--panel); border-radius: 6px; cursor: pointer;
  font-size: 13px; font-weight: 500; white-space: nowrap; color: var(--text); transition: background 0.1s;
}
.btn:hover { background: var(--panel-2); }
.btn:active { background: var(--panel-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-3); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12.5px; }
.btn.big { height: 34px; padding: 0 16px; font-size: 13.5px; font-weight: 600; }
.btn:disabled { opacity: 0.45; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; border: 0;
  background: transparent; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.sm .ic { width: 15px; height: 15px; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.file-btn { position: relative; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

select, .text-input {
  width: 100%; height: 30px; padding: 0 9px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel);
  color: var(--text); font-size: 13px; min-width: 0;
}
textarea.text-input { height: auto; padding: 7px 9px; }
select:focus, .text-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); min-width: 0; }
.field.compact { margin-top: 10px; }

.switch-line { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; user-select: none; }
.switch-line.compact { font-size: 12.5px; }
.switch-line input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 30px; height: 18px; border-radius: 9px; background: var(--line-2); position: relative; flex: none; transition: background 0.15s; }
.switch::after { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.switch-line input:checked + .switch { background: var(--accent); }
.switch-line input:checked + .switch::after { transform: translateX(12px); }
.switch-line input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; cursor: pointer; margin: 0; }
input[type='range']::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(var(--accent) 0 0) 0 0 / var(--p, 50%) 100% no-repeat, var(--line-2); }
input[type='range']::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-2); }
input[type='range']::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; margin-top: -5px; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.3); }
input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.3); }

/* segmented control */
.seg { display: flex; padding: 2px; border-radius: 7px; background: var(--panel-3); gap: 2px; }
.seg button {
  flex: 1; height: 24px; border: 0; background: transparent; border-radius: 5px; cursor: pointer; font-size: 12.5px; font-weight: 500;
  color: var(--text-2); display: flex; align-items: center; justify-content: center; gap: 5px; padding: 0 8px; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.12); }
:root[data-theme='dark'] .seg button.on { background: var(--line-2); }

/* ------------------------------------------------ app bar */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--bar-h); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); justify-self: start; }
.brand-mark { display: none; }
.brand-name { display: block; height: 26px; }
.brand-name svg { height: 26px; width: auto; display: block; overflow: visible; }
.brand-name .fallback { font-weight: 600; font-size: 15px; line-height: 26px; }
.tier-badge {
  height: 20px; padding: 0 7px; border-radius: 4px; border: 1px solid var(--line-2); background: transparent; color: var(--text-2);
  font-size: 11px; font-weight: 600; cursor: pointer; letter-spacing: 0.01em;
}
.tier-badge:hover { background: var(--panel-2); color: var(--text); }
.tier-badge.plus, .tier-badge.pro { border-color: transparent; background: var(--accent-soft); color: var(--accent-text); }
.tabs { display: flex; padding: 2px; border-radius: 8px; background: var(--panel-3); gap: 2px; }
.tabs a {
  display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 14px; border-radius: 6px; text-decoration: none;
  color: var(--text-2); font-weight: 500; font-size: 13px;
}
.tabs a:hover { color: var(--text); }
.tabs a.on { background: var(--panel); color: var(--text); box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.12); }
:root[data-theme='dark'] .tabs a.on { background: var(--line-2); }
.tabs a .ic { width: 15px; height: 15px; }
.top-actions { display: flex; gap: 2px; justify-self: end; }

main { padding: 0; }
.card { padding: 14px 16px; }

/* ------------------------------------------------ write view */
.write-grid { display: grid; grid-template-columns: 380px minmax(0, 1fr) 300px; height: calc(100vh - var(--bar-h)); }
.editor-card { display: flex; flex-direction: column; gap: 10px; background: var(--panel); border-right: 1px solid var(--line); overflow: auto; min-height: 0; }
.card-head { display: flex; align-items: center; gap: 8px; }
.title-input {
  flex: 1; min-width: 0; height: 32px; border: 1px solid transparent; background: transparent; font-size: 17px; font-weight: 600;
  padding: 0 6px; margin-left: -7px; border-radius: 6px; color: var(--text);
}
.title-input:hover { border-color: var(--line); }
.title-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.save-state { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.toolbar { display: flex; align-items: center; gap: 1px; flex-wrap: wrap; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.toolbar button {
  min-width: 28px; height: 28px; border: 0; background: transparent; border-radius: 6px; cursor: pointer;
  display: grid; place-items: center; padding: 0 6px; font-size: 13.5px; color: var(--text-2);
}
.toolbar button:hover { background: var(--panel-3); color: var(--text); }
.toolbar button.on { background: var(--panel-3); color: var(--text); }
.toolbar .sep { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
.toolbar .ai-btn { display: flex; gap: 4px; font-weight: 600; font-size: 12.5px; color: var(--accent-text); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; border-radius: 8px; padding: 4px; min-width: 210px;
  display: flex; flex-direction: column; background: var(--panel); box-shadow: var(--pop-shadow);
}
.menu button { display: flex; align-items: center; gap: 9px; text-align: left; border: 0; background: transparent; height: 28px; padding: 0 9px; border-radius: 5px; cursor: pointer; font-size: 13px; width: 100%; }
.menu button:hover { background: var(--accent); color: #fff; }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger); color: #fff; }
.menu.symbols { display: grid; grid-template-columns: repeat(6, 1fr); min-width: 240px; }
.menu.symbols button { justify-content: center; font-size: 15px; padding: 0; }
.font-picker .menu { left: auto; right: 0; }
.editor {
  flex: 1; min-height: 240px; overflow: auto; padding: 2px 0; outline: none; font-size: 15px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.editor:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.editor mark { background: #fff0a3; color: inherit; border-radius: 2px; }
:root[data-theme='dark'] .editor mark { background: #6a5a12; }
.editor h1, .editor h2, .editor h3 { font-size: 19px; font-weight: 600; margin: 0.2em 0; }
.editor ul { margin: 0.2em 0; padding-left: 1.3em; }
.editor table { border-collapse: collapse; width: 100%; margin: 4px 0; }
.editor td, .editor th { border: 1px solid var(--line-2); padding: 3px 7px; min-width: 40px; vertical-align: top; text-align: left; }
.editor th { background: var(--panel-2); font-weight: 600; }
.counter { font-size: 11.5px; color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
.write-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.write-options .field:first-child { grid-column: 1 / -1; }
.cta-row { display: flex; gap: 8px; }
.cta-row .big, .magnet { flex: 1; display: flex; }
.magnet > .btn { flex: 1; }

/* canvas area */
.preview-card { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); padding: 0; position: relative; }
.preview-bar { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.pager, .zoom { display: flex; align-items: center; gap: 2px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pager span { min-width: 84px; text-align: center; }
.zoom span { min-width: 40px; text-align: center; }
.preview-actions { display: flex; gap: 4px; margin-left: auto; }
.preview-scroll { flex: 1; overflow: auto; padding: 28px 24px 60px; position: relative; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.page { position: relative; background: #fff; box-shadow: var(--paper-shadow); }
.page canvas { display: block; width: 100%; height: auto; }
.page .page-no { position: absolute; bottom: -19px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--text-3); }
.page.fresh { animation: pagein 0.25s ease-out; }
@keyframes pagein { from { opacity: 0; } }
.preview-empty { display: grid; place-items: center; text-align: center; color: var(--text-2); padding: 80px 20px; gap: 10px; }
.empty-art { width: min(340px, 80%); color: var(--text-3); }
.empty-art svg { width: 100%; height: auto; overflow: visible; }
.render-busy {
  position: absolute; top: 54px; right: 14px; display: flex; align-items: center; gap: 7px; font-size: 12px; padding: 4px 9px;
  border-radius: 6px; background: var(--panel); box-shadow: var(--pop-shadow); color: var(--text-2);
}
.spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* inspector */
.look-card { display: flex; flex-direction: column; gap: 12px; background: var(--panel); border-left: 1px solid var(--line); overflow: auto; min-height: 0; }
.look-head { display: flex; align-items: center; gap: 8px; }
.look-head h2 { flex: 1; }
.look-close { display: none; }
.presets { display: flex; }
.presets select { flex: 1; }
.chip { border: 1px solid var(--line-2); background: var(--panel); border-radius: 5px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.chip:hover { background: var(--panel-2); }
.chip.on { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.look-body { display: flex; flex-direction: column; gap: 12px; }
.ctl { display: flex; flex-direction: column; gap: 4px; position: relative; }
.ctl-top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); }
.ctl-top .val { margin-left: auto; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ctl-row { display: grid; grid-template-columns: 1fr 58px; gap: 8px; align-items: center; }
.num-input { height: 24px; width: 100%; padding: 0 6px; border: 1px solid var(--line-2); border-radius: 5px; background: var(--panel); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.num-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ctl small { color: var(--text-3); font-size: 11.5px; line-height: 1.35; }
.ctl-group-title { font-size: 11.5px; font-weight: 600; color: var(--text-2); padding-top: 10px; border-top: 1px solid var(--line); margin-top: 2px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatch { width: 20px; height: 20px; border-radius: 50%; border: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.swatch.on { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15), 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.hex-input { width: 78px; height: 24px; font-family: var(--mono); font-size: 11.5px; padding: 0 6px; }
.color-native { width: 24px; height: 24px; border: 1px solid var(--line-2); border-radius: 5px; padding: 1px; background: var(--panel); cursor: pointer; }
.paper-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; }
.paper-tile { border: 0; background: transparent; padding: 0; cursor: pointer; display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-2); text-align: center; }
.paper-tile canvas { width: 100%; aspect-ratio: 210 / 297; border-radius: 2px; box-shadow: 0 0 0 1px var(--line-2); }
.paper-tile.on { color: var(--accent-text); font-weight: 600; }
.paper-tile.on canvas { box-shadow: 0 0 0 2px var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ------------------------------------------------ font view */
.font-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr) 300px; height: calc(100vh - var(--bar-h)); }
.chars-card { display: flex; flex-direction: column; gap: 12px; border-right: 1px solid var(--line); min-height: 0; }
.font-picker { display: flex; gap: 4px; }
.progress-wrap { display: flex; flex-direction: column; gap: 5px; }
.progress-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); }
.progress-top b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.progress { height: 4px; border-radius: 2px; background: var(--panel-3); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.chars-filters { display: flex; gap: 10px; align-items: center; }
.chars-filters select { flex: 1; }
.char-groups { overflow: auto; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.char-group h4 { margin: 0 0 6px; font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.char-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 4px; }
.char-tile {
  aspect-ratio: 1; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 15px;
  display: grid; place-items: center; position: relative; color: var(--text-3);
}
.char-tile:hover { background: var(--panel-2); color: var(--text); }
.char-tile.done { color: var(--text); background: var(--panel-2); }
.char-tile.done::after { content: ''; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.char-tile.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.char-tile.on::after { background: #fff; }
.capture-card { display: flex; flex-direction: column; gap: 12px; background: var(--bg); overflow: auto; padding: 16px 24px; }
.capture-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mode-seg { width: 290px; }
.char-nav { display: flex; align-items: center; gap: 6px; }
.current-char { display: flex; align-items: baseline; gap: 8px; min-width: 120px; justify-content: center; }
.current-char span { font-size: 30px; font-weight: 600; line-height: 1; }
.current-char small { color: var(--text-3); font-size: 12px; }
.hint { margin: 0; font-size: 12.5px; color: var(--text-2); text-align: center; }
.canvas-wrap { position: relative; width: min(100%, 520px); margin: 0 auto; }
.glyph-canvas { width: 100%; aspect-ratio: 1; display: block; border-radius: 4px; background: var(--canvas-bg); box-shadow: var(--paper-shadow); cursor: crosshair; touch-action: none; }
.fast-banner { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); font-size: 11.5px; padding: 3px 9px; border-radius: 5px; background: var(--text); color: var(--panel); white-space: nowrap; }
.tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; }
.tool-seg { flex: none; }
.tool-seg button { flex: none; }
.range-inline { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.range-inline input { width: 120px; }
.range-inline output { min-width: 40px; font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.capture-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; width: min(100%, 520px); margin: 0 auto; }
.variants { width: min(100%, 520px); margin: 0 auto; padding-top: 12px; border-top: 1px solid var(--line-2); }
.variants-head { font-size: 12.5px; margin-bottom: 8px; color: var(--text-2); }
.variants-head b { color: var(--text); }
.variants-head small { color: var(--text-3); }
.variant-list { display: flex; gap: 8px; flex-wrap: wrap; min-height: 64px; }
.variant { width: 64px; height: 64px; border-radius: 6px; background: var(--canvas-bg); box-shadow: 0 0 0 1px var(--line-2); position: relative; cursor: pointer; }
.variant:hover { box-shadow: 0 0 0 2px var(--accent); }
.variant canvas { width: 100%; height: 100%; display: block; }
.variant .del {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--text); color: var(--panel); cursor: pointer; opacity: 0;
}
.variant .del .ic { width: 10px; height: 10px; }
.variant:hover .del, .variant:focus-within .del { opacity: 1; }
@media (hover: none) { .variant .del { opacity: 1; } }
.variant-empty { color: var(--text-3); font-size: 12.5px; align-self: center; }
.side-stack { display: flex; flex-direction: column; border-left: 1px solid var(--line); overflow: auto; min-height: 0; }
.side-stack > .card { border-bottom: 1px solid var(--line); }
.test-canvas { width: 100%; height: 110px; display: block; margin-top: 8px; border-radius: 6px; background: var(--canvas-bg); box-shadow: 0 0 0 1px var(--line); }
.btn-col { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tips { margin: 0; padding-left: 16px; font-size: 12.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }

/* ------------------------------------------------ notebooks */
#view-hefte { background: var(--bg); min-height: calc(100vh - var(--bar-h)); }
.docs-card { max-width: 1180px; margin: 0 auto; padding: 22px 24px 60px; background: transparent; }
.docs-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.docs-head h2 { margin-right: auto; font-size: 20px; }
.docs-head .search { width: 200px; }
.docs-head select { width: 160px; }
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 24px 18px; }
.doc-card { display: flex; flex-direction: column; cursor: pointer; border-radius: 8px; padding: 6px; margin: -6px; }
.doc-card:hover { background: rgba(0, 0, 0, 0.035); }
:root[data-theme='dark'] .doc-card:hover { background: rgba(255, 255, 255, 0.04); }
.doc-thumb { aspect-ratio: 210 / 250; background: #fff; overflow: hidden; box-shadow: var(--paper-shadow); border-radius: 2px; }
.doc-thumb canvas { width: 100%; display: block; }
.doc-meta { padding: 9px 2px 0; display: flex; flex-direction: column; gap: 1px; }
.doc-meta b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta small { color: var(--text-3); font-size: 11.5px; }
.doc-actions { display: flex; padding-top: 2px; visibility: hidden; }
.doc-card:hover .doc-actions, .doc-card:focus-within .doc-actions { visibility: visible; }
@media (hover: none) { .doc-actions { visibility: visible; } }
.folder-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-2); }
.folder-chip .ic { width: 12px; height: 12px; }
.docs-empty { text-align: center; color: var(--text-2); padding: 60px 20px; display: grid; place-items: center; gap: 8px; }

/* ------------------------------------------------ dialogs */
.dialog {
  border: 0; border-radius: 12px; padding: 18px 20px; width: min(500px, calc(100% - 24px)); color: var(--text);
  max-height: calc(100vh - 40px); overflow: auto; background: var(--panel); box-shadow: var(--pop-shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.3); }
.dialog[open] { animation: pop 0.16s ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(0.98); } }
.dialog.full { width: min(1100px, calc(100% - 24px)); height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--bg); }
.dialog.full[open] { display: flex; }
.dialog.wide { width: min(720px, calc(100% - 24px)); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.dlg-head h2 { font-size: 15px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.export-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.export-item { display: flex; gap: 12px; align-items: center; text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--text); }
.export-item:hover { background: var(--panel-3); }
.export-item b { display: block; font-size: 13.5px; font-weight: 600; }
.export-item small { color: var(--text-2); font-size: 12px; }
.ex-ic {
  width: 34px; height: 42px; flex: none; display: grid; place-items: end center; padding-bottom: 5px; font-size: 9px; font-weight: 700; letter-spacing: 0.02em;
  background: var(--panel); color: var(--text-2); border: 1px solid var(--line-2); border-radius: 3px 8px 3px 3px;
}
.ex-ic.pdf { color: var(--danger); }
.ex-ic.gn { color: var(--accent-text); }
.full-scroll { flex: 1; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 12px; }
.full-scroll canvas { width: min(100%, 900px); height: auto; box-shadow: var(--paper-shadow); }
.scan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; max-height: 50vh; overflow: auto; padding: 2px; }
.scan-item { border: 1px solid var(--line); border-radius: 6px; padding: 5px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; background: var(--canvas-bg); }
.scan-item canvas { width: 60px; height: 60px; }
.scan-item.off { opacity: 0.3; }
.scan-item span { font-size: 12px; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 10px); opacity: 0; pointer-events: none; z-index: 100;
  padding: 8px 14px; border-radius: 8px; background: rgba(30, 30, 32, 0.94); color: #fff; font-size: 13px;
  box-shadow: var(--pop-shadow); transition: opacity 0.18s, transform 0.18s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast[data-kind='err'] { background: var(--danger); }

/* ------------------------------------------------ tiers, AI, editor, sharing */
.plus-tag, .pro-tag { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; vertical-align: 1px; background: var(--accent-soft); color: var(--accent-text); }
.ctl.locked > *:not(.lock-overlay) { opacity: 0.4; pointer-events: none; }
.lock-overlay { position: absolute; inset: 0; border: 0; background: transparent; cursor: pointer; display: flex; justify-content: flex-end; align-items: flex-start; padding: 0; }
.lock-overlay span { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-text); }
.tier-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.tier-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.tier-card b { font-size: 13px; }
.tier-card ul { margin: 4px 0 0; padding-left: 16px; font-size: 12.5px; color: var(--text-2); }
.unlock-form { display: flex; gap: 6px; margin: 8px 0 4px; }
.unlock-form input { flex: 1; }
.ai-q { resize: vertical; min-height: 90px; line-height: 1.5; }
.ai-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.ai-row .text-input { flex: 1; }
.ai-thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ai-thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.ai-answer { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--panel-2); white-space: pre-wrap; max-height: 40vh; overflow: auto; line-height: 1.55; }
.ai-memory { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.ai-memory summary { cursor: pointer; font-weight: 500; }
.mem-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 2px 0; }
.mem-item span { flex: 1; }
#ai-which { font-size: 11px; margin-left: 6px; vertical-align: 1px; font-weight: 500; }
.history-list { display: flex; flex-direction: column; max-height: 60vh; overflow: auto; }
.history-item { display: flex; gap: 10px; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.history-item div { flex: 1; min-width: 0; }
.history-item b { display: block; font-size: 12px; font-weight: 600; }
.history-item small { display: block; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edit-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--panel); flex: none; }
.edit-bar .seg { flex: none; }
.edit-actions { display: flex; gap: 2px; align-items: center; margin-left: auto; }
.page.editing { box-shadow: var(--paper-shadow), 0 0 0 2px var(--accent); }
.editor-text-input { position: absolute; width: 240px; z-index: 5; box-shadow: var(--pop-shadow); }
.edited-banner { display: flex; gap: 10px; align-items: center; padding: 6px 12px; font-size: 12.5px; background: #fdf6d8; color: #5c4a00; border-bottom: 1px solid var(--line); flex: none; }
:root[data-theme='dark'] .edited-banner { background: #3b3315; color: #f1e2a0; }
.edited-banner span { flex: 1; }
.shared-preview { width: 100%; max-height: 60vh; object-fit: contain; box-shadow: var(--paper-shadow); background: #fff; }
.ai-settings { display: grid; gap: 10px; }
.ai-settings .field span { display: flex; justify-content: space-between; gap: 8px; }
.ai-settings .field a { text-decoration: none; }
.key-row { display: flex; gap: 6px; align-items: center; }
.key-row .text-input { flex: 1; }
.handwrite path { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------ responsive */
@media (max-width: 1280px) {
  .write-grid { grid-template-columns: 340px minmax(0, 1fr); }
  .look-card { position: fixed; top: var(--bar-h); right: 0; bottom: 0; width: min(320px, 100%); z-index: 40; transform: translateX(102%); transition: transform 0.25s ease; box-shadow: var(--pop-shadow); }
  .look-card.open { transform: none; }
  .look-close { display: grid; }
  .font-grid { grid-template-columns: 300px minmax(0, 1fr); height: auto; min-height: calc(100vh - var(--bar-h)); }
  .side-stack { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .side-stack > .card { border-bottom: 0; border-right: 1px solid var(--line); }
}
@media (min-width: 1281px) { #btn-edit-look { display: none; } }
@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; height: auto; padding: 8px 10px; row-gap: 8px; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-content: stretch; }
  .tabs a { flex: 1; justify-content: center; padding: 0 6px; }
  .write-grid, .font-grid { grid-template-columns: 1fr; height: auto; }
  .editor-card, .chars-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .editor { max-height: 45vh; }
  .preview-card { min-height: 70vh; }
  .preview-actions .btn span, #edit-tools button span, .tool-seg button span { display: none; }
  .char-groups { max-height: 40vh; }
  .docs-head .search, .docs-head select { width: 100%; }
  .tier-cards { grid-template-columns: 1fr; }
  .look-card { top: 0; }
}
@media (max-width: 420px) { .tabs .ic { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.import-review { max-height: 46vh; outline: none; }
.import-review:focus { box-shadow: 0 0 0 2px var(--accent-soft); }
mark.unsure { background: #ffe58a; color: inherit; border-radius: 2px; padding: 0 1px; }
:root[data-theme='dark'] mark.unsure { background: #6a5a12; }
#admin-box code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); padding: 0 4px; border-radius: 3px; }

a.btn { text-decoration: none; }
