:root{--ink:#3b3050;--bg:#f7f1e6;--card:#fff;--line:#d9cfc0;--berry:#c75b7a;--mint:#5aa98a;--c1:#fde7c2;--c2:#d8ecf7;--c3:#e6dcf6;--c4:#dff2e1;--warn:#fff3cd}
*{box-sizing:border-box}
html,body{margin:0;background:var(--bg);color:var(--ink);font:17px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
main{max-width:640px;margin:0 auto;padding:max(16px,env(safe-area-inset-top)) 16px max(24px,env(safe-area-inset-bottom))}
h1{font-size:1.6rem;margin:.3em 0 .1em}h2{font-size:1.25rem;margin:.6em 0 .4em}
p.sub{margin:0 0 1em;opacity:.8}
.card{background:var(--card);border:2px solid var(--line);border-radius:14px;padding:14px;margin:12px 0}
button{font:inherit;border:2px solid var(--ink);border-radius:12px;background:#fff;color:var(--ink);padding:.7em 1em;min-height:48px;cursor:pointer}
button.primary{background:var(--berry);border-color:var(--berry);color:#fff}
button:disabled{opacity:.45;cursor:not-allowed}
button.link{border:none;background:none;text-decoration:underline;padding:.4em .2em;min-height:40px}
.row{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.stack>*{display:block;width:100%;margin:8px 0}
textarea{width:100%;min-height:220px;font:inherit;border:2px solid var(--line);border-radius:12px;padding:10px;background:#fff;color:var(--ink)}
.count{font-weight:600}
.errors{background:var(--warn);border-radius:10px;padding:8px 12px;margin:8px 0}
.errors li{margin:2px 0}
.pets{display:flex;gap:6px;justify-content:center;margin:8px 0}.pets svg{width:56px;height:56px}
.word{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line)}
.word:last-child{border-bottom:none}
.chunks{display:inline-flex;font-size:1.5rem;font-weight:700;letter-spacing:.02em}
.chunk{padding:2px 4px;border-radius:8px}
.chunk.k0{background:var(--c1)}.chunk.k1{background:var(--c2)}.chunk.k2{background:var(--c3)}.chunk.k3{background:var(--c4)}
.whole{background:#eee}
.dbl{text-decoration:underline;text-decoration-thickness:3px;text-underline-offset:4px}
.note{width:100%;font-size:.92rem;opacity:.85}
.status{padding:12px;border-radius:12px;background:#fff;border:2px dashed var(--line)}
label.choice{display:flex;gap:10px;align-items:flex-start;padding:10px;border:2px solid var(--line);border-radius:12px;background:#fff}
label.choice input{width:24px;height:24px;margin-top:2px}
pre.notice{white-space:pre-wrap;font-size:.85rem;background:#fff;border:1px solid var(--line);border-radius:10px;padding:10px;max-height:50vh;overflow:auto}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
body.reduce-motion *{animation:none!important;transition:none!important}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
/* D3: consistent touch controls and breathing room above mobile browser chrome. */
main{padding-bottom:calc(28px + env(safe-area-inset-bottom))}
select{display:block;width:100%;min-width:0;min-height:48px;font:inherit;color:var(--ink);background:#fff;border:2px solid var(--line);border-radius:12px;padding:8px 10px}
.voice-card{display:grid;gap:10px}
.voice-card h3,.voice-card p{margin:0}
.voice-card label{font-weight:650}
.voice-card input[type=range]{width:100%;margin:0;min-height:44px}
.voice-card .row>button{flex:1 1 160px}
.row>button{min-height:48px}
button.link{min-height:48px}
.row>button.link:last-child{padding:.7em 1em}
.pets{min-height:72px;align-items:center;background:linear-gradient(120deg,#dff2e1,#fff0ba);border-radius:24px;padding:8px}
.pets>span{display:grid;place-items:center}
.setup-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));align-items:stretch}
.setup-actions>button:first-child{grid-column:1 / -1}
.back-button{width:100%}
/* D4: cream-and-rose spelling garden with existing WordBar pets. */
body{background:radial-gradient(ellipse at 8% 0,#fce0e8,transparent 45%),var(--bg)}
.garden-eyebrow{font-size:.76rem;letter-spacing:.1em;color:#93506a;font-weight:800;margin-top:12px}
.flow-guide{background:#fff9ed;border:2px solid #e5d8c5;border-radius:20px;padding:14px;margin:18px 0}
.flow-guide h2{font-size:1.05rem;margin:0 0 10px}
.garden-steps{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:1fr 1fr;gap:8px;counter-reset:step}
.garden-steps li{counter-increment:step;font-size:.85rem;padding:9px;border-radius:12px;background:#fbe4eb;font-weight:650}
.garden-steps li:before{content:counter(step) '. ';color:#9e4763}
.flow-guide .note{margin-bottom:0}
.list-shelves{display:grid;gap:12px}
.list-card{position:relative;background:#fffaf5;border:2px solid #e6cbd4;border-radius:20px;padding:14px 16px;box-shadow:0 4px 0 #eadbe0}
.list-card h3{padding-right:35px;overflow-wrap:anywhere;margin:0 0 3px;font-size:1.1rem}
.list-card p{margin:2px 0 10px}
.list-flower{position:absolute;right:15px;top:8px;color:#cc7394;font-size:30px}
.empty-garden{border:2px dashed #d7b6c2;border-radius:22px;text-align:center;padding:16px;background:#fffaf4}
.empty-garden>span{font-size:2rem}.empty-garden h3{margin:4px}.empty-garden p{margin:6px}
#list-name{width:100%;min-height:48px;margin:6px 0 14px;padding:10px 12px;font:inherit;border:2px solid var(--line);border-radius:12px;background:#fff;color:var(--ink)}
@media(max-width:480px){.row>button:not(.link){flex:1 1 140px}.row>button.link:last-child{border:2px solid var(--line);background:#fff;text-decoration:none}.voice-card .row>button{flex-basis:100%}}
.community-links input{width:100%;min-width:0}.community-links a{font-weight:700}.community-links [hidden]{display:none}
.garden-progress{display:flex;flex-wrap:wrap;gap:6px;font-size:1.3rem}
/* D7.2 layout: play first */
.home-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.home-head h1{margin:2px 0 4px;font-size:clamp(1.6rem,7vw,2.2rem)}
.home-head .sub{margin:0}
.home-head .pets{min-height:0;padding:6px;margin:0;border-radius:18px;flex-shrink:0;gap:2px}
.home-head .pets svg{width:40px;height:40px}
.community-links{padding:10px 14px;margin:12px 0}
.community-links .row{margin:0;align-items:center}
.lists-title{margin:14px 0 10px}
details.flow-guide summary{cursor:pointer;font-weight:800;font-size:1rem;min-height:44px;display:flex;align-items:center}
details.flow-guide[open] summary{margin-bottom:8px}
.play-bar{margin:8px 0 14px}
.play-bar .row{margin-top:0}
.play-bar .choice{margin:10px 0 4px}
.pending-note{color:#9e3a5c;font-weight:700;margin:6px 0 0}
@media(max-width:360px){.home-head .pets{display:none}}
/* D7.3 settings */
.settings-group{margin:0 0 12px;display:grid;gap:10px}
.settings-group h3{margin:0}
.slider-head{display:flex;justify-content:space-between;align-items:baseline;gap:8px;font-weight:700}
.slider-value{font-weight:800;color:#9e3a5c;min-width:3.2em;text-align:right}
.slider-row{display:flex;align-items:center;gap:10px}
.slider-row input[type=range]{flex:1;min-height:44px;margin:0}
.slider-row button{flex-shrink:0;min-height:44px}
/* ================= D8: iOS-style flow ================= */
/* Polish: no zoom-on-focus (inputs >= 16px), no double-tap delay, no grey tap flash. */
input,select,textarea{font-size:max(16px,1em)}
button,a,summary,label.choice{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
button:not(:disabled):active{transform:scale(.98)}
/* Titles receive focus for screen readers after each screen change; they are
   not controls, so they don't need a focus box. */
h1[tabindex="-1"]:focus,h2[tabindex="-1"]:focus{outline:none}
/* A solid strip behind the clock / status bar so text never scrolls under it. */
body:not(.in-game)::before{content:"";position:fixed;left:0;right:0;top:0;height:env(safe-area-inset-top);background:var(--bg);z-index:60;pointer-events:none}
body.sheet-open{overflow:hidden}

/* Top bar on every screen except Home and the game. */
.nav-bar{position:sticky;top:env(safe-area-inset-top);z-index:50;display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:6px;
  margin:-4px -16px 10px;padding:6px 16px;background:rgba(247,241,230,.94);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border-bottom:1px solid var(--line)}
.nav-back{border:none;background:none;color:#a93e66;font-weight:700;padding:.4em .2em;min-height:44px;display:flex;align-items:center;gap:4px}
.nav-chevron{font-size:1.7rem;line-height:1;margin-top:-3px}
.nav-title{grid-column:2;text-align:center;font-size:1.05rem;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.nav-bar::after{content:"";grid-column:3;width:64px}

/* Home */
.lists-head{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.lists-count{font-size:.9rem;color:#8a6a78;font-weight:700}
.list-card{padding:14px 16px 16px}
.card-top{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}
.card-top h3{padding-right:0;margin:2px 0 3px}
.card-more{border:none;background:#f6e6ec;color:#7d3f58;border-radius:999px;min-height:40px;min-width:48px;padding:0 10px;font-weight:900;letter-spacing:1px;flex-shrink:0}
.card-play{width:100%;margin-top:4px;font-weight:800}
.new-list{display:block;width:100%;margin:12px 0}
.home-links{display:flex;flex-wrap:wrap;justify-content:center;gap:4px 14px;margin:16px 0 8px}
.home-links .link{min-height:44px}
.tip-card{background:#fffdf7;border-color:#e8d7b8}
.tip-card h3{margin:0 0 6px}.tip-card p{margin:4px 0}
.share-glyph{display:inline-block;border:1.5px solid currentColor;border-radius:4px;padding:0 3px;font-size:.85em;line-height:1.2}

/* Action sheet (iOS style) */
.sheet-backdrop{position:fixed;inset:0;z-index:200;background:rgba(40,28,48,.38);display:flex;align-items:flex-end;justify-content:center;
  padding:12px 10px calc(10px + env(safe-area-inset-bottom));animation:sheetFade .18s ease-out}
.sheet{width:100%;max-width:440px;display:grid;gap:8px;animation:sheetUp .22s cubic-bezier(.2,.9,.3,1)}
.sheet-group{background:rgba(255,253,248,.98);border-radius:16px;overflow:hidden}
.sheet-title{margin:0;padding:14px 16px 4px;text-align:center;font-weight:800;color:#6e5a72;font-size:.95rem;overflow-wrap:anywhere}
.sheet-message{margin:0;padding:2px 18px 12px;text-align:center;font-size:.9rem;color:#6e5a72}
.sheet-item{display:block;width:100%;border:none;border-top:1px solid #eadfd4;border-radius:0;background:transparent;color:#2f6fb5;font-size:1.08rem;min-height:56px}
.sheet-group .sheet-item:first-child{border-top:none}
.sheet-item.preferred{font-weight:800}
.sheet-item.destructive{color:#c62f45}
.sheet-cancel{background:#fff;border:none;border-radius:16px;font-weight:800}
@keyframes sheetUp{from{transform:translateY(40px);opacity:.4}to{transform:none;opacity:1}}
@keyframes sheetFade{from{opacity:0}to{opacity:1}}

/* Toast with Undo */
.toast-region{position:fixed;left:0;right:0;bottom:calc(18px + env(safe-area-inset-bottom));z-index:150;display:flex;justify-content:center;pointer-events:none;padding:0 12px}
.app-toast{pointer-events:auto;display:flex;align-items:center;gap:14px;max-width:440px;background:#3b3050;color:#fff;border-radius:14px;padding:10px 12px 10px 16px;box-shadow:0 8px 24px rgba(40,28,48,.25);font-weight:600;animation:sheetUp .2s ease-out}
.app-toast span{overflow-wrap:anywhere}
.toast-undo{border:none;background:#fff;color:#3b3050;font-weight:900;min-height:40px;padding:0 14px;border-radius:10px;flex-shrink:0}
body.in-game .toast-region{display:none}

/* New / edit list: paste + chunks on one screen */
.words-label{display:block;font-weight:650;margin-top:4px}
#words{min-height:170px;margin-top:6px}
.scan-tip{margin:6px 0 0}
.count-row{display:flex;align-items:center;justify-content:space-between;gap:8px}
.count-row .count{margin:6px 0}
.tidy{min-height:40px}
.action-block{display:grid;gap:4px;margin:10px 0 14px}
.start-button{width:100%;font-weight:800;font-size:1.08rem;min-height:54px}
.bar-note{margin:2px 0 0;font-size:.92rem;color:#8a4a62;font-weight:650;min-height:0}
.bar-note:empty{display:none}
.warn-note{margin:0;color:#7a5a2a}
.save-later{justify-self:center}
.chunk-preview .word{padding:10px 0}
.chunk-intro,.chunk-status{margin:0 0 4px}
.check-note{color:#8a4a62;font-weight:700;margin:0}
.confirmed{color:#2f7a4a;font-weight:700;margin:0}
.voice-fold{padding:0}
.voice-fold>summary{padding:14px;font-weight:800;cursor:pointer;min-height:48px}
.voice-fold>.voice-card{border:none;margin:0;padding:0 14px 14px}

/* Storage & privacy */
.setting-state{font-weight:800;margin:4px 0}
button.danger{border-color:#c62f45;color:#c62f45;background:#fff}
.home-head h1{font-size:clamp(1.45rem,6.3vw,2.2rem);line-height:1.15}
.home-head h1{font-size:clamp(1.3rem,5.7vw,2.2rem);white-space:nowrap}
.home-head .pets svg{width:34px;height:34px}
@media(max-width:340px){.home-head .pets{display:none}}
/* D8.1 */
.nav-bar{position:relative;top:auto}   /* no longer slides under the clock when the keyboard opens */
.kate-steps{margin:6px 0 8px;padding-left:1.3em}.kate-steps li{margin:3px 0}
.kate-help[hidden]{display:none}
