/* Rodina – vzhled. Velké písmo, velká tlačítka, vysoký kontrast (SPECIFIKACE 13.1). */

:root {
    --bg: #f6f4ef;
    --card: #ffffff;
    --card2: #f1eee7;
    --text: #1b1b1f;
    --muted: #55565c;
    --line: #dcd7cc;
    --primary: #2457c5;
    --primary-text: #ffffff;
    --primary-soft: #e3ebfb;
    --danger: #c0262d;
    --danger-soft: #fbe5e5;
    --warn: #b35c00;
    --warn-soft: #fff0dc;
    --ok: #2b7a33;
    --ok-soft: #e2f3e3;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 2px 8px rgba(0, 0, 0, .04);
    --radius: 14px;
    --nav-h: 72px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16171b;
        --card: #212329;
        --card2: #2a2c33;
        --text: #f1f1f3;
        --muted: #b3b5bd;
        --line: #3a3d46;
        --primary: #6d9cff;
        --primary-text: #0d1220;
        --primary-soft: #23304f;
        --danger: #ff6b6b;
        --danger-soft: #3d2324;
        --warn: #ffae4a;
        --warn-soft: #3b2e1c;
        --ok: #6fcf78;
        --ok-soft: #1f3322;
        --shadow: none;
    }
}

* { box-sizing: border-box; }
html { font-size: 19px; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .7rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ── Kostra ─────────────────────────────────────────────── */

.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.5rem; }
.boot-logo { font-size: 4rem; }

.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: .5rem;
    padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    min-height: 60px;
}
.topbar h1 { margin: 0; font-size: 1.25rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back {
    background: none; border: none; font-size: 1.6rem; line-height: 1; padding: .3rem .6rem .3rem 0; cursor: pointer;
    min-width: 48px; min-height: 48px; text-align: left;
}

main#view { padding: 1rem 1rem calc(var(--nav-h) + 2rem + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }

.bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; justify-content: space-around;
    background: var(--card);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600;
}
.bottomnav a .ico { font-size: 1.55rem; line-height: 1; }
.bottomnav a.active { color: var(--primary); }
.bottomnav a.add .ico {
    background: var(--primary); color: var(--primary-text); border-radius: 50%;
    width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; font-weight: 700;
}

/* ── Tlačítka a formuláře ───────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: 52px; padding: .6rem 1.1rem;
    border-radius: 12px; border: 2px solid transparent;
    background: var(--card2); color: var(--text);
    font-weight: 650; font-size: 1rem; cursor: pointer; text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-outline { background: transparent; border-color: var(--line); }
.btn-block { width: 100%; }
.btn-big { min-height: 64px; font-size: 1.15rem; }
.btn-small { min-height: 40px; padding: .3rem .8rem; font-size: .88rem; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; }
.actions { display: grid; gap: .7rem; margin: 1.2rem 0; }

.field { margin-bottom: 1.1rem; }
.field > label, .label { display: block; font-weight: 650; margin-bottom: .35rem; }
.field .hint { font-size: .85rem; color: var(--muted); margin-top: .3rem; }
input[type=text], input[type=email], input[type=date], input[type=time], input[type=number], input[type=search], select, textarea {
    width: 100%; min-height: 52px; padding: .55rem .8rem;
    border: 2px solid var(--line); border-radius: 12px; background: var(--card);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.inline { display: flex; gap: .5rem; align-items: center; }
.inline > * { flex: 1; min-width: 0; }
.inline > .shrink { flex: 0 0 auto; }

.check {
    display: flex; align-items: center; gap: .8rem; min-height: 56px; padding: .5rem .8rem;
    background: var(--card); border: 2px solid var(--line); border-radius: 12px; cursor: pointer; margin-bottom: .5rem;
}
.check input { width: 26px; height: 26px; accent-color: var(--primary); flex: 0 0 auto; }
.check.on { border-color: var(--primary); background: var(--primary-soft); }

.seg { display: flex; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; min-height: 50px; border: none; background: var(--card); font-weight: 650; cursor: pointer; padding: .3rem .5rem; }
.seg button.on { background: var(--primary); color: var(--primary-text); }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem; min-height: 40px; padding: .25rem .8rem;
    border-radius: 999px; border: 2px solid var(--line); background: var(--card); font-size: .9rem; font-weight: 600; cursor: pointer;
}
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.chip .x { font-weight: 800; opacity: .8; }

/* ── Karty a seznamy ────────────────────────────────────── */

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: .8rem; border: 1px solid var(--line); }
.section-title { margin: 1.5rem 0 .6rem; font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 750; }
.section-title.red { color: var(--danger); }

.item {
    display: flex; gap: .8rem; align-items: center;
    background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--line);
    border-radius: var(--radius); padding: .8rem .9rem; margin-bottom: .6rem;
    text-decoration: none; color: inherit; box-shadow: var(--shadow); min-height: 72px; cursor: pointer;
}
.item .ico { font-size: 1.8rem; line-height: 1; flex: 0 0 auto; width: 2.1rem; text-align: center; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 700; font-size: 1.05rem; }
.item .meta { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.item .when { font-weight: 700; font-size: .95rem; color: var(--primary); margin-top: 1px; }
.item .chev { color: var(--muted); font-size: 1.4rem; flex: 0 0 auto; }
.item.urg-red { border-left-color: var(--danger); }
.item.urg-red .when { color: var(--danger); }
.item.urg-orange { border-left-color: var(--warn); }
.item.urg-orange .when { color: var(--warn); }
.item.done { opacity: .7; }
.item.done .title { text-decoration: line-through; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--card2); color: var(--muted); margin-right: 4px; }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.orange { background: var(--warn-soft); color: var(--warn); }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.badge.blue { background: var(--primary-soft); color: var(--primary); }

.row-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.row { display: flex; align-items: center; gap: .7rem; padding: .75rem .9rem; border-bottom: 1px solid var(--line); min-height: 60px; text-decoration: none; color: inherit; }
.row:last-child { border-bottom: none; }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 650; }
.row .meta { color: var(--muted); font-size: .85rem; }
a.row, .row.click { cursor: pointer; }

.info { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: .5rem 0 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; font-weight: 600; }

.banner { border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: 1rem; border: 2px solid; }
.banner.warn { background: var(--warn-soft); border-color: var(--warn); }
.banner.red { background: var(--danger-soft); border-color: var(--danger); }
.banner.blue { background: var(--primary-soft); border-color: var(--primary); }
.banner .btn { margin-top: .6rem; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .big { font-size: 3rem; }

.tabs { display: flex; gap: .4rem; overflow-x: auto; margin-bottom: 1rem; padding-bottom: 2px; }
.tabs .chip { white-space: nowrap; flex: 0 0 auto; }
a.chip { text-decoration: none; color: inherit; }
a.chip.on { color: var(--primary-text); }

.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.type-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; text-align: center;
    min-height: 104px; padding: .6rem; border-radius: var(--radius); border: 2px solid var(--line); background: var(--card);
    font-weight: 650; cursor: pointer; font-size: .95rem;
}
.type-tile .ico { font-size: 2rem; }
.type-tile.on { border-color: var(--primary); background: var(--primary-soft); }

.step-num {
    display: inline-flex; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--primary); color: var(--primary-text);
    align-items: center; justify-content: center; font-size: .95rem; margin-right: .4rem;
}

.note-warning { font-size: .85rem; color: var(--warn); margin: .3rem 0; }

table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: .3rem; text-align: left; vertical-align: middle; }
table.grid input, table.grid select { min-height: 44px; padding: .3rem .5rem; }
.scroll-x { overflow-x: auto; }

/* ── Dialogy ────────────────────────────────────────────── */

.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
    background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
    border-radius: 20px 20px 0 0; padding: 1.1rem 1rem calc(1rem + env(safe-area-inset-bottom));
    animation: up .18s ease-out;
}
@media (min-width: 700px) {
    .overlay { align-items: center; }
    .sheet { border-radius: 20px; }
}
@keyframes up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet h2 { margin-bottom: 1rem; }
.sheet .search { position: sticky; top: -1.1rem; background: var(--bg); padding: .3rem 0 .6rem; z-index: 1; }

#toast {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom));
    background: var(--text); color: var(--bg); padding: .8rem 1.2rem; border-radius: 12px; font-weight: 650; z-index: 60;
    max-width: 90vw; opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); color: #fff; }

.spinner { width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Přihlášení ─────────────────────────────────────────── */

.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1.2rem; text-align: center; }
.login .logo { font-size: 4.5rem; }
.login h1 { font-size: 2rem; margin: .5rem 0; }
.login .box { width: 100%; max-width: 380px; margin-top: 1.5rem; }
#gbtn { display: flex; justify-content: center; min-height: 50px; }
