@import url('/fonts.css');

:root{
  --bg:#f7f5f9;--surface:#ffffff;--surface-2:#f0ecf5;--surface-3:#e7e0ef;
  --primary:#8d76b8;--primary-strong:#6f579c;--primary-deep:#554276;--primary-soft:#ebe5f3;
  --text:#292530;--muted:#746d7d;--line:#ded8e5;--success:#44745c;--warn:#a56b30;--danger:#a44f5b;
  --shadow:0 8px 28px rgba(50,39,63,.08);--radius:18px;--tap:48px;
  --sidebar:238px;--bottom:72px;--max:1280px;
  font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
*{box-sizing:border-box}
html{background:var(--bg);color:var(--text);-webkit-text-size-adjust:100%}
body{margin:0;min-height:100vh;background:var(--bg);font-size:16px;line-height:1.5}
button,input,select,textarea{font:inherit}
button{cursor:pointer}
button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid rgba(141,118,184,.28);outline-offset:2px}
a{color:inherit;text-decoration:none}
[hidden]{display:none!important}

.app-shell{min-height:100vh}
.sidebar{display:none}
.app-main{min-height:100vh;padding-bottom:calc(var(--bottom) + env(safe-area-inset-bottom))}
.topbar{position:sticky;top:0;z-index:20;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:18px 18px 12px;background:rgba(247,245,249,.96);border-bottom:1px solid transparent;backdrop-filter:blur(14px)}
.topbar h1{margin:0;font-size:1.55rem;letter-spacing:-.035em;line-height:1.15}
.eyebrow{margin:0 0 2px;color:var(--muted);font-size:.78rem;font-weight:700;letter-spacing:.035em;text-transform:uppercase}
.top-actions{display:flex;gap:8px;align-items:center}
.icon-btn,.avatar-btn{width:44px;height:44px;border:1px solid var(--line);border-radius:14px;background:var(--surface);color:var(--text);display:grid;place-items:center;font-weight:800}
.avatar-btn{border-radius:50%;background:var(--primary);border-color:var(--primary);color:#fff}
.view{width:min(100%,var(--max));margin:0 auto;padding:14px 16px 32px}
.bottom-nav{position:fixed;left:0;right:0;bottom:0;z-index:30;height:calc(var(--bottom) + env(safe-area-inset-bottom));padding:8px 10px env(safe-area-inset-bottom);display:grid;grid-template-columns:repeat(5,1fr);gap:4px;background:rgba(255,255,255,.97);border-top:1px solid var(--line);backdrop-filter:blur(16px)}
.bottom-nav button{min-width:0;border:0;background:transparent;color:var(--muted);border-radius:14px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-size:.68rem;font-weight:700}
.bottom-nav button .nav-ico{font-size:1.2rem;line-height:1}
.bottom-nav button.active{background:var(--primary-soft);color:var(--primary-deep)}

.auth-shell{min-height:100vh;display:grid;place-items:center;padding:24px;background:var(--bg)}
.auth-card{width:min(100%,440px);background:var(--surface);border:1px solid var(--line);border-radius:26px;padding:28px;box-shadow:var(--shadow)}
.auth-brand{display:flex;align-items:center;gap:12px;margin-bottom:24px}
.auth-brand .brand-mark,.brand-mark{width:46px;height:46px;border-radius:15px;background:var(--primary);color:#fff;display:grid;place-items:center;font-weight:900;font-size:1.3rem}
.auth-card h1{font-size:1.8rem;margin:0;letter-spacing:-.04em}
.auth-card p{color:var(--muted)}
.auth-tabs{display:grid;grid-template-columns:1fr 1fr;background:var(--surface-2);border-radius:14px;padding:4px;margin:20px 0}
.auth-tabs button{height:42px;border:0;background:transparent;border-radius:11px;color:var(--muted);font-weight:700}
.auth-tabs button.active{background:var(--surface);color:var(--text);box-shadow:0 2px 9px rgba(50,39,63,.06)}

.section{margin:12px 0 28px}
.section-head{display:flex;align-items:end;justify-content:space-between;gap:12px;margin-bottom:12px}
.section-head h2{margin:0;font-size:1.16rem;letter-spacing:-.02em}
.section-head p{margin:2px 0 0;color:var(--muted);font-size:.9rem}
.text-btn{border:0;background:none;color:var(--primary-strong);font-weight:800;padding:7px 0}

.hero-welcome{padding:18px 0 8px}
.hero-welcome h2{font-size:1.85rem;line-height:1.15;letter-spacing:-.045em;margin:0 0 8px}
.hero-welcome p{margin:0;color:var(--muted)}
.ai-command{margin:18px 0 6px;background:var(--surface);border:1px solid var(--line);border-radius:22px;padding:10px;box-shadow:var(--shadow)}
.ai-command-row{display:flex;gap:8px}
.ai-command input{flex:1;border:0;background:transparent;min-height:48px;padding:0 8px;color:var(--text);min-width:0}
.ai-command input:focus{outline:none}
.ai-command .primary{white-space:nowrap}
.quick-chips{display:flex;gap:8px;overflow-x:auto;padding:8px 2px 2px;scrollbar-width:none}
.quick-chips::-webkit-scrollbar{display:none}
.chip{height:36px;padding:0 13px;border-radius:999px;border:1px solid var(--line);background:var(--surface);color:var(--text);white-space:nowrap;font-size:.87rem;font-weight:700}
.chip.active,.chip:hover{border-color:var(--primary);background:var(--primary-soft);color:var(--primary-deep)}

.recipe-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.recipe-card{overflow:hidden;border:1px solid var(--line);border-radius:18px;background:var(--surface);min-width:0}
.recipe-card button.card-hit{display:block;width:100%;padding:0;border:0;background:transparent;text-align:left;color:inherit}
.recipe-photo{aspect-ratio:1.35/1;background:var(--surface-2);display:grid;place-items:center;overflow:hidden;color:var(--primary-strong);font-size:2rem}
.recipe-photo img{width:100%;height:100%;object-fit:cover}
.recipe-card-body{padding:12px}
.recipe-card h3{font-size:.98rem;margin:0 0 6px;line-height:1.25}
.recipe-meta{display:flex;gap:8px;flex-wrap:wrap;color:var(--muted);font-size:.78rem}
.fav-star{color:#9b7a38}

.card,.panel{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:16px}
.card+.card,.panel+.panel{margin-top:10px}
.soft-card{background:var(--primary-soft);border-color:#d9cfe7}
.stat-row{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.stat{padding:13px 10px;border-radius:16px;background:var(--surface);border:1px solid var(--line);text-align:center}
.stat strong{display:block;font-size:1.1rem}.stat span{color:var(--muted);font-size:.76rem}
.empty{padding:28px 18px;text-align:center;border:1px dashed #cec6d7;border-radius:18px;color:var(--muted)}
.empty strong{display:block;color:var(--text);margin-bottom:4px}

.btn,.primary,.secondary,.danger-btn{min-height:var(--tap);border-radius:14px;padding:0 16px;font-weight:800;border:1px solid transparent}
.primary{background:var(--primary);color:#fff;border-color:var(--primary)}
.primary:hover{background:var(--primary-strong)}
.secondary{background:var(--surface);color:var(--text);border-color:var(--line)}
.danger-btn{background:#fff4f5;color:var(--danger);border-color:#ead0d4}
.btn-row{display:flex;gap:10px;flex-wrap:wrap}
.btn-row>*{flex:1 1 auto}
.fab{position:fixed;right:18px;bottom:calc(var(--bottom) + 18px + env(safe-area-inset-bottom));z-index:18;width:58px;height:58px;border:0;border-radius:20px;background:var(--primary);color:#fff;font-size:1.5rem;box-shadow:0 12px 30px rgba(85,66,118,.3)}

.field{display:flex;flex-direction:column;gap:6px;margin:0 0 14px}
.field label,.label{font-size:.82rem;color:var(--muted);font-weight:800}
.input,textarea,select{width:100%;border:1px solid var(--line);background:var(--surface);border-radius:13px;color:var(--text);padding:12px 13px;min-height:46px}
textarea{resize:vertical;min-height:96px}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.form-grid .wide{grid-column:1/-1}
.inline-fields{display:grid;grid-template-columns:1.3fr .55fr .7fr 42px;gap:7px;align-items:end;margin-bottom:8px}
.inline-fields .field{margin:0}
.remove-row{width:42px;height:46px;border-radius:12px;border:1px solid var(--line);background:var(--surface);color:var(--danger)}
.step-row{display:grid;grid-template-columns:36px 1fr 72px 42px;gap:8px;align-items:start;margin-bottom:8px}
.step-num{width:36px;height:36px;border-radius:12px;background:var(--primary-soft);color:var(--primary-deep);display:grid;place-items:center;font-weight:900}
.muted{color:var(--muted)}
.small{font-size:.84rem}
.note{padding:12px 14px;background:var(--surface-2);border-radius:13px;color:var(--muted);font-size:.87rem}
.error{padding:12px 14px;border-radius:13px;background:#fff1f2;color:var(--danger);font-weight:700}
.success{padding:12px 14px;border-radius:13px;background:#edf7f1;color:var(--success);font-weight:700}

.searchbar{display:flex;gap:8px;margin-bottom:12px}
.searchbar input{flex:1}
.filter-row{display:flex;gap:8px;overflow:auto;margin-bottom:14px;scrollbar-width:none}
.filter-row::-webkit-scrollbar{display:none}

.detail-hero{margin:-14px -16px 0;position:relative}
.detail-hero .recipe-photo{aspect-ratio:1.5/1;border-radius:0}
.detail-hero-actions{position:absolute;top:12px;left:12px;right:12px;display:flex;justify-content:space-between}
.overlay-btn{width:44px;height:44px;border-radius:14px;border:0;background:rgba(255,255,255,.92);display:grid;place-items:center;font-weight:900}
.detail-title{padding:18px 0 8px}
.detail-title h2{font-size:2rem;letter-spacing:-.045em;line-height:1.1;margin:0 0 8px}
.pill-row{display:flex;gap:8px;flex-wrap:wrap}
.pill{padding:7px 10px;border-radius:999px;background:var(--surface-2);font-size:.8rem;color:var(--muted);font-weight:700}
.sticky-cook{position:sticky;bottom:calc(var(--bottom) + 10px);z-index:14;margin:14px 0}
.sticky-cook .primary{width:100%;box-shadow:0 10px 30px rgba(85,66,118,.24)}

.ingredients{list-style:none;margin:0;padding:0}
.ingredients li{display:flex;gap:10px;padding:11px 0;border-bottom:1px solid var(--line);align-items:flex-start}
.ingredients li:last-child{border:0}
.check{width:24px;height:24px;border:1.5px solid #bcb3c7;border-radius:8px;flex:0 0 24px;background:#fff}
.ingredients .qty{font-weight:800}
.steps{display:flex;flex-direction:column;gap:14px}
.step{display:grid;grid-template-columns:38px 1fr;gap:12px;align-items:start}
.step .step-num{margin-top:1px}

.cook-shell{position:fixed;inset:0;z-index:100;background:#fcfbfd;display:flex;flex-direction:column}
.cook-top{display:flex;align-items:center;justify-content:space-between;padding:16px;border-bottom:1px solid var(--line)}
.cook-progress{height:4px;background:var(--surface-3)}
.cook-progress span{display:block;height:100%;background:var(--primary)}
.cook-body{flex:1;overflow:auto;padding:28px 22px;display:flex;flex-direction:column;justify-content:center;max-width:760px;width:100%;margin:auto}
.cook-body .kicker{color:var(--primary-strong);font-weight:900;font-size:.86rem;text-transform:uppercase;letter-spacing:.04em}
.cook-body h2{font-size:clamp(1.65rem,7vw,2.6rem);line-height:1.2;letter-spacing:-.04em;margin:8px 0 22px}
.cook-needed{padding:15px;border-radius:16px;background:var(--primary-soft);margin-bottom:18px}
.cook-controls{display:grid;grid-template-columns:1fr 1.7fr;gap:10px;padding:14px 16px calc(14px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:#fff}
.timer-bar{position:fixed;top:74px;right:14px;z-index:110;padding:9px 12px;border-radius:13px;background:var(--primary-deep);color:#fff;font-weight:800;box-shadow:var(--shadow)}

.plan-list{display:flex;flex-direction:column;gap:10px}
.plan-day{display:grid;grid-template-columns:76px 1fr;gap:10px;align-items:center}
.plan-date{font-weight:900;color:var(--primary-deep)}
.plan-meal{min-height:64px;padding:12px;border-radius:15px;background:var(--surface);border:1px solid var(--line)}
.shopping-item{display:grid;grid-template-columns:32px 1fr 42px;gap:8px;align-items:center;padding:11px 0;border-bottom:1px solid var(--line)}
.shopping-item.checked .item-name{text-decoration:line-through;color:var(--muted)}
.pantry-row{display:grid;grid-template-columns:1fr auto;gap:12px;align-items:center;padding:12px 0;border-bottom:1px solid var(--line)}
.expiry-soon{color:var(--warn);font-weight:800}

.ai-screen .prompt-box{background:var(--surface);border:1px solid var(--line);border-radius:20px;padding:12px}
.ai-screen textarea{border:0;min-height:120px;padding:8px;background:transparent}
.ai-screen textarea:focus{outline:none}
.suggestion{padding:16px;border:1px solid var(--line);border-radius:18px;background:var(--surface);margin-bottom:10px}
.suggestion h3{margin:0 0 6px}
.proposal{border:1px solid #d5c9e4;background:#fcfaff;border-radius:20px;padding:16px}
.diff-list{margin:10px 0;padding-left:20px;color:var(--primary-deep)}

.modal-host{position:fixed;inset:0;z-index:200;background:rgba(29,25,34,.45);padding:16px;display:grid;place-items:end center}
.modal-sheet{width:min(100%,620px);max-height:88vh;overflow:auto;background:var(--surface);border-radius:24px 24px 18px 18px;padding:18px;box-shadow:0 20px 60px rgba(20,15,25,.22)}
.modal-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}
.modal-head h2{margin:0;font-size:1.25rem}
.close-btn{width:42px;height:42px;border:0;background:var(--surface-2);border-radius:13px}

.toast{position:fixed;z-index:500;left:50%;top:16px;transform:translate(-50%,-20px);opacity:0;pointer-events:none;max-width:min(92vw,520px);padding:12px 16px;border-radius:14px;background:var(--primary-deep);color:#fff;font-weight:800;box-shadow:var(--shadow);transition:.18s ease}
.toast.show{opacity:1;transform:translate(-50%,0)}
.skeleton{background:#ece8f0;border-radius:10px;min-height:18px;animation:pulse 1.4s ease infinite}
@keyframes pulse{50%{opacity:.55}}

@media(min-width:760px){
  .recipe-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  .view{padding:18px 24px 48px}
  .detail-hero{margin:0;border-radius:24px;overflow:hidden}
  .detail-hero .recipe-photo{border-radius:24px}
  .fab{right:28px}
  .modal-host{place-items:center}
  .modal-sheet{border-radius:24px}
}
@media(min-width:1024px){
  .app-shell{display:grid;grid-template-columns:var(--sidebar) 1fr}
  .sidebar{display:flex;position:sticky;top:0;height:100vh;flex-direction:column;padding:22px 14px;border-right:1px solid var(--line);background:#fbfafc}
  .brand{display:flex;align-items:center;gap:11px;font-size:1.18rem;font-weight:900;padding:0 8px 20px}
  .brand-mark{width:40px;height:40px;border-radius:13px}
  .side-nav{display:flex;flex-direction:column;gap:4px;flex:1}
  .nav-link{width:100%;min-height:46px;padding:0 12px;border:0;border-radius:13px;background:transparent;color:var(--muted);display:flex;align-items:center;gap:11px;text-align:left;font-weight:750}
  .nav-link.active{background:var(--primary-soft);color:var(--primary-deep)}
  .side-foot{border-top:1px solid var(--line);padding-top:10px}
  .bottom-nav{display:none}
  .app-main{padding-bottom:0}
  .topbar{padding:22px 32px 14px}
  .view{padding:18px 32px 60px}
  .recipe-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
  .fab{bottom:28px;right:32px}
  .sticky-cook{bottom:18px}
  .cook-controls{grid-template-columns:180px 240px;justify-content:center}
}
@media(prefers-color-scheme:dark){
  :root{--bg:#19171d;--surface:#232027;--surface-2:#2c2831;--surface-3:#393340;--text:#f4f0f7;--muted:#b5acbf;--line:#3c3742;--primary-soft:#352f43;--shadow:0 8px 28px rgba(0,0,0,.24)}
  .topbar{background:rgba(25,23,29,.95)}.bottom-nav{background:rgba(35,32,39,.97)}
  .icon-btn,.auth-tabs button.active,.secondary,.remove-row,.overlay-btn{background:var(--surface)}
  .cook-shell,.cook-controls{background:var(--bg)}.check{background:var(--surface)}
}

@media print{
  .sidebar,.bottom-nav,.topbar,.detail-hero-actions,.btn-row,.sticky-cook,.fab{display:none!important}
  body,.app-main,.view{background:#fff!important;color:#111!important;padding:0!important;margin:0!important}
  .detail-hero{max-height:280px;overflow:hidden}.detail-hero .recipe-photo{max-height:280px}
  .section{break-inside:avoid}.card{border:1px solid #ccc;box-shadow:none}
}

@media (prefers-color-scheme: dark){
  :root{--bg:#19161d;--surface:#242029;--surface-2:#2d2733;--surface-3:#38303f;--text:#f5f0f8;--muted:#bbb0c4;--line:#453b4d;--primary:#aa91d2;--primary-strong:#bea8df;--primary-deep:#d3c1ec;--primary-soft:#392f46;--shadow:0 8px 28px rgba(0,0,0,.28)}
  html,body{background:var(--bg);color:var(--text)}
  input,select,textarea,.input{background:#211d25;color:var(--text);border-color:var(--line)}
  .topbar,.bottom-nav,.sidebar,.card,.recipe-card,.auth-card,.modal-sheet,.cook-shell,.cook-top,.cook-controls{background:var(--surface);color:var(--text)}
  .recipe-photo,.hero-welcome,.prompt-box,.soft-card{background:var(--surface-2)}
}

.ingredient-section{list-style:none;padding:14px 0 6px!important;border-bottom:0!important;color:var(--primary);font-size:.82rem;text-transform:uppercase;letter-spacing:.08em}
.plan-tray{padding-bottom:8px}
.plan-drag{cursor:grab}
.drop-slot{transition:.15s ease;border:1px solid transparent;border-radius:12px;padding:8px}
.drop-slot.drag-over{border-color:var(--primary);background:var(--primary-soft)}
@media print{
  .side,.topbar,.bottom-nav,.btn-row,.sticky-cook,.fab,.overlay-btn,.text-btn,.secondary,.primary{display:none!important}
  .main{margin:0!important;padding:0!important}.view{max-width:none!important}.detail-hero{max-height:280px;overflow:hidden}
}
