:root {
  --bg: #FBF3E4;
  --card: #FFFDF8;
  --ink: #4A3426;
  --ink-soft: #8A6F5C;
  --line: #EEDFC6;
  --yolk: #F5A623;
  --yolk-deep: #E8791C;
  --terra: #C8553D;
  --green: #5E8C4A;
  --water: #BFE3EE;
  --radius: 22px;
  --shadow: 0 6px 18px rgba(120, 80, 30, .10);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 0%, #FDE9C4 0, transparent 45%);
  min-height: 100vh;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  background: rgba(251, 243, 228, .92);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.35rem; letter-spacing: .3px; }
.brand img { border-radius: 10px; }

main { max-width: 560px; margin: 0 auto; padding: 4px 16px 24px; }
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-title { font-size: 1.75rem; margin: 10px 4px 2px; }
.lead { margin: 0 4px 14px; color: var(--ink-soft); }
h2 { font-size: 1.05rem; margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.hero { display: flex; align-items: center; gap: 10px; }
.hero svg { width: 46%; max-width: 220px; flex: none; }
.result { flex: 1; text-align: center; }
.result-label { font-size: .85rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 1px; }
.result-time { font-size: 3rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--yolk-deep); }
.result-name { font-weight: 700; margin-bottom: 10px; }
.warn { background: #FBE3DC; color: var(--terra); border-radius: 12px; padding: 8px; font-size: .85rem; margin-bottom: 10px; }

.ctrl-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.pill { background: #FCEBCB; color: var(--ink); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: .9rem; white-space: nowrap; }
.scale { display: flex; justify-content: space-between; font-size: .78rem; color: var(--ink-soft); margin-top: 2px; }
.note { color: var(--ink-soft); font-size: .88rem; margin: 8px 0 0; }
.center { text-align: center; }

.seg { display: flex; gap: 6px; background: #F6EAD3; padding: 4px; border-radius: 14px; margin-bottom: 12px; }
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-weight: 700; font-size: .9rem;
  padding: 9px 4px; border-radius: 11px; cursor: pointer;
  transition: background .2s, box-shadow .2s;
}
.seg button.on { background: var(--card); box-shadow: 0 2px 6px rgba(120, 80, 30, .15); color: var(--yolk-deep); }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 32px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 10px; border-radius: 10px; background: linear-gradient(90deg, var(--yolk) var(--p, 50%), #F1E2C8 var(--p, 50%)); }
input[type=range]::-moz-range-track { height: 10px; border-radius: 10px; background: #F1E2C8; }
input[type=range]::-moz-range-progress { height: 10px; border-radius: 10px; background: var(--yolk); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -9px; border-radius: 50%;
  background: #fff; border: 3px solid var(--yolk-deep); box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 3px solid var(--yolk-deep); }

.row-ctrl { display: flex; align-items: center; gap: 12px; }
.mini { width: 26px; height: 78px; flex: none; }
.wide { width: 100%; height: auto; display: block; }

.btn {
  border: 0; font: inherit; font-weight: 800; cursor: pointer;
  background: #F6EAD3; color: var(--ink);
  padding: 12px 18px; border-radius: 14px;
}
.btn-primary { background: var(--yolk-deep); color: #fff; box-shadow: 0 4px 10px rgba(232, 121, 28, .35); }
.btn-primary:active { transform: translateY(1px); }
.btn-small { padding: 7px 12px; font-size: .85rem; border-radius: 11px; background: var(--yolk); color: #fff; }
.btn-link { border: 0; background: none; font: inherit; cursor: pointer; color: var(--ink-soft); }

.banner {
  max-width: 560px; margin: 6px auto 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 14px; width: calc(100% - 32px);
}
.banner-soft { background: #FCEBCB; color: var(--ink); }
[hidden] { display: none !important; }

.recipes { display: grid; gap: 10px; margin-top: 10px; }
.recipe { display: flex; gap: 12px; align-items: flex-start; background: #FBF4E6; border-radius: 16px; padding: 12px; }
.recipe .ico { font-size: 1.6rem; line-height: 1; }
.recipe b { display: block; margin-bottom: 2px; }
.recipe p { margin: 0; font-size: .9rem; color: var(--ink-soft); }

.acc summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after { content: "＋"; font-weight: 800; color: var(--yolk-deep); }
.acc[open] summary::after { content: "－"; }
.tips { padding-left: 20px; margin: 12px 0 0; }
.tips li { margin-bottom: 8px; }

/* Freschezza */
.hero-glass { text-align: center; }
.hero-glass svg { width: 100%; max-width: 280px; }
.verdict { border-radius: 16px; padding: 12px 14px; text-align: left; margin-top: 6px; }
.verdict b { font-size: 1.1rem; display: block; }
.verdict p { margin: 4px 0 0; font-size: .9rem; }
.v-ok { background: #E6F0DC; } .v-ok b { color: var(--green); }
.v-mid { background: #FCEBCB; } .v-mid b { color: var(--yolk-deep); }
.v-bad { background: #FBE3DC; } .v-bad b { color: var(--terra); }

.positions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.positions button {
  border: 2px solid transparent; background: #FBF4E6; border-radius: 14px; padding: 4px 2px 6px; cursor: pointer;
  font: inherit; font-size: .68rem; font-weight: 700; color: var(--ink);
}
.positions button.on { border-color: var(--yolk-deep); background: #fff; }
.positions svg { width: 100%; height: auto; display: block; }

.aircell { margin-top: 6px; }
.aircell-head { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 6px; }
.bar { height: 12px; border-radius: 12px; background: #EAF5F9; overflow: hidden; }
.bar div { height: 100%; width: 0; background: linear-gradient(90deg, #8FCBE0, #4E9DBA); border-radius: 12px; transition: width .3s; }
.pkg { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 12px; }
.pkg label { font-size: .9rem; font-weight: 700; display: block; margin-bottom: 8px; }
.pkg input { font: inherit; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink); width: 100%; }

/* Timer */
.timer { position: fixed; inset: 0; z-index: 30; background: rgba(74, 52, 38, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.timer-box { background: var(--card); border-radius: 28px; padding: 20px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.timer-box svg { width: 72%; max-width: 240px; }
.timer-left { font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--yolk-deep); }
.timer-msg { min-height: 1.4em; color: var(--ink-soft); margin-bottom: 12px; }
.timer-actions { display: flex; gap: 10px; justify-content: center; }
.timer.done .timer-left { animation: pulse .8s ease-in-out infinite; color: var(--terra); }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 8px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 248, .96); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 200px; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-weight: 700; font-size: .8rem; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; border-radius: 14px;
}
.tab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--yolk-deep); background: #FCEBCB; }

@media (max-width: 380px) {
  .result-time { font-size: 2.5rem; }
  .positions button { font-size: .6rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
