:root {
  --bg: #E9EFE9;
  --surface: #F8FBF7;
  --surface-2: #DFE8E0;
  --ink: #17251E;
  --muted: #55665C;
  --line: #C6D3C9;
  --pandan: #2E6A4C;
  --pandan-ink: #FFFFFF;
  --pandan-soft: #D3E6DA;
  --sambal: #B8361F;
  --kunyit: #E4AC2E;
  --kunyit-soft: #F7E3AE;
  --shadow: 0 1px 0 rgba(23, 37, 30, .06), 0 8px 24px -12px rgba(23, 37, 30, .25);
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --chat-w: clamp(360px, 36vw, 540px);
  --tab-w: 44px;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101814; --surface: #17221C; --surface-2: #203027; --ink: #E4EDE6; --muted: #9DB0A4;
    --line: #2F4237; --pandan: #6CC199; --pandan-ink: #0D1A13; --pandan-soft: #1F3B2D;
    --sambal: #FF8065; --kunyit: #F0C25A; --kunyit-soft: #4A3B12;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 10px 28px -14px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101814; --surface: #17221C; --surface-2: #203027; --ink: #E4EDE6; --muted: #9DB0A4;
  --line: #2F4237; --pandan: #6CC199; --pandan-ink: #0D1A13; --pandan-soft: #1F3B2D;
  --sambal: #FF8065; --kunyit: #F0C25A; --kunyit-soft: #4A3B12;
  --shadow: 0 1px 0 rgba(0,0,0,.3), 0 10px 28px -14px rgba(0,0,0,.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 17px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--kunyit); outline-offset: 2px; border-radius: 6px; }
svg { width: 1.2em; height: 1.2em; flex: none; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; margin: 0; letter-spacing: -.01em; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.app {
  height: 100dvh; display: grid;
  grid-template-columns: minmax(0, 1fr) 0;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top chat" "stage chat";
  transition: grid-template-columns .28s ease;
}
.app[data-chat="open"] { grid-template-columns: minmax(0, 1fr) var(--chat-w); }

.topbar {
  grid-area: top; display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; padding-right: calc(var(--tab-w) + 12px);
  border-bottom: 1px solid var(--line); background: var(--bg); min-width: 0; overflow: hidden;
}
.app[data-chat="open"] .topbar { padding-right: 20px; }
.brand {
  display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 2px;
  font-family: var(--font-display); font-weight: 800; font-size: 19px; color: var(--pandan); white-space: nowrap;
}
.brand svg { width: 28px; height: 28px; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: none; padding: 8px 12px; border-radius: 999px; color: var(--muted); font-weight: 700;
}
.nav-btn[aria-current="page"] { background: var(--pandan-soft); color: var(--ink); }
.nav-btn:hover { color: var(--ink); }
.nav-btn svg { width: 20px; height: 20px; }
.timers { display: flex; gap: 6px; margin-left: auto; overflow-x: auto; min-width: 0; flex: 0 1 auto; scrollbar-width: none; }
.timer-chip {
  display: inline-flex; align-items: center; gap: 6px; border: 0; white-space: nowrap;
  background: var(--kunyit-soft); color: var(--ink); padding: 6px 12px; border-radius: 999px;
  font-variant-numeric: tabular-nums; font-weight: 700;
}
.timer-chip.done { background: var(--sambal); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.sync { font-size: 13px; color: var(--muted); white-space: nowrap; }
.sync:empty { display: none; }

.stage {
  grid-area: stage; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 28px 32px 48px; padding-right: calc(var(--tab-w) + 28px);
  outline: none;
}
.app[data-chat="open"] .stage { padding-right: 32px; }

/* ---------- Chat panel ---------- */
.chat {
  grid-area: chat; min-width: 0; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line);
  visibility: hidden;
}
.app[data-chat="open"] .chat { visibility: visible; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--line); }
.chat-head h2 { font-size: 19px; margin-right: auto; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: 16px; word-wrap: break-word; }
.msg p { margin: 0 0 .5em; } .msg p:last-child { margin-bottom: 0; }
.msg ul { margin: .2em 0 .5em; padding-left: 1.2em; }
.msg.user { align-self: flex-end; background: var(--pandan); color: var(--pandan-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg.error { align-self: stretch; background: transparent; border: 2px solid var(--sambal); color: var(--ink); }
.msg img { display: block; max-width: 160px; border-radius: 10px; margin-bottom: 6px; }
.msg .view-link {
  display: inline-flex; margin-top: 8px; border: 0; background: var(--surface); color: var(--pandan);
  padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 15px;
}
.msg .learned { margin-top: 8px; font-size: 14px; color: var(--muted); }
.typing { display: inline-flex; gap: 4px; padding: 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-empty { color: var(--muted); font-size: 15px; padding: 4px 4px 0; }
.chat-empty button { margin: 6px 6px 0 0; }

.composer { border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer textarea {
  flex: 1; resize: none; max-height: 160px; min-height: 44px; border: 1px solid var(--line); background: var(--bg);
  border-radius: 22px; padding: 10px 16px; line-height: 1.35;
}
.composer textarea:focus { outline: none; border-color: var(--pandan); }
.send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--pandan); color: var(--pandan-ink); display: grid; place-items: center; }
.send:disabled { opacity: .5; }
.attach-preview { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; color: var(--muted); }
.attach-preview img { height: 48px; border-radius: 8px; }

.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; border: 0; background: none; color: var(--muted); flex: none; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; }

.chat-tab {
  position: fixed; right: 0; bottom: 96px; z-index: 5;
  width: var(--tab-w); padding: 16px 0; border: 0; border-radius: 14px 0 0 14px;
  background: var(--pandan); color: var(--pandan-ink); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 10px; font-weight: 700;
}
.chat-tab span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 15px; letter-spacing: .02em; }
.chat-tab .dot { position: absolute; top: 8px; left: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--kunyit); }
.app[data-chat="open"] .chat-tab { display: none; }

/* ---------- Generic ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  border: 0; border-radius: 999px; padding: 10px 20px; font-weight: 700;
  background: var(--pandan); color: var(--pandan-ink);
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: default; }
.ghost { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 16px; font-weight: 700; }
.ghost:hover { border-color: var(--pandan); }
.ghost.small { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.ghost.danger { color: var(--sambal); }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 15px; }
.chip:hover { border-color: var(--pandan); }
.muted { color: var(--muted); }
.tag {
  display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; white-space: nowrap; line-height: 1.5;
  background: var(--surface-2); color: var(--ink);
}
.tag.vardag { background: var(--pandan-soft); }
.tag.helg { background: var(--kunyit-soft); }
.tag.healthy { background: var(--pandan); color: var(--pandan-ink); }
.tag.healthy::before { content: "♥ "; }
.tag.veg { background: transparent; border: 1.5px solid var(--muted); color: var(--muted); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 8px; font-size: 24px; }

/* ---------- Home ---------- */
.home { max-width: 860px; }
.home h1 { font-size: clamp(30px, 5vw, 52px); font-weight: 800; white-space: nowrap; color: var(--ink); margin: 8px 0 18px; }
.day-line { font-size: 18px; color: var(--muted); margin: 0 0 22px; max-width: 60ch; }
.day-line strong { color: var(--ink); }
.asker {
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-lg); padding: 14px; box-shadow: var(--shadow);
}
.asker:focus-within { border-color: var(--pandan); }
.asker textarea { width: 100%; border: 0; background: none; resize: vertical; min-height: 96px; font-size: 19px; padding: 6px 8px; }
.asker textarea:focus { outline: none; }
.asker-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.asker-row .btn { margin-left: auto; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 40px; }
.home h2 { font-size: 22px; margin-bottom: 12px; }
.recent { display: grid; gap: 2px; }

/* ---------- Suggestions ---------- */
.sugg-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.sugg-head h1 { font-size: clamp(26px, 3.4vw, 38px); }
.sugg-intro { color: var(--muted); max-width: 70ch; margin: 0 0 22px; }
.sugg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 16px; }
.sugg {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 8px;
}
.sugg.healthier { border: 2px solid var(--pandan); }
.sugg .tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sugg h3 { font-size: 22px; }
.sugg .origin { color: var(--muted); font-size: 15px; margin-top: -4px; }
.sugg .why { margin: 4px 0; }
.sugg dl { margin: 0; font-size: 15px; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.sugg dt { color: var(--muted); }
.sugg dd { margin: 0; }
.sugg .btn { margin-top: auto; align-self: flex-start; }
.sugg-foot { margin-top: 10px; }

/* ---------- Recipe (en kolumn: välj → ta fram → laga) ---------- */
.recipe { max-width: 780px; }
.r-head { margin-bottom: 18px; }
.r-origin { color: var(--muted); font-size: 15px; margin-bottom: 6px; }
.r-head h1 { font-size: clamp(28px, 4vw, 44px); font-weight: 800; }
.r-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; color: var(--muted); margin-top: 10px; font-size: 15px; }
.r-intro { margin: 12px 0 0; max-width: 64ch; font-size: 18px; }
.r-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.r-jump {
  position: sticky; top: -28px; z-index: 3; display: flex; gap: 6px;
  margin: 0 -8px 18px; padding: 36px 8px 10px; background: var(--bg);
}
.r-jump button {
  flex: 1; display: flex; justify-content: center; align-items: center; gap: 8px; min-height: 46px;
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; font-weight: 700; font-size: 16px; color: var(--muted);
}
.r-jump button span { font-size: 13px; font-variant-numeric: tabular-nums; }
.r-jump button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.r-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 24px 24px; margin-bottom: 18px; scroll-margin-top: 80px; }
.sec-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.sec-head h2 { font-size: 26px; font-weight: 800; }
.sec-head .muted { font-size: 14px; }

.ingredients .group-label { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--pandan); margin: 18px 0 2px; }
.ing {
  display: grid; grid-template-columns: 28px minmax(84px, max-content) 1fr; gap: 12px; align-items: baseline;
  padding: 12px 8px; margin: 0 -8px; border-radius: var(--r-sm); cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--line); font-size: 18px;
}
.ing-group .ing:last-child { border-bottom: 0; }
.ing input { width: 22px; height: 22px; accent-color: var(--pandan); margin: 0; align-self: center; cursor: pointer; }
.ing .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ing .note { color: var(--muted); font-size: 15px; }
.ing.checked .amt, .ing.checked .name { text-decoration: line-through; color: var(--muted); }
.start-cook { width: 100%; margin-top: 18px; min-height: 52px; font-size: 17px; }

.steps ol { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.step {
  counter-increment: s; display: grid; grid-template-columns: 48px 1fr; gap: 6px 14px;
  padding: 18px 12px; margin: 0 -12px; border-radius: var(--r-md); cursor: pointer; border-bottom: 1px solid var(--line);
}
.step:last-child { border-bottom: 0; }
.step::before {
  content: counter(s); grid-row: span 2; font-family: var(--font-display); font-weight: 800; font-size: 36px; line-height: 1;
  color: var(--pandan); text-align: right; font-variant-numeric: tabular-nums;
}
.step-text { font-size: 19px; line-height: 1.55; }
.step-text b { font-weight: 700; background: linear-gradient(transparent 62%, var(--kunyit-soft) 62%); }
.step.active { background: var(--pandan-soft); }
.step.done .step-text, .step.done::before { color: var(--muted); }
.step-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.step-tools .ghost { min-height: 36px; padding: 4px 14px; font-size: 14px; }

.extras .health { margin: 0; padding: 16px 18px; border-radius: var(--r-md); background: var(--pandan-soft); }
.health h3, .tips h3 { font-size: 18px; margin-bottom: 6px; }
.health ul, .tips ul { margin: 6px 0 0; padding-left: 1.2em; }
.tips { margin-top: 18px; }
.extras .health + .tips { margin-top: 18px; }
.r-sec .notes-box { margin: 0; padding: 0; border: 0; }

.notes-box { margin-top: 24px; padding-top: 18px; border-top: 2px solid var(--line); }
.notes-box h3 { font-size: 18px; margin-bottom: 8px; }
.notes-box textarea { width: 100%; min-height: 110px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); padding: 10px 12px; resize: vertical; }
.stars { display: inline-flex; gap: 2px; }
.stars button { border: 0; background: none; padding: 2px; font-size: 26px; line-height: 1; color: var(--line); }
.stars button.on { color: var(--kunyit); }
.cooked-log { font-size: 14px; color: var(--muted); margin-top: 8px; }

/* ---------- Cookbook ---------- */
.book-head { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.book-head h1 { font-size: clamp(28px, 4vw, 44px); font-weight: 800; margin-right: auto; }
.search { flex: 1 1 240px; max-width: 360px; min-height: 44px; border: 1px solid var(--line); border-radius: 999px; padding: 8px 18px; background: var(--surface); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filters .chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.book-list { display: grid; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.book-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center; text-align: left;
  border: 0; border-bottom: 1px solid var(--line); background: none; padding: 14px 20px; width: 100%;
}
.book-row:last-child { border-bottom: 0; }
.book-row:hover { background: var(--surface-2); }
.book-row h3 { font-size: 19px; }
.book-row .sub { color: var(--muted); font-size: 15px; grid-column: 1; }
.book-row .note-snip { grid-column: 1 / -1; font-size: 15px; font-style: italic; color: var(--muted); }
.book-row .rt { color: var(--kunyit); font-size: 18px; letter-spacing: 1px; grid-row: 1; grid-column: 2; }
.recent .book-row { border: 0; border-radius: var(--r-md); padding: 10px 14px; }

/* ---------- Settings ---------- */
.settings { max-width: 760px; }
.settings h1 { font-size: clamp(28px, 4vw, 44px); font-weight: 800; margin-bottom: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; margin-bottom: 18px; }
.card h2 { font-size: 21px; margin-bottom: 4px; }
.card > p { margin: 0 0 14px; color: var(--muted); max-width: 64ch; }
.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: 15px; }
.field input, .field select, .field textarea {
  min-height: 44px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); padding: 8px 12px; width: 100%;
}
.field textarea { min-height: 160px; resize: vertical; font-size: 15px; line-height: 1.45; }
.field textarea.tall { min-height: 340px; }
.field .hint { font-size: 14px; color: var(--muted); }
.field .hint a { color: var(--pandan); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--bg); }
.seg button { border: 0; background: none; padding: 7px 16px; border-radius: 999px; font-weight: 700; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--pandan); color: var(--pandan-ink); }
.memory-list { list-style: none; margin: 0 0 12px; padding: 0; }
.memory-list li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.memory-list li span { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, calc(100% + 40px)); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 700;
  max-width: calc(100vw - 32px); transition: transform .25s ease, visibility .25s; pointer-events: none; visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

.loading-stage { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 19px; padding: 40px 0; }
.pot { width: 46px; height: 46px; color: var(--pandan); }
.pot .steam { animation: steam 1.6s ease-in-out infinite; transform-origin: center bottom; }
.pot .steam:nth-child(2) { animation-delay: .3s; } .pot .steam:nth-child(3) { animation-delay: .6s; }
@keyframes steam { 0%, 100% { opacity: .2; transform: translateY(2px); } 50% { opacity: 1; transform: translateY(-2px); } }

/* ---------- Tablet / phone ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) 0; grid-template-areas: "top" "stage" "chat"; transition: grid-template-rows .28s ease; }
  .app[data-chat="open"] { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) 52%; }
  .chat { border-left: 0; border-top: 2px solid var(--pandan); border-radius: 18px 18px 0 0; }
  .app:not([data-chat="open"]) .chat { border-top: 0; }
  .topbar { padding: 8px 12px; gap: 6px; }
  .app[data-chat="open"] .topbar, .topbar { padding-right: 12px; }
  .brand span { display: none; }
  .nav { margin-left: 0; }
  .nav-btn { padding: 8px 10px; }
  .nav-label { display: none; }
  .stage, .app[data-chat="open"] .stage { padding: 18px 16px 88px; }
  .app[data-chat="open"] .stage { padding-bottom: 16px; }
  .chat-tab {
    right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); width: auto; flex-direction: row; padding: 12px 18px;
    border-radius: 999px;
  }
  .chat-tab span { writing-mode: horizontal-tb; transform: none; }
  .home h1 { margin-top: 0; }
  .r-sec { padding: 16px 16px 18px; border-radius: 14px; }
  .r-jump { top: -18px; padding-top: 24px; margin-bottom: 12px; }
  .ing { font-size: 17px; grid-template-columns: 26px minmax(70px, max-content) 1fr; gap: 10px; }
  .step { grid-template-columns: 34px 1fr; gap: 6px 10px; }
  .step::before { font-size: 28px; }
  .step-text { font-size: 17.5px; }
  .app[data-chat="open"] { grid-template-rows: auto minmax(0, 1fr) 62%; }
}

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

/* ---------- Preferenser ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip.opt[aria-pressed="true"] { background: var(--pandan-soft); border-color: var(--pandan); color: var(--ink); }
.chip.opt[aria-pressed="true"]::before { content: "✓"; color: var(--pandan); font-weight: 800; }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.opt-grid.three { grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); }
.opt-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  border: 1.5px solid var(--line); background: var(--bg); border-radius: var(--r-md); padding: 12px 14px;
}
.opt-card strong { font-family: var(--font-display); font-size: 17px; }
.opt-card span { font-size: 14px; color: var(--muted); line-height: 1.4; }
.opt-card em { font-size: 13.5px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 8px; margin-top: 4px; }
.opt-card:hover { border-color: var(--pandan); }
.opt-card[aria-pressed="true"] { border: 2px solid var(--pandan); background: var(--pandan-soft); padding: 11.5px 13.5px; }
.opt-card[aria-pressed="true"] em { border-left-color: var(--pandan); }
.stepper { justify-self: start; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.stepper button { width: 44px; height: 40px; border: 0; background: none; font-size: 22px; font-weight: 700; color: var(--pandan); }
.stepper output { min-width: 2.2ch; text-align: center; font-weight: 800; font-size: 19px; font-variant-numeric: tabular-nums; }
details.adv summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.adv summary::-webkit-details-marker { display: none; }
details.adv summary::after { content: "+"; margin-left: auto; font-size: 24px; color: var(--muted); }
details.adv[open] summary::after { content: "–"; }
details.adv[open] summary { margin-bottom: 8px; }
.linkish { border: 0; background: none; padding: 0; color: var(--pandan); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Statusknapp ---------- */
.status-wrap { flex: none; }
.timers:empty + .status-wrap { margin-left: auto; }
.status-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px 6px 14px;
  font-size: 14.5px; font-weight: 700; color: var(--ink);
}
.status-btn:hover, .status-btn[aria-expanded="true"] { border-color: var(--pandan); }
.status-btn .short { display: none; }
.status-btn svg { width: 16px; height: 16px; color: var(--muted); }
.status-pop {
  position: fixed; top: 60px; right: calc(var(--tab-w) + 12px); z-index: 30; width: min(360px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 16px 18px;
}
.status-pop .field:last-of-type { margin-bottom: 12px; }
.status-pop .seg { display: flex; }
.status-pop .seg button { flex: 1; padding: 7px 8px; }
@media (max-width: 1100px) { .status-btn .long { display: none; } .status-btn .short { display: inline; } }
@media (max-width: 1500px) { .app[data-chat="open"] .status-btn .long { display: none; } .app[data-chat="open"] .status-btn .short { display: inline; } }
@media (max-width: 760px) { .status-pop { right: 16px; top: 56px; } .status-btn { padding: 6px 8px 6px 10px; font-size: 13.5px; min-height: 36px; } .brand svg { width: 24px; height: 24px; } .nav-btn { padding: 8px 8px; } .nav { gap: 0; } }

/* ---------- Flaggor ---------- */
.origin { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.flag { width: 22px; height: 16px; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); vertical-align: -2px; }
.sugg .origin { font-size: 15px; }
.book-row h3 .origin { margin-right: 8px; vertical-align: 1px; }

.status-line { display: block; margin-top: 4px; color: var(--ink); font-weight: 700; }

.day-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 14px; }
.day-col { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; }
.day-col h3 { font-size: 19px; margin-bottom: 10px; }
.day-col h3 .muted { font-size: 14px; font-weight: 400; font-family: var(--font-body); }
.day-col .field { margin-bottom: 10px; }
.day-col .hint { margin: 0; font-size: 14px; color: var(--muted); }
.seg.wrap { flex-wrap: wrap; border-radius: 18px; }
.status-pop .chips .chip { padding: 6px 12px; font-size: 14px; }

/* ---------- Receptvy: portioner, stäng, liggande delad vy ---------- */
.r-head { position: relative; padding-right: 48px; }
.r-close { position: absolute; top: -6px; right: -6px; }
.r-meta .r-actions { margin: 0 0 0 auto; }
.btn.small { min-height: 36px; padding: 6px 16px; font-size: 15px; }
.stepper.portions { margin-left: auto; }
.stepper.portions output { min-width: 0; padding: 0 4px; font-size: 16px; font-weight: 700; }
.stepper.portions button { width: 40px; height: 38px; }
.steps .sec-head .stepper { display: none; }
.r-split { display: block; }

.stage.split { overflow: hidden; display: flex; flex-direction: column; padding-top: 16px; padding-bottom: 14px; }
.stage.split .recipe { flex: 1; min-height: 0; display: flex; flex-direction: column; max-width: none; }
.stage.split .r-head { margin-bottom: 12px; }
.stage.split .r-head h1 { font-size: clamp(22px, 2.6vw, 32px); }
.stage.split .r-meta { margin-top: 6px; }
.stage.split .r-intro, .stage.split .r-jump, .stage.split .start-cook, .stage.split .step-hint { display: none; }
.stage.split .r-split { flex: 1; min-height: 0; display: grid; gap: 16px;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr); grid-template-areas: "steps ing"; }
.stage.split #r-steps { grid-area: steps; }
.stage.split #r-ing { grid-area: ing; }
.stage.split .r-sec { margin: 0; overflow-y: auto; overscroll-behavior: contain; padding-top: 0; }
.stage.split .sec-head { position: sticky; top: 0; z-index: 2; background: var(--surface); padding: 16px 0 10px; margin-bottom: 0; flex-wrap: nowrap; }
.stage.split .sec-head h2 { font-size: 22px; }
.stage.split .steps .sec-head .stepper { display: inline-flex; }
.stage.split .ingredients .sec-head .stepper { display: none; }
.stage.split .ing { padding: 9px 8px; font-size: 17px; }
.stage.split .step { padding: 14px 10px; }
.stage.split .step-text { font-size: 18px; }
.stage.split .extras { margin-top: 18px; }
.stage.split .notes-wrap { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.extras { margin-top: 20px; }
.notes-wrap .notes-box { margin: 0; padding: 0; border: 0; }
.notes-wrap { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }

/* Mobil i liggande läge: lite höjd – göm toppmenyn i receptet */
@media (orientation: landscape) and (max-height: 520px) {
  .app:has(.stage.split) .topbar { display: none; }
  .stage.split { padding-top: 10px; padding-bottom: 8px; }
  .stage.split .r-head { margin-bottom: 8px; }
  .stage.split .r-head h1 { font-size: 20px; }
  .stage.split .r-origin { display: none; }
  .stage.split .sec-head { padding: 10px 0 6px; }
  .stage.split .sec-head h2 { font-size: 18px; }
  .stage.split .ing { padding: 7px 6px; font-size: 16px; }
  .stage.split .step { padding: 10px 8px; grid-template-columns: 34px 1fr; }
  .stage.split .step::before { font-size: 26px; }
  .stage.split .step-text { font-size: 16.5px; }
  .chat-tab { bottom: 16px; }
}

.opt-group { margin-bottom: 12px; }
.opt-group h3 { font-family: var(--font-body); font-size: 14px; font-weight: 700; color: var(--muted); margin: 0 0 6px; }
.chip.flagchip .flag { width: 20px; height: 14px; }
.chip.opt.flagchip[aria-pressed="true"]::before { content: none; }
.chip.flagchip:not([aria-pressed="true"]) .flag { filter: grayscale(1); opacity: .55; }

/* ---------- Fortsätt matlagning ---------- */
.resume { display: flex; gap: 12px 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--kunyit-soft); border: 1.5px solid var(--kunyit); border-radius: var(--r-lg); padding: 14px 18px; margin: 0 0 22px; max-width: 860px; }
.resume strong { display: block; font-family: var(--font-display); font-size: 19px; }
.resume .muted { font-size: 14.5px; }
.nav-btn { white-space: nowrap; }
@media (max-width: 760px) { .sync { display: none; } .nav-btn { font-size: 15px; } }

/* ---------- Introduktion ---------- */
.app.onboarding .chat-tab, .app.onboarding .status-wrap, .app.onboarding .nav { display: none; }
.welcome { max-width: 720px; margin: 0 auto; }
.w-progress { display: flex; gap: 6px; margin: 4px 0 18px; }
.w-progress span { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.w-progress span.done { background: var(--pandan); opacity: .5; }
.w-progress span.on { background: var(--pandan); }
.w-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 26px 28px; }
.w-card h1 { font-size: clamp(28px, 4.4vw, 42px); font-weight: 800; margin-bottom: 12px; }
.w-card .w-lead { font-size: 19px; margin: 0 0 16px; max-width: 60ch; }
.w-card p { max-width: 62ch; }
.w-card .hint { font-size: 14.5px; color: var(--muted); }
.w-card a { color: var(--pandan); font-weight: 700; }
.w-steps, .w-tips { padding-left: 1.3em; margin: 0 0 14px; }
.w-steps li, .w-tips li { margin-bottom: 8px; }
.w-card .field input, .w-card .field textarea { min-height: 46px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); padding: 10px 12px; width: 100%; }
.w-card .field textarea { min-height: 90px; resize: vertical; }
.w-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.w-nav .btn { min-width: 140px; }
@media (max-width: 760px) { .w-card { padding: 20px 18px; } }

.r-source { color: var(--pandan); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.ask-hint { flex: 1 1 200px; font-size: 14px; color: var(--muted); min-width: 0; }
.asker-row .btn { margin-left: 0; }
@media (max-width: 520px) { .ask-hint { order: 3; flex-basis: 100%; } .asker-row .btn { margin-left: auto; } }

/* ---------- Senaste recept ---------- */
.recent-strip { margin: 22px 0 6px; max-width: 860px; }
.strip-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.strip-head h2 { font-size: 20px; margin: 0; }
.strip { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 10px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.mini-card { flex: 0 0 200px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; min-height: 96px; }
.mini-card:hover { border-color: var(--pandan); }
.mc-flag .flag { width: 22px; height: 16px; }
.mc-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mc-sub { font-size: 13px; color: var(--muted); margin-top: auto; }
.sugg-card { background: var(--pandan-soft); border-color: var(--pandan); }
.quick { margin-top: 14px; }
.book-tabs { display: flex; gap: 6px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.book-tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 700; font-size: 16px; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.book-tabs button span { font-size: 13px; background: var(--surface-2); border-radius: 999px; padding: 1px 8px; margin-left: 4px; }
.book-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--pandan); }
.saved-badge { font-size: 12px; font-weight: 700; color: var(--pandan); background: var(--pandan-soft); border-radius: 999px; padding: 2px 8px; letter-spacing: 0; }

.time-input { max-width: 140px; }
.day-col .field input[type=time] { min-height: 40px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 6px 10px; }

.msg .offer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.msg .offer span { font-size: 14px; color: var(--sambal); font-weight: 700; flex-basis: 100%; }
.msg .learned.upd ul { margin: 4px 0 0; padding-left: 1.1em; }
.msg .learned .view-link { margin: 0 0 0 6px; padding: 2px 10px; font-size: 13px; }

.sync-note { font-size: 14px; color: var(--muted); background: var(--surface-2); border-radius: var(--r-md); padding: 8px 12px; margin: 0 0 12px; }
.sync-note.err { background: transparent; border: 1.5px solid var(--sambal); color: var(--ink); }

.msg .offer.weak { margin-top: 6px; }
.msg .offer.weak .linkish { font-size: 14px; }

/* ---------- Inloggning & familj ---------- */
.login-card { text-align: left; max-width: 560px; margin: 6vh auto 0; }
.google-btn { gap: 10px; min-height: 52px; padding: 12px 24px; font-size: 17px; margin: 6px 0 14px; }
.google-btn svg { width: 22px; height: 22px; }
.fam-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 14px; margin: 8px 0 14px; }
.fam-cols .field input { min-height: 44px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); padding: 8px 12px; width: 100%; }
.fam-code { font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: .08em; background: var(--kunyit-soft); border-radius: var(--r-sm); padding: 4px 12px; }
