/* Inkwell — e-ink calm. Warm paper, near-black ink, greyscale chrome, minimal
   toolbar that fades while you write. CSP-clean: system fonts only, no CDN.
   Reuses the repo's :root-token structure but goes deliberately monochrome. */

:root {
  --paper: #F7F5F0;
  --paper-2: #FBFAF7;
  --ink: #1A1A1A;
  --ink-soft: #4a4642;
  --muted: #8b857c;
  --rule: #e2dcd0;
  --rule-strong: #cfc7b8;
  --chrome: #efece5;
  --chrome-hi: #ffffff;
  --shadow: rgba(40, 34, 26, 0.14);
  --accent: #1A1A1A;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Playfair Display", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Open Sans", system-ui, sans-serif;

  --bar-h: 52px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.toolbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  height: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 14px 0;
  background: var(--chrome);
  border-bottom: 1px solid var(--rule-strong);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
  transition: opacity 0.4s ease;
  overflow-x: auto;
  scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }
.toolbar.dimmed { opacity: 0.18; }

.tool-group { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.tool-group.push { margin-left: auto; }

.brand .wordmark {
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.01em;
  padding-right: 6px;
  color: var(--ink);
}

/* Buttons */
.tool-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  height: 36px;
  min-width: 36px;
  padding: 0 8px;
  border-radius: 9px;
  font: inherit;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.tool-btn:hover { background: rgba(0,0,0,0.05); }
.tool-btn:active { background: rgba(0,0,0,0.09); }
.tool-btn:disabled { opacity: 0.34; cursor: default; }
.tool-btn.is-on { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
.tool-btn svg { display: block; }

/* Brush chips */
.brush {
  position: relative;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--rule-strong);
  background: var(--chrome-hi);
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.brush.is-active {
  background: var(--ink);
  color: var(--paper-2);
  border-color: var(--ink);
  box-shadow: 0 1px 4px var(--shadow);
}

/* Colour swatches */
.swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  min-width: 0;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.12);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.swatch.is-active {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}
.swatch.is-white { border-color: var(--rule-strong); }

/* Size indicator */
.size-dot {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ink);
  transition: width 0.12s ease, height 0.12s ease;
}

/* ── Stage / canvas ──────────────────────────────────────────────────────── */
.stage {
  position: relative;
  height: calc(100% - var(--bar-h) - env(safe-area-inset-top, 0px));
}
.paper {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;               /* the pen/gesture handler owns all input */
  cursor: crosshair;
}

/* ── Page bar (bottom) ───────────────────────────────────────────────────── */
.pagebar {
  position: absolute;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  background: rgba(239, 236, 229, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  box-shadow: 0 4px 16px var(--shadow);
  transition: opacity 0.4s ease;
}
.pagebar.dimmed { opacity: 0.12; }
.page-indicator {
  font-size: 13px;
  color: var(--ink-soft);
  min-width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pagebar-sep { width: 1px; height: 22px; background: var(--rule-strong); margin: 0 4px; }
.ocr-btn { font-size: 13px; font-family: var(--serif); }

@media (max-width: 640px) {
  .brand { display: none; }
  .brush { padding: 0 9px; font-size: 12px; }
}
