* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green: #15803d;
    --green-2: #22c55e;
    --green-dark: #166534;
    --bg: #f5f7f3;
    --card: #ffffff;
    --ink: #1e2a23;
    --muted: #6b7c72;
    --line: #e6ebe4;
    --amber: #d97706;
    --amber-bg: #fef3e2;
    --danger: #dc2626;
    --radius: 14px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { font-size: 155%; } /* +55% για ευανάγνωστο κείμενο (πρεσβυωπία) */
html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}

/* ==================== APP SHELL ==================== */

.app { height: 100%; display: flex; flex-direction: column; }

.header {
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
    color: #fff;
    padding: calc(14px + var(--safe-top)) 18px 16px;
}
.header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: .3px; }
.header-sub { font-size: .9rem; color: rgba(255,255,255,.82); margin-top: 3px; }

.main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 14px calc(16px + var(--safe-bottom));
}

.view { display: none; }
.view.active { display: block; animation: fade .2s; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ==================== NAV ==================== */

.nav {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--card);
    border-top: 1px solid var(--line);
    padding-bottom: var(--safe-bottom);
}
.nav-item {
    border: none;
    background: none;
    padding: 9px 0 7px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: .68rem;
    color: var(--muted);
    cursor: pointer;
    transition: color .15s;
}
.nav-item .nav-ic { font-size: 1.35rem; line-height: 1; filter: grayscale(.4); transition: filter .15s; }
.nav-item.active { color: var(--green); font-weight: 700; }
.nav-item.active .nav-ic { filter: none; }

/* ==================== CARDS / GENERIC ==================== */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 12px;
}

.section-title {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted);
    margin: 18px 4px 8px;
}
.section-title:first-child { margin-top: 0; }

.empty { color: var(--muted); text-align: center; padding: 40px 20px; }

/* ==================== TODAY ==================== */

.today-day {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--green-dark);
}
.today-note {
    font-size: .88rem;
    color: var(--muted);
    margin-top: 6px;
}

/* Βελάκια αλλαγής μέρας */
.day-nav { display: flex; align-items: center; gap: 8px; }
.dn-btn {
    flex-shrink: 0;
    width: 2.4rem; height: 2.4rem;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--green);
    font-size: 1.5rem; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    padding: 0 0 .15rem;
    cursor: pointer;
}
.dn-btn:disabled { opacity: .25; cursor: default; }
.dn-title { flex: 1; min-width: 0; text-align: center; font-size: 1.15rem; font-weight: 700; color: var(--green-dark); }
.dn-title small { display: block; font-size: .78rem; font-weight: 400; color: var(--muted); margin-top: 2px; }
.dn-today { color: var(--green); font-size: .78rem; padding: 0; }

.meal {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.meal:last-child { border-bottom: none; }
.meal-time {
    flex-shrink: 0;
    width: 3.25rem;
    font-weight: 700;
    color: var(--green);
    font-size: .9rem;
}
.meal-body { flex: 1; min-width: 0; }
.meal-title { font-weight: 600; margin-bottom: 3px; }
.meal-sub { font-size: .82rem; color: var(--muted); font-style: italic; margin-bottom: 4px; }
.meal-detail { font-size: .88rem; color: var(--muted); line-height: 1.5; }
.meal-detail strong { color: var(--ink); font-weight: 600; }

/* Βιβλιοθήκη μέσα στην ημέρα: εναλλακτικές σνακ, λίστα 23:00 */
.lib-fold { margin-top: 6px; font-size: .85rem; }
.lib-fold summary { color: var(--green); font-weight: 600; cursor: pointer; list-style: none; }
.lib-fold summary::-webkit-details-marker { display: none; }
.lib-fold summary::before { content: '▸ '; }
.lib-fold[open] summary::before { content: '▾ '; }
.lib-list { margin: 6px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.5; }
.lib-list li { margin: 3px 0; }
.lib-list strong { color: var(--ink); font-weight: 600; }
.lib-list em { color: var(--muted); }

.freeze-banner {
    background: var(--amber-bg);
    border: 1px solid #f5d9a8;
    border-radius: var(--radius);
    padding: 13px 15px;
    margin-bottom: 14px;
    display: flex;
    gap: 11px;
    align-items: flex-start;
}
.freeze-banner .fb-ic { font-size: 1.3rem; line-height: 1.2; }
.freeze-banner .fb-title { font-weight: 700; color: var(--amber); font-size: .82rem; text-transform: uppercase; letter-spacing: .4px; }
.freeze-banner ul { margin: 5px 0 0; padding-left: 18px; }
.freeze-banner li { font-size: .92rem; line-height: 1.5; }

/* ==================== SHOPPING ==================== */

.shop-group { margin-bottom: 12px; }
.shop-head {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 13px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-align: left;
}
.shop-head.open { border-radius: var(--radius) var(--radius) 0 0; border-bottom: none; }
.shop-head .sh-ic { font-size: 1.25rem; }
.shop-head .sh-title { flex: 1; font-weight: 700; }
.shop-head .sh-title small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; margin-top: 1px; }
.shop-head .sh-count {
    font-size: .78rem;
    font-weight: 700;
    color: var(--green);
    background: #e7f6ec;
    border-radius: 20px;
    padding: 3px 9px;
}
.shop-head .sh-count.done { color: #fff; background: var(--green-2); }
.shop-head .sh-chev { color: var(--muted); transition: transform .2s; }
.shop-head.open .sh-chev { transform: rotate(180deg); }

.shop-body {
    background: var(--card);
    border: 1px solid var(--line);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
    display: none;
}
.shop-body.open { display: block; }

.shop-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 11px 15px;
    border-top: 1px solid var(--line);
    cursor: pointer;
}
.shop-check {
    flex-shrink: 0;
    width: 22px; height: 22px;
    margin-top: 1px;
    border: 2px solid #c7d2cb;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .8rem;
    transition: background .12s, border-color .12s;
}
.shop-item.checked .shop-check { background: var(--green-2); border-color: var(--green-2); }
.shop-item.checked .si-name { text-decoration: line-through; color: var(--muted); }
.si-main { flex: 1; min-width: 0; }
.si-name { font-weight: 600; }
.si-name .si-qty { color: var(--green); font-weight: 700; margin-left: 6px; }
.si-for { font-size: .8rem; color: var(--muted); margin-top: 2px; line-height: 1.4; }

.shop-tools { padding: 10px 15px; border-top: 1px solid var(--line); text-align: right; }
.link-btn {
    background: none; border: none;
    color: var(--danger);
    font-size: .82rem; font-weight: 600;
    cursor: pointer;
}

/* ==================== FREEZE TABLE ==================== */

.freeze-row {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.freeze-row:last-child { border-bottom: none; }
.freeze-row.today {
    background: var(--amber-bg);
    margin: 0 -16px;
    padding: 12px 16px;
    border-bottom: 1px solid #f5d9a8;
}
.fr-when { flex-shrink: 0; width: 6rem; font-weight: 700; font-size: .84rem; color: var(--green-dark); }
.freeze-row.today .fr-when { color: var(--amber); }
.fr-what { flex: 1; }
.fr-what .fr-item { font-weight: 600; font-size: .92rem; }
.fr-what .fr-for { font-size: .8rem; color: var(--muted); margin-top: 1px; }

/* ==================== PLAN (markdown) ==================== */

.md { line-height: 1.6; font-size: .95rem; }
.md h1 { font-size: 1.4rem; margin: 4px 0 10px; color: var(--green-dark); }
.md h2 {
    font-size: 1.12rem; margin: 22px 0 8px;
    padding-bottom: 5px; border-bottom: 2px solid var(--line);
    color: var(--green-dark);
}
.md h3 { font-size: 1rem; margin: 16px 0 6px; color: var(--ink); }
.md p { margin: 8px 0; }
.md ul { margin: 8px 0; padding-left: 20px; }
.md li { margin: 4px 0; }
.md strong { font-weight: 700; }
.md em { color: var(--muted); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
.md blockquote {
    background: var(--amber-bg);
    border-left: 4px solid var(--amber);
    border-radius: 8px;
    padding: 10px 14px;
    margin: 12px 0;
    font-size: .9rem;
}
.md table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: .86rem;
}
.md th, .md td {
    border: 1px solid var(--line);
    padding: 7px 9px;
    text-align: left;
    vertical-align: top;
}
.md th { background: #eef4ec; font-weight: 700; }
.md code {
    background: #eef2ee;
    padding: 1px 5px;
    border-radius: 5px;
    font-size: .85em;
    font-family: ui-monospace, monospace;
}

/* ==================== DESKTOP / WEB ==================== */
/* Στο κινητό το 155% (μεγάλα γράμματα, στενό) είναι σωστό. Σε μεγάλη οθόνη
   το θέλουμε τυπική σελίδα: κανονικά γράμματα, φαρδύ κεντραρισμένο περιεχόμενο. */
@media (min-width: 700px) {
    html { font-size: 112%; }
    .main { max-width: 840px; width: 100%; margin: 0 auto; }
}

/* ==================== PLAN: επιλογή τρέχον / παλιά πλάνα ==================== */

.plan-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: .85rem;
    font-family: inherit;
    cursor: pointer;
}
.chip.active { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
