:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #16191f;
  --muted: #646b78;
  --accent: #2557d6;
  --accent-soft: #e8eefc;
  --good: #188a4b;
  --good-soft: #e3f4ea;
  --warn: #a86400;
  --warn-soft: #fdf1dc;
  --bad: #c62f2f;
  --bad-soft: #fbe7e7;
  --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1f232b;
    --border: #2b303a;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --accent: #6d95ff;
    --accent-soft: #1d2a4a;
    --good: #4cc784;
    --good-soft: #15301f;
    --warn: #f0b04a;
    --warn-soft: #34270f;
    --bad: #ff7a7a;
    --bad-soft: #3a1717;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
code { font-size: .92em; background: var(--surface-2); padding: 0 .3em; border-radius: 4px; }
small { color: var(--muted); font-weight: 400; }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--accent); }
.status { flex: 1; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.status.running .dot { background: var(--accent); animation: pulse 1s infinite alternate; }
.status span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes pulse { to { opacity: .3; } }
.top-actions { display: flex; gap: 8px; }

/* --- buttons & inputs --- */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 500;
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.icon { padding: 7px; }

input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 13px; }
label.toggle, .checks label { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
label.toggle input, .checks input { width: auto; accent-color: var(--accent); }
label.inline { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; }

/* --- layout --- */
.layout { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100vh - 53px); }
.sidebar { border-right: 1px solid var(--border); background: var(--surface); padding: 16px; min-width: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.side-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0; }
.watches { display: flex; flex-direction: column; gap: 8px; }
.main { padding: 16px 20px 40px; min-width: 0; }

.watch {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer;
  background: var(--surface);
}
.watch:hover { border-color: var(--accent); }
.watch.active { border-color: var(--accent); background: var(--accent-soft); }
.watch.disabled { opacity: .6; }
.watch-top { display: flex; align-items: center; gap: 6px; }
.watch-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-sum { color: var(--muted); font-size: 12px; margin: 2px 0 6px; }
.watch-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.watch-actions { display: flex; gap: 2px; margin-top: 6px; }
.watch-actions .btn { padding: 2px 8px; font-size: 12px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 500; }
.pill.new { background: var(--accent); color: #fff; }
.pill.good { background: var(--good-soft); color: var(--good); }
.srcdots { display: inline-flex; gap: 3px; margin-left: auto; }
.srcdot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.srcdot.warn { background: var(--warn); }
.srcdot.err { background: var(--bad); }
.srcdot.idle { background: var(--border); }

.all-watches { font-weight: 600; }

/* --- toolbar --- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 9px; }
.tab { border: 0; background: transparent; font: inherit; color: var(--muted); padding: 5px 12px; border-radius: 7px; cursor: pointer; font-weight: 500; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tab .n { color: var(--muted); font-weight: 400; margin-left: 2px; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filters select { width: auto; padding: 5px 8px; font-size: 13px; }

/* --- filtry nabídek --- */
.filterbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 10px; }
.filterbar input, .filterbar select { width: auto; padding: 5px 8px; font-size: 13px; }
.filterbar .fb-search { flex: 1 1 220px; min-width: 180px; }
.fb-range { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.fb-range input { width: 96px; }
#f-km { width: 132px; }
.engine-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip.toggle { border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; cursor: pointer; }
.chip.toggle:hover { border-color: var(--accent); }
.chip.toggle .n { color: var(--muted); margin-left: 3px; }
.chip.toggle.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.toggle.on .n { color: rgb(255 255 255 / .8); }
.fb-count { margin: -2px 0 10px; }

/* --- banner --- */
.banner { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; display: flex; gap: 12px; align-items: flex-start; }
.banner.warn { background: var(--warn-soft); border-color: transparent; }
.banner h4 { margin: 0 0 2px; font-size: 14px; }
.banner p { margin: 0; color: var(--muted); }
.banner ul { margin: 4px 0 0; padding-left: 18px; color: var(--muted); }

/* --- cards --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
  position: relative;
}
.card.hidden-hit { opacity: .55; }
.card-img { aspect-ratio: 4 / 3; background: var(--surface-2); position: relative; display: block; overflow: hidden; }
.card-img img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; }
.card-img .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.score {
  position: absolute; top: 8px; left: 8px;
  min-width: 38px; padding: 3px 7px; border-radius: 8px; text-align: center;
  font-weight: 700; font-size: 13px; color: #fff; background: #5d6878;
  box-shadow: 0 1px 4px rgb(0 0 0 / .25);
  z-index: 2;
}
.score.s-hi { background: #1f9d55; }
.score.s-mid { background: #d18a00; }
.srcbadge { position: absolute; top: 8px; right: 8px; padding: 2px 7px; border-radius: 6px; background: rgb(0 0 0 / .62); color: #fff; font-size: 11px; font-weight: 600; z-index: 2; }
.newdot { position: absolute; bottom: 8px; left: 8px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; z-index: 2; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text); }
.price-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price { font-size: 18px; font-weight: 700; }
.price-alt { color: var(--muted); font-size: 12px; }
.drop { color: var(--good); font-size: 12px; font-weight: 600; }
.deal { font-size: 12.5px; font-weight: 600; }
.deal.good { color: var(--good); }
.deal.bad { color: var(--muted); font-weight: 500; }
.specs { color: var(--muted); font-size: 12.5px; }
.specs .engine { color: var(--text); font-weight: 600; }
.specs .engine.muted { color: var(--muted); font-weight: 400; font-style: italic; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 11.5px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.chip.bonus { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.card-foot { display: flex; align-items: center; gap: 4px; margin-top: auto; padding-top: 4px; color: var(--muted); font-size: 12px; }
.card-foot .loc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot .btn { padding: 3px 7px; font-size: 13px; }
.card-foot .btn.on { color: #e0a100; }

.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 60px 20px; }
.empty h3 { color: var(--text); margin: 0 0 6px; }
.empty .btn { margin-top: 14px; }

/* --- dialogs --- */
.dialog { border: 0; border-radius: 14px; padding: 0; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 40px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
.dialog::backdrop { background: rgb(10 14 20 / .45); }
.dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.dlg-head, .dlg-foot { display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.dlg-foot { border-bottom: 0; border-top: 1px solid var(--border); }
.dlg-head h3 { margin: 0; flex: 1; font-size: 16px; }
.dlg-body { padding: 4px 20px 16px; overflow-y: auto; flex: 1; min-height: 0; }
fieldset { border: 0; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; padding: 0; }
.row2, .row3, .row4 { display: grid; gap: 10px; }
.row2 { grid-template-columns: repeat(2, 1fr); }
.row3 { grid-template-columns: repeat(3, 1fr); }
.row4 { grid-template-columns: repeat(4, 1fr); }
.row-btn { display: flex; align-items: center; gap: 10px; }
.hint { color: var(--muted); font-size: 12px; margin: 0; font-weight: 400; }
.hint.ok { color: var(--good); }
.hint.err { color: var(--bad); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.advanced { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.advanced[open] { gap: 10px; }
.advanced > * + * { margin-top: 10px; }
.advanced summary { cursor: pointer; color: var(--muted); font-weight: 500; }
.spacer { flex: 1; }
.howto { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
details.sub summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.sub[open] { display: flex; flex-direction: column; gap: 8px; }
.row-btn input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.login { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; overflow-y: auto;
  background: radial-gradient(120% 90% at 70% 10%, #1d3a8f 0%, #0b1020 60%); }
.login > :not(canvas) { position: relative; z-index: 1; }
.login-box { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-box .brand { font-size: 18px; }

/* --- účet, správa --- */
.who { color: var(--muted); font-size: 13px; align-self: center; white-space: nowrap; }
.dc-status { flex: 1; font-size: 13px; }
.dc-status.ok { color: var(--good); font-weight: 600; }
.admin-zone { margin-top: 22px; padding-top: 4px; border-top: 2px dashed var(--border); }
.admin-title { margin: 12px 0 0; font-weight: 700; }
.people { display: flex; flex-direction: column; gap: 6px; }
.person { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.person .name { font-weight: 600; }
.person .meta { color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .btn { padding: 2px 8px; font-size: 12px; }
.btn.big { padding: 11px 18px; font-size: 15px; justify-content: center; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; justify-content: center; }
.btn.discord:hover { background: #4752c4; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.hint.center { text-align: center; margin-top: -6px; }

/* --- registrace --- */
.login-box.reg { width: min(440px, 100%); }
.reg-hero { text-align: center; }
.reg-hero h2 { margin: 4px 0 6px; font-size: 22px; }
.reg-hero p { margin: 0; color: var(--muted); }
.reg-emoji { font-size: 44px; line-height: 1; animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce { 50% { transform: translateY(-6px) rotate(-4deg); } }
.steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0; }
.steps li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
.steps li span { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); border: 2px solid var(--border); }
.steps li.on { color: var(--accent); font-weight: 600; }
.steps li.on span { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.pw-meter { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: -6px; }
.pw-meter i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--bad); transition: width .3s, background .3s; }

/* --- průvodce (mise) --- */
.dialog.onb { width: min(640px, calc(100vw - 32px)); }
.onb-wrap { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.onb-head { flex: none; padding: 18px 20px 14px; color: #fff; background: linear-gradient(135deg, #2557d6, #1a3a9e 60%, #13296f); }
.onb-top { display: flex; align-items: flex-start; gap: 8px; }
.onb-top > div { flex: 1; }
.onb-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.onb-head h3 { margin: 2px 0 10px; font-size: 22px; }
.onb-x { color: #fff; }
#onb-rank.levelup { animation: levelup .9s ease; }
@keyframes levelup { 30% { transform: scale(1.18); color: #ffd166; text-shadow: 0 0 18px rgb(255 209 102 / .8); } }
.onb-x:hover { background: rgb(255 255 255 / .12); }
.xp { height: 12px; border-radius: 99px; background: rgb(255 255 255 / .18); overflow: hidden; }
.xp i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #ffd166, #2ecc71); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.onb-meta { display: flex; justify-content: space-between; font-size: 12.5px; margin-top: 6px; opacity: .9; }
.badges { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.badge { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: rgb(255 255 255 / .1); filter: grayscale(1); opacity: .45; transition: .4s; }
.badge.done { filter: none; opacity: 1; background: rgb(255 255 255 / .2); box-shadow: 0 0 0 2px #ffd166, 0 4px 14px rgb(0 0 0 / .25); }
.badge.pop { animation: pop .6s ease; }
@keyframes pop { 40% { transform: scale(1.35) rotate(-8deg); } }
.onb-body { flex: 1; min-height: 0; padding: 14px 20px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.mission { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; background: var(--surface); }
.mission .m-icon { font-size: 22px; width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); }
.mission .m-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.mission .m-title { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.mission .m-xp { margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.mission .m-text { color: var(--muted); font-size: 13px; margin: 0; }
.mission .m-steps { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.mission .m-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mission .m-actions input { flex: 1 1 200px; width: auto; }
.mission.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mission.done { background: var(--good-soft); border-color: transparent; }
.mission.done .m-icon { background: var(--good); color: #fff; }
.mission.done .m-xp { color: var(--good); background: transparent; }
.mission.bonus .m-xp { color: #b7791f; background: #fdf1dc; }
.m-state { font-size: 12.5px; font-weight: 600; }
.m-state.ok { color: var(--good); }
.m-state.err { color: var(--bad); font-weight: 500; }
.onb-finish { text-align: center; padding: 8px 4px 2px; }
.onb-finish .trophy { font-size: 52px; animation: bounce 1.4s ease-in-out infinite; }
.onb-finish h4 { margin: 4px 0; font-size: 18px; }
.onb-finish p { margin: 0; color: var(--muted); }

/* --- 3D scéna (three.js) --- */
canvas.scene3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
canvas.scene3d.small { left: auto; width: 62%; opacity: .95;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 35%); mask-image: linear-gradient(90deg, transparent, #000 35%); }
.onb-head { position: relative; overflow: hidden; }
.onb-head > :not(canvas) { position: relative; z-index: 1; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate3d(var(--dx), 105vh, 0) rotate(var(--rot)); } }
@media (prefers-reduced-motion: reduce) {
  .reg-emoji, .onb-finish .trophy, .badge.pop { animation: none; }
  .confetti { display: none; }
}

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: .2s; font-weight: 500; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .watches { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .watch { min-width: 240px; }
  .row3, .row4 { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .status { order: 3; flex-basis: 100%; }
  .main { padding: 16px; }
}
@media (max-width: 480px) {
  .row2, .row3, .row4 { grid-template-columns: 1fr; }
  .fb-range { flex: 1 1 100%; }
  .fb-range input { flex: 1; width: auto; min-width: 0; }
  .filterbar select, #f-km { flex: 1 1 calc(50% - 8px); }
  #btn-run { padding: 6px 10px; }
}
