:root {
    color-scheme: light dark;
    --bg: #faf7f2;
    --surface: #ffffff;
    --ink: #1d2a24;
    --muted: #66766d;
    --line: #e8e2d8;
    --accent: #2f7d5b;
    --accent-ink: #ffffff;
    --accent-soft: #e3f1ea;
    --felt-soft: #fdeccf;
    --felt-ink: #8a5a12;
    --danger: #c0392b;
    --shadow: 0 1px 2px rgb(20 30 25 / 6%), 0 8px 24px rgb(20 30 25 / 6%);
    --radius: 18px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121715;
        --surface: #1c2420;
        --ink: #eaf1ed;
        --muted: #93a39a;
        --line: #2b3631;
        --accent: #4fb98a;
        --accent-ink: #06251a;
        --accent-soft: #1f3a2f;
        --felt-soft: #3a2e18;
        --felt-ink: #f0c785;
        --danger: #ff8a7a;
        --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
    }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 560px; margin: 0 auto; padding: 0 16px; }

.screen { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
.screen:not([hidden]) { animation: rise 0.22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen:not([hidden]) { animation: none; } }

h1 { font-size: 1.75rem; line-height: 1.15; letter-spacing: -0.02em; margin: 8px 0 18px; }
h2 { font-size: 1.1rem; margin: 0 0 6px; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; }

.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.big { width: 40px; height: 40px; }

.top { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 0 10px; }
.brandrow { display: flex; align-items: center; gap: 10px; }
.brand { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.step { color: var(--muted); font-weight: 600; font-size: 0.9rem; }

.logo { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--accent); color: var(--accent-ink); }
.logo.small { width: 34px; height: 34px; border-radius: 11px; }
.logo.small .icon { width: 20px; height: 20px; }
.logo.big { width: 84px; height: 84px; border-radius: 26px; margin: 0 auto 16px; background: var(--accent-soft); color: var(--accent); }
.logo.big .icon { width: 44px; height: 44px; }

.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; margin-right: -10px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:active { background: var(--accent-soft); }

.center { min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-bottom: 0; }
.center .brand { font-size: 2rem; margin: 18px 0 6px; }
.center p { max-width: 28ch; margin: 0 0 28px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px; border: 1px solid transparent; border-radius: 14px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: transform 0.08s ease; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.grow { flex: 1; }
.btn:disabled { opacity: 0.45; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.recording { background: var(--danger); border-color: var(--danger); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.7; } }

/* Bottom action bar, kept inside thumb reach */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.bar-inner { display: flex; gap: 10px; max-width: 560px; margin: 0 auto; }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 11; margin: 0; padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 0.9rem; box-shadow: var(--shadow); }
.toast:empty { display: none; }

.notice { min-height: 1.4em; margin: 8px 0 0; color: var(--muted); font-size: 0.92rem; }

/* Home */
.pdf-card { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.pdf-card span { flex: 1; display: grid; }
.pdf-card strong { color: var(--ink); }
.pdf-card small { color: var(--muted); }

.empty { text-align: center; padding: 56px 12px 0; }
.empty p { max-width: 30ch; margin: 0 auto; }

.day h2 { margin: 22px 4px 10px; color: var(--muted); font-size: 0.95rem; font-weight: 600; }
.day h2 b { color: var(--ink); font-weight: 700; }

.meal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.meal .photo { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--accent-soft); }
.meal .body { padding: 14px 16px 12px; }
.meal .meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.meal .time { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.meal .del { display: grid; place-items: center; width: 40px; height: 40px; margin: -6px -8px -6px 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.meal .del:active { color: var(--danger); background: var(--accent-soft); }
.meal .row { display: flex; gap: 10px; align-items: baseline; margin-top: 8px; }
.meal .row p { margin: 0; flex: 1; overflow-wrap: anywhere; white-space: pre-wrap; }
.tag { flex: none; min-width: 3.4em; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; text-align: center; }
.tag.ate { background: var(--accent-soft); color: var(--accent); }
.tag.felt { background: var(--felt-soft); color: var(--felt-ink); }

/* Wizard */
.progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 18px; }
.progress i { height: 5px; border-radius: 3px; background: var(--line); }
.progress i.on { background: var(--accent); }

.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; aspect-ratio: 4 / 3; border: 2px dashed var(--accent); border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); text-align: center; cursor: pointer; }
.tile strong { color: var(--ink); font-size: 1.1rem; }
.tile small { color: var(--muted); }
#preview { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; }
#retake { width: 100%; }

textarea { width: 100%; min-height: 150px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); font: inherit; font-size: 1.1rem; resize: vertical; margin-bottom: 12px; }
textarea::placeholder { color: var(--muted); }
textarea:focus { outline: 3px solid var(--accent); outline-offset: 0; border-color: transparent; }
.mic { width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.chip:active { background: var(--accent-soft); border-color: var(--accent); }
