/* My Kitchen: tablet kiosk, styled after Hans's mockup.
   Target engine Chrome 103 (no :has, no container queries, no CSS nesting). */
:root {
  --bg: #f4efe3; --panel: #fbf8f1; --fill: #ece6d8; --hl: #dde8ee;
  --navy: #153F7E; --teal: #138a8a; --teal-d: #0f7474; --text: #0a1a33; --muted: #4f5d70;
  --pill: #f8a650; --pill-t: #3a2304; --over: #d64545; --wx: #dbe7f0;
  --gap: 16px;
}
html[data-theme="night"] {
  --bg: #0b1626; --panel: #12233a; --fill: #1a3050; --hl: #1d3a5c;
  --navy: #8fb4ec; --teal: #1a9a9a; --teal-d: #138a8a; --text: #e8eef7; --muted: #9fb0c8;
  --pill: #d9893a; --pill-t: #1b1003; --wx: #17304f;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 18px/1.3 system-ui, -apple-system, "Roboto", sans-serif; background: var(--bg); color: var(--text);
  overflow: hidden; -webkit-tap-highlight-color: transparent; user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, select { font: inherit; color: var(--text); background: var(--panel); border: 0; border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--teal); }
svg { width: 24px; height: 24px; flex: none; }
h1, h2, h3 { margin: 0; }
button:active { transform: scale(.97); }

/* ---------- Frame ---------- */
.app { height: 100%; display: grid; padding: 14px 18px 12px; gap: 12px var(--gap);
  grid-template-columns: 176px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top" "nav main" "bottom bottom"; }
.top { grid-area: top; min-width: 0; display: flex; align-items: center; gap: 16px; min-width: 0; }
.side { grid-area: nav; display: flex; flex-direction: column; gap: 4px; }
.view { grid-area: main; min-height: 0; }
.view[hidden], [hidden] { display: none !important; }
.bottom { grid-area: bottom; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--gap); }

/* ---------- Header ---------- */
.logo { width: 58px; height: 58px; color: var(--navy); }
.title { flex: 1; min-width: 0; }
h1 { font-size: 44px; line-height: 1; font-weight: 800; color: var(--navy); letter-spacing: -.01em; white-space: nowrap; }
.subtitle { font-size: 19px; color: var(--text); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#clock { font-weight: 700; font-variant-numeric: tabular-nums; }
.weather { flex: none; background: var(--wx); border-radius: 14px; padding: 8px 16px; display: flex; align-items: center; gap: 18px; height: 86px; white-space: nowrap; }
.wx-now { padding-right: 18px; box-shadow: 1px 0 0 rgba(10,26,51,.15); }
.wx-place { font-size: 15px; display: flex; align-items: center; gap: 3px; }
.wx-place svg { width: 16px; height: 16px; }
.wx-temp { font-size: 32px; font-weight: 500; line-height: 1.15; }
.wx-day { text-align: center; font-size: 15px; line-height: 1.25; }
.wx-day b { display: block; font-weight: 600; }
.wx-day i { font-style: normal; font-size: 22px; display: block; }
.gear { width: 52px; height: 52px; display: grid; place-items: center; color: var(--navy); }
.gear svg { width: 34px; height: 34px; }

/* ---------- Side nav ---------- */
.side button { display: flex; align-items: center; gap: 12px; padding: 14px 12px; border-radius: 12px; font-size: 18px; text-align: left; color: var(--text); }
.side button svg { width: 28px; height: 28px; color: var(--navy); }
.side button.on { background: var(--teal); color: #fff; font-weight: 600; }
.side button.on svg { color: #fff; }

/* ---------- Overview ---------- */
#v-overview { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 20px; }
.use { display: flex; flex-direction: column; min-height: 0; padding-left: 16px; box-shadow: -1px 0 0 rgba(10,26,51,.12); }
.h-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex: none; }
h2 { font-size: 34px; font-weight: 800; color: var(--navy); }
.info { width: 32px; height: 32px; font-size: 20px; color: var(--muted); }
.items { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; flex: 1; }
.items li { display: flex; align-items: center; gap: 12px; padding: 8px 4px; }
.thumb { width: 58px; height: 58px; border-radius: 14px; flex: none; background: var(--fill); display: grid; place-items: center;
  font-size: 28px; font-weight: 700; color: var(--navy); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.it-text { flex: 1; min-width: 0; }
.it-name { font-size: 23px; font-weight: 700; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.it-sub { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { background: var(--fill); color: var(--text); border-radius: 12px; padding: 9px 12px; font-size: 17px; white-space: nowrap; min-width: 108px; text-align: center; flex: none; }
.pill.soon { background: var(--pill); color: var(--pill-t); }
.pill.over { background: var(--over); color: #fff; }
.act { background: var(--teal); color: #fff; border-radius: 12px; padding: 8px 0; width: 88px; font-size: 17px; font-weight: 600; flex: none; }
.items.compact .thumb { width: 48px; height: 48px; font-size: 22px; }
.items.compact .it-name { font-size: 20px; }
.items .empty { color: var(--muted); padding: 30px 8px; }

.right { display: flex; flex-direction: column; gap: 18px; min-height: 0; }
.cal-card { background: var(--panel); border-radius: 14px; overflow: hidden; flex: none; }
.cal-head { background: var(--teal); color: #fff; display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; font-size: 18px; font-weight: 600; }
.cal-head span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-head button { width: 30px; height: 34px; display: grid; place-items: center; color: #fff; }
.cal-head svg { width: 26px; height: 26px; }
.cal-rows { list-style: none; margin: 0; padding: 0; }
.cal-rows li { display: grid; grid-template-columns: 82px 1fr; font-size: 17px; }
.cal-rows li > * { padding: 9px 12px; }
.cal-rows .d { box-shadow: 1px 0 0 rgba(10,26,51,.12); white-space: nowrap; }
.cal-rows .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-rows .t small { display: block; color: var(--muted); font-size: 14px; }
.cal-rows li.today { background: var(--hl); }
.cal-rows .none { grid-template-columns: 1fr; color: var(--muted); }

.shop-card { min-height: 0; display: flex; flex-direction: column; }
h3 { font-size: 24px; font-weight: 700; color: var(--navy); }
.shop-rows { list-style: none; margin: 6px 0 0; padding: 0; font-size: 21px; overflow-y: auto; min-height: 0; flex: 1; }
.shop-rows li { padding: 5px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foot-note { font-size: 16px; color: var(--muted); padding-top: 8px; margin-top: 4px; box-shadow: 0 -1px 0 rgba(10,26,51,.12); flex: none; }

/* ---------- Full views ---------- */
#v-shopping, #v-calendar { display: flex; flex-direction: column; padding-left: 18px; box-shadow: -1px 0 0 rgba(10,26,51,.12); }
.pill-btn { background: var(--fill); color: var(--navy); border-radius: 12px; padding: 10px 16px; font-size: 17px; font-weight: 600; white-space: nowrap; }
.pill-btn.teal { background: var(--teal); color: #fff; }
.h-row .pill-btn { margin-left: auto; }
.quick-add { display: flex; gap: 10px; margin-bottom: 10px; flex: none; }
.quick-add input:first-child { flex: 1.4; }
.quick-add input:nth-child(2) { flex: 1; }
.big-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; flex: 1; }
.big-list li { display: flex; align-items: center; gap: 14px; padding: 12px 10px; border-radius: 12px; font-size: 21px; }
.big-list li:active { background: var(--fill); }
.big-list .box { width: 30px; height: 30px; border-radius: 8px; background: var(--fill); flex: none; display: grid; place-items: center; color: #fff; font-size: 18px; }
.big-list li.done .box { background: var(--teal); }
.big-list li.done .nm { text-decoration: line-through; color: var(--muted); }
.big-list .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.big-list .tag { font-size: 15px; color: var(--muted); white-space: nowrap; }
.big-list .day { font-size: 15px; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: .04em; padding: 14px 10px 2px; }
.big-list .when { width: 110px; flex: none; color: var(--muted); font-size: 17px; }

/* ---------- Bottom ---------- */
.big { background: var(--teal); color: #fff; border-radius: 14px; height: 58px; font-size: 21px; font-weight: 600; letter-spacing: .01em;
  display: flex; align-items: center; justify-content: center; gap: 16px; }
.big svg { width: 24px; height: 24px; }
.reminder { display: flex; align-items: center; gap: 10px; font-size: 19px; white-space: nowrap; }
.reminder svg { color: var(--muted); }

/* ---------- Dialogs ---------- */
.sheet { position: fixed; inset: 0; background: rgba(10,26,51,.28); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.sheet[hidden] { display: none; }
.dialog { background: var(--bg); border-radius: 18px; padding: 18px 22px 16px; width: 440px; max-width: 100%; max-height: 100%; overflow-y: auto;
  box-shadow: 0 18px 50px rgba(10,26,51,.25); }
.dialog.narrow { width: 500px; }
.d-head { display: flex; align-items: center; margin-bottom: 12px; }
.d-head h3 { flex: 1; font-size: 30px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.x { width: 40px; height: 40px; display: grid; place-items: center; color: var(--text); }
.f-row { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 20px; }
.f-row input, .f-row select { font-size: 20px; }
.scan-row { display: flex; gap: 10px; margin-bottom: 12px; }
.scan-row input { font-size: 20px; letter-spacing: .03em; }
#camVideo { width: 100%; max-height: 220px; border-radius: 12px; background: #000; object-fit: cover; margin-bottom: 10px; }
.save { width: 100%; background: var(--teal); color: #fff; border-radius: 12px; height: 56px; font-size: 26px; font-weight: 600; margin-top: 6px; }
.hint { text-align: center; font-size: 16px; padding-top: 10px; min-height: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: flex; background: var(--panel); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; padding: 8px; border-radius: 8px; font-size: 17px; }
.seg button.on { background: var(--teal); color: #fff; font-weight: 600; }
.menu-links { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.menu-links button { text-align: left; padding: 12px 14px; border-radius: 10px; background: var(--panel); font-size: 19px; }
.page { line-height: 1.5; font-size: 18px; user-select: text; }
.page h4 { margin: 14px 0 4px; color: var(--navy); }

.popover { position: fixed; z-index: 30; max-width: 320px; background: var(--text); color: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 16px; }
.toast { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 22px; border-radius: 12px; z-index: 40; max-width: 80%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 18px; }

/* ---------- Portrait (768 x 1024) ---------- */
@media (orientation: portrait) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: "top" "nav" "main" "bottom"; padding: 12px 14px 10px; gap: 10px; }
  .logo { width: 44px; height: 44px; }
  h1 { font-size: 34px; }
  .subtitle { font-size: 16px; }
  .weather { height: 74px; padding: 6px 12px; gap: 12px; }
  .wx-now { padding-right: 12px; }
  .wx-temp { font-size: 26px; }
  .wx-day:nth-child(n+4) { display: none; }
  .side { flex-direction: row; gap: 4px; }
  .side button { flex: 1; justify-content: center; gap: 8px; padding: 10px 6px; font-size: 17px; }
  .side button svg { width: 24px; height: 24px; }
  .side button[data-act] { display: none; }
  #v-overview { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 14px 18px; }
  .use { grid-column: 1 / span 2; padding-left: 0; box-shadow: none; }
  .right { display: contents; }
  .cal-card { align-self: start; }
  #v-shopping, #v-calendar { padding-left: 0; box-shadow: none; }
  h2 { font-size: 28px; }
  .bottom { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .reminder { grid-column: 1 / span 2; grid-row: 2; justify-content: center; font-size: 16px; }
  .big { height: 54px; font-size: 19px; }
}

html, body { overflow: hidden; max-width: 100vw; }

/* Slide-in panels (Add shopping, Use / finish) */
.sheet.slide { justify-content: flex-end; align-items: stretch; padding: 0; background: rgba(10,26,51,0); transition: background .25s; }
.sheet.slide.open { background: rgba(10,26,51,.28); }
.sheet.slide .dialog { width: 470px; max-height: none; height: 100%; border-radius: 22px 0 0 22px; padding: 22px 24px;
  transform: translateX(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
.sheet.slide.open .dialog { transform: translateX(0); }
.sheet.slide .items { max-height: none; }
@media (orientation: portrait) {
  .sheet.slide { align-items: flex-end; }
  .sheet.slide .dialog { width: 100%; height: auto; max-height: 82%; border-radius: 22px 22px 0 0; transform: translateY(100%); }
  .sheet.slide.open .dialog { transform: translateY(0); }
}

/* Say items */
.shop-head { display: flex; align-items: center; justify-content: space-between; }
.mic-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; }
.mic-btn svg { width: 24px; height: 24px; }
.mic-big { width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; background: var(--teal); color: #fff; border-radius: 14px; height: 74px; font-size: 22px; font-weight: 600; margin-bottom: 12px; }
.mic-big svg { width: 32px; height: 32px; }
.mic-big.live { background: var(--over); }
#sayText { font: inherit; font-size: 21px; color: var(--text); background: var(--panel); border: 0; border-radius: 12px; padding: 12px; width: 100%; resize: none; }
#sayText:focus { outline: 2px solid var(--teal); }
.chips { list-style: none; margin: 10px 0 4px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; min-height: 44px; }
.chips li { background: var(--panel); border-radius: 20px; padding: 8px 14px; font-size: 19px; }
.chips li b { color: var(--teal); margin-right: 4px; }
@media (orientation: portrait) { .side button.say-nav { display: flex; } }

/* UI size (Settings) is set through the viewport meta tag in app.js (CSS zoom broke taps on old WebView). */

#sizeSeg button { font-size: 15px; padding: 8px 2px; }
.dialog .f-row { grid-template-columns: 130px minmax(0, 1fr); }

/* Radio */
.mid { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.now-playing { display: flex; align-items: center; gap: 8px; background: var(--panel); color: var(--teal); border-radius: 20px; padding: 6px 12px; font-size: 16px; font-weight: 600; max-width: 280px; }
.now-playing span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-playing svg { width: 18px; height: 18px; }
.stations { list-style: none; margin: 0 0 14px; padding: 0; }
.stations li { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; margin-bottom: 6px; background: var(--panel); }
.stations li.on { background: var(--teal); color: #fff; }
.stations li.on .genre { color: rgba(255,255,255,.85); }
.stations .st-name { flex: 1; min-width: 0; font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stations .genre { font-size: 15px; color: var(--muted); white-space: nowrap; }
.stations svg { width: 22px; height: 22px; }
#vol { padding: 0; background: none; accent-color: var(--teal); height: 36px; }
@media (orientation: portrait) { .mid { grid-column: 1 / span 2; grid-row: 2; flex-direction: row; justify-content: center; gap: 16px; } .reminder { grid-column: auto; grid-row: auto; } }

/* Radio: player, sections, visualizer */
.st-head { font-size: 15px; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: .05em; margin: 10px 2px 8px; }
.st-head .muted { color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 500; }
.stations .st-text { flex: 1; min-width: 0; }
.stations .st-text .st-name { display: block; }
.stations .ep { display: block; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stations li.on .ep { color: rgba(255,255,255,.85); }
.player { background: var(--panel); border-radius: 14px; padding: 14px; margin-bottom: 8px; }
.pl-name { font-size: 20px; font-weight: 700; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-ep { font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 20px; }
.pl-seek { display: flex; align-items: center; gap: 8px; font-size: 14px; font-variant-numeric: tabular-nums; margin-top: 6px; }
.pl-seek input { flex: 1; padding: 0; background: none; accent-color: var(--teal); }
.pl-btns { display: flex; gap: 10px; justify-content: center; margin: 10px 0; }
.pl-btns .pill-btn { min-width: 90px; }
.viz { display: inline-flex; align-items: flex-end; gap: 3px; height: 18px; }
.viz i { width: 4px; height: 20%; background: currentColor; border-radius: 2px; }
.big-viz { height: 30px; margin-right: 12px; color: var(--teal); visibility: hidden; }
.big-viz i { width: 5px; }
body.playing .viz i { animation: eq 1s ease-in-out infinite; }
body.playing .big-viz { visibility: visible; }
body.paused .viz i { animation-play-state: paused; }
.viz i:nth-child(1) { animation-delay: -.2s !important; animation-duration: .9s !important; }
.viz i:nth-child(2) { animation-delay: -.5s !important; animation-duration: 1.1s !important; }
.viz i:nth-child(3) { animation-delay: -.1s !important; animation-duration: .8s !important; }
.viz i:nth-child(4) { animation-delay: -.7s !important; animation-duration: 1.2s !important; }
.viz i:nth-child(5) { animation-delay: -.35s !important; animation-duration: .95s !important; }
.viz i:nth-child(6) { animation-delay: -.6s !important; animation-duration: 1.05s !important; }
.viz i:nth-child(7) { animation-delay: -.15s !important; animation-duration: .85s !important; }
@keyframes eq { 0%, 100% { height: 20%; } 25% { height: 95%; } 50% { height: 45%; } 75% { height: 75%; } }

/* With real levels the bars follow the sound instead of the animation */
body.realviz.playing .viz i { animation: none; transition: height .08s linear; }
