/* Úkoly – vzhled. Jedno písmo pro nadpisy (Bricolage Grotesque), systémové pro text. */
@font-face {
  font-family: 'Bricolage';
  src: url('/fonts/bricolage-grotesque-latin-ext-wght-normal.woff2') format('woff2');
  font-weight: 200 800; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Bricolage';
  src: url('/fonts/bricolage-grotesque-latin-wght-normal.woff2') format('woff2');
  font-weight: 200 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #EEF1EE;
  --surface: #FFFFFF;
  --ink: #13201B;
  --muted: #55635D;
  --line: #D6DDD8;
  --accent: #1E6B52;
  --accent-ink: #FFFFFF;
  --accent-soft: #DDEBE4;
  --amber: #E0A21A;
  --amber-soft: #FBEFCF;
  --danger: #B4372B;
  --display: 'Bricolage', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --tabs-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --kb: 0px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1714;
    --surface: #18231F;
    --ink: #E8EEEA;
    --muted: #98A8A0;
    --line: #2A3A34;
    --accent: #6ACBA5;
    --accent-ink: #0C1512;
    --accent-soft: #1D332B;
    --amber: #F2B632;
    --amber-soft: #3A2F12;
    --danger: #F1867A;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.4 var(--text); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, p { margin: 0; }

/* ---------- rozvržení ---------- */
#view {
  max-width: 600px; margin: 0 auto; outline: none;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 18px calc(var(--tabs-h) + var(--safe-b) + 96px);
}
.no-capture #view { padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 28px); }

.head { margin: 6px 2px 22px; }
.head h1 { font: 650 31px/1.08 var(--display); letter-spacing: -0.02em; }
.head .sub { color: var(--muted); margin-top: 6px; font-size: 16px; }

.head-link { margin-top: 6px; }
.panel > .demo-note { margin: 0 0 14px; }
.panel > .sub { color: var(--muted); font-size: 15.5px; margin: -4px 0 16px; }
.panel .group { margin-bottom: 16px; }

.group { margin: 0 0 22px; }
.group > h2, .group > summary {
  font: 620 15px/1.2 var(--display); color: var(--muted);
  margin: 0 2px 2px; padding: 6px 0;
}
.group.is-late > h2 { color: var(--danger); }
.group h2 .tag { font: 500 13px var(--text); color: var(--accent); margin-left: 6px; }
.group > summary { cursor: pointer; list-style: none; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after { content: ' zobrazit'; font: 400 13px var(--text); color: var(--accent); }
.group[open] > summary::after { content: ' skrýt'; }
.quiet { color: var(--muted); font-size: 15.5px; padding: 6px 2px; }

/* Dnešek je jediný blok na vlastní ploše – to hlavní na obrazovce. */
.group.today { background: var(--surface); border-radius: 20px; padding: 12px 14px 8px; margin-left: -4px; margin-right: -4px; }
.group.today > h2 { color: var(--ink); font-size: 17px; padding-top: 2px; }
.group.today .quiet { padding-bottom: 10px; }

/* ---------- řádky ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: start; border-top: 1px solid var(--line); }
.rows > .row:first-child { border-top: 0; }
.row-main { display: block; width: 100%; padding: 11px 2px 11px 4px; min-height: 46px; }
.row-title { display: block; font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.row-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 3px; font-size: 13.5px; color: var(--muted); }
.row-meta > span { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta .time { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.row-meta .late { color: var(--danger); font-weight: 600; }
.row-meta .from-mail { display: inline-flex; align-items: center; gap: 4px; }
.row-meta .from-mail svg { width: 14px; height: 14px; flex: none; stroke-width: 1.8; }

.check { width: 44px; height: 46px; display: grid; place-items: center; }
.check::before {
  content: ''; width: 23px; height: 23px; border-radius: 50%;
  border: 1.8px solid var(--muted); transition: background-color .15s, border-color .15s;
}
.check[aria-pressed='true']::before {
  background: var(--accent) center / 14px no-repeat; border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3 7.4l2.7 2.7L11 4.4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.is-done .row-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.flag { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--amber); margin-right: 8px; transform: rotate(45deg) translateY(-1px); }
.is-important .check::before { border-color: var(--amber); border-width: 2.2px; }
.is-important .check[aria-pressed='true']::before { border-color: var(--accent); }

.row.event .ev-time {
  padding: 13px 0 0; font-size: 12.5px; line-height: 1.25; color: var(--accent); font-weight: 650;
  font-variant-numeric: tabular-nums; text-align: center;
}
.row.event .row-title { font-size: 16px; }
.row.event .row-main { border-left: 3px solid var(--accent-soft); padding-left: 10px; margin: 6px 0; min-height: 0; padding-top: 5px; padding-bottom: 5px; }

.row.note { grid-template-columns: minmax(0, 1fr); }
.row.note .row-title { font-weight: 600; }
.note-body { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); font-size: 15px; margin-top: 2px; white-space: pre-line; }

.hint { background: var(--amber-soft); border-radius: 14px; padding: 12px 14px; margin: 0 -4px 20px; font-size: 15px; }
.hint .link { margin-top: 6px; }

/* ---------- tlačítka a pole ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 18px;
  border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 16px;
}
.btn.quiet { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: none; color: var(--danger); padding: 0 8px; }
.btn:disabled { opacity: .6; }
.link { color: var(--accent); font-size: 15px; font-weight: 600; min-height: 32px; text-decoration: none; display: inline-flex; align-items: center; }
.error { color: var(--danger); }

.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: 13.5px; color: var(--muted); margin: 0 0 4px 2px; }
.field input:not([type='checkbox']), .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; font-size: 17px; line-height: 1.35;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; -webkit-appearance: none; appearance: none;
}
.field textarea { resize: none; display: block; }
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.check-field { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check-field > span { margin: 0; font-size: 17px; color: var(--ink); }
.check-field input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

/* ---------- nastavení ---------- */
.set { background: var(--surface); border-radius: 18px; padding: 14px 16px 6px; margin-left: -4px; margin-right: -4px; }
.set > h2 { color: var(--ink); font-size: 17px; padding: 0 0 8px; margin: 0; }
.set > p { font-size: 15.5px; margin: 0 0 12px; }
.set h3 { font: 620 14px var(--display); color: var(--muted); margin: 6px 0 4px; }
.maillog { list-style: none; margin: 0 0 8px; padding: 0; font-size: 14.5px; }
.maillog li { display: flex; gap: 10px; justify-content: space-between; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); }
.ml-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.ml-main strong { color: var(--ink); font-weight: 600; }
.ml-res { flex: none; color: var(--muted); font-size: 13.5px; }
.ml-res.has { color: var(--accent); font-weight: 600; }
.ml-res.error { color: var(--danger); }
.ml-act { min-height: 28px; font-size: 13.5px; margin-left: 6px; }

/* ---------- lišta pro zápis ---------- */
#capture {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + var(--safe-b)); z-index: 20;
  padding: 8px 12px 10px; background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.kb-open #capture { bottom: var(--kb); }
.kb-open #tabs { display: none; }
.capture-row {
  max-width: 600px; margin: 0 auto; display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1.5px solid var(--accent); border-radius: 16px; padding: 5px;
}
.capture-row input { flex: 1; min-width: 0; height: 44px; border: 0; background: none; outline: none; font-size: 17px; padding: 0 4px; }
.capture-row input::placeholder { color: var(--muted); opacity: 1; font-size: 15.5px; }
.kind { display: flex; background: var(--bg); border-radius: 11px; padding: 2px; flex: none; }
.kind button { width: 38px; height: 40px; display: grid; place-items: center; border-radius: 9px; color: var(--muted); }
.kind button[aria-pressed='true'] { background: var(--accent-soft); color: var(--accent); }
.kind svg { width: 22px; height: 22px; }
.send { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--accent); color: var(--accent-ink); }
.send svg { stroke-width: 2.2; }
.send .i-shot { display: none; stroke-width: 1.8; }
.send.is-shot .i-shot { display: block; }
.send.is-shot .i-add { display: none; }
.send.is-busy { animation: busy 1s ease-in-out infinite; }
@keyframes busy { 50% { opacity: .45; } }
.capture-hint { max-width: 600px; margin: 0 auto 6px; display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.chip { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 4px 12px; font-size: 14.5px; font-weight: 600; }

/* ---------- spodní navigace ---------- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tabs-h) + var(--safe-b));
  padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
}
#tabs button { display: grid; place-items: center; align-content: center; gap: 2px; color: var(--muted); font-size: 11.5px; font-weight: 500; }
#tabs button[aria-current='page'] { color: var(--accent); font-weight: 650; }
#tabs svg { width: 25px; height: 25px; }

/* ---------- panel úprav ---------- */
#sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.backdrop { position: absolute; inset: 0; background: rgba(8, 16, 13, .45); }
.panel {
  position: relative; width: 100%; max-width: 600px; max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 24px); overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 14px 18px calc(16px + var(--safe-b) + var(--kb));
  animation: rise .2s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.panel-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-top h2 { font: 650 20px var(--display); }
.when { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin: -2px 0 12px; }
.quick button { min-height: 36px; padding: 0 13px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 14.5px; font-weight: 600; }
.origin { background: var(--bg); border-radius: 12px; padding: 10px 12px; font-size: 14.5px; color: var(--muted); margin-bottom: 12px; }
.origin strong { color: var(--ink); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.panel-actions .btn[type='submit'] { flex: 1 0 100%; }
.panel-actions .danger { margin-left: auto; }
.sheet-open { overflow: hidden; }

/* ---------- hlášky ---------- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabs-h) + var(--safe-b) + 84px + var(--kb)); max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 14px; padding: 11px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-size: 15px; box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
}
#toast button { color: var(--amber); font-weight: 700; min-height: 28px; }

/* ---------- přihlášení ---------- */
#login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 360px; }
.login-box h1 { font: 700 44px/1 var(--display); letter-spacing: -0.03em; margin-bottom: 10px; }
.login-box p { color: var(--muted); margin-bottom: 18px; }
.login-box label { display: block; font-size: 13.5px; color: var(--muted); margin: 0 0 4px 2px; }
.login-box input { width: 100%; height: 50px; padding: 0 14px; font-size: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; }
.login-box .btn { width: 100%; }

/* ---------- poznámka přes celou obrazovku ---------- */
#sheet.is-page { align-items: stretch; }
.note-page {
  position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--surface);
  padding-top: env(safe-area-inset-top, 0px); animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { transform: translateX(28px); opacity: 0; } }
.note-bar { display: flex; align-items: center; gap: 2px; min-height: 52px; padding: 4px 6px; }
.note-bar .back { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px 0 2px; color: var(--accent); font-size: 17px; font-weight: 600; }
.note-bar .back svg { width: 26px; height: 26px; stroke-width: 2.2; }
.note-status { flex: 1; text-align: center; color: var(--muted); font-size: 13px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--accent); border-radius: 12px; }
.done-btn { min-height: 44px; padding: 0 12px; color: var(--accent); font-size: 17px; font-weight: 700; }
.note-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 20px calc(40px + var(--safe-b) + var(--kb)); }
.note-meta { text-align: center; color: var(--muted); font-size: 13px; margin: 2px 0 14px; }
#note-title, #note-body { display: block; width: 100%; max-width: 680px; margin: 0 auto; border: 0; outline: none; resize: none; background: none; padding: 0; overflow: hidden; }
#note-title { font: 700 27px/1.2 var(--display); letter-spacing: -0.01em; }
#note-body { margin-top: 10px; font-size: 18px; line-height: 1.5; min-height: 55vh; }
#note-title::placeholder, #note-body::placeholder { color: var(--muted); opacity: 1; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
