/* =====================================================================
   CHILL TYPING  (isolated styles, every selector is prefixed .ct- / chill-)
   Uses the site's existing tokens: --zoom purple, --border-soft, Manrope /
   Inter / JetBrains Mono, rounded 999px buttons. Colours for typed text
   mirror the existing typing-trace box (.trace-box .ok/.bad/.pend).
   ===================================================================== */
.ct-root{--ct-ok:#171717;--ct-bad:#e0247a;--ct-bad-bg:rgba(250,88,167,.16);--ct-pend:#b9b9c8;--ct-line:2.15em;
  max-width:880px;margin:0 auto;padding:clamp(1.4rem,4vw,2.6rem) clamp(1rem,4vw,2rem) 3rem}
.ct-sr{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* ---------- setup ---------- */
.ct-setup{max-width:520px;margin:0 auto}
.ct-setup h1{font-family:'Manrope';font-weight:800;font-size:clamp(1.7rem,4vw,2.2rem);letter-spacing:-.03em;line-height:1.1}
.ct-setup .ct-lede{color:var(--text-muted);margin:.4rem 0 1.4rem;font-size:1rem}
.ct-form{display:grid;gap:.8rem;padding:clamp(1.1rem,3vw,1.5rem)}
.ct-field{display:flex;flex-direction:column;gap:.3rem;font-size:.76rem;color:var(--text-muted);font-weight:600}
.ct-select{font-family:inherit;font-size:.95rem;padding:.6rem .7rem;border:1.5px solid var(--border-soft);border-radius:12px;background:#fff;color:var(--text-main);width:100%;max-width:100%;transition:border-color .15s}
.ct-select:focus{outline:none;border-color:var(--zoom);box-shadow:0 0 0 3px rgba(63,34,236,.12)}
.ct-row2{display:grid;grid-template-columns:1fr 1fr;gap:.8rem}
.ct-actions{display:flex;gap:.6rem;flex-wrap:wrap;align-items:center;margin-top:.4rem}
.ct-surprise{position:relative;display:inline-flex}
.ct-surprise .btn-ghost:first-child{border-top-right-radius:0;border-bottom-right-radius:0;padding-right:1rem}
.ct-surprise .ct-more{border-top-left-radius:0;border-bottom-left-radius:0;border-left:none;padding:.72rem .7rem}
.ct-menu{position:absolute;z-index:30;top:calc(100% + 6px);left:0;min-width:240px;background:#fff;border:1px solid var(--border-soft);border-radius:14px;box-shadow:var(--shadow-md);padding:.35rem;display:none}
.ct-menu.open{display:block}
.ct-menu button{display:block;width:100%;text-align:left;padding:.55rem .7rem;border-radius:10px;font-size:.88rem;color:var(--text-main)}
.ct-menu button:hover,.ct-menu button:focus-visible{background:#f6f6fb;outline:none}
.ct-menu small{display:block;color:var(--text-muted);font-size:.74rem}
.ct-note{font-size:.8rem;color:var(--text-muted);margin-top:.9rem;line-height:1.5}
.ct-lifetime{font-size:.8rem;color:var(--text-muted);margin-top:1.1rem;text-align:center}
.ct-err{background:rgba(250,88,167,.08);border:1px solid rgba(250,88,167,.35);color:#a32468;border-radius:12px;padding:.7rem .9rem;font-size:.86rem}

/* ---------- typing view ---------- */
.ct-bar{display:flex;align-items:center;justify-content:space-between;gap:.6rem;margin-bottom:clamp(1.2rem,4vw,2.2rem);position:relative}
.ct-switch{display:inline-flex;align-items:center;gap:.45rem;font-family:'Manrope';font-weight:700;font-size:.95rem;padding:.45rem .85rem;border-radius:999px;color:var(--text-main);border:1px solid var(--border-soft);background:#fff;max-width:100%;min-width:0}
.ct-switch span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ct-switch:hover{border-color:#cfcfe6}
.ct-switch .ct-dot{width:9px;height:9px;border-radius:50%;flex:none}
.ct-switch svg{flex:none;opacity:.55}
.ct-bar>[data-el="panel"]{display:contents}
.ct-tools{display:flex;align-items:center;gap:.35rem;flex:none}
.ct-icon{width:36px;height:36px;border-radius:12px;display:grid;place-items:center;color:var(--text-muted);transition:background .15s,color .15s}
.ct-icon:hover,.ct-icon.on{background:#f3f2fd;color:var(--zoom)}
.ct-icon:focus-visible,.ct-switch:focus-visible,.ct-seg button:focus-visible{outline:3px solid rgba(63,34,236,.35);outline-offset:2px}
.ct-chip{font-size:.74rem;font-weight:700;color:var(--zoom);background:rgba(63,34,236,.07);padding:.25rem .6rem;border-radius:999px;white-space:nowrap}

.ct-panel{position:absolute;z-index:40;top:calc(100% + 8px);background:#fff;border:1px solid var(--border-soft);border-radius:16px;box-shadow:var(--shadow-md);padding:1rem;width:min(380px,calc(100vw - 2rem))}
.ct-panel.left{left:0}.ct-panel.right{right:0}
.ct-panel h3{font-family:'Manrope';font-size:.82rem;text-transform:uppercase;letter-spacing:.06em;color:var(--text-muted);margin-bottom:.7rem}
.ct-panel .ct-form{padding:0;gap:.65rem}
.ct-panel .ct-warn{font-size:.8rem;color:#8a5a00;background:rgba(239,202,98,.2);border-radius:10px;padding:.5rem .65rem}
.ct-setrow{display:flex;align-items:center;justify-content:space-between;gap:.8rem;padding:.42rem 0}
.ct-setrow>span{font-size:.85rem;font-weight:600}
.ct-seg{display:inline-flex;background:#f4f4f8;border-radius:999px;padding:3px;flex-wrap:wrap;justify-content:flex-end}
.ct-seg button{font-size:.76rem;font-weight:600;padding:.3rem .62rem;border-radius:999px;color:var(--text-muted)}
.ct-seg button.on{background:#fff;color:var(--zoom);box-shadow:var(--shadow-sm)}

.ct-stage{position:relative;cursor:text;outline:none;-webkit-tap-highlight-color:transparent}
.ct-input{position:absolute;left:0;top:0;width:100%;height:100%;opacity:0;font-size:16px;border:0;padding:0;margin:0;resize:none;background:transparent;color:transparent;caret-color:transparent;pointer-events:none;z-index:-1}
.ct-viewport{position:relative;overflow:hidden;height:calc(var(--ct-line) * 3);
  font-family:'JetBrains Mono',ui-monospace,monospace;font-size:clamp(1.12rem,2.7vw,1.55rem);line-height:var(--ct-line);letter-spacing:.01em;transition:filter .2s,opacity .2s}
.ct-text{position:relative;white-space:pre-wrap;overflow-wrap:normal;word-break:normal;color:var(--ct-pend);transition:transform .16s ease-out;will-change:transform}
.ct-w{white-space:nowrap}
.ct-c.ok{color:var(--ct-ok)}
.ct-c.bad{color:var(--ct-bad);background:var(--ct-bad-bg);border-radius:3px}
.ct-c.sp.bad{background:rgba(250,88,167,.3)}
.ct-caret{position:absolute;left:0;top:0;width:2px;height:1.25em;margin-top:calc((var(--ct-line) - 1.25em) / 2);background:var(--zoom);border-radius:2px;
  transition:transform 70ms linear;will-change:transform;pointer-events:none;animation:ct-blink 1.05s steps(1) infinite}
.ct-stage.typing .ct-caret{animation:none}
.ct-stage.done .ct-caret,.ct-stage.blurred .ct-caret{opacity:0;animation:none}
.ct-stage.shake .ct-caret{background:var(--ct-bad)}
@keyframes ct-blink{50%{opacity:0}}
.ct-stage.blurred .ct-viewport,.ct-stage.paused .ct-viewport{filter:blur(4px);opacity:.55}
.ct-overlay{position:absolute;inset:0;display:none;align-items:center;justify-content:center;text-align:center;font-size:.95rem;font-weight:600;color:var(--text-main);z-index:2}
.ct-overlay small{display:block;font-weight:500;color:var(--text-muted);font-size:.8rem;margin-top:.2rem}
.ct-stage.blurred .ct-overlay,.ct-stage.paused .ct-overlay{display:flex}

.ct-stats{display:flex;flex-wrap:wrap;gap:.25rem .9rem;align-items:center;margin-top:1.3rem;font-size:.84rem;color:var(--text-muted);font-variant-numeric:tabular-nums;min-height:1.4em}
.ct-stats b{color:var(--text-main);font-weight:700}
.ct-stats .ct-sep{opacity:.4}
.ct-timer{margin-left:auto;font-weight:700;color:var(--zoom)}
.ct-hidden{visibility:hidden}

.ct-done{margin-top:1.1rem;display:none;align-items:center;gap:.7rem 1rem;flex-wrap:wrap;padding:.85rem 1rem;border:1px solid rgba(3,226,157,.45);background:rgba(3,226,157,.06);border-radius:16px;animation:ct-in .22s ease-out}
.ct-done.show{display:flex}
.ct-done .ct-tick{font-weight:700;color:#0a8f63}
.ct-done .ct-dstats{font-size:.85rem;color:var(--text-muted);font-variant-numeric:tabular-nums}
.ct-done .ct-key{flex-basis:100%;font-size:.86rem;color:#3f3f46;line-height:1.45;display:flex;gap:.5rem;align-items:flex-start}
.ct-done .ct-key b{color:var(--zoom)}
.ct-done .ct-mascot{width:26px;flex:none;margin-top:-2px}
.ct-done .btn{margin-left:auto}
.ct-kbd{font-family:'JetBrains Mono';font-size:.72rem;border:1px solid var(--border-soft);border-bottom-width:2px;border-radius:6px;padding:.05rem .35rem;color:var(--text-muted);background:#fff}
@keyframes ct-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}

.ct-banner{margin-top:1rem;font-size:.84rem;color:var(--text-muted);display:flex;gap:.6rem;align-items:center;flex-wrap:wrap}
.ct-linkbtn{color:var(--zoom);font-weight:600;font-size:.84rem;text-decoration:underline;text-underline-offset:2px}
.ct-foot{display:flex;gap:1rem;align-items:center;justify-content:center;margin-top:2.2rem;font-size:.78rem;color:var(--text-muted);flex-wrap:wrap}
.ct-foot button{color:var(--text-muted);font-size:.78rem;display:inline-flex;gap:.35rem;align-items:center}
.ct-foot button:hover{color:var(--zoom)}

.ct-summary{text-align:center;padding:clamp(1.4rem,4vw,2rem);max-width:520px;margin:1.2rem auto 0}
.ct-summary h2{font-family:'Manrope';font-weight:800;font-size:1.35rem}
.ct-sumgrid{display:grid;grid-template-columns:repeat(3,1fr);gap:.8rem;margin:1.2rem 0}
.ct-sumgrid div{background:#fafafe;border:1px solid var(--border-soft);border-radius:14px;padding:.7rem .4rem}
.ct-sumgrid b{display:block;font-family:'Manrope';font-size:1.3rem;font-weight:800}
.ct-sumgrid span{font-size:.74rem;color:var(--text-muted)}
.ct-summary .ct-actions{justify-content:center}

/* ---------- focus mode: nav, tools, footers and coach are hidden ---------- */
body.chill-focus .nav,body.chill-focus #coach{display:none!important}
body.chill-focus .ct-root{padding-top:clamp(3rem,14vh,8rem)}
body.chill-focus .ct-hide-focus{display:none!important}
body.chill-focus .ct-bar{justify-content:flex-end;margin-bottom:1.6rem}
body.chill-focus .ct-stats{justify-content:center}
body.chill-focus .ct-timer{margin-left:0}

@media(max-width:560px){
  .ct-row2{grid-template-columns:1fr}
  .ct-viewport{font-size:1.08rem}
  .ct-done .btn{margin-left:0}
  .ct-sumgrid{grid-template-columns:repeat(2,1fr)}
}
@media(prefers-reduced-motion:reduce){
  .ct-text,.ct-caret{transition:none}
  .ct-done{animation:none}
}
