/* quirk design system: aqua on deep teal-black. Montserrat for text, Benzin for headings. */

@font-face {
    font-family: "Montserrat";
    src: url("/static/fonts/Montserrat.ttf") format("truetype");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Benzin";
    src: url("/static/fonts/Benzin-Semibold.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Benzin";
    src: url("/static/fonts/Benzin-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #081013;
    --bg-2: #0c171b;
    --card: #0f1c21;
    --card-2: #142a31;
    --field: #0a1519;
    --border: #1c343c;
    --border-2: #285059;
    --text: #effbfb;
    --text-2: #c9e3e5;
    --aqua: #34e6d4;
    --aqua-2: #12b9cc;
    --aqua-ink: #04201f;
    --aqua-bg: rgba(52, 230, 212, 0.12);
    --aqua-line: rgba(52, 230, 212, 0.45);
    --red: #ff6b74;
    --red-bg: rgba(255, 107, 116, 0.13);
    --red-line: rgba(255, 107, 116, 0.5);
    --amber: #ffcb5c;
    --amber-bg: rgba(255, 203, 92, 0.13);
    --green: #45e3a0;
    --green-bg: rgba(69, 227, 160, 0.13);
    --radius: 16px;
    --radius-sm: 10px;
    --font: "Montserrat", "Segoe UI", system-ui, sans-serif;
    --head: "Benzin", "Montserrat", "Segoe UI", sans-serif;
    --mono: "Cascadia Mono", "JetBrains Mono", Consolas, ui-monospace, monospace;
    color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); }
body {
    min-height: 100vh; color: var(--text); font: 500 15px/1.55 var(--font); -webkit-font-smoothing: antialiased;
    background:
        radial-gradient(900px 600px at 0% 0%, rgba(52, 230, 212, 0.10), transparent 60%),
        radial-gradient(800px 600px at 100% 100%, rgba(18, 185, 204, 0.10), transparent 60%),
        radial-gradient(rgba(52, 230, 212, 0.07) 1px, transparent 1px) 0 0 / 26px 26px,
        var(--bg);
    background-attachment: fixed;
}
a { color: var(--aqua); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, .head { font-family: var(--head); font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 34px; line-height: 1.15; }
h2 { font-size: 19px; line-height: 1.25; }
h3 { font-size: 15px; line-height: 1.3; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
.w-full { width: 100%; }
.minw0 { min-width: 0; }
.soft { color: var(--text-2); }

/* logo */
.logo { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.logo:hover { text-decoration: none; }
.logo .mark { width: 38px; height: 38px; flex: none; }
.logo .word { font: 700 21px/1 var(--head); letter-spacing: .04em; }
.logo.lg .mark { width: 46px; height: 46px; }
.logo.lg .word { font-size: 25px; }

/* buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px;
    border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--card-2); color: var(--text);
    font: 700 15px var(--font); cursor: pointer; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap;
}
.btn:hover { border-color: var(--aqua-line); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: linear-gradient(135deg, var(--aqua), var(--aqua-2)); border: 0; color: var(--aqua-ink); }
.btn-primary:hover { filter: brightness(1.08); }

.icon-btn {
    position: relative; width: 42px; height: 42px; display: inline-grid; place-items: center; flex: none;
    border-radius: 12px; border: 1px solid var(--border-2); background: var(--card-2); color: var(--text); cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { border-color: var(--aqua-line); color: var(--aqua); }
.icon-btn.danger:hover { border-color: var(--red-line); color: var(--red); background: var(--red-bg); }
.icon-btn.ok { color: var(--green); border-color: var(--green); }
.icon-btn.ghost { background: transparent; border-color: transparent; }
.icon-btn.ghost:hover { background: var(--card-2); border-color: var(--border-2); }

/* hover labels */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
    content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); z-index: 40;
    width: max-content; max-width: 260px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border-2);
    background: #061013; color: var(--text); font: 600 13px/1.35 var(--font); box-shadow: 0 10px 30px rgba(0,0,0,.45);
    pointer-events: none; white-space: normal; text-align: center;
}
[data-tip].tip-left:hover::after { left: auto; right: 0; transform: none; }

/* fields */
input, select, textarea {
    height: 44px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--field);
    color: var(--text); font: 500 15px var(--font); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 14px; }
input::placeholder { color: #7fa1a6; }
input:focus, select:focus, textarea:focus { border-color: var(--aqua); box-shadow: 0 0 0 3px var(--aqua-bg); }
label { display: block; font-weight: 700; margin-bottom: 8px; }
.field { margin-bottom: 16px; }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 13px; width: 18px; height: 18px; color: var(--text-2); }
.search input { padding-left: 40px; width: 100%; }

/* cards */
.card { background: linear-gradient(180deg, rgba(20, 42, 49, .55), rgba(15, 28, 33, .9)); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }

/* badges and counters */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px; font: 700 13px var(--font); white-space: nowrap; border: 1px solid transparent; }
.b-neutral { background: var(--card-2); color: var(--text); border-color: var(--border-2); }
.b-aqua { background: var(--aqua-bg); color: var(--aqua); }
.b-green { background: var(--green-bg); color: var(--green); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.circle { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 999px; font: 800 13px var(--font); }
.circle.detect { background: #e8434f; color: #fff; }
.circle.warning { background: #d68a0e; color: #fff; }
.circle.info { background: var(--card-2); color: var(--text); border: 1px solid var(--border-2); }
.circles { display: inline-flex; gap: 6px; }

/* toasts and modals */
.toast { position: fixed; bottom: 22px; right: 22px; z-index: 80; padding: 12px 18px; border-radius: 12px; border: 1px solid var(--aqua-line);
         background: #0b1a1e; color: var(--text); font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.modal-bg { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(2, 8, 10, .7); }
.modal { width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }

/* =========================== public page ============================ */
.pub { min-height: 100vh; display: flex; flex-direction: column; }
.pub-top { padding: 22px 40px; }
.pub-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px 64px; text-align: center; }
.pub-main h1 { margin-bottom: 12px; }
.pub-main .lead { color: var(--text-2); font-size: 17px; margin-bottom: 40px; }
.os-row { display: grid; grid-template-columns: repeat(3, minmax(0, 340px)); gap: 22px; width: 100%; justify-content: center; align-items: stretch; }
.os-card { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 34px 26px 30px; border-radius: 20px; border: 1px solid var(--border);
           background: linear-gradient(180deg, rgba(20, 42, 49, .6), rgba(12, 23, 27, .9)); }
.os-card.active { border-color: var(--aqua-line); box-shadow: 0 0 0 1px rgba(52,230,212,.15), 0 20px 60px rgba(18, 185, 204, .12); }
.os-card.off { opacity: .55; }
.os-name { display: flex; align-items: center; gap: 12px; font: 700 23px var(--head); }
.os-name svg { width: 32px; height: 32px; }
.os-card.active .os-name svg { color: var(--aqua); }
.code-form { display: flex; gap: 8px; width: 100%; }
.code-form input { flex: 1; min-width: 0; height: 52px; text-align: center; font: 700 20px var(--mono); letter-spacing: .3em; text-transform: uppercase; padding: 0 10px 0 calc(10px + .3em); }
.code-form input::placeholder { font: 600 15px var(--font); letter-spacing: .02em; text-transform: none; }
.code-form .go { width: 52px; height: 52px; border: 0; border-radius: var(--radius-sm); background: linear-gradient(135deg, var(--aqua), var(--aqua-2)); color: var(--aqua-ink); cursor: pointer; display: grid; place-items: center; }
.code-form .go svg { width: 22px; height: 22px; }
.code-form .go:disabled { background: var(--card-2); color: var(--text-2); cursor: not-allowed; }
.os-note { font-weight: 600; color: var(--text-2); min-height: 24px; }
.os-note.error { color: var(--red); }
.os-note.ok { color: var(--green); }
.done-card { margin-top: 30px; width: 100%; max-width: 560px; text-align: left; }
.done-card ol { margin: 12px 0 0 22px; }
.done-card li { margin: 6px 0; }
.done-card .file { font-family: var(--mono); color: var(--aqua); font-weight: 700; }

/* ============================== login ============================== */
.center-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 420px; padding: 34px 30px; }
.login-card .logo { margin-bottom: 26px; }
.msg { margin-top: 14px; min-height: 22px; font-weight: 600; }
.msg.error { color: var(--red); }

/* ============================== panel ============================== */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 28px;
          background: rgba(8, 16, 19, .82); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); }
.topbar .right { display: flex; align-items: center; gap: 8px; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--border-2); font-weight: 700; }
.user-chip svg { width: 18px; height: 18px; color: var(--aqua); }
.container { max-width: 1280px; margin: 0 auto; padding: 28px; }
.home-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
.new-pin { margin-top: 18px; padding: 18px; border-radius: 14px; border: 1px solid var(--aqua-line); background: var(--aqua-bg); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.new-pin .pin { font: 700 30px var(--head); letter-spacing: .12em; }
.new-pin .acts { display: flex; gap: 8px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; font: 700 14px var(--font); color: var(--text-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; overflow-wrap: anywhere; }
tr.click { cursor: pointer; }
tr.click:hover td { background: rgba(52, 230, 212, .05); }
.table-wrap { overflow-x: auto; }
.pin-cell { font: 700 16px var(--head); letter-spacing: .08em; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.empty { padding: 28px 8px; text-align: center; color: var(--text-2); font-weight: 600; }

/* detail */
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.detail-id { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-width: 0; }
.detail-pin { font: 700 32px var(--head); letter-spacing: .1em; }
.detail-sub { margin-top: 10px; display: flex; gap: 18px; flex-wrap: wrap; color: var(--text-2); font-weight: 600; }
.detail-sub span { display: inline-flex; align-items: center; gap: 7px; }
.detail-sub svg { width: 17px; height: 17px; color: var(--aqua); }
.actions { display: flex; gap: 8px; }

.progress-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.stage-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.stage-name { font: 600 20px var(--head); }
.stage-pct { font: 700 30px var(--head); color: var(--aqua); }
.bar { height: 18px; border-radius: 999px; background: var(--field); border: 1px solid var(--border); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--aqua-2), var(--aqua)); transition: width .5s; }
.bar.lost > i { background: linear-gradient(90deg, #b8862b, var(--amber)); }
.timer { min-width: 170px; padding: 14px 18px; border-radius: 14px; border: 1px solid var(--border-2); background: var(--field); text-align: center; }
.timer .t { font: 700 30px/1.1 var(--head); letter-spacing: .04em; }
.timer .l { font-weight: 700; color: var(--text-2); margin-top: 4px; }
.timer.low .t { color: var(--amber); }
.lost-note { margin-top: 12px; color: var(--amber); font-weight: 700; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.seg { display: flex; gap: 6px; padding: 5px; border-radius: 14px; background: var(--field); border: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.seg-btn { flex: 1; min-width: 110px; height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 10px;
           background: transparent; color: var(--text-2); font: 700 15px var(--font); cursor: pointer; }
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--card-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-2); }

.findings { display: flex; flex-direction: column; gap: 10px; }
.finding { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--field); min-width: 0; }
.finding .ico { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 800 14px var(--font); }
.finding .name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.finding .src { font-size: 13px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--card-2); color: var(--text-2); }
.finding .why { margin-top: 6px; color: var(--text); font: 500 14px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; opacity: .92; }
.finding.info .ico { background: var(--card-2); color: var(--text); border: 1px solid var(--border-2); }
.finding.warning .ico { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber); cursor: help; }
.finding.detect { border-color: var(--red-line); background: var(--red-bg); }
.finding.detect .ico { background: #e8434f; color: #fff; }
.finding.detect .ico svg { width: 17px; height: 17px; }

details.block { border: 1px solid var(--border); border-radius: 14px; background: var(--field); margin-top: 10px; }
details.block > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer; font-weight: 700; }
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--aqua); border-bottom: 2px solid var(--aqua); transform: rotate(-45deg); transition: transform .15s; margin-right: 4px; }
details.block[open] > summary::before { transform: rotate(45deg); }
details.block .body { padding: 0 16px 16px; }
details.block .spacer { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { padding: 12px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--border); }
.stat .v { font: 600 17px var(--head); overflow-wrap: anywhere; }
.stat .l { font-weight: 600; color: var(--text-2); margin-top: 2px; }
details.tbl { margin-top: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
details.tbl > summary { padding: 11px 14px; cursor: pointer; font-weight: 700; }
details.tbl .table-wrap { max-height: 520px; overflow: auto; border-top: 1px solid var(--border); }
details.tbl td { font: 500 13.5px var(--mono); }

.timeline { max-height: 520px; overflow: auto; }
.tl-time { font: 600 14px var(--head); color: var(--aqua); margin: 12px 0 4px; }
.tl-time:first-child { margin-top: 0; }
.tl-ev { padding: 3px 0 3px 12px; border-left: 2px solid var(--border-2); }
.tl-ev.error { color: var(--red); border-left-color: var(--red-line); }
.tl-ev .n { color: var(--aqua); font-weight: 700; margin-left: 6px; }
.kv { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 8px 16px; }
.kv dt { font-weight: 700; color: var(--text-2); }
.kv dd { overflow-wrap: anywhere; }

@media (max-width: 1000px) {
    .home-grid, .detail-grid { grid-template-columns: 1fr; }
    .container { padding: 18px 16px; }
    .topbar { padding: 12px 16px; }
    .progress-card { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .pub-top { padding: 18px 16px; }
    h1 { font-size: 26px; }
    .os-row { grid-template-columns: minmax(0, 420px); }
    .os-card.active { order: -1; }
}
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.list-tools { display: flex; gap: 10px; flex: 1; justify-content: flex-end; min-width: 260px; }
.list-tools .search { flex: 1; max-width: 340px; }
.row-gap { display: inline-flex; align-items: center; gap: 10px; }
.pct { font: 700 15px var(--head); color: var(--aqua); }
.player-cell { font-weight: 700; white-space: nowrap; }
.new-pin .pin { color: var(--text); }
.new-pin .pin:hover { text-decoration: none; color: var(--aqua); }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--aqua); }
details.block.debug > summary svg { width: 18px; height: 18px; color: var(--aqua); }
