:root {
  color-scheme: light dark;
  --bg: #f3f0ff;
  --card: #ffffff;
  --card2: #f7f5ff;
  --text: #241f3d;
  --muted: #706c8c;
  --primary: #6c4cf1;
  --primary-dark: #5636d6;
  --accent: #ff5fa2;
  --ok: #12a150;
  --warn: #e08a00;
  --danger: #e5384f;
  --border: #e6e1fb;
  --chip: #ece8ff;
  --shadow: 0 2px 8px rgba(80, 50, 180, .10);
  --radius: 20px;
  --grad: linear-gradient(135deg, #6c4cf1 0%, #b04cf1 55%, #ff5fa2 100%);
  --tap: 52px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14111f;
    --card: #1f1a33;
    --card2: #281f45;
    --text: #f1eeff;
    --muted: #a29cc4;
    --primary: #9a82ff;
    --primary-dark: #7f65f0;
    --accent: #ff7ab8;
    --ok: #3ddc84;
    --warn: #ffb547;
    --danger: #ff6b7e;
    --border: #35295a;
    --chip: #2f2556;
    --shadow: 0 2px 10px rgba(0, 0, 0, .45);
    --grad: linear-gradient(135deg, #4a32b8 0%, #8a3fc4 55%, #c7407f 100%);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin-top: 6px; }
h3 { font-size: 1.02rem; }
.wrap { max-width: 640px; margin: 0 auto; padding: 14px; }

/* hlavička */
header.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--grad); color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 18px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-radius: 0 0 24px 24px;
  box-shadow: 0 4px 16px rgba(108, 76, 241, .35);
}
header.top .title { font-weight: 800; font-size: 1.15rem; letter-spacing: .2px; }
header.top .sub { font-size: .8rem; opacity: .85; font-weight: 500; }
header.top .pts { background: rgba(255,255,255,.25); padding: 6px 14px; border-radius: 99px; font-weight: 800; font-size: 1.05rem; white-space: nowrap; }

/* spodní navigace */
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  background: var(--card); border-top: 1px solid var(--border);
  display: flex; padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(80, 50, 180, .10);
}
nav.tabs button {
  flex: 1; border: 0; background: none; padding: 8px 2px 6px; min-height: 60px;
  font: inherit; font-size: .74rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; border-radius: 16px;
}
nav.tabs button .ic { font-size: 1.6rem; line-height: 1; transition: transform .15s; }
nav.tabs button.active { color: var(--primary); font-weight: 800; background: var(--chip); }
nav.tabs button.active .ic { transform: scale(1.15); }
.badge { position: absolute; top: 2px; right: calc(50% - 26px); background: var(--danger); color: #fff; border-radius: 99px; font-size: .68rem; padding: 1px 7px; font-weight: 800; }

/* karty */
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.card.click { cursor: pointer; transition: transform .1s; }
.card.click:active { transform: scale(.98); }
.card.task { border-left: 6px solid var(--primary); }
.card.task.s-submitted { border-left-color: var(--warn); }
.card.task.s-approved { border-left-color: var(--ok); opacity: .85; }
.card.task.s-rejected { border-left-color: var(--danger); }
.card.task.overdue { border-left-color: var(--danger); }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: .88rem; }
.title { font-weight: 700; }
.pill { display: inline-block; font-size: .76rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--chip); color: var(--primary); margin: 0 4px 4px 0; }
.pill.ok { background: rgba(18, 161, 80, .15); color: var(--ok); }
.pill.warn { background: rgba(224, 138, 0, .17); color: var(--warn); }
.pill.danger { background: rgba(229, 56, 79, .15); color: var(--danger); }
.stars { color: var(--warn); font-weight: 800; white-space: nowrap; }
.emoji { font-size: 2rem; width: 54px; height: 54px; flex: none; display: grid; place-items: center; background: var(--chip); border-radius: 18px; }
.emoji.sm { font-size: 1.5rem; width: 42px; height: 42px; border-radius: 14px; }

/* tlačítka */
button.btn, a.btn {
  border: 0; border-radius: 16px; padding: 12px 20px; min-height: var(--tap); font: inherit; font-size: 1.02rem; font-weight: 800;
  background: var(--primary); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center;
  box-shadow: 0 3px 0 var(--primary-dark); transition: transform .08s, box-shadow .08s;
}
button.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--primary-dark); }
button.btn.ok { background: var(--ok); box-shadow: 0 3px 0 rgba(0,0,0,.25); }
button.btn.danger { background: var(--danger); box-shadow: 0 3px 0 rgba(0,0,0,.25); }
button.btn.ghost { background: var(--chip); color: var(--primary); box-shadow: none; }
button.btn.sm { padding: 8px 14px; min-height: 44px; font-size: .92rem; border-radius: 14px; }
button.btn.block { display: flex; width: 100%; }
button.btn:disabled { opacity: .5; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* formuláře */
label { display: block; font-size: .88rem; font-weight: 700; color: var(--muted); margin: 12px 0 5px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 13px 14px; min-height: var(--tap); border: 2px solid var(--border); border-radius: 14px; background: var(--card2); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: 26px; height: 26px; min-height: 0; margin-right: 10px; accent-color: var(--primary); }
label.check { display: flex; align-items: center; color: var(--text); font-size: 1rem; margin-top: 14px; }

/* filtry a skupiny */
.filters { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; padding: 2px 0 4px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { border: 2px solid var(--border); background: var(--card); border-radius: 99px; padding: 9px 16px; min-height: 44px; font: inherit; font-size: .92rem; font-weight: 700; white-space: nowrap; color: var(--text); }
.filters button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.group { font-size: .92rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 18px 4px 8px; display: flex; align-items: center; gap: 8px; }
.group.today { color: var(--primary); }
.group.late { color: var(--danger); }
.group .n { background: var(--chip); border-radius: 99px; padding: 0 9px; font-size: .78rem; }

/* fotky */
.photos { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.photo { position: relative; width: 104px; height: 104px; border-radius: 16px; overflow: hidden; background: var(--chip); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .kind { position: absolute; left: 0; bottom: 0; right: 0; background: rgba(0,0,0,.6); color: #fff; font-size: .7rem; font-weight: 700; text-align: center; padding: 2px; }
.photo .del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.65); color: #fff; border: 0; border-radius: 99px; width: 28px; height: 28px; line-height: 1; font-size: 1rem; }

/* modál */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 10, 50, .6); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.modal { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 28px 28px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); animation: up .25s ease-out; }
@media (min-width: 700px) { .modal-bg { align-items: center; } .modal { border-radius: 28px; } }
.modal .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.modal .head h2 { margin: 0; }
.modal .x { border: 0; background: var(--chip); color: var(--muted); font-size: 1.6rem; width: 44px; height: 44px; border-radius: 99px; flex: none; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.fab { position: fixed; right: 18px; bottom: calc(94px + env(safe-area-inset-bottom)); z-index: 6; width: 64px; height: 64px; min-height: 0; border-radius: 99px; font-size: 2.2rem; padding: 0; background: var(--grad); box-shadow: 0 6px 16px rgba(176, 76, 241, .5); }
.fab:active { transform: scale(.93); box-shadow: 0 6px 16px rgba(176, 76, 241, .5); }

/* přihlášení */
.auth { max-width: 400px; margin: 0 auto; padding: 36px 18px; }
.auth h1 { text-align: center; font-size: 2rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth .logo { text-align: center; font-size: 4rem; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
.link { background: none; border: 0; color: var(--primary); font: inherit; font-weight: 700; padding: 12px 0; cursor: pointer; }
.error { color: var(--danger); font-size: .92rem; font-weight: 600; margin-top: 8px; min-height: 1.2em; }
.empty { text-align: center; color: var(--muted); padding: 36px 10px; }
.empty .big { font-size: 3.4rem; display: block; margin-bottom: 6px; }
.progress { height: 12px; background: var(--chip); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: linear-gradient(90deg, #ffb547, #ff5fa2); border-radius: 99px; transition: width .6s; }
.progress.green > div { background: linear-gradient(90deg, #3ddc84, #12a150); }
.code { font-size: 1.6rem; letter-spacing: .15em; font-weight: 800; text-align: center; background: var(--card); border: 3px dashed var(--primary); border-radius: 18px; padding: 14px; margin: 12px 0; user-select: all; }

/* domovská obrazovka */
.hero { background: var(--grad); color: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: 0 6px 18px rgba(108, 76, 241, .35); }
.hero h2 { margin: 0 0 2px; font-size: 1.35rem; }
.hero .big { font-size: 2.4rem; font-weight: 800; line-height: 1.1; }
.hero .progress { background: rgba(255,255,255,.3); }
.hero .progress > div { background: #fff; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; box-shadow: var(--shadow); cursor: pointer; }
.stat .num { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1.1; }
.stat.alert .num { color: var(--danger); }
.stat .lbl { font-size: .82rem; color: var(--muted); font-weight: 700; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.lb-row + .lb-row { border-top: 1px solid var(--border); }
.medal { font-size: 1.7rem; width: 36px; text-align: center; flex: none; }
.avatar { font-size: 1.6rem; width: 46px; height: 46px; border-radius: 99px; display: grid; place-items: center; background: var(--chip); flex: none; }

/* toast a konfety */
#toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: #1d1735; color: #fff; padding: 12px 20px; border-radius: 99px; opacity: 0; transition: .25s; pointer-events: none; z-index: 60; font-size: .95rem; font-weight: 700; max-width: 92vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.confetti { position: fixed; top: -20px; z-index: 100; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .9; } }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } .auth .logo { animation: none; } }

/* rozvrh a akce */
.lesson { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.lesson + .lesson { border-top: 1px solid var(--border); }
.lnum { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 99px; background: var(--grad); color: #fff; font-weight: 800; font-size: .9rem; }
.subj { font-weight: 700; }
.ev { display: flex; gap: 12px; padding: 8px 0; align-items: flex-start; }
.ev + .ev, .row + .row { border-top: 1px solid var(--border); }
.evdate { min-width: 66px; font-size: .85rem; display: flex; flex-direction: column; color: var(--muted); }
.evdate b { color: var(--primary); font-size: 1rem; }
details.card summary { cursor: pointer; min-height: 32px; }
details.card[open] summary { margin-bottom: 6px; }
code { background: var(--chip); padding: 1px 6px; border-radius: 6px; }
nav.tabs button { font-size: .7rem; }

/* odznaky, série, zprávy, porovnání, dny v týdnu */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-bottom: 12px; }
.bdg { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 10px 6px; text-align: center; box-shadow: var(--shadow); }
.bdg .bi { font-size: 2rem; line-height: 1.2; }
.bdg .bn { font-size: .74rem; font-weight: 800; }
.bdg .bh { font-size: .64rem; color: var(--muted); margin-top: 2px; }
.bdg.locked { opacity: .45; filter: grayscale(1); box-shadow: none; }
.hero .small { font-size: 1rem; font-weight: 700; opacity: .9; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare div { position: relative; border-radius: 16px; overflow: hidden; background: var(--chip); }
.compare img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.compare span { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.65); color: #fff; font-size: .75rem; font-weight: 800; padding: 2px 10px; border-radius: 99px; }
#cm { max-height: 200px; overflow-y: auto; }
.msg { background: var(--chip); border-radius: 14px 14px 14px 4px; padding: 8px 12px; margin: 4px 0; max-width: 90%; color: var(--text); font-size: .95rem; }
.msg.mine { margin-left: auto; background: var(--primary); color: #fff; border-radius: 14px 14px 4px 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
label.chip { display: inline-flex; margin: 0; }
label.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
label.chip span { border: 2px solid var(--border); background: var(--card); color: var(--text); border-radius: 99px; padding: 8px 14px; min-height: 44px; display: inline-flex; align-items: center; font-weight: 700; font-size: .92rem; }
label.chip input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
label.chip input:focus-visible + span { outline: 3px solid var(--accent); }
.prefrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.prefrow input[type=time] { width: auto; min-width: 110px; }

.row span { white-space: nowrap; }


/* rutiny, společná nástěnka, grafy */
:root { --s1: #2a78d6; --s2: #eb6834; --grid: #e1e0d9; --axisline: #c3c2b7; --axtext: #898781; }
@media (prefers-color-scheme: dark) { :root { --s1: #3987e5; --s2: #d95926; --grid: #2c2c2a; --axisline: #383835; } }
.filters.seg { position: sticky; top: 74px; z-index: 4; background: var(--bg); padding-top: 4px; margin-top: -4px; }
.routine.done { opacity: .85; }
.steps { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.step { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 2px solid var(--border); background: var(--card2); color: var(--text); border-radius: 14px; padding: 8px 12px; min-height: 48px; font: inherit; font-weight: 600; cursor: pointer; }
.step .box { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--border); display: grid; place-items: center; flex: none; font-weight: 800; color: #fff; background: var(--card); }
.step.on { background: rgba(18, 161, 80, .12); border-color: rgba(18, 161, 80, .5); }
.step.on .box { background: var(--ok); border-color: var(--ok); }
.step.on span:last-child { text-decoration: line-through; opacity: .7; }
.shop { display: flex; align-items: center; gap: 4px; }
.shop + .shop { border-top: 1px solid var(--border); }
.shop .step { border: 0; background: none; padding: 6px 4px; min-height: 44px; }
.shop.done .step span:last-child { text-decoration: line-through; opacity: .6; }
.x2 { border: 0; background: none; color: var(--muted); font-size: 1.6rem; width: 44px; height: 44px; flex: none; cursor: pointer; }
.stat.static { cursor: default; }
.chartcard h3 { margin: 0; }
.chartsvg { width: 100%; height: auto; display: block; }
.chartsvg .s1 { fill: var(--s1); }
.chartsvg .s2 { fill: var(--s2); }
.chartsvg .grid { stroke: var(--grid); stroke-width: 1; }
.chartsvg .axis { stroke: var(--axisline); stroke-width: 1; }
.chartsvg .ax { fill: var(--axtext); font-size: 10px; }
.chartsvg .hit { cursor: pointer; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.sw.s1 { background: var(--s1); }
.sw.s2 { background: var(--s2); }
.legend { display: flex; gap: 14px; font-size: .85rem; margin: 6px 0 4px; color: var(--muted); }
.chartwrap { position: relative; }
.tip { display: none; position: absolute; pointer-events: none; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; font-size: .8rem; line-height: 1.5; box-shadow: var(--shadow); white-space: nowrap; z-index: 2; }
.dt { width: 100%; border-collapse: collapse; font-size: .92rem; margin-top: 8px; }
.dt th, .dt td { padding: 7px 4px; text-align: left; border-bottom: 1px solid var(--border); }
.dt th:not(:first-child), .dt td:not(:first-child) { text-align: right; }
.filters.seg { position: static; margin-top: 0; padding-top: 0; }
.filters.seg button { padding: 8px 12px; font-size: .86rem; }
.filters.seg { overflow: visible; gap: 6px; }
.filters.seg button { flex: 1 1 0; min-width: 0; padding: 8px 4px; font-size: .84rem; text-align: center; }

/* knihovna šablon */
.libbar { margin: -2px 0 10px; display: flex; justify-content: flex-end; }
.libitem { margin-bottom: 8px; padding: 12px 14px; }
.libbtns { display: flex; flex-direction: column; gap: 6px; flex: none; }
.libdetail { margin-top: 4px; font-size: .82rem; line-height: 1.35; }
.modal .filters { flex-wrap: wrap; overflow: visible; }
.modal .filters button { flex: 0 0 auto; }
.modal .filters { gap: 6px; margin-bottom: 8px; }
.modal .filters button { padding: 6px 12px; min-height: 38px; font-size: .84rem; }

/* rychlé nastavení */
.card.quick { cursor: pointer; border: 2px dashed var(--primary); background: var(--card2); }
.card.quick.big { background: var(--grad); border: 0; color: #fff; box-shadow: 0 6px 18px rgba(108, 76, 241, .35); }
.card.quick.big .muted { color: rgba(255,255,255,.88); }
.card.quick.big .emoji { background: rgba(255,255,255,.22); }
.card.quick:active { transform: scale(.98); }
.qlist { font-size: .88rem; margin-top: 8px; line-height: 1.45; color: var(--text); }

/* časová zátěž */
.progress.warn > div { background: linear-gradient(90deg, #ffd166, #e08a00); }
.progress.over > div { background: linear-gradient(90deg, #ff8a95, #e5384f); }
.card.load { margin-bottom: 10px; }
.liveload { font-size: .85rem; font-weight: 700; color: var(--muted, #6b6b80); margin: 6px 0 0; min-height: 1.2em; }
.liveload.over { color: var(--danger); }
.loadweek { display: flex; gap: 6px; margin-top: 12px; align-items: flex-end; }
.loadweek .lw { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.loadweek .bar { width: 100%; max-width: 26px; height: 44px; background: var(--chip); border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.loadweek .b { width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; }
.loadweek .lw.warn .b { background: var(--warn); }
.loadweek .lw.over .b { background: var(--danger); }
.loadweek .d { font-size: .68rem; color: var(--muted, #6b6b80); }

/* opravy */
.card.repair .rphotos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.card.repair .rphotos img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; cursor: zoom-in; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }
.card.attn { box-shadow: 0 0 0 2px #e08a00, 0 4px 14px rgba(108, 76, 241, .15); }
