/* Inkpane — layout: a desk. Tools on the left, the document pages lying on the desk on the right. */
:root {
  --paper: #f4f5f8; --surface: #ffffff; --ink: #1b2130; --muted: #5b6375; --line: #dce0e8;
  --accent: #2340a6; --accent-ink: #ffffff; --accent-soft: #e6ebfb; --desk: #e7eaf0;
  --pad: #fdfdfb; --pad-line: #c9cfdb; --danger: #b3261e; --shadow: 0 1px 2px rgba(20,30,60,.08), 0 6px 18px rgba(20,30,60,.10);
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #12151c; --surface: #1a1f29; --ink: #e6e9ef; --muted: #9aa3b5; --line: #2b3240;
  --accent: #91a8ff; --accent-ink: #0c1230; --accent-soft: #232c4a; --desk: #0d1016;
  --pad: #f3f3ee; --pad-line: #b9bfcb; --danger: #ff8a80; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --paper: #12151c; --surface: #1a1f29; --ink: #e6e9ef; --muted: #9aa3b5; --line: #2b3240;
  --accent: #91a8ff; --accent-ink: #0c1230; --accent-soft: #232c4a; --desk: #0d1016;
  --pad: #f3f3ee; --pad-line: #b9bfcb; --danger: #ff8a80; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  color-scheme: dark; }

html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.45; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { height: 100%; display: grid; grid-template-rows: auto 1fr; }
.bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: auto; }
.brand img { width: 32px; height: 32px; flex: none; border-radius: 8px; }
.brand .txt { display: flex; flex-direction: column; min-width: 0; }
.brand h1 { font-family: var(--f-display); font-weight: 600; font-size: 20px; margin: 0; letter-spacing: -.01em; }
.brand small { color: var(--muted); font-size: 12px; }
.file { font-family: var(--f-mono); font-size: 12px; color: var(--muted); max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--surface); cursor: pointer; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); padding-inline: 8px; }
.btn.ghost:hover { color: var(--ink); }
.btn.small { padding: 4px 9px; font-size: 13px; }

.main { min-height: 0; display: grid; grid-template-columns: 330px 1fr; }
.side { min-height: 0; overflow: auto; border-right: 1px solid var(--line); background: var(--surface);
  padding-block: 16px 28px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: 16px; display: flex; flex-direction: column; gap: 22px; }
.sec { display: flex; flex-direction: column; gap: 10px; }
.sec h2 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.tabs { display: flex; gap: 4px; background: var(--paper); border-radius: 8px; padding: 3px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.padwrap { position: relative; border: 1px solid var(--line); border-radius: 10px; background: var(--pad); overflow: hidden; }
.padwrap::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 38px; border-bottom: 1px dashed var(--pad-line); pointer-events: none; }
.padwrap .x { position: absolute; left: 14px; bottom: 40px; font-family: var(--f-mono); color: var(--pad-line); font-size: 14px; pointer-events: none; }
#pad { display: block; width: 100%; height: 170px; touch-action: none; cursor: crosshair; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); }
label.inline { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
input[type="range"] { accent-color: var(--accent); width: 90px; }
input[type="checkbox"] { accent-color: var(--accent); }
.field { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--surface); }

.drop { border: 1px dashed var(--line); border-radius: 10px; padding: 18px 12px; text-align: center; color: var(--muted); cursor: pointer; background: var(--paper); }
.drop:hover { border-color: var(--accent); color: var(--ink); }

.current { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--paper); }
.current .thumb { width: 120px; height: 56px; flex: none; border-radius: 6px; background: var(--pad); display: grid; place-items: center; overflow: hidden; }
.current .thumb img { max-width: 100%; max-height: 100%; }
.current .info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }

.remember { display: flex; flex-direction: column; gap: 4px; }
.remember p { margin: 0 0 0 22px; font-size: 12px; color: var(--muted); }

ol.steps { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; display: grid; gap: 4px; }
.note { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin: 0; }
.ver { font-family: var(--f-mono); font-size: 11px; color: var(--muted); margin: 0; }

.viewer { position: relative; min-height: 0; overflow: auto; background: var(--desk); }
.viewer.placing .page { cursor: copy; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 22px 16px 60px; }
.page { position: relative; background: #fff; box-shadow: var(--shadow); flex: none; max-width: none; }
.page canvas { display: block; }
.page .num { position: absolute; top: 100%; right: 0; margin-top: 4px; font-family: var(--f-mono); font-size: 11px; color: var(--muted); }
.layer { position: absolute; inset: 0; }
.item { position: absolute; touch-action: none; cursor: grab; outline: 1px dashed transparent; user-select: none; }
.item:hover { outline-color: rgba(35,64,166,.5); }
.item.sel { outline: 1.5px solid var(--accent); }
.item img { display: block; width: 100%; height: 100%; pointer-events: none; }
.item span { display: block; white-space: pre; line-height: 1; font-family: Helvetica, Arial, sans-serif; }
.item .h { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; cursor: nwse-resize; display: none; }
.item .del { position: absolute; right: -10px; top: -26px; border: 0; background: var(--danger); color: #fff; border-radius: 6px; font-size: 12px; padding: 2px 7px; cursor: pointer; display: none; }
.item.sel .h, .item.sel .del { display: block; }

.hint { position: sticky; top: 12px; z-index: 5; margin: 12px auto 0; width: max-content; max-width: calc(100% - 32px);
  background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 6px 14px; font-weight: 500; box-shadow: var(--shadow); }
.banner { margin: 16px auto 0; max-width: 620px; width: calc(100% - 32px); background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.dropping::before { content: attr(data-drop-label); position: absolute; inset: 10px; z-index: 20; display: grid; place-items: center; border: 2px dashed var(--accent);
  border-radius: 14px; background: color-mix(in srgb, var(--desk) 80%, transparent); color: var(--accent); font-family: var(--f-display); font-size: 22px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 50; background: var(--ink); color: var(--paper);
  padding: 9px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

@media (max-width: 820px) {
  html, body { height: auto; }
  .app { height: auto; }
  .main { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .viewer { overflow: visible; min-height: 60vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
