/* Reader — application stylesheet. System fonts only, light theme by default, dark via prefers-color-scheme. */

:root {
    --red: #d40000;
    --red-hover: #b80000;
    --red-soft: #fff1f1;
    --red-text: #c00000;
    --bg: #ffffff;
    --bg-alt: #fafafa;
    --bg-hover: #f5f5f5;
    --surface: #ffffff;
    --text: #1a1a1a;
    --text-strong: #000000;
    --muted: #6b6b6b;
    --muted-light: #9a9a9a;
    --border: #e6e6e6;
    --border-strong: #cfcfcf;
    --focus: #d40000;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    --ok: #1a7f37;
    --warn: #9a6700;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --topbar-h: 52px;
    --sidebar-w: 268px;
    --radius: 8px;
    --row-pad: 12px 16px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --red: #ff3b3b;
        --red-hover: #ff6262;
        --red-soft: #3a1414;
        --red-text: #ff5a5a;
        --bg: #151515;
        --bg-alt: #1b1b1b;
        --bg-hover: #222222;
        --surface: #1e1e1e;
        --text: #e8e8e8;
        --text-strong: #ffffff;
        --muted: #a0a0a0;
        --muted-light: #707070;
        --border: #2c2c2c;
        --border-strong: #444444;
        --focus: #ff3b3b;
        --shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
        --ok: #4cc26a;
        --warn: #e3b341;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--red-text); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

button, input, select, textarea { font: inherit; color: inherit; }

.mono, .meta { font-family: var(--mono); font-size: 12px; letter-spacing: 0.01em; }

.skip-link {
    position: absolute; left: -9999px; top: 8px; z-index: 100;
    background: var(--red); color: #fff; padding: 8px 12px; border-radius: var(--radius);
}
.skip-link:focus { left: 8px; }

[hidden] { display: none !important; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- buttons & forms ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius); border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
    font-weight: 500; line-height: 1.2; min-height: 40px;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn-outline { border-color: var(--text); }
.btn-danger { color: var(--red-text); border-color: var(--red-text); }
.btn-danger:hover { background: var(--red-soft); }
.btn-block { width: 100%; }
.btn-small { padding: 5px 10px; min-height: 30px; font-size: 14px; }
.btn-text { border-color: transparent; background: transparent; color: var(--red-text); }
.btn-text:hover { background: var(--red-soft); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: default; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; color: var(--text);
}
.icon-btn:hover { background: var(--bg-hover); }

.form label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: 14px; }
.form input[type="text"], .form input[type="email"], .form input[type="password"], .form input[type="url"],
.form input[type="number"], .form select, .form textarea, .input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--text);
}
.form input:focus, .form select:focus, .form textarea:focus, .input:focus { border-color: var(--red); outline: 2px solid var(--red); outline-offset: 0; }
.form button, .form .btn { margin-top: 18px; }
.form .check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-top: 12px; }
.form .check input { width: 18px; height: 18px; }
.form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px 16px; margin: 20px 0; }
.form legend { padding: 0 6px; font-weight: 600; }
.form-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.form-inline label { margin: 0 0 4px; }
.form-inline input, .form-inline select { width: auto; min-width: 180px; }
.form-inline .btn { margin-top: 0; }
.input-code { font-family: var(--mono); font-size: 24px; letter-spacing: 0.3em; text-align: center; }
.input-small { width: 90px !important; }
.hint { color: var(--muted); font-size: 14px; }
.msg { padding: 10px 14px; border-radius: var(--radius); margin: 12px 0; font-size: 15px; }
.msg-error { background: var(--red-soft); color: var(--red-text); border: 1px solid var(--red-text); }
.msg-info { background: var(--bg-alt); border: 1px solid var(--border); }

/* ---------- server pages (auth, install, tech) ---------- */

.auth-main { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px 28px 20px; }
.auth-card h2 { margin: 6px 0 10px; font-size: 22px; }
.auth-links { margin-top: 20px; font-size: 14px; }
.brand { font-weight: 800; letter-spacing: -0.02em; color: var(--red); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-large { font-size: 26px; margin: 0 0 4px; }
.lang-switch { margin-top: 18px; font-size: 13px; color: var(--muted); }
.lang-switch a { margin-right: 8px; color: var(--muted); }
.lang-switch a.current { color: var(--red-text); font-weight: 600; }

.tech-header { display: flex; align-items: center; gap: 20px; padding: 10px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tech-nav { display: flex; gap: 14px; flex-wrap: wrap; }
.tech-nav a { color: var(--text); font-size: 15px; padding: 4px 0; }
.tech-user { margin-left: auto; color: var(--muted); font-size: 14px; }
.tech-main { padding: 20px; max-width: 1200px; }
.tech-main h1 { font-size: 24px; margin: 0 0 16px; }
.tech-main h2 { font-size: 18px; margin: 28px 0 10px; }
.table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; }
.table td.ok { color: var(--ok); }
.table td.ko { color: var(--red-text); }
.table-wrap { overflow-x: auto; }
.table .actions { white-space: nowrap; }
.table .actions form { display: inline-block; margin: 2px 2px 2px 0; }
.inline { display: inline; }
.code { background: var(--bg-alt); border: 1px solid var(--border); padding: 12px; border-radius: var(--radius); overflow-x: auto; font-family: var(--mono); font-size: 13px; }
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; background: var(--surface); }
.card summary { cursor: pointer; }
.status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-family: var(--mono); background: var(--bg-alt); border: 1px solid var(--border); }
.status-error, .status-dead { color: var(--red-text); border-color: var(--red-text); background: var(--red-soft); }
.status-ok { color: var(--ok); }

/* ---------- application layout ---------- */

body.app { overflow-x: hidden; }

.layout { min-height: 100vh; }

.topbar {
    position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 30;
    display: flex; align-items: center; gap: 8px; padding: 0 8px 0 4px;
    background: var(--bg); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-size: 20px; padding: 0 8px; display: none; }
.topbar-title { flex: 1; margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.topbar-search { display: none; }
@media (min-width: 900px) {
    .topbar-search { display: block; width: 320px; margin-right: 12px; }
    .topbar-search input { width: 100%; padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--bg-alt); color: var(--text); font-size: 14px; }
    .topbar-search input:focus { border-color: var(--red); outline: 2px solid var(--red); outline-offset: 0; background: var(--surface); }
    #btn-search { display: none; }
}
.search-page .form-inline { margin: 8px 0 16px; }
.search-page .form-inline input { flex: 1; min-width: 0; }
.row.is-highlight .row-title::after { content: " ★"; color: var(--red); font-size: 12px; vertical-align: super; }
.row.is-highlight .row-meta .feed { color: var(--red-text); font-weight: 600; }
.rules-list { list-style: none; margin: 0; padding: 0; }
.rules-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.rules-list li .rule-type { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 130px; }
.rules-list li .rule-value { flex: 1; }
.file-input { display: none; }
.menu-wrap { position: relative; }
.menu {
    position: absolute; right: 0; top: 44px; min-width: 260px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; z-index: 40;
}
.menu button, .menu a {
    display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; color: var(--text); font-size: 15px;
}
.menu button:hover, .menu a:hover { background: var(--bg-hover); text-decoration: none; }
.menu .menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu .menu-label { padding: 6px 12px 2px; font-size: 12px; color: var(--muted); font-family: var(--mono); text-transform: uppercase; }

.sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(var(--sidebar-w), 88vw); z-index: 50;
    background: var(--surface); border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform 0.22s ease; display: flex; flex-direction: column;
    padding: 0 12px 12px; overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 45; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); }
.sidebar-title { font-weight: 700; font-size: 17px; }
.sidebar > .btn { margin: 4px 0 12px; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot a { color: var(--text); padding: 6px 4px; font-size: 15px; }
.sidebar-foot a:first-child { font-weight: 600; }

.nav-tree { display: flex; flex-direction: column; }
.nav-item {
    display: flex; align-items: center; gap: 8px; padding: 9px 8px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 15px;
}
.nav-item:hover { background: var(--bg-hover); text-decoration: none; }
.nav-item.active { background: var(--red-soft); color: var(--red-text); font-weight: 600; }
.nav-item .count { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.nav-item.active .count { color: var(--red-text); }
.nav-item.is-error .label::after { content: " !"; color: var(--red-text); font-weight: 700; }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-section { display: flex; align-items: center; margin: 14px 8px 4px; font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.nav-topic { display: flex; align-items: center; }
.nav-topic .nav-item { flex: 1; font-weight: 600; }
.nav-topic .toggle { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 6px; flex: none; }
.nav-topic .toggle::before { content: "▸"; display: inline-block; transition: transform 0.15s; }
.nav-topic.open .toggle::before { transform: rotate(90deg); }
.nav-topic-feeds { display: none; flex-direction: column; padding-left: 22px; }
.nav-topic.open + .nav-topic-feeds { display: flex; }
.nav-topic-feeds .nav-item { font-size: 14px; padding: 7px 8px; }
.nav-empty { color: var(--muted); font-size: 14px; padding: 10px 8px; }

.main { padding-top: var(--topbar-h); min-height: 100vh; }
.main:focus { outline: none; }

@media (min-width: 900px) {
    .topbar { padding-left: 16px; }
    .topbar .brand { display: inline-block; }
    #btn-menu, #btn-close-menu { display: none; }
    .sidebar { top: var(--topbar-h); transform: none; z-index: 20; width: var(--sidebar-w); padding-top: 12px; }
    .sidebar-head { display: none; }
    .backdrop { display: none !important; }
    .main { margin-left: var(--sidebar-w); }
}

/* ---------- river of news ---------- */

.river { max-width: 1100px; }
.river-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px 6px; color: var(--muted); font-size: 13px; font-family: var(--mono); }
.river-head .spacer { flex: 1; }
.river-empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.river-list { list-style: none; margin: 0; padding: 0; }

.row {
    position: relative; border-bottom: 1px solid var(--border); background: var(--bg); overflow: hidden;
}
.row-inner {
    display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: start; gap: 0 4px; padding: 10px 12px 10px 4px; cursor: pointer;
    background: var(--bg); position: relative; touch-action: pan-y;
}
.row.is-expanded > .row-inner { background: var(--bg-alt); }
.row-inner:hover { background: var(--bg-hover); }
.row .star-btn {
    width: 36px; height: 36px; border: 0; background: transparent; cursor: pointer; color: var(--muted-light); font-size: 18px; line-height: 1; border-radius: 50%; margin-top: -2px;
}
.row .star-btn:hover { color: var(--red); background: var(--red-soft); }
.row.is-starred .star-btn { color: var(--red); }
.row-main { min-width: 0; }
.row-meta { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.row-meta .feed { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta .time { margin-left: auto; flex: none; }
.row-meta .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); flex: none; }
.row.is-read .row-meta .dot { visibility: hidden; }
.row-title { font-weight: 600; font-size: 16px; line-height: 1.3; color: var(--text-strong); overflow-wrap: anywhere; }
.row.is-read .row-title { color: var(--muted); font-weight: 500; }
.row.is-expanded .row-title { color: var(--text-strong); font-weight: 700; }
.row.is-current > .row-inner { box-shadow: inset 3px 0 0 var(--red); }

/* swipe feedback (mobile) */
.row .swipe-under {
    position: absolute; inset: 0; display: flex; align-items: center; padding: 0 20px; font-weight: 700; color: #fff; font-size: 15px; opacity: 0;
}
.row .swipe-under.left { justify-content: flex-end; background: var(--red); }
.row .swipe-under.right { justify-content: flex-start; background: #2a2a2a; }
.row.swiping .swipe-under.visible { opacity: 1; }
.row .row-inner.dragging { transition: none; }
.row .row-inner { transition: transform 0.18s ease; }

@media (min-width: 900px) {
    .row-inner { grid-template-columns: 40px 10px 150px minmax(0, 1fr) 70px; align-items: center; padding: 9px 16px 9px 8px; gap: 0 10px; }
    .row-meta { display: contents; }
    .row-meta .dot { order: 1; width: 7px; height: 7px; }
    .row-meta .feed { order: 2; }
    .row-meta .time { order: 4; text-align: right; margin-left: 0; }
    .row-title { order: 3; font-size: 15px; font-weight: 600; }
    .row-main { display: contents; }
    .row.is-read .row-inner .feed, .row.is-read .row-inner .time { color: var(--muted-light); }
}

.row-body { padding: 4px 16px 18px 52px; }
@media (max-width: 899px) { .row-body { padding-left: 44px; } }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.item-content { font-size: 16px; line-height: 1.55; max-width: 72ch; overflow-wrap: anywhere; }
.item-content p { margin: 0 0 1em; }
.item-content h3, .item-content h4 { font-size: 1.05em; margin: 1.2em 0 0.5em; color: var(--text-strong); }
.item-content blockquote { margin: 1em 0; padding-left: 14px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.item-content pre { background: var(--bg-alt); border: 1px solid var(--border); padding: 12px; border-radius: var(--radius); overflow-x: auto; font-size: 13px; }
.item-content code { font-family: var(--mono); font-size: 0.92em; }
.item-content ul, .item-content ol { padding-left: 24px; }
.item-content a { text-decoration: underline; }
.item-content .truncated { color: var(--muted); font-size: 14px; border: 1px dashed var(--border-strong); padding: 10px 12px; border-radius: var(--radius); }

.river-sentinel { height: 1px; }
.river-loading { padding: 20px; text-align: center; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.river-end { padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- item screen (mobile) ---------- */

.item-screen { max-width: 760px; padding: 0 16px 100px; }
.item-screen-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; margin: 0 -4px; }
.item-screen-head .back { color: var(--red-text); font-weight: 500; padding: 8px 4px; }
.item-screen-head .position { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.item-screen .meta { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 16px 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.item-screen h2 { font-size: 24px; line-height: 1.2; margin: 0 0 16px; color: var(--text-strong); overflow-wrap: anywhere; }
.item-screen .btn-read { width: 100%; margin: 24px 0 12px; font-size: 16px; padding: 14px; }
.item-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; font-size: 14px; }
.item-nav a, .item-nav button { color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 8px 12px; background: var(--surface); cursor: pointer; flex: 1; text-align: center; }
.item-nav a:hover, .item-nav button:hover { background: var(--bg-hover); text-decoration: none; }
.item-nav .next { text-align: right; }
.item-nav [aria-disabled="true"] { opacity: 0.4; pointer-events: none; }
.item-actions {
    position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: center;
    background: var(--bg); border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 25;
}
.item-actions button { border: 0; background: transparent; color: var(--text); padding: 10px 12px; font-size: 14px; cursor: pointer; border-radius: var(--radius); display: flex; align-items: center; gap: 6px; }
.item-actions button:hover { background: var(--bg-hover); }
.item-actions .star { font-size: 20px; color: var(--muted-light); }
.item-actions .star.is-starred { color: var(--red); }
@media (min-width: 900px) { .item-actions { left: var(--sidebar-w); } }

/* ---------- subscriptions ---------- */

.page-inner { max-width: 760px; padding: 12px 16px 60px; }
.page-inner h2 { font-size: 22px; margin: 8px 0 16px; }
.page-inner h3 { font-size: 16px; margin: 24px 0 8px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-head .btn { margin: 0; }
.sub-count { font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 12px 0 6px; text-transform: uppercase; }
.sub-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.sub-row { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.sub-row:hover { background: var(--bg-hover); }
.sub-row .sub-main { flex: 1; min-width: 0; }
.sub-row .sub-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-row .sub-meta { font-family: var(--mono); font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-row.is-error { background: var(--red-soft); }
.sub-row.is-error .sub-title, .sub-row.is-error .sub-meta { color: var(--red-text); }
.sub-row .chevron { color: var(--muted-light); }
.sub-row .unread { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
    border: 1px solid var(--border-strong); border-radius: 999px; padding: 6px 12px; background: var(--surface); cursor: pointer; font-size: 14px; color: var(--text);
}
.chip[aria-pressed="true"] { background: var(--text-strong); color: var(--bg); border-color: var(--text-strong); }
.chip-new { border-style: dashed; }
.candidates { list-style: none; margin: 8px 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.candidates li { border-bottom: 1px solid var(--border); }
.candidates li:last-child { border-bottom: 0; }
.candidates label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; font-weight: 500; }
.candidates .url { font-family: var(--mono); font-size: 12px; color: var(--muted); display: block; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; background: var(--bg-alt); }
.preview .sub-count { margin: 0 0 6px; }
.preview p { margin: 4px 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-label { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 20px 0 6px; }

.feed-sheet dl { margin: 0; border-top: 1px solid var(--border); }
.feed-sheet .setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.feed-sheet .setting dt { font-weight: 500; }
.feed-sheet .setting dd { margin: 0; color: var(--muted); text-align: right; }
.feed-sheet .setting input[type="text"] { text-align: right; border: 0; background: transparent; width: 55%; padding: 4px 0; }
.feed-sheet .setting input[type="text"]:focus { outline: 2px solid var(--red); border-radius: 4px; }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; vertical-align: middle; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background 0.15s; }
.switch span::after { content: ""; position: absolute; width: 20px; height: 20px; top: 3px; left: 3px; background: #fff; border-radius: 50%; transition: transform 0.15s; }
.switch input:checked + span { background: var(--red); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.topic-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.topic-list li { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.topic-list input { flex: 1; border: 1px solid transparent; background: transparent; padding: 6px 8px; border-radius: 6px; }
.topic-list input:hover, .topic-list input:focus { border-color: var(--border-strong); background: var(--surface); }
.topic-list .drag { color: var(--muted-light); cursor: grab; font-size: 18px; padding: 0 4px; }
.topic-list li.drag-over { border-top: 2px solid var(--red); }

/* ---------- settings ---------- */

.settings-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px 12px; margin: 16px 0; }
.settings-group h3 { margin: 12px 0 8px; }
.devices { list-style: none; margin: 0; padding: 0; }
.devices li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.devices li:last-child { border-bottom: 0; }
.devices .current { color: var(--ok); font-family: var(--mono); font-size: 12px; }
.kbd-list { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24px; }
.kbd-list li { padding: 6px 0; font-size: 15px; break-inside: avoid; }
kbd { font-family: var(--mono); background: var(--bg-alt); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 7px; font-size: 13px; }

/* ---------- toasts, dialogs ---------- */

.toast-area { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 480px); pointer-events: none; }
.toast {
    pointer-events: auto; background: #1f1f1f; color: #fff; border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 14px; font-size: 15px; width: 100%;
}
@media (prefers-color-scheme: dark) { .toast { background: #f0f0f0; color: #111; } }
.toast.error { background: var(--red); color: #fff; }
.toast button { margin-left: auto; border: 0; background: transparent; color: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 4px; }

.dialog-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--surface); border-radius: 12px; padding: 20px; max-width: 440px; width: 100%; box-shadow: var(--shadow); }
.dialog h3 { margin: 0 0 10px; }
.dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.shortcut-hint { display: none; }
@media (min-width: 900px) {
    .shortcut-hint { display: block; position: fixed; bottom: 0; left: var(--sidebar-w); right: 0; padding: 6px 16px; font-family: var(--mono); font-size: 11px; color: var(--muted-light); background: var(--bg); border-top: 1px solid var(--border); z-index: 10; }
}

.noscript { padding: 40px; text-align: center; }

/* ---------- icons (inline SVG in the shell, currentColor) ---------- */

.icon { display: inline-block; width: 22px; height: 22px; }
.icon svg { width: 100%; height: 100%; display: block; }
.icon-btn.spinning .icon { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

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