/* XBloom Studio — visual language follows xbloom.com: white paper, black ink,
   flat grey surfaces, a light display serif and Inter Tight for UI. */

:root{
  --bg:#ffffff;
  --surface:#f4f4f4;
  --surface-2:#ededed;
  --surface-3:#e3e3e3;
  --line:#e6e6e6;
  --line-strong:#cfcfcf;
  --text:#000000;
  --text-2:#3d3d3d;
  --muted:#6e6e6e;
  --machine:#1d1d1f;
  --blue:#0b45c5;
  --ice:#e8f0fb;
  --ok:#1f7a45;
  --danger:#b3261e;
  --brand:var(--accent);
  --brand-ink:#ffffff;
  --radius:16px;
  --radius-md:12px;
  --radius-sm:8px;
  --accent:#000000;
  --accent-2:#3a3a3a;
  --accent-faint:rgba(0,0,0,.08);
  --ui:"Inter Tight","IBM Plex Sans Arabic",system-ui,-apple-system,"Segoe UI",sans-serif;
  --display:"Instrument Serif","IBM Plex Sans Arabic",Georgia,serif;
  --num:"Inter Tight","IBM Plex Sans Arabic",system-ui,sans-serif;
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background:var(--bg);color:var(--text);min-height:100vh;
  font-family:var(--ui);font-size:15px;line-height:1.6;
  -webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent;
}
h1{font-family:var(--display);font-weight:300;font-size:2rem;line-height:1.15;letter-spacing:-.01em;margin:0}
h2,h3{margin:0;font-weight:500;font-size:1rem}
p{margin:.3rem 0}
a{color:var(--blue)}
.hidden{display:none !important}
.muted{color:var(--muted)}
.small{font-size:.8rem}
.row{display:flex;gap:.6rem;align-items:center}
.row.end{justify-content:flex-end}
.ok{color:var(--ok)}
.bad{color:var(--danger)}
.i{width:16px;height:16px;flex-shrink:0;vertical-align:-3px}
.num{font-family:var(--num);font-variant-numeric:tabular-nums}
:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
option{background:#fff;color:#000}

.wordmark{display:inline-flex;align-items:center;gap:.5rem;font-family:var(--ui);font-weight:600;font-size:1.15rem;letter-spacing:.04em;direction:ltr;unicode-bidi:isolate}
.wordmark-logo{width:30px;height:30px;flex-shrink:0}

/* ---------- layout ---------- */
.app{display:flex;min-height:100vh;background:var(--bg)}

.sidebar{
  width:240px;flex-shrink:0;background:#fff;border-inline-end:1px solid var(--line);
  display:flex;flex-direction:column;padding:1.3rem 1rem;height:100vh;position:sticky;top:0;
}
.logo{display:flex;align-items:center;gap:.6rem;padding:0 .4rem 1.4rem}
.logo-mark{width:34px;height:34px;flex-shrink:0;object-fit:contain}
.mod-grid{display:flex;flex-direction:column;gap:2px}
.mod-card{
  display:flex;align-items:center;gap:.7rem;width:100%;padding:.6rem .75rem;border-radius:var(--radius-sm);
  background:none;border:none;color:var(--text-2);font:inherit;font-size:.9rem;font-weight:500;cursor:pointer;text-align:start;
}
.mod-card svg{width:19px;height:19px;flex-shrink:0}
.mod-card:hover{background:var(--surface)}
.mod-card.active{background:#000;color:#fff}

.sidebar-foot{margin-top:auto;padding-top:1rem;border-top:1px solid var(--line)}
.who{display:flex;align-items:center;gap:.6rem;padding:.2rem .2rem .8rem}
.avatar{width:34px;height:34px;border-radius:50%;background:var(--surface-2);display:grid;place-items:center;font-weight:600;font-size:.9rem;flex-shrink:0}
.who-text b{display:block;font-size:.84rem;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:140px}
.who-text .small{font-size:.72rem}

.main{flex:1;padding:2rem 2.4rem 4rem;min-width:0}
.panel{display:none}
.panel.active{display:block;animation:fade .2s ease}
@keyframes fade{from{opacity:0}to{opacity:1}}
.panel-head{display:flex;justify-content:space-between;align-items:flex-end;gap:1rem;flex-wrap:wrap;margin-bottom:1.5rem}
.panel-head p{margin:.35rem 0 0;font-size:.9rem;color:var(--muted)}

/* ---------- buttons ---------- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:.45rem;
  background:#fff;color:#000;border:1px solid var(--line-strong);
  padding:.62rem 1.05rem;border-radius:var(--radius-sm);cursor:pointer;font:inherit;
  font-size:.875rem;font-weight:500;letter-spacing:.01em;white-space:nowrap;transition:background .15s,border-color .15s;
}
.btn:hover{background:var(--surface)}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn .i{width:15px;height:15px}
.btn-accent{background:var(--accent);border-color:var(--accent);color:var(--brand-ink)}
.btn-accent:hover{background:var(--accent-2);border-color:var(--accent-2)}
.btn-ghost-soft{background:var(--surface);border-color:transparent}
.btn-ghost-soft:hover{background:var(--surface-2)}
.btn-block{width:100%}
.btn-danger{color:var(--danger);border-color:#ecc9c6}
.btn-danger:hover{background:#fbefee}
.btn-brew{background:#000;border-color:#000;color:#fff}
.btn-brew:hover{background:#2b2b2b}
.btn-send-device{border-color:var(--blue);color:var(--blue);background:#fff}
.btn-send-device:hover{background:var(--ice)}
.btn-add{padding:.45rem .8rem;font-size:.82rem}
.btn-save{padding:.7rem 1.4rem}
.badge{background:#000;color:#fff;font-size:.68rem;font-weight:600;padding:.18rem .55rem;border-radius:999px}
.icon-btn{
  width:38px;height:38px;border-radius:var(--radius-sm);display:grid;place-items:center;cursor:pointer;
  background:#fff;border:1px solid var(--line-strong);color:var(--text-2);
}
.icon-btn:hover{background:var(--surface)}
.icon-btn svg{width:17px;height:17px}

/* ---------- surfaces ---------- */
.card{background:var(--surface);border-radius:var(--radius);padding:1.25rem}
.card-head{display:flex;justify-content:space-between;align-items:center;gap:1rem;margin-bottom:1rem}
.split{display:grid;grid-template-columns:1fr 1fr;gap:1.1rem;align-items:start}

/* ---------- fields ---------- */
.field{display:flex;flex-direction:column;gap:.35rem;font-size:.85rem}
.field>span{color:var(--muted);font-weight:500}
input,select,textarea{
  background:#fff;border:1px solid var(--line-strong);color:var(--text);
  padding:.62rem .75rem;border-radius:var(--radius-sm);font:inherit;font-size:.95rem;width:100%;
}
input:focus,select:focus,textarea:focus{outline:none;border-color:#000;box-shadow:0 0 0 3px var(--accent-faint)}
input::placeholder,textarea::placeholder{color:#9a9a9a}
textarea{resize:vertical;font-family:inherit}
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:.9rem}

/* segmented control */
.seg{display:inline-flex;background:var(--surface-2);border-radius:10px;padding:3px;gap:2px}
.seg-btn{
  display:inline-flex;align-items:center;gap:.4rem;background:none;border:none;color:var(--text-2);
  padding:.5rem .9rem;cursor:pointer;font:inherit;font-weight:500;font-size:.85rem;border-radius:8px;
}
.seg-btn .i{width:15px;height:15px}
.seg-btn.active{background:#fff;color:#000;box-shadow:0 1px 2px rgba(0,0,0,.12)}

.chips{display:flex;flex-wrap:wrap;gap:.4rem}
.chip{
  background:#fff;border:1px solid var(--line-strong);color:var(--text-2);
  padding:.45rem .85rem;border-radius:999px;cursor:pointer;font:inherit;font-size:.82rem;font-weight:500;
  min-height:38px;display:inline-flex;align-items:center;touch-action:manipulation;
}
.chip:hover{border-color:#000}
.chip.active{background:#000;border-color:#000;color:#fff}

.range{width:100%;accent-color:#000;height:36px;cursor:pointer;padding:0;border:none;background:transparent}
.range:focus{box-shadow:none}

.swatches{display:flex;gap:.55rem;flex-wrap:wrap;align-items:center}
.swatch-btn{width:36px;height:36px;border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 1px var(--line-strong);cursor:pointer;padding:0}
.swatch-btn.active{box-shadow:0 0 0 2px #000}
.custom-color{display:inline-flex;align-items:center;gap:.45rem;font-size:.75rem;color:var(--muted);cursor:pointer}
.custom-color input{width:36px;height:36px;padding:0;border:1px solid var(--line-strong);border-radius:50%;background:transparent;cursor:pointer;overflow:hidden}
.custom-color input::-webkit-color-swatch-wrapper{padding:0}
.custom-color input::-webkit-color-swatch{border:none;border-radius:50%}

/* ---------- manual builder ---------- */
.recipe-hero{
  position:relative;overflow:hidden;border-radius:var(--radius);color:#fff;
  background:linear-gradient(160deg,var(--machine),#2c2c2e);
  padding:1.4rem 1.6rem;margin-bottom:1.2rem;min-height:140px;
}
.hero-bignum{
  position:absolute;inset-inline-end:.6rem;bottom:-2.2rem;font-family:var(--display);
  font-size:10rem;line-height:1;color:rgba(255,255,255,.1);user-select:none;pointer-events:none;
}
.hero-word{
  position:absolute;inset-inline-end:1.5rem;top:.8rem;font-family:var(--display);font-style:italic;
  font-size:2.4rem;line-height:1;color:rgba(255,255,255,.16);user-select:none;pointer-events:none;
}
.hero-icon{width:40px;height:40px;border-radius:10px;background:rgba(255,255,255,.1);display:grid;place-items:center;margin-bottom:.9rem}
.hero-icon svg{width:22px;height:22px;color:#fff}
.hero-name{font-size:1.25rem;font-weight:500;position:relative;z-index:1}

.spec-rows{display:flex;flex-direction:column;gap:.6rem;margin-bottom:1rem}
.spec-row{background:var(--surface);border-radius:var(--radius-md);padding:1rem 1.2rem}
.ctrl-row{display:flex;flex-direction:column;gap:.65rem}
.spec-label{display:block;color:var(--muted);font-size:.8rem;font-weight:500}
.name-row{display:flex;gap:.6rem;align-items:flex-end;margin-bottom:1rem}
.name-row .field{flex:1}

.stepper{display:inline-flex;align-items:center;gap:.8rem;user-select:none}
.stepper button{
  width:48px;height:48px;border-radius:50%;background:#fff;border:1px solid var(--line-strong);color:#000;
  font-size:1.4rem;font-weight:400;cursor:pointer;display:grid;place-items:center;line-height:1;touch-action:manipulation;
}
.stepper button:hover{border-color:#000}
.stepper button:active{transform:scale(.94)}
.stepper b{font-family:var(--num);font-size:2.2rem;font-weight:500;min-width:84px;text-align:center;line-height:1.1;font-variant-numeric:tabular-nums}
.stepper .unit{color:var(--muted);font-size:1rem;margin-inline-start:-.4rem}

.totals{display:flex;gap:.6rem;flex-wrap:wrap;margin:1rem 0;font-size:.85rem;align-items:center}
.total-chip{display:inline-flex;align-items:center;gap:.45rem;background:var(--surface);padding:.45rem .8rem;border-radius:999px}
.total-chip .i{width:14px;height:14px}
#volumeCheck{font-weight:500;font-size:.82rem}

.steps-head{display:flex;justify-content:space-between;align-items:center;margin:1.3rem 0 .7rem;padding-top:1rem;border-top:1px solid var(--line)}
.steps-head h3{display:flex;align-items:center;gap:.5rem}
.steps-count{font-family:var(--num);background:var(--surface);font-size:.78rem;font-weight:600;padding:.1rem .55rem;border-radius:999px}
.steps{display:flex;flex-direction:column;gap:.6rem}
.step{background:var(--surface);border-radius:var(--radius-md);padding:.9rem 1rem}
.step-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:.6rem}
.step-head b{font-size:.88rem;font-weight:600}
.step-ctrls{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:.5rem}
.mini-stepper{display:flex;align-items:center;gap:.3rem;background:#fff;border-radius:10px;padding:.25rem .3rem}
.mini-stepper span{font-size:.7rem;color:var(--muted);margin:0 .2rem;min-width:34px}
.mini-stepper button{
  width:34px;height:34px;border-radius:50%;background:var(--surface);border:none;color:#000;
  font-size:1.1rem;cursor:pointer;display:grid;place-items:center;line-height:1;touch-action:manipulation;
}
.mini-stepper button:hover{background:var(--surface-2)}
.mini-stepper b{font-family:var(--num);font-size:1.1rem;font-weight:500;min-width:46px;text-align:center;font-variant-numeric:tabular-nums}
.check{display:flex;align-items:center;gap:.4rem;font-size:.8rem;color:var(--muted);cursor:pointer}
.check input{width:auto;accent-color:#000}
.remove{background:none;border:none;color:var(--danger);cursor:pointer;font-size:1rem;padding:.2rem .4rem}
.form-actions{display:flex;gap:.6rem;justify-content:flex-end;margin-top:1.25rem;padding-top:1rem;border-top:1px solid var(--line)}

/* ---------- preview ---------- */
.preview-card{background:var(--surface);border-radius:var(--radius);padding:1.25rem;display:flex;flex-direction:column}
.preview-body{flex:1;overflow-y:auto;min-height:280px}
.empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.7rem;padding:3.5rem 1rem;text-align:center}
.empty svg{width:48px;height:48px;color:var(--line-strong)}
.empty .muted{font-size:.88rem}
.preview-actions{display:flex;gap:.6rem;justify-content:flex-end;margin-top:1rem;padding-top:1rem;border-top:1px solid var(--line)}
.recipe-title{display:flex;align-items:center;gap:.6rem;margin-bottom:.7rem}
.recipe-title h2{font-size:1.05rem}
.swatch{width:14px;height:14px;border-radius:50%;flex-shrink:0;box-shadow:inset 0 0 0 1px rgba(0,0,0,.12)}
.serve-banner{background:#fff;border-radius:var(--radius-sm);padding:.6rem .8rem;font-size:.86rem;margin-bottom:.8rem}
.serve-banner.iced{background:var(--ice);color:var(--blue)}
.stat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(90px,1fr));gap:.5rem;margin:.6rem 0 .9rem}
.stat{background:#fff;border-radius:var(--radius-sm);padding:.6rem .5rem;text-align:center}
.stat b{display:block;font-family:var(--num);font-size:1.05rem;font-weight:500}
.stat span{font-size:.72rem;color:var(--muted)}
.psteps{list-style:none;margin:0;padding:0;background:#fff;border-radius:var(--radius-sm)}
.pstep{display:grid;grid-template-columns:4.6rem 3.4rem 2.6rem 1fr auto;align-items:center;gap:.4rem;padding:.65rem .8rem;font-size:.84rem;border-bottom:1px solid var(--line)}
.pstep:last-child{border-bottom:none}
.pstep b{font-weight:500}
.pstep span{color:var(--text-2)}
.pstep span:last-child{color:var(--muted);font-size:.78rem}

/* ---------- recipe list ---------- */
.recipe-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(290px,1fr));gap:.8rem}
.recipe{background:var(--surface);border-radius:var(--radius-md);padding:1rem 1.1rem;display:flex;flex-direction:column;gap:.45rem}
.recipe h3{display:flex;align-items:center;gap:.55rem;font-size:.95rem}
.recipe .meta{font-size:.78rem;color:var(--muted)}
.recipe .acts{display:flex;gap:.4rem;margin-top:auto;padding-top:.6rem}
.recipe .acts .btn{padding:.4rem .5rem;font-size:.76rem;flex:1}

/* ---------- import ---------- */
.import-card{max-width:660px}
.import-row{display:flex;gap:.6rem}
.import-row input{flex:1}
.import-result{margin-top:1rem}

/* ---------- toast / modal ---------- */
.toast{
  position:fixed;bottom:1.5rem;left:50%;transform:translateX(-50%);z-index:400;
  background:#000;color:#fff;border-radius:999px;padding:.62rem 1.2rem;font-size:.88rem;font-weight:500;
  max-width:min(92vw,480px);text-align:center;animation:fade .2s ease;
}
.toast.bad{background:var(--danger)}
.modal{position:fixed;inset:0;background:rgba(0,0,0,.38);display:flex;align-items:center;justify-content:center;z-index:350;padding:1rem;animation:fade .2s ease}
.modal-box{background:#fff;border-radius:var(--radius);padding:1.5rem;width:min(420px,100%);box-shadow:0 20px 60px rgba(0,0,0,.18)}
.modal-head h2{font-family:var(--display);font-weight:300;font-size:1.6rem;margin-bottom:.1rem}
.secure-note{display:flex;align-items:center;gap:.5rem;background:var(--surface);padding:.6rem .75rem;border-radius:var(--radius-sm);font-size:.78rem;margin:1rem 0;color:var(--text-2)}
.secure-note .i{width:15px;height:15px}
.login-reason{font-size:.86rem;line-height:1.65;color:var(--text-2);margin:0 0 1rem}
.login-error{background:#fbefee;color:var(--danger);border-radius:var(--radius-sm);padding:.6rem .8rem;font-size:.84rem;margin:.2rem 0 .4rem}
.modal-box .field{margin-bottom:.8rem}
.modal-box .row{margin-top:1.1rem}

/* ---------- community ---------- */
.community-filters{display:flex;flex-wrap:wrap;gap:.85rem;align-items:flex-end;background:var(--surface);border-radius:var(--radius-md);padding:.9rem 1.1rem;margin-bottom:1.1rem}
.filter-group{display:flex;flex-direction:column;gap:.35rem}
.filter-label{color:var(--muted);font-size:.75rem;font-weight:500}
.filter-search{width:250px}
.com-recipe{position:relative;overflow:hidden;padding:0}
.com-color-bar{height:4px;width:100%;flex-shrink:0}
.com-body{padding:.9rem 1rem}
.com-tags{display:flex;flex-wrap:wrap;gap:.3rem;margin:.4rem 0}
.com-tag{background:#fff;color:var(--text-2);font-size:.72rem;padding:.15rem .55rem;border-radius:999px}
.com-tag-company{color:var(--blue);background:var(--ice)}
.com-notes{margin:.35rem 0;line-height:1.55}
.com-foot{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.4rem;margin-top:.55rem;padding-top:.55rem;border-top:1px solid var(--line)}
.com-author{color:var(--muted)}

/* ---------- settings ---------- */
.settings-form{display:flex;flex-direction:column;gap:1.1rem;max-width:560px}
.settings-section{background:var(--surface);border-radius:var(--radius-md);padding:1.2rem 1.3rem;display:flex;flex-direction:column;gap:.9rem}
.settings-section h3{font-size:.95rem;font-weight:600}
.settings-field{display:flex;flex-direction:column;gap:.38rem}
.settings-field>label{font-size:.83rem;color:var(--muted)}
.settings-field .hint{font-size:.76rem;color:var(--muted)}
.color-row{display:flex;align-items:center;gap:.8rem;flex-wrap:wrap}
.settings-field input[type=color]{width:2.6rem;height:2.2rem;border-radius:var(--radius-sm);cursor:pointer;padding:.1rem}
.color-swatches{display:flex;gap:.5rem;flex-wrap:wrap}
.color-swatch{width:28px;height:28px;border-radius:50%;border:2px solid #fff;box-shadow:0 0 0 1px var(--line-strong);cursor:pointer}
.color-swatch.active{box-shadow:0 0 0 2px #000}
.settings-static-note{background:#fff;border-radius:var(--radius-sm);padding:.65rem .85rem;font-size:.8rem;color:var(--text-2)}

/* ---------- AI (برّد / حضّر) ---------- */
.ai-advanced{background:var(--surface);border-radius:var(--radius-md);padding:.75rem 1rem;margin-bottom:1rem}
.ai-advanced summary{cursor:pointer;font-size:.88rem;font-weight:500;list-style:none}
.ai-advanced summary::-webkit-details-marker{display:none}
.ai-advanced summary::before{content:"+";display:inline-block;width:1.1em;font-weight:400}
.ai-advanced[open] summary::before{content:"−"}
.provider-bar{display:flex;flex-wrap:wrap;gap:.7rem;align-items:center;margin-top:.4rem}
#modelRow{flex:1;min-width:0}
.model-select{min-width:180px;flex:1}
.or-key-banner{display:flex;align-items:center;gap:.6rem;flex-wrap:wrap;background:#fff;border-radius:var(--radius-sm);padding:.55rem .8rem;font-size:.8rem;margin-top:.6rem}
.or-key-banner .i{width:14px;height:14px}

.ai-flow{display:flex;flex-direction:column}
.ai-state{display:flex;align-items:flex-start;justify-content:center;padding:.4rem 0}
.ai-state.hidden{display:none}
.ai-hero-card{width:100%;max-width:620px;display:flex;flex-direction:column;gap:1.1rem}
.ai-hero-top{display:flex;flex-direction:column;gap:.35rem}
.ai-hero-emblem{display:none}
.ai-hero-title{font-family:var(--display);font-weight:300;font-size:2.1rem;line-height:1.15}
.ai-hero-sub{color:var(--muted);font-size:.9rem;margin:0;line-height:1.6;max-width:46ch}
.ai-img-preview{position:relative;display:inline-flex;align-self:flex-start;border-radius:10px;overflow:hidden}
.ai-img-preview img{display:block;max-height:100px;max-width:180px}
.attach-remove{position:absolute;top:.25rem;inset-inline-end:.25rem;width:24px;height:24px;border:none;border-radius:50%;background:rgba(0,0,0,.6);color:#fff;cursor:pointer;display:grid;place-items:center;font-size:.75rem}
.ai-composer{border:1px solid var(--line-strong);border-radius:var(--radius-md);background:#fff;transition:border-color .15s}
.ai-composer:focus-within,.ai-composer.dragover{border-color:#000}
.ai-composer.dragover{background:var(--surface)}
.ai-composer .ai-desc-input{border:none;box-shadow:none;border-radius:var(--radius-md) var(--radius-md) 0 0}
.ai-composer-bar{display:flex;align-items:center;justify-content:space-between;gap:.6rem;padding:.5rem .75rem;border-top:1px solid var(--line)}
.ai-composer-bar .ai-upload-lbl{display:inline-flex;align-items:center;gap:.4rem;font-size:.84rem;font-weight:500}
.ai-drop-hint{font-size:.76rem;color:var(--muted)}
.ai-composer .ai-img-preview{margin:.7rem .75rem 0;display:flex;align-items:center;gap:.6rem;font-size:.8rem;color:var(--text-2)}
.ai-composer .ai-img-preview.hidden{display:none}
.ai-composer .ai-img-preview img{max-height:56px;border-radius:6px}
.ai-composer .ai-img-preview .attach-remove{position:static;background:var(--surface-2);color:#000}
.seg-txt small{color:var(--muted);font-weight:400;margin-inline-start:.2rem}
.model-pick{display:flex;align-items:center;gap:.45rem;flex:1}
.model-pick svg{width:17px;height:17px;color:var(--muted);flex-shrink:0}
.ai-desc-input{min-height:96px;border-radius:var(--radius-md);font-size:1rem;line-height:1.6}
.ai-opts{display:flex;flex-direction:column;gap:.6rem}
.opt-row{display:flex;align-items:center;justify-content:space-between;gap:1rem}
.opt-label{font-size:.85rem;color:var(--muted)}
.opt-seg{display:inline-flex;background:var(--surface);border-radius:10px;padding:3px;gap:2px}
.opt-btn{
  border:none;background:none;font:inherit;font-size:.86rem;font-weight:500;color:var(--text-2);
  padding:.5rem .95rem;border-radius:8px;cursor:pointer;min-width:64px;touch-action:manipulation;
}
.opt-btn.active{background:#000;color:#fff}
.opt-seg[data-opt="serve"] .opt-btn.active[data-v="iced"]{background:var(--blue)}
.ai-hero-btns{display:flex;gap:.6rem;justify-content:space-between;flex-wrap:wrap}
.ai-upload-lbl{cursor:pointer}
.ai-brew-btn{flex:1;max-width:280px;padding:.8rem 1.4rem;font-size:.95rem}
.ai-brew-btn svg{width:16px;height:16px;transform:scaleX(-1)}

/* brewing */
.brew-scene{display:flex;flex-direction:column;align-items:center;gap:1.2rem;padding:3rem 1rem;text-align:center}
.brew-rings{position:relative;width:110px;height:110px;display:grid;place-items:center}
.brew-r{position:absolute;border-radius:50%;border:1.5px solid transparent}
.brew-r1{width:110px;height:110px;border-top-color:#000;animation:brew-spin 2.2s linear infinite}
.brew-r2{width:80px;height:80px;border-bottom-color:#000;opacity:.5;animation:brew-spin 1.5s linear infinite reverse}
.brew-r3{width:52px;height:52px;border-top-color:var(--blue);animation:brew-spin 1s linear infinite}
.brew-core{width:34px;height:34px;border-radius:50%;background:var(--surface);display:grid;place-items:center}
.brew-core svg{width:18px;height:18px}
@keyframes brew-spin{to{transform:rotate(360deg)}}
.brew-label{font-size:1rem;min-height:1.5em;transition:opacity .3s}
.brew-steps-row{display:flex;align-items:center;gap:.5rem;font-size:.8rem;color:var(--muted);flex-wrap:wrap;justify-content:center}
.brew-sep{color:var(--line-strong)}
.brew-step.active{color:#000;font-weight:600}

/* result */
.result-left{display:flex;flex-direction:column;gap:1rem}
.result-top{display:flex;flex-direction:column;gap:.4rem}
.result-source{font-size:.76rem;color:var(--muted)}
.result-name{font-family:var(--display);font-weight:300;font-size:1.7rem;line-height:1.2}
.result-notes{line-height:1.75;white-space:pre-wrap;font-size:.9rem;color:var(--text-2);max-width:60ch}
.result-acts{display:flex;flex-wrap:wrap;gap:.5rem;padding-top:.9rem;border-top:1px solid var(--line-strong)}
.result-err{background:#fbefee;border-radius:var(--radius-sm);padding:.65rem .85rem;font-size:.85rem;color:var(--danger)}

/* brew modal */
.brew-modal-box{max-width:480px}
.brew-modal-head{display:flex;align-items:center;gap:1rem;margin-bottom:1rem}
.brew-modal-head h2{font-family:var(--display);font-weight:300;font-size:1.5rem}
.brew-modal-icon{width:46px;height:46px;border-radius:50%;flex-shrink:0;background:#000;display:grid;place-items:center}
.brew-modal-icon svg{width:24px;height:24px;color:#fff}
@keyframes brew-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.08)}}
.brew-log{background:var(--surface);border-radius:var(--radius-sm);padding:.75rem 1rem;font-size:.82rem;max-height:180px;overflow-y:auto;line-height:1.7;color:var(--text-2);white-space:pre-wrap}
.brew-checklist{list-style:none;margin:0 0 .4rem;padding:0;display:flex;flex-direction:column}
.brew-checklist li{display:flex;align-items:center;gap:.7rem;font-size:.92rem;padding:.65rem 0;border-bottom:1px solid var(--line)}
.brew-checklist li::before{content:"";width:18px;height:18px;border-radius:50%;border:1.5px solid #000;flex-shrink:0}
.ble-setup-body{display:flex;flex-direction:column;gap:.8rem;padding:.3rem 0}
.ble-setup-step{margin:0;font-size:.9rem;display:flex;align-items:flex-start;gap:.65rem;line-height:1.55}
.ble-step-num{display:inline-grid;place-items:center;width:24px;height:24px;border-radius:50%;background:#000;color:#fff;font-size:.78rem;flex-shrink:0;margin-top:.1rem}
.send-modal-body{display:flex;flex-direction:column;align-items:center;gap:1rem;padding:.5rem 0 .2rem}
.send-success-icon{width:56px;height:56px;border-radius:50%;background:var(--surface);display:grid;place-items:center}
.send-success-icon svg{width:28px;height:28px}
.send-instructions{text-align:center;line-height:1.7;color:var(--text-2);font-size:.92rem;margin:0}

/* ---------- home ---------- */
.home{max-width:620px;margin:0 auto;display:flex;flex-direction:column;gap:1.4rem}
.home-bar{display:flex;align-items:center;justify-content:space-between;gap:1rem}
.home-bar-acts{display:flex;align-items:center;gap:.7rem}
.ble-state{font-size:.76rem;color:var(--muted);cursor:pointer;display:inline-flex;align-items:center;gap:.35rem}
.ble-state::before{content:"";width:7px;height:7px;border-radius:50%;background:var(--line-strong)}
.ble-state.on{color:var(--blue)}
.ble-state.on::before{background:var(--blue)}
.avatar-btn{width:38px;height:38px;border-radius:50%;border:1px solid var(--line-strong);background:#fff;font:inherit;font-weight:600;cursor:pointer}

.home-hero{background:var(--surface);border-radius:20px;padding:2rem 1.5rem 1.6rem;display:flex;flex-direction:column;align-items:center;text-align:center}
.machine{width:120px;height:150px;color:#000;margin-bottom:.8rem}
.machine-led{fill:var(--blue)}
.machine .drip{animation:drip 1.6s linear infinite}
@keyframes drip{to{stroke-dashoffset:-24}}
.home-q{font-family:var(--display);font-weight:300;font-size:2.2rem;line-height:1.15}
.home-sub{color:var(--muted);font-size:.92rem;margin:.5rem 0 0}

.picks{display:grid;grid-template-columns:repeat(3,1fr);gap:.6rem}
.pick{
  display:flex;flex-direction:column;align-items:flex-start;gap:.15rem;padding:1rem .9rem;text-align:start;
  background:#fff;border:1px solid var(--line-strong);border-radius:var(--radius-md);cursor:pointer;font:inherit;color:#000;
  touch-action:manipulation;transition:border-color .15s,background .15s;
}
.pick svg{width:30px;height:30px;margin-bottom:.5rem}
.pick b{font-size:.95rem;font-weight:500}
.pick small{font-size:.74rem;color:var(--muted)}
.pick:hover{border-color:#000}
.pick:active{background:var(--surface)}
.pick-iced svg{color:var(--blue)}

.ask{display:flex;align-items:center;gap:.5rem;border:1px solid var(--line-strong);border-radius:999px;padding:5px;padding-inline-start:1.1rem;background:#fff}
.ask:focus-within{border-color:#000}
.ask input{flex:1;min-width:0;border:none;padding:.5rem 0;background:none}
.ask input:focus{box-shadow:none}
.ask-photo{width:38px;height:38px;border-radius:50%;display:grid;place-items:center;color:var(--text-2);cursor:pointer;flex-shrink:0}
.ask-photo:hover{background:var(--surface)}
.ask-photo svg{width:20px;height:20px}
.home-img-preview{display:flex;align-items:center;gap:.6rem;font-size:.82rem;color:var(--text-2);background:var(--surface);border-radius:var(--radius-sm);padding:.5rem .6rem}
.home-img-preview.hidden{display:none}
.home-img-preview img{height:44px;border-radius:6px}
.home-img-preview .attach-remove{position:static;margin-inline-start:auto;background:#fff;color:#000}
.ask-go{width:42px;height:42px;border-radius:50%;border:none;background:#000;color:#fff;display:grid;place-items:center;cursor:pointer;flex-shrink:0}
.ask-go svg{width:19px;height:19px}

.login-line{align-self:center;background:none;border:none;font:inherit;font-size:.82rem;color:var(--blue);cursor:pointer;text-decoration:underline;text-underline-offset:3px}
.login-line.on{color:var(--muted);text-decoration:none}

.home-recipes{display:flex;flex-direction:column}
.sec-hdr{display:flex;align-items:baseline;justify-content:space-between;padding-bottom:.6rem;border-bottom:1px solid #000}
.sec-hdr h2{font-family:var(--display);font-weight:300;font-size:1.5rem}
.link-btn{background:none;border:none;font:inherit;font-size:.84rem;color:var(--text-2);cursor:pointer}
.rows{display:flex;flex-direction:column}
.home-empty{padding:1.4rem 0;margin:0}
.hrow{display:flex;align-items:center;gap:.8rem;padding:.85rem 0;border-bottom:1px solid var(--line);cursor:pointer;text-align:start}
.hrow:active{background:var(--surface)}
.hrow-dot{width:12px;height:12px;border-radius:50%;flex-shrink:0;box-shadow:inset 0 0 0 1px rgba(0,0,0,.15)}
.hrow-txt{flex:1;min-width:0;display:flex;flex-direction:column}
.hrow-txt b{font-weight:500;font-size:.95rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.hrow-txt small{font-size:.76rem;color:var(--muted)}
.hrow-brew{width:36px;height:36px;border-radius:50%;border:none;background:#000;color:#fff;display:grid;place-items:center;cursor:pointer;flex-shrink:0}
.hrow-brew svg{width:14px;height:14px}

/* ---------- home: machine tiles ---------- */
.home-machine{display:flex;flex-direction:column;gap:.8rem}
.tiles{display:grid;grid-template-columns:repeat(3,1fr);gap:.6rem}
.tile{
  display:flex;flex-direction:column;align-items:center;gap:.45rem;padding:1rem .5rem;
  background:var(--machine);color:#fff;border:none;border-radius:var(--radius-md);cursor:pointer;font:inherit;
}
.tile svg{width:30px;height:30px;color:#d9d9d9}
.tile b{font-size:.86rem;font-weight:500}
.tile:active{background:#2c2c2e}

/* ---------- machine panel ---------- */
.machine-display{background:var(--machine);color:#fff;border-radius:var(--radius);padding:1.1rem 1.2rem 1.3rem;margin-bottom:.8rem}
.md-top{display:flex;justify-content:space-between;align-items:center;gap:1rem;font-size:.84rem;color:#bdbdbd;margin-bottom:.9rem}
.md-state{color:#fff;font-weight:500}
.md-readouts{display:grid;grid-template-columns:repeat(3,1fr);gap:.6rem}
.md-readouts div{display:flex;flex-direction:column;gap:.15rem}
.md-readouts b{font-family:var(--num);font-weight:400;font-size:2rem;line-height:1;font-variant-numeric:tabular-nums}
.md-readouts span{font-size:.74rem;color:#9a9a9a}
.machine-note{font-size:.8rem;color:var(--muted);line-height:1.65;margin:0 0 1rem;max-width:70ch}
.machine-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:.8rem;margin-bottom:.8rem}
.mcard{background:var(--surface);border-radius:var(--radius-md);padding:1.1rem 1.15rem;display:flex;flex-direction:column;gap:.9rem}
.mcard h2{font-family:var(--display);font-weight:300;font-size:1.45rem}
.mc-field{display:flex;flex-direction:column;gap:.45rem}
.mc-field>span{font-size:.84rem;color:var(--text-2)}
.mc-field small{color:var(--muted)}
.mcard .opt-seg{background:#fff;align-self:flex-start}
.mc-acts{display:flex;flex-wrap:wrap;gap:.45rem}
.mc-acts .btn{flex:1 1 calc(50% - .45rem)}
.mlog{list-style:none;margin:0;padding:0;font-size:.84rem}
.mlog li{display:flex;gap:.8rem;padding:.45rem 0;border-bottom:1px solid var(--line)}
.mlog li:last-child{border-bottom:none}
.mlog time{color:var(--muted);font-size:.76rem;min-width:4.5rem}
.mlog li.bad span{color:var(--danger)}

/* ---------- library ---------- */
.lib-filters{display:flex;flex-direction:column;gap:.6rem;margin-bottom:.6rem}
.lib-row{display:flex;flex-wrap:wrap;gap:.6rem;align-items:center}
.lib-row select{width:auto;flex:1;min-width:160px}
.lib-list .hrow-txt small+small{margin-top:.1rem}
.approved{font-style:normal;color:var(--ok);font-weight:500;margin-inline-start:.25rem}

/* ---------- live brew view ---------- */
.live{
  position:fixed;inset:0;z-index:380;background:#fff;overflow-y:auto;
  padding:max(12px,env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  display:flex;flex-direction:column;gap:1rem;
}
.live>*{width:100%;max-width:640px;margin-inline:auto}
.live-hdr{display:flex;align-items:center;justify-content:space-between;gap:.8rem}
.live-hdr b{flex:1;text-align:center;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.live-display{background:var(--machine);color:#fff;border-radius:var(--radius);padding:1.3rem 1.2rem;text-align:center}
.live-clock{font-family:var(--num);font-size:3.4rem;font-weight:300;line-height:1;letter-spacing:.02em;font-variant-numeric:tabular-nums}
.live-phase{font-size:.9rem;color:#cfcfcf;margin-top:.6rem;min-height:1.4em}
.live-main{display:flex;align-items:center;gap:1.2rem}
.live-pct{display:flex;align-items:baseline;gap:.1rem;position:relative}
.live-pct b{font-family:var(--display);font-weight:300;font-size:4.2rem;line-height:1}
.live-pct span{font-size:1.4rem}
.live-pct[data-est]:not([data-est=""])::after{content:attr(data-est);position:absolute;bottom:-1.1rem;inset-inline-start:0;font-size:.7rem;color:var(--muted)}
.live-stats{flex:1;display:grid;grid-template-columns:repeat(3,1fr);gap:.5rem}
.live-stats div{display:flex;flex-direction:column;background:var(--surface);border-radius:var(--radius-sm);padding:.55rem .6rem}
.live-stats span{font-size:.72rem;color:var(--muted)}
.live-stats b{font-family:var(--num);font-size:1.35rem;font-weight:500;font-variant-numeric:tabular-nums}
.live-stats small{font-size:.7rem;color:var(--muted)}
.live-chart{margin:0}
.live-chart figcaption{display:flex;align-items:center;gap:1rem;font-size:.82rem;margin-bottom:.4rem}
.live-chart figcaption b{font-weight:500;margin-inline-end:auto}
.lg{display:inline-flex;align-items:center;gap:.35rem;color:var(--text-2)}
.lg::before{content:"";width:14px;height:2px;border-radius:2px;background:currentColor}
.lg-water::before{background:#0b45c5}
.lg-coffee::before{background:#c8641e}
.chart-wrap{position:relative;direction:ltr;background:var(--surface);border-radius:var(--radius-md);padding:.4rem .2rem}
#liveChart{display:block;width:100%;height:190px;touch-action:pan-y}
#liveChart .grid{stroke:var(--line-strong);stroke-width:1;opacity:.6}
#liveChart .target{stroke:#9a9a9a;stroke-width:1;stroke-dasharray:4 4}
#liveChart .tick{font:10px var(--num);fill:var(--muted)}
#liveChart .dlabel{font:600 11px var(--num);fill:var(--text)}
#liveChart .cross{stroke:var(--text-2);stroke-width:1}
.chart-tip{position:absolute;top:.4rem;width:130px;background:#000;color:#fff;border-radius:var(--radius-sm);padding:.45rem .6rem;font-size:.76rem;display:flex;flex-direction:column;gap:.15rem;pointer-events:none;direction:rtl}
.lg-dot{display:inline-block;width:8px;height:8px;border-radius:50%;margin-inline-end:.35rem}
.live-steps{list-style:none;margin:0;padding:0}
.live-steps li{display:grid;grid-template-columns:1fr 4rem 3rem;gap:.5rem;padding:.6rem .2rem;border-bottom:1px solid var(--line);font-size:.88rem;color:var(--muted)}
.live-steps li b{font-weight:500}
.live-steps li.on{color:#000}
.live-steps li.on b::after{content:" ←";color:var(--blue)}
.live-steps li.done{color:var(--text-2)}
.live-steps li.done b::before{content:"✓ ";color:var(--ok)}
.live-acts{display:flex;gap:.6rem}
.live-acts .btn{flex:1;padding:.85rem}
.live-resume{
  position:fixed;z-index:360;left:50%;transform:translateX(-50%);bottom:calc(84px + env(safe-area-inset-bottom));
  background:#000;color:#fff;border:none;border-radius:999px;padding:.65rem 1.1rem;font:inherit;font-size:.86rem;cursor:pointer;
}

/* ---------- camera ---------- */
.ai-photo-acts{display:flex;gap:1rem;align-items:center}
.ai-photo-acts .ai-upload-lbl{background:none;border:none;padding:0;font:inherit;font-size:.84rem;font-weight:500;color:var(--text);cursor:pointer}
.camera{position:fixed;inset:0;z-index:420;background:#000;color:#fff;display:flex;flex-direction:column;overflow:hidden}
.camera video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.cam-frame{
  position:absolute;left:50%;top:44%;transform:translate(-50%,-50%);
  width:min(78vw,420px);aspect-ratio:3/4;border:2px solid rgba(255,255,255,.9);border-radius:18px;
  box-shadow:0 0 0 100vmax rgba(0,0,0,.38);pointer-events:none;
}
.cam-hint{position:absolute;top:max(18px,env(safe-area-inset-top));left:0;right:0;margin:0;text-align:center;font-size:.9rem;text-shadow:0 1px 4px rgba(0,0,0,.6)}
.cam-bar{
  position:absolute;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:space-around;
  padding:1.2rem 1rem calc(1.4rem + env(safe-area-inset-bottom));background:linear-gradient(transparent,rgba(0,0,0,.6));
}
.cam-side{display:flex;flex-direction:column;align-items:center;gap:.3rem;min-width:72px;background:none;border:none;color:#fff;font:inherit;font-size:.8rem;cursor:pointer}
.cam-side .i{width:26px;height:26px}
.cam-snap{width:74px;height:74px;border-radius:50%;background:#fff;border:5px solid rgba(255,255,255,.35);background-clip:padding-box;cursor:pointer;box-shadow:0 0 0 2px #fff}
.cam-snap:active{transform:scale(.94)}
.camera.flash::after{content:"";position:absolute;inset:0;background:#fff;opacity:.7;pointer-events:none}
body.cam-open{overflow:hidden}

/* ---------- mobile ---------- */
.mobile-nav{display:none}

@media (max-width:820px){
  .split{grid-template-columns:1fr}
  .provider-bar{flex-direction:column;align-items:stretch}
  .filter-search{width:100%}
  .hero-bignum{font-size:8rem}
  .stepper b{font-size:1.9rem;min-width:70px}
}

@media (max-width:767px){
  .app{flex-direction:column;min-height:100dvh}
  .sidebar{display:none}
  .main{padding:max(14px,env(safe-area-inset-top)) 16px calc(92px + env(safe-area-inset-bottom))}
  .panel-head{margin-bottom:1.1rem}
  h1{font-size:1.75rem}
  .home{gap:1.15rem}
  .home-hero{padding:1.6rem 1.2rem 1.3rem}
  .machine{width:100px;height:125px}
  .home-q{font-size:1.9rem}
  .picks{gap:.5rem}
  .pick{padding:.85rem .7rem}
  .pick small{display:none}
  .ai-hero-title{font-size:1.8rem}
  .opt-btn{padding:.5rem .75rem;min-width:56px}
  .ai-hero-btns{flex-direction:column-reverse}
  .ai-brew-btn{max-width:none;width:100%}
  .ai-upload-lbl{width:100%}
  .result-acts .btn{flex:1 1 calc(50% - .5rem)}
  .modal{align-items:flex-end;padding:0}
  .modal-box{width:100%;max-width:none;border-radius:20px 20px 0 0;padding:1.4rem 1.2rem calc(1.4rem + env(safe-area-inset-bottom))}
  .toast{bottom:calc(84px + env(safe-area-inset-bottom))}
  .recipe-list{grid-template-columns:1fr}

  .mobile-nav{
    display:flex;position:fixed;inset-inline:0;bottom:0;z-index:300;
    background:rgba(255,255,255,.96);border-top:1px solid var(--line);
    -webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);
    padding:6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mnav-btn{
    flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;padding:6px 0;
    background:none;border:none;font:inherit;font-size:.68rem;color:#8a8a8a;cursor:pointer;
  }
  .mnav-btn svg{width:23px;height:23px}
  .mnav-btn.active{color:#000;font-weight:600}
}

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