/* Pebbble design system, shared by the player and the writer.
   Calm and light: a stone-grey ground, paper sheets, ink stones, one moss accent.
   Light theme only, because the stones are drawn in dark ink. */
:root {
    --bg: #ecebe7; --paper: #f6f5f2; --ink: #1d1b18; --soft: #66625a; --faint: #9d988e; --line: #dcd8cf;
    --accent: #3f5e4a; --accent-soft: #e3e8e2; --warn: #9a3b2a; --warn-soft: #f3e6e2; --field: #fff;
    --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, monospace;
    --ease: cubic-bezier(.22, .8, .24, 1);
    color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); overflow-x: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: inherit; }
[hidden] { display: none !important; }
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; }
.soft { color: var(--soft); }
.faint { color: var(--faint); }
.app { max-width: 440px; margin: 0 auto; min-height: 100%; position: relative; padding: 0 24px calc(96px + env(safe-area-inset-bottom)); }

/* stone */
.stone svg { display: block; width: 100%; height: auto; }
.stone.breathing { animation: breathe 6s var(--ease) infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1) rotate(0deg); } 50% { transform: scale(1.025) rotate(.6deg); } }
.appear { animation: appear 1.2s var(--ease) both; }
.appear.d1 { animation-delay: .25s; } .appear.d2 { animation-delay: .5s; } .appear.d3 { animation-delay: .8s; } .appear.d4 { animation-delay: 1.2s; }
@keyframes appear { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.rings { position: relative; width: 120px; height: 120px; margin: 0 auto 28px; }
.rings i { position: absolute; inset: 0; border: 1px solid var(--soft); border-radius: 50%; opacity: 0; animation: ring 3.6s var(--ease) infinite; }
.rings i:nth-child(2) { animation-delay: 1.2s; } .rings i:nth-child(3) { animation-delay: 2.4s; }
.rings b { position: absolute; inset: 38%; background: var(--ink); border-radius: 46% 54% 50% 50% / 55% 45% 55% 45%; }
@keyframes ring { from { transform: scale(.35); opacity: .7; } to { transform: scale(1); opacity: 0; } }

/* buttons */
.primary { display: block; width: 100%; padding: 16px; border-radius: 999px; background: var(--ink); color: var(--paper); font-weight: 600; letter-spacing: .01em; text-align: center; }
.primary:active { transform: scale(.98); }
.primary.warn { background: var(--warn); }
.ghost { display: block; width: 100%; padding: 14px; border-radius: 999px; border: 1px solid var(--line); text-align: center; }
.link { color: var(--accent); font-weight: 600; font-size: .9rem; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.icon-btn:active { background: rgba(0,0,0,.05); }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.danger { color: var(--warn); padding: 12px 0; font-weight: 600; }

/* top bar and labels */
.bar { display: flex; justify-content: space-between; align-items: center; height: 56px; margin: 0 -10px; padding-top: env(safe-area-inset-top); }
.bar .title { font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--soft); }
.eyebrow { font-size: .78rem; letter-spacing: .16em; text-transform: uppercase; color: var(--soft); margin: 0 0 28px; }
.cap, .set-group > label { display: block; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); margin: 0 0 8px; }
.note { font-size: .85rem; color: var(--soft); margin: 0 0 18px; line-height: 1.5; }

/* rows */
.menu-row { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 16px 4px; border-top: 1px solid var(--line); }
.menu-row:last-of-type { border-bottom: 1px solid var(--line); }
.menu-row .txt { flex: 1; min-width: 0; }
.menu-row b { display: block; font-weight: 600; }
.menu-row span { font-size: .88rem; color: var(--soft); }
.menu-row .chev { width: 18px; height: 18px; color: var(--faint); flex: none; }
.menu-row.warn b { color: var(--warn); }
.menu-row.confirm { background: var(--warn-soft); border-radius: 12px; border-color: transparent; padding-left: 12px; }
.voices { list-style: none; margin: 8px 0 0; padding: 0; }
.voice { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-top: 1px solid var(--line); cursor: pointer; }
.voice:last-child { border-bottom: 1px solid var(--line); }
.voice .n { width: 22px; text-align: center; font-size: .85rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.voice .n .icon { width: 16px; height: 16px; }
.voice .t { flex: 1; min-width: 0; }
.voice .d { font-size: .85rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.voice.current .t { font-weight: 600; }
.voice.current .n { color: var(--accent); }
.voice.sleeping .t { color: var(--soft); }
.voice .wake { display: block; font-size: .8rem; color: var(--faint); }

/* shelf of stones */
.library h1 { font-size: 1.7rem; margin: 8px 0 24px; }
.shelf { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 20px; }
.shelf button { text-align: center; }
.shelf .stone { width: 78%; margin: 0 auto 12px; transition: transform .4s var(--ease); }
.shelf button:active .stone { transform: scale(.96); }
.shelf .name { font-family: var(--serif); font-size: 1.1rem; line-height: 1.25; }
.shelf .sub { font-size: .8rem; color: var(--faint); }
.empty { text-align: center; padding-top: 18vh; }

/* sheets */
.scrim { position: fixed; inset: 0; background: rgba(29,27,24,.28); opacity: 0; pointer-events: none; transition: opacity .35s var(--ease); z-index: 20; }
.scrim.on { opacity: 1; pointer-events: auto; }
.scrim.over { z-index: 35; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 440px; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; margin: 0 auto; background: var(--paper); border-radius: 22px 22px 0 0; padding: 10px 24px calc(28px + env(safe-area-inset-bottom)); transform: translateY(105%); transition: transform .45s var(--ease); z-index: 30; box-shadow: 0 -10px 40px rgba(0,0,0,.08); }
.sheet.on { transform: none; }
.sheet.over { z-index: 40; }
.handle { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 18px; }
.sheet h2 { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; margin: 6px 0 6px; }
.sheet p.lead { color: var(--soft); margin: 0 0 20px; }
.sheet-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; }
.sheet-head .stone { width: 52px; }
.sheet-head h2 { margin: 0; }
.choice { display: block; width: 100%; text-align: left; padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px; margin-bottom: 10px; }
.choice b { display: block; font-weight: 600; margin-bottom: 2px; }
.choice span { font-size: .9rem; color: var(--soft); }
.choice.selected { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.field { display: block; width: 100%; padding: 15px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--field); font: inherit; color: var(--ink); margin: 0 0 14px; }
.field:focus { outline: none; border-color: var(--ink); }
.field.mono { font-family: var(--mono); font-size: .85rem; }
.pw-field { position: relative; margin: 0 0 14px; }
.pw-field .field { margin: 0; padding-right: 54px; }
.reveal { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--soft); }
.reveal .icon { width: 20px; height: 20px; }
.hint { font-family: var(--serif); font-style: italic; font-size: 1.1rem; margin: 0 0 18px; }
.msg { color: var(--warn); font-size: .9rem; min-height: 1.4em; margin: 10px 0 0; text-align: center; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* settings */
.set-group { margin: 22px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); }
.chips button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.version { font-size: .78rem; color: var(--faint); margin-top: 18px; }

.toast { position: fixed; left: 50%; top: calc(56px + env(safe-area-inset-top)); transform: translate(-50%, -12px); opacity: 0; background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-size: .88rem; transition: all .4s var(--ease); z-index: 60; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
