:root {
  --bg: #f4f2ec; --card: #ffffff; --ink: #1c1c1e; --muted: #6b6860; --line: #e2ded4;
  --accent: #b22c24; --accent-ink: #fff;
  --c-black: #1c1c1e; --c-red: #b22c24; --c-blue: #28469a; --c-green: #347640; --c-yellow: #e2c426;
  --c-orange: #e0822e; --c-pink: #e59aa6; --c-purple: #7a4a9c; --c-brown: #7a4a2e; --c-lightblue: #8fb3e3; --c-lightgreen: #9ccf96; --c-gray: #9a978f;
  --radius: 14px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0b0b0b; --card: #1a1a19; --ink: #eeebe3; --muted: #9c988d; --line: #2e2d2a; --c-black: #d8d4ca; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #000000; --card: #161615; --ink: #eeebe3; --muted: #9c988d; --line: #2c2b28; --c-black: #d8d4ca; color-scheme: dark; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(96px + var(--safe-b)); overscroll-behavior-y: none; }
/* Päist ei kinnitata: kerides ei jää midagi ekraani ülaossa ette. Ainult telefoni
   staatusriba / sälgu alune ala kaetakse taustaga, et sisu selle all ei paistaks. */
body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top, 0px); background: var(--bg); z-index: 10; pointer-events: none; }
body.has-fab { padding-bottom: calc(160px + var(--safe-b)); }
#app { max-width: 720px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }
h1 { font-size: 28px; margin: 4px 0 12px; letter-spacing: -0.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 24px 4px 8px; font-weight: 600; }
.card { background: var(--card); border-radius: var(--radius); padding: 4px 0; margin-bottom: 12px; box-shadow: 0 1px 0 var(--line); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 48px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow-wrap: anywhere; }
.row .sub { font-size: 13px; color: var(--muted); }
.row.off { opacity: 0.45; }
.row.done .title { text-decoration: line-through; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--c-blue); }
.bar { width: 4px; align-self: stretch; border-radius: 2px; flex: none; }
button, .btn { font: inherit; border: 0; border-radius: 10px; padding: 10px 16px; background: var(--line); color: var(--ink); cursor: pointer; font-weight: 500; }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.ghost { background: transparent; color: var(--accent); padding: 8px 10px; }
button.danger { background: transparent; color: var(--c-red); }
button:disabled { opacity: 0.5; }
button.icon { padding: 6px 10px; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; }
input[type=checkbox] { width: auto; }
label.field { display: block; padding: 8px 16px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.check { width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--muted); flex: none; display: grid; place-items: center; background: transparent; padding: 0; }
.check.on { background: var(--c-green); border-color: var(--c-green); }
.check.on::after { content: ""; width: 10px; height: 6px; border: solid #fff; border-width: 0 0 3px 3px; transform: rotate(-45deg) translate(1px, -1px); }
/* lüliti */
.sw { position: relative; width: 50px; height: 30px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; position: absolute; }
.sw i { position: absolute; inset: 0; border-radius: 30px; background: var(--line); transition: .2s; }
.sw i::before { content: ""; position: absolute; width: 26px; height: 26px; left: 2px; top: 2px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: .2s; }
.sw input:checked + i { background: var(--c-green); }
.sw input:checked + i::before { transform: translateX(20px); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
.chip { padding: 7px 14px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); font-size: 14px; cursor: pointer; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--line); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button { background: transparent; padding: 8px 0; border-radius: 8px; font-size: 15px; }
.seg button.on { background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.preview { width: 100%; border-radius: 10px; display: block; background: #ece9de; aspect-ratio: 4/3; object-fit: contain; }
.status { font-size: 13px; color: var(--muted); padding: 8px 16px 12px; }
.status b { color: var(--ink); font-weight: 600; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--line); color: var(--muted); }
.pill.warn { background: #f7e0dd; color: var(--c-red); }
.pill.ok { background: #dcefdf; color: var(--c-green); }
.day h3 { margin: 18px 4px 6px; font-size: 16px; display: flex; gap: 8px; align-items: baseline; }
.day h3 small { color: var(--muted); font-weight: 400; }
.day.today h3 { color: var(--accent); }
.empty { padding: 16px; color: var(--muted); text-align: center; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); padding: 4px 16px 12px; }
.hint code { font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches label { position: relative; }
.swatches input { position: absolute; opacity: 0; }
.swatches span { display: block; width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; outline: 1px solid var(--line); }
.swatches input:checked + span { border-color: var(--card); outline: 2px solid var(--ink); }
.fab { position: fixed; right: max(16px, calc(50vw - 344px)); bottom: calc(80px + var(--safe-b)); z-index: 4; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 30px; line-height: 1; box-shadow: 0 4px 14px rgba(0,0,0,.25); padding: 0; }
nav#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 5; }
nav#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500; }
nav#tabs a.on { color: var(--accent); }
nav#tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 20px; font-size: 14px; z-index: 20; max-width: calc(100vw - 32px); }
dialog#sheet { border: 0; border-radius: 18px 18px 0 0; padding: 0; width: 100%; max-width: 720px; margin: auto auto 0; background: var(--card); color: var(--ink); max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 12px); overflow-y: auto; overscroll-behavior: contain; }
#sheetForm header { position: sticky; top: 0; background: var(--card); z-index: 1; }
dialog#sheet::backdrop { background: rgba(0,0,0,.35); }
#sheetForm { padding: 8px 0 calc(16px + var(--safe-b)); }
#sheetForm header { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; }
#sheetForm header b { font-size: 18px; }
.login { max-width: 360px; margin: 18vh auto 0; }
.login h1 { text-align: center; }
.big-img-wrap { position: fixed; inset: 0; background: #000d; z-index: 30; display: grid; place-items: center; overflow: auto; }
.big-img-wrap img { width: 1600px; max-width: none; }
@media (min-width: 700px) { .big-img-wrap img { width: 100%; max-width: 1600px; } }

/* ---------- päevakava ---------- */
.chips.filter { position: relative; margin: 0 0 4px; }
.pchip { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; margin-right: 6px; vertical-align: 1px; }
.ag-day { margin-bottom: 8px; }
.ag-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 14px 4px 8px; }
.ag-dname { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.ag-date { font-size: 13px; color: var(--muted); }
.ag-day.today .ag-dname { font-size: 30px; color: var(--accent); }
.ag-day.today .ag-head { padding-top: 4px; }
.ag-day.empty-day .ag-head { padding-bottom: 2px; }
.ag-free { padding: 0 4px 6px; color: var(--muted); font-size: 14px; }
.wx { display: flex; align-items: baseline; gap: 6px; font-size: 15px; white-space: nowrap; }
.wx .wx-ico { font-size: 20px; align-self: center; }
.wx .wx-min { color: var(--muted); }
.wx .wx-rain { font-size: 12px; color: var(--c-blue); }
.wx.big { font-size: 22px; }
.wx.big .wx-ico { font-size: 34px; }
.wx.big .wx-rain { font-size: 14px; }
.ag-card { padding: 6px 0; overflow: hidden; }
.ag-allday { margin: 6px 12px; padding: 8px 12px; border-radius: 10px; background: var(--ic); color: #fff; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; overflow-wrap: anywhere; }
.ag-allday small { font-weight: 400; opacity: .85; white-space: nowrap; }
.ag-item { display: grid; grid-template-columns: 50px 4px 1fr; gap: 0 12px; align-items: stretch; padding: 9px 14px 9px 12px; }
.ag-item + .ag-item { border-top: 1px solid var(--line); }
.ag-item.lesson { background: color-mix(in srgb, var(--ic) 11%, var(--card)); }
.ag-item.past { opacity: .45; }
.ag-item.now { box-shadow: inset 3px 0 0 var(--accent); }
.ag-time { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; line-height: 1.25; }
.ag-time b { font-size: 16px; }
.ag-time span { font-size: 13px; color: var(--muted); }
.ag-bar { border-radius: 2px; background: var(--ic); }
.ag-body { min-width: 0; }
.ag-title { font-weight: 500; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; hyphens: auto; }
.ag-sub { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.ag-sub .pill { margin-right: 6px; }
.ag-item.task { grid-template-columns: 50px 26px 1fr; align-items: center; }
.ag-item.task.done .ag-title { text-decoration: line-through; color: var(--muted); }
.ag-sep { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 14px 2px; border-top: 1px solid var(--line); }
details.fridge { margin-top: 20px; }
details.fridge summary { padding: 14px 16px; font-weight: 600; cursor: pointer; list-style: none; }
details.fridge summary::-webkit-details-marker { display: none; }
details.fridge summary .sub { font-weight: 400; color: var(--muted); font-size: 14px; }
.swatches span.none { display: grid; place-items: center; background: var(--bg); color: var(--muted); font-size: 16px; }
.cdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: 0; }

/* ---------- pildirežiim ---------- */
.photo-bar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.photo-bar img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; flex: none; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-tile { position: relative; aspect-ratio: 4/3; border-radius: 10px; overflow: hidden; border: 3px solid transparent; background: var(--bg); cursor: pointer; display: grid; place-items: center; }
.photo-tile.on { border-color: var(--accent); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile.add { border: 2px dashed var(--line); color: var(--muted); text-align: center; font-size: 13px; line-height: 1.3; }
.photo-tile.add span { font-size: 13px; }
.photo-tile .del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; padding: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 16px; line-height: 1; }
input[type=range] { padding: 0; }
