:root {
  --bg: #f4f4f8; --card: #ffffff; --ink: #1d1d27; --muted: #666677; --line: #e3e3ea;
  --accent: #5b54d6; --accent-ink: #ffffff; --soft: #ecebfb; --danger: #c0344b;
  --m5: #178f6a; --m4: #9aa51a; --m3: #5a7fe6; --m2: #e2852a; --m1: #c23a6b;
  --nav-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14141a; --card: #1f1f28; --ink: #ececf2; --muted: #a0a0b0; --line: #30303c;
    --accent: #9a94ff; --accent-ink: #14141a; --soft: #2a2940; --danger: #f0738a;
    --m5: #1fa97e; --m4: #8c9618; --m3: #6b8cf0; --m2: #d4772a; --m1: #d6508a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14141a; --card: #1f1f28; --ink: #ececf2; --muted: #a0a0b0; --line: #30303c;
  --accent: #9a94ff; --accent-ink: #14141a; --soft: #2a2940; --danger: #f0738a;
  --m5: #1fa97e; --m4: #8c9618; --m3: #6b8cf0; --m2: #d4772a; --m1: #d6508a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
h2, h3 { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

#top, #main, #nav { max-width: 600px; margin: 0 auto; }
#top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; min-height: 56px;
  display: flex; flex-direction: column; gap: 8px; justify-content: center;
}
#main { padding: 4px 16px calc(var(--nav-h) + 56px + env(safe-area-inset-bottom)); }

.mnav { display: flex; align-items: center; justify-content: center; gap: 8px; }
.mnav b { min-width: 170px; text-align: center; font-size: 17px; }
.icon {
  width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 20px; color: var(--ink); flex: none;
}
button.icon:hover { background: var(--soft); }
.titlebar { display: flex; align-items: center; gap: 8px; }
.titlebar b { font-size: 18px; }

/* spodná navigácia */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr 1fr 72px 1fr 1fr; align-items: center;
}
.tab { display: grid; justify-items: center; gap: 2px; font-size: 11px; color: var(--muted); height: 100%; align-content: center; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--accent); font-weight: 600; }
.fab {
  width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-size: 34px; line-height: 1; justify-self: center; transform: translateY(-16px);
  box-shadow: 0 6px 16px rgba(60, 50, 180, .35); display: grid; place-items: center;
}

/* karty */
.card { background: var(--card); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.card > h3 { font-size: 15px; margin-bottom: 12px; }
.card > h3 small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.dayhead { font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 4px 6px; text-transform: uppercase; letter-spacing: .04em; }
.entry { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border-radius: 16px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.entry:hover { outline: 2px solid var(--soft); }
.entry-body { flex: 1; min-width: 0; }
.entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.entry-head b { font-size: 17px; }
.acts { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; font-size: 14px; color: var(--muted); }
.etitle { font-weight: 600; margin-top: 6px; }
.enote { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }
.search { width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.face { flex: none; display: block; }

/* tlačidlá */
.btn { padding: 11px 18px; border-radius: 12px; font-weight: 600; background: var(--soft); color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.wide { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.row.center { justify-content: center; }
.seg { display: inline-flex; background: var(--soft); border-radius: 12px; padding: 3px; }
.seg button { padding: 7px 14px; border-radius: 10px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; }
input[type=text], input:not([type]), input[type=date], input[type=time], select, textarea {
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); width: 100%;
}
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* vrstvy */
.layer { position: fixed; inset: 0; z-index: 20; background: rgba(10, 10, 20, .5); display: flex; justify-content: center; align-items: flex-end; }
#dialog { z-index: 30; align-items: center; padding: 16px; }
.sheet-box { background: var(--bg); width: 100%; max-width: 600px; height: 100%; display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: calc(8px + env(safe-area-inset-top)) 8px 8px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 16px 16px; }
.sheet-body h3 { font-size: 15px; margin: 22px 0 10px; }
.sheet-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--card); }
.q { text-align: center; font-size: 24px; margin: 8px 0 14px; }
.dt { display: flex; gap: 8px; justify-content: center; }
.dt input { width: auto; }
.moods { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 18px; }
.moodbtn { display: grid; justify-items: center; gap: 4px; padding: 8px 6px; border-radius: 14px; width: 64px; font-size: 12px; opacity: .55; }
.moodbtn.on, .moods.none .moodbtn { opacity: 1; }
.moodbtn.on { background: var(--card); font-weight: 700; box-shadow: 0 0 0 2px var(--accent); }
.gname { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.dialog { background: var(--card); border-radius: 18px; padding: 20px; width: 100%; max-width: 380px; }
.dialog h3 { margin-bottom: 10px; }
.dialog p { margin: 0 0 10px; }
.dialog label { display: block; font-size: 13px; color: var(--muted); margin-top: 10px; }
.dialog label input, .dialog label select { margin-top: 4px; color: var(--ink); font-size: 16px; }

/* štatistiky */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.tile { background: var(--card); border-radius: 16px; padding: 14px 16px; }
.tile .lab { font-size: 13px; color: var(--muted); }
.tile .val { font-size: 28px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.streak { display: flex; justify-content: space-between; gap: 4px; margin-top: 4px; }
.streak div { display: grid; justify-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.dot { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 15px; }
.dot.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { stroke: var(--card); stroke-width: 2; }
.chart .hit { fill: transparent; }
.stack { display: flex; gap: 2px; height: 14px; margin-bottom: 14px; }
.stack span { border-radius: 4px; min-width: 4px; }
.moodcount { display: flex; justify-content: space-around; }
.moodcount div { display: grid; justify-items: center; gap: 2px; font-size: 12px; color: var(--muted); }
.moodcount b { font-size: 16px; color: var(--ink); }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 44px; gap: 8px; align-items: center; font-size: 14px; }
.bar .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .tr { height: 10px; }
.bar .tr span { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--accent); min-width: 3px; }
.bar .n { text-align: right; font-variant-numeric: tabular-nums; }
.infl { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; }
.infl .v { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.wd { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 130px; }
.wd div { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; height: 100%; font-size: 12px; color: var(--muted); gap: 4px; }
.wd .col { width: 60%; max-width: 24px; align-self: end; border-radius: 4px 4px 0 0; min-height: 2px; }
.wd .val { color: var(--ink); font-variant-numeric: tabular-nums; }
.pixels { display: grid; grid-template-columns: 20px repeat(12, 1fr); gap: 2px; font-size: 10px; color: var(--muted); text-align: center; }
.px { aspect-ratio: 1; border-radius: 3px; background: var(--line); max-height: 16px; }
.px.none { background: transparent; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }

/* kalendár */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wdh { text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.calday { display: grid; justify-items: center; gap: 2px; padding: 5px 0; border-radius: 12px; font-size: 12px; color: var(--muted); }
.calday .ring { width: 32px; height: 32px; border-radius: 50%; border: 2px dashed var(--line); }
.calday.today { color: var(--accent); font-weight: 700; }
.calday.sel { background: var(--soft); color: var(--ink); }
.calday.future { opacity: .4; }

/* viac */
.menu { background: var(--card); border-radius: 16px; overflow: hidden; margin-bottom: 12px; }
.menu > button, .menu > div { display: flex; width: 100%; align-items: center; gap: 12px; padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.menu > :last-child { border-bottom: 0; }
.menu > button:hover { background: var(--soft); }
.menu .ic { font-size: 20px; width: 26px; text-align: center; }
.menu .tx { flex: 1; }
.menu .tx small { display: block; color: var(--muted); }
.menu .danger { color: var(--danger); }
.ghead { display: flex; align-items: center; justify-content: space-between; margin: 16px 4px 6px; }
.ghead b { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ghead .icon { width: 34px; height: 34px; font-size: 16px; }
.chip.add { border-style: dashed; color: var(--muted); }
table.map { width: 100%; border-collapse: collapse; font-size: 14px; }
table.map td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.map select { padding: 6px 8px; }

/* zámok */
body.locked #top, body.locked #main, body.locked #nav { display: none; }
#lock { background: var(--bg); align-items: center; z-index: 25; padding: 16px; overflow-y: auto; }
.lockbox { width: 100%; max-width: 360px; display: grid; gap: 12px; text-align: center; justify-items: stretch; }
.lockbox img { justify-self: center; border-radius: 18px; }
.lockbox p { margin: 0; }
.errtx { color: var(--danger) !important; }
input[type=password] { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); width: 100%; }
button:disabled { opacity: .6; }

/* ťahanie aktivít */
.manage .chip { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.chip.dragging { opacity: .3; }
.chip.before { box-shadow: -4px 0 0 var(--accent); }
.chips.over { outline: 2px dashed var(--accent); outline-offset: 5px; border-radius: 12px; }
.ghost-chip { position: fixed; z-index: 70; pointer-events: none; transform: translate(-50%, -130%) scale(1.08); box-shadow: 0 8px 20px rgba(0, 0, 0, .3); background: var(--card); }

/* detail aktivity */
.clickable { cursor: pointer; }
.clickable:hover { background: var(--soft); border-radius: 8px; }
.wd.m12 { grid-template-columns: repeat(12, 1fr); gap: 4px; }
.wd.m12 div { font-size: 11px; }
.ynav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ynav h3 { margin: 0; }
.ynav .icon { width: 34px; height: 34px; }

#tip { position: fixed; z-index: 40; background: var(--ink); color: var(--bg); font-size: 12px; padding: 5px 9px; border-radius: 8px; pointer-events: none; max-width: 240px; }
#toast { position: fixed; z-index: 50; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 40px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; text-align: center; }

/* filtre, škály, ciele, fotky */
.filters { display: flex; align-items: center; gap: 6px; margin: 10px 0 4px; }
.filters select { flex: 1; min-width: 0; padding: 8px 10px; }
.lvbtn { border-radius: 50%; padding: 3px; opacity: .45; flex: none; }
.lvbtn.on { opacity: 1; box-shadow: 0 0 0 2px var(--accent); }
.scale-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sc { display: flex; gap: 6px; }
.scb { width: 38px; height: 38px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); font-weight: 600; color: var(--muted); }
.scb.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bar .tr.goal { background: var(--line); border-radius: 5px; overflow: hidden; }
.bar .tr.goal span { min-width: 0; border-radius: 5px; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; background: var(--line); display: block; cursor: pointer; }
.thumb.missing { opacity: .4; }
.thumbwrap { position: relative; }
.thumbx { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 12px; }
.addph { display: grid; place-items: center; font-size: 28px; color: var(--muted); border: 2px dashed var(--line); background: transparent; }
.viewer { max-width: 100%; max-height: 100%; border-radius: 8px; cursor: zoom-out; }

/* správa na tlač */
#print { display: none; }
@media print {
  body.printing > *:not(#print) { display: none !important; }
  body.printing { background: #fff; }
  body.printing #print { display: block; }
}
#print { --muted: #444; --line: #bbb; --card: #fff; --m5: #178f6a; --m4: #9aa51a; --m3: #5a7fe6; --m2: #e2852a; --m1: #c23a6b; color: #000; background: #fff; font-size: 11pt; padding: 0 4mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
#print h1 { font-size: 18pt; margin: 0 0 4px; }
#print h2 { font-size: 13pt; margin: 16px 0 6px; }
#print table { width: 100%; border-collapse: collapse; }
#print th, #print td { border: 1px solid #bbb; padding: 4px 6px; text-align: left; vertical-align: top; font-size: 10pt; }
#print th { background: #eee; }
#print .rchart { max-width: 150mm; }
#print tr { break-inside: avoid; }
