:root {
  --paper: #fbfaf6;
  --rule: rgba(150, 168, 186, .38);
  --ink: #1d2421;
  --muted: #8a918c;
  --chrome: rgba(251, 250, 246, .92);
  --edge: rgba(29, 36, 33, .08);
  --accent: #5f8210;
  --line: 34px;
  --top: 96px;
}
/* Paper stays paper in dark mode, the way a notebook does. */
html { color-scheme: light; }
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--paper); color: var(--ink);
  font-family: -apple-system, system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

.bar {
  position: fixed; z-index: 3; top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top) + 6px) 12px 6px;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(var(--paper) 70%, transparent);
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.date { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); letter-spacing: .02em; }

.icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; }
.icon svg { width: 22px; height: 22px; fill: none; stroke: #39433e; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon:active { background: var(--edge); }
.icon:disabled svg { stroke: #c4c8c5; }

#scroller {
  position: fixed; inset: 0; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
#scroller::-webkit-scrollbar { display: none; }
#sheet {
  position: relative; width: 100%;
  background-color: var(--paper);
  background-image: linear-gradient(to bottom, var(--rule) 1px, transparent 1px);
  background-size: 100% var(--line);
  background-position: 0 var(--top);
}
/* The canvas is only ever the size of the screen; it stays put while the ruled sheet scrolls under it. */
#stage { position: sticky; top: 0; height: 100vh; height: 100dvh; margin-bottom: -100vh; margin-bottom: -100dvh; }
#ink { display: block; width: 100%; height: 100%; }

.tools {
  position: fixed; z-index: 3; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  display: flex; align-items: center; gap: 2px; padding: 6px 10px;
  background: var(--chrome); border-radius: 22px;
  box-shadow: 0 6px 24px rgba(29, 36, 33, .10), 0 0 0 1px var(--edge);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.sep { width: 1px; height: 26px; background: var(--edge); margin: 0 6px; }
.tool { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; }
.tool i { width: 20px; height: 20px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.tool.hl i { border-radius: 4px; width: 14px; height: 22px; transform: rotate(20deg); opacity: .85; }
.tool svg { width: 22px; height: 22px; fill: none; stroke: #39433e; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool.on { background: rgba(95, 130, 16, .12); box-shadow: inset 0 0 0 1.5px rgba(95, 130, 16, .45); }

.pages {
  position: fixed; inset: 0; z-index: 5; background: #f3f2ec; overflow-y: auto;
  padding-bottom: calc(env(safe-area-inset-bottom) + 24px);
}
.pages-bar {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 20px 8px; background: rgba(243, 242, 236, .94);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.pages-bar h2 { margin: 0; font-size: 17px; font-weight: 600; }
.text { min-height: 44px; padding: 0 8px; color: var(--accent); font-weight: 600; font-size: 17px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px; padding: 12px 20px; }
.tile { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.tile canvas {
  width: 100%; aspect-ratio: 3 / 4; border-radius: 10px; background: var(--paper);
  box-shadow: 0 2px 8px rgba(29, 36, 33, .07), 0 0 0 1px var(--edge);
}
.tile.current canvas { box-shadow: 0 0 0 2px var(--accent); }
.tile span { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.tile .del { display: none; }
.empty { color: var(--muted); padding: 40px 20px; }
