/* Bean Trace: shared styles. Tokens, base, layout, components. */
:root{
  --bg:#17120E;--surface:#221A14;--surface-2:#2C2219;--line:#3A2E24;
  --text:#F3EADF;--muted:#A8998A;--ember:#E8894A;--on-ember:#17120E;--danger:#F2877B;
  --dry:#7A5A40;--maillard:#B8793F;--dev:#F4A26B;
  --tab-h:88px;--safe-t:env(safe-area-inset-top,0px);--safe-b:env(safe-area-inset-bottom,0px);
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--text);font:400 16px/1.4 Inter,system-ui,-apple-system,sans-serif}
a{color:inherit;text-decoration:none}
.sprite{position:absolute}
button,input,textarea{font:inherit;color:inherit}
h1{margin:0;font-size:34px;font-weight:600;letter-spacing:-.02em;line-height:1.2}
:focus-visible{outline:2px solid var(--ember);outline-offset:2px}
fieldset{margin:0;padding:0;border:0;min-width:0}
legend{padding:0;margin-bottom:6px}
.tn{font-variant-numeric:tabular-nums}
.muted{color:var(--muted);font-size:13px;font-weight:400}
.label{color:var(--muted);font-size:13px;font-weight:500}

/* Layout */
.app{max-width:480px;min-height:100dvh;margin:0 auto;padding:calc(var(--safe-t) + 48px) 20px 24px}
.app--tabs{padding-bottom:calc(var(--tab-h) + var(--safe-b) + 16px)}
.stack{display:flex;flex-direction:column;gap:16px}
.stack--tight{gap:8px}
.cluster{display:flex;gap:10px}
.cluster>*{flex:1}
.cluster>.btn--wide{flex:1.6}
.topbar{display:flex;align-items:center;gap:12px}
.topbar__title{flex:1;margin:0;font-size:18px;font-weight:600}
.page-head{display:flex;align-items:baseline;justify-content:space-between}

/* Buttons */
.icon{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex:none}
.btn{display:flex;align-items:center;justify-content:center;gap:10px;min-height:52px;padding:0 16px;border:1px solid var(--line);border-radius:18px;background:var(--surface);font-weight:600;cursor:pointer}
.btn--primary{background:var(--ember);border-color:var(--ember);color:var(--on-ember)}
.btn--danger{background:transparent;border-color:var(--danger);color:var(--danger)}
.btn--dashed{background:transparent;border:1px dashed var(--line);border-radius:14px;min-height:44px;color:var(--ember);font-size:15px}
.btn--lg{min-height:64px;font-size:18px}
.btn--event{flex-direction:column;gap:2px;min-height:60px;font-size:16px}
.btn--event[data-done]{border-color:var(--ember)}
.btn--event time{font-size:13px;color:var(--ember)}
.icon-btn{display:grid;place-items:center;width:44px;height:44px;border:0;border-radius:50%;background:var(--surface);cursor:pointer}
.pill{display:flex;align-items:center;gap:8px;height:32px;padding:0 14px;border-radius:16px;background:var(--surface-2);font-size:13px;font-weight:500}
.pill::before{content:"";width:8px;height:8px;border-radius:50%;background:var(--ember)}

/* Home: roast list */
.roast-list{list-style:none;margin:20px 0 0;padding:0;display:flex;flex-direction:column;gap:10px}
.roast-row{display:flex;align-items:center;gap:14px;min-height:44px;padding:12px 16px;border-radius:16px;background:var(--surface)}
.roast-row__id{width:38px;font-size:13px;font-weight:600;color:var(--ember)}
.roast-row__main{flex:1;display:flex;flex-direction:column;gap:2px;font-weight:500}
.roast-row__meta{display:flex;flex-direction:column;align-items:flex-end;gap:2px;font-weight:500}

/* Tab bar */
.tabbar{position:fixed;bottom:0;left:50%;transform:translateX(-50%);width:100%;max-width:480px;height:calc(var(--tab-h) + var(--safe-b));padding:0 20px calc(20px + var(--safe-b));display:flex;align-items:center;justify-content:space-between;background:var(--bg);border-top:1px solid var(--surface-2)}
.tab{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;min-width:64px;min-height:44px;color:var(--muted);font-size:12px;font-weight:500}
.tab[aria-current=page]{color:var(--ember)}
button.tab{border:0;cursor:pointer}
.tab--primary{flex-direction:row;gap:8px;height:52px;padding:0 22px;border-radius:26px;background:var(--ember);color:var(--on-ember);font-size:16px;font-weight:600}

/* New roast: timer, phases, log */
.timer{margin-top:8px;text-align:center}
.timer__value{font-size:clamp(80px,26vw,104px);font-weight:300;letter-spacing:-.04em;line-height:1.05}
.phases__bar{display:flex;gap:3px;height:10px}
.phases__bar span{flex:var(--w);background:var(--c)}
.phases__bar span:first-child{border-radius:5px 0 0 5px}
.phases__bar span:last-child{border-radius:0 5px 5px 0}
.phases__legend{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:8px 0 0}
.phases__legend dt{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--muted)}
.phases__legend dt::before{content:"";width:8px;height:8px;border-radius:50%;background:var(--c)}
.phases__legend dd{margin:2px 0 0;font-size:15px;font-weight:500}
.phases__legend [aria-current] dd{color:var(--ember)}
.actions{display:flex;flex-direction:column;gap:10px}
.log{list-style:none;margin:4px 0 0;padding:0;font-size:15px}
.log li{display:flex;gap:16px;padding:10px 0;border-bottom:1px solid var(--surface-2)}
.log time{width:48px;color:var(--muted)}
.log span{flex:1}
.log b{font-weight:500}

/* Temp keypad (shown in a modal sheet, see ask_temp) */
.sheet__head{display:flex;justify-content:space-between;align-items:center;font-size:18px;font-weight:600}
.sheet__value{display:block;margin:0;text-align:center;font-size:72px;font-weight:500;letter-spacing:-.03em}
.sheet__unit{font-size:28px;letter-spacing:0;color:var(--muted)}
.keypad{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.key{display:grid;place-items:center;height:56px;border:0;border-radius:14px;background:var(--surface-2);font-size:24px;font-weight:500;cursor:pointer}

/* Details form */
.field{display:flex;flex-direction:column;gap:6px}
.input{width:100%;height:52px;padding:0 16px;background:var(--surface);border:1px solid var(--line);border-radius:14px;font-size:16px}
textarea.input{height:96px;padding:12px 16px;resize:none;line-height:1.4}
.segmented{display:flex;gap:4px;padding:4px;background:var(--surface);border:1px solid var(--line);border-radius:14px}
.segmented label{position:relative;flex:1}
.segmented input{position:absolute;inset:0;margin:0;opacity:0;cursor:pointer}
.segmented span{display:grid;place-items:center;height:44px;border-radius:11px;color:var(--muted);font-size:15px;font-weight:600}
.segmented input:checked+span{background:var(--ember);color:var(--on-ember)}
.segmented input:focus-visible+span{outline:2px solid var(--ember);outline-offset:2px}
.check{display:flex;align-items:center;gap:14px;min-height:48px;padding:8px 16px;background:var(--surface);border-radius:14px;font-size:15px}
.check input{width:20px;height:20px;margin:0;accent-color:var(--ember)}
.savebar{position:sticky;bottom:0;margin-top:8px;padding:16px 0 calc(28px + var(--safe-b));background:var(--bg)}

/* Settings */
.group-label{margin:20px 4px 8px}
.group{background:var(--surface);border-radius:16px;overflow:hidden}
.setting{display:flex;align-items:center;gap:12px;width:100%;min-height:56px;padding:8px 16px;border:0;background:none;text-align:left;cursor:pointer}
.setting+.setting{border-top:1px solid var(--surface-2)}
.setting__text{flex:1;display:flex;flex-direction:column;gap:2px;font-weight:500}
.setting--danger .setting__text{color:var(--danger)}
.setting .icon{width:18px;height:18px;color:var(--muted)}
.switch{appearance:none;position:relative;flex:none;width:48px;height:28px;margin:0;border-radius:14px;background:var(--line);cursor:pointer}
.switch::before{content:"";position:absolute;top:2px;left:2px;width:24px;height:24px;border-radius:50%;background:var(--text);transition:transform .15s}
.switch:checked{background:var(--ember)}
.switch:checked::before{transform:translateX(20px);background:var(--on-ember)}
@media (prefers-reduced-motion:reduce){.switch::before{transition:none}}
.group__note{padding:5px}

/* Modal */
dialog.modal{padding:0;border:0;width:calc(100% - 40px);max-width:400px;border-radius:24px;background:var(--surface);color:var(--text)}
dialog.modal::backdrop{background:rgb(0 0 0/.55)}
dialog.modal.modal__danger{border:2px solid var(--danger)}
.modal__body{display:flex;flex-direction:column;gap:12px;padding:24px}
.modal__body h2{margin:0;font-size:20px;font-weight:600}
.modal__actions{display:flex;gap:10px;margin-top:8px}
.modal__actions>*{flex:1}
body:has(dialog[open]){overflow:hidden}
dialog.modal--sheet{width:100%;max-width:480px;margin:auto auto 0;border-radius:28px 28px 0 0}
dialog.modal--sheet .modal__body{padding-bottom:calc(24px + var(--safe-b))}

/* Press feedback */
button,a{-webkit-tap-highlight-color:transparent;touch-action:manipulation}
.btn,.icon-btn,.tab,.key{transition:transform .08s ease-out,filter .08s ease-out,opacity .08s ease-out}
.btn:active,.icon-btn:active,.tab--primary:active,.key:active{transform:scale(.96);filter:brightness(1.2)}
.tab:not(.tab--primary):active{opacity:.6}
.setting:active{background:var(--surface-2)}
@media (prefers-reduced-motion:reduce){.btn,.icon-btn,.tab,.key{transition:none}}

