/* Цвета берутся из темы Telegram (applyTheme в app.js), здесь — запасные на случай обычного браузера */
:root {
  --bg: #ffffff; --text: #111418; --hint: #6b7480; --link: #2481cc; --btn: #2481cc; --btn-text: #ffffff;
  --bg2: #f1f3f6; --section: #ffffff; --line: rgba(0, 0, 0, .08); --danger: #d63c3c;
  --st-check: #e8890c; --st-question: #8a5cf6; --st-work: #2481cc; --st-new: #6b7480; --st-done: #2c9b5a;
  --st-draft: #c27a00; --st-paused: #8c95a0; --st-closed: #a0a7b0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17212b; --text: #f5f5f5; --hint: #8b9aa7; --link: #62bcf9; --btn: #5288c1; --btn-text: #ffffff;
    --bg2: #0e1621; --section: #17212b; --line: rgba(255, 255, 255, .08);
  }
}
* { box-sizing: border-box; }
input[type=radio] { accent-color: var(--btn); width: 18px; height: 18px; margin: 0; }
html, body { margin: 0; background: var(--bg2); color: var(--text); }
body { font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
main { max-width: 640px; margin: 0 auto; padding: 0 0 calc(24px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; }
a { color: var(--link); }
.hint { color: var(--hint); }
.center { text-align: center; padding: 48px 24px; }
.center h2 { font-size: 18px; margin: 0 0 8px; color: var(--text); }

/* шапка доски */
.top { position: sticky; top: 0; z-index: 2; background: var(--bg2); padding: 12px 16px 8px; }
.top-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.top h1 { font-size: 20px; margin: 0; }
.net { font-size: 12px; color: var(--hint); white-space: nowrap; }
.net::before { content: "●"; margin-right: 4px; color: var(--st-done); }
.net.off::before { color: var(--danger); }
.who { font-size: 13px; color: var(--hint); margin: 2px 0 10px; }
.search { width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: var(--section); color: var(--text); font: inherit; }
.search:focus { outline: 2px solid var(--btn); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; border-radius: 16px; padding: 6px 12px; background: var(--section); color: var(--text); font-size: 14px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--btn); color: var(--btn-text); }

/* разделы и строки задач */
.sec { margin: 12px 0 0; }
.sec > summary { list-style: none; cursor: pointer; padding: 6px 16px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--hint); }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary .n { font-weight: 400; margin-left: 4px; }
.sec:not([open]) > summary::after { content: " ›"; }
.list { background: var(--section); border-radius: 12px; margin: 0 12px; overflow: hidden; }
.row { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 11px 14px 11px 16px; border-top: 1px solid var(--line); cursor: pointer; position: relative; }
.row:first-child { border-top: 0; }
.row::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c, var(--st-new)); }
.row:active { background: var(--bg2); }
.row-head { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--hint); }
.code { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.row-title { margin: 2px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-meta { font-size: 13px; color: var(--c, var(--hint)); }
.empty { padding: 14px 16px; color: var(--hint); }

[data-st="check"] { --c: var(--st-check); } [data-st="question"] { --c: var(--st-question); }
[data-st="work"] { --c: var(--st-work); } [data-st="new"] { --c: var(--st-new); } [data-st="done"] { --c: var(--st-done); }
[data-st="draft"] { --c: var(--st-draft); } [data-st="paused"] { --c: var(--st-paused); }
[data-st="dup"], [data-st="rejected"] { --c: var(--st-closed); }

/* карточка задачи */
.bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg2); }
.back { border: 0; background: none; color: var(--link); font-size: 16px; padding: 4px 6px; cursor: pointer; }
.bar .code { font-size: 17px; }
.badge { margin-left: auto; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 12px; color: #fff; background: var(--c); white-space: nowrap; }
.box { background: var(--section); border-radius: 12px; margin: 10px 12px 0; padding: 14px 16px; }
.box h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .02em; color: var(--hint); }
.box h3:not(:first-child) { margin-top: 14px; }
.box p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.meta { font-size: 13px; color: var(--hint); margin-bottom: 8px; }
.banner { margin: 10px 12px 0; padding: 10px 14px; border-radius: 12px; font-size: 14px; background: color-mix(in srgb, var(--c) 14%, var(--section)); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); }
.where { display: inline-block; font-weight: 600; padding: 2px 8px; border-radius: 8px; margin-bottom: 4px; }
.where.live { background: color-mix(in srgb, var(--st-done) 18%, transparent); }
.where.test { background: color-mix(in srgb, var(--st-check) 20%, transparent); }
.result { background: color-mix(in srgb, var(--st-done) 10%, transparent); border-radius: 8px; padding: 8px 10px; }
.open-link { display: inline-block; margin-top: 6px; }
.media { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-top: 10px; }
.media button { border: 0; padding: 0; background: var(--bg2); border-radius: 8px; overflow: hidden; aspect-ratio: 1; cursor: zoom-in; }
.media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media video { width: 100%; border-radius: 8px; grid-column: 1 / -1; background: #000; }
.file-loading { display: grid; place-items: center; font-size: 12px; color: var(--hint); }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: grid; grid-template-columns: 92px 1fr; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.hist li:first-child { border-top: 0; }
.hist time { color: var(--hint); font-size: 13px; font-variant-numeric: tabular-nums; }
.hist .by { color: var(--hint); }

.viewer { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .92); display: grid; place-items: center; padding: 12px; }
.viewer[hidden] { display: none; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer button { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; border: 0; background: rgba(255, 255, 255, .15); color: #fff; font-size: 22px; width: 40px; height: 40px; border-radius: 20px; cursor: pointer; }

/* формы и действия */
.btn { border: 0; border-radius: 10px; padding: 11px 14px; font-weight: 600; cursor: pointer; background: var(--bg2); color: var(--text); display: inline-block; }
.btn.main { background: var(--btn); color: var(--btn-text); width: 100%; margin-top: 14px; }
.btn.ok { background: var(--st-done); color: #fff; flex: 1; }
.btn.warn { background: var(--st-check); color: #fff; flex: 1; }
.btn.ghost { background: transparent; color: var(--link); }
.btn:disabled { opacity: .6; }
.row-btns { display: flex; gap: 8px; align-items: center; }
.row-btns .btn.main { margin-top: 10px; flex: 1; }
.actions { margin: 10px 12px 0; }
.actions p { margin: 0 0 8px; }
.actions.sticky { position: sticky; bottom: 0; z-index: 2; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: var(--bg2); }
.panel { background: var(--section); border-radius: 12px; margin: 10px 12px 0; padding: 14px 16px; border: 1px solid var(--line); }
.panel h3, .form h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .02em; color: var(--hint); }
.form h3:not(:first-child) { margin-top: 16px; }
textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg2); border: 0; border-radius: 10px; padding: 10px 12px; resize: vertical; }
textarea:focus { outline: 2px solid var(--btn); }
.small { font-size: 13px; }
p.small { margin: -4px 0 8px; }
.chips.wrap { flex-wrap: wrap; overflow: visible; padding: 0; }
.chips.wrap .chip { background: var(--bg2); }
.chips.wrap .chip[aria-pressed="true"] { background: var(--btn); color: var(--btn-text); }
.choices { display: grid; gap: 6px; margin-bottom: 10px; }
.choice { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--bg2); cursor: pointer; }
.similar { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--st-check) 12%, transparent); font-size: 14px; display: grid; gap: 4px; }
.link { border: 0; background: none; padding: 0; color: var(--link); text-align: left; cursor: pointer; font-size: 14px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg2); display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .x { position: absolute; top: 4px; right: 4px; border: 0; width: 26px; height: 26px; border-radius: 13px; background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer; }
.fab { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 3; border: 0; border-radius: 24px; padding: 13px 22px;
  background: var(--btn); color: var(--btn-text); font-weight: 600; box-shadow: 0 4px 16px rgba(0, 0, 0, .2); cursor: pointer; }
main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.toast { position: fixed; left: 16px; right: 16px; top: calc(12px + env(safe-area-inset-top)); z-index: 11; padding: 12px 14px; border-radius: 12px;
  background: #1f2a36; color: #fff; text-align: center; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
.toast.bad { background: var(--danger); }
.toast[hidden] { display: none; }
[data-st="cancelled"] { --c: var(--st-closed); }

.grid-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-btns .btn { background: var(--section); color: var(--text); margin: 0; width: auto; }
.grid-btns .btn.main { grid-column: 1 / -1; background: var(--btn); color: var(--btn-text); }
.actions.owner .hint { margin: 8px 2px 0; }
[data-st="split"] { --c: var(--st-closed); }
.thumb > button { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; }
.btn.star { margin-top: 10px; background: var(--bg2); }
.btn.star.on { background: color-mix(in srgb, #f5b301 25%, var(--section)); }
.media.hero > :first-child { grid-column: 1 / -1; aspect-ratio: auto; max-height: 70vh; }
.media.hero > :first-child img { object-fit: contain; max-height: 70vh; background: var(--bg2); }
.media.hero > .thumb:first-child { min-height: 160px; }
.btn.open-page { display: block; text-align: center; text-decoration: none; margin: 12px 0 4px; }
[data-st="legacy"] { --c: var(--st-closed); }
.caution { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; background: color-mix(in srgb, var(--danger) 12%, var(--section)); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); }
.center-text { text-align: center; margin: 2px 0 6px; }

.asks { margin: 12px 12px 0; }
.asks h2 { font-size: 15px; margin: 6px 4px 8px; }
.ask { background: color-mix(in srgb, var(--st-question) 10%, var(--section)); border: 1px solid color-mix(in srgb, var(--st-question) 35%, transparent); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.ask.done { background: var(--section); border-color: var(--line); opacity: .85; }
.ask p { margin: 6px 0; white-space: pre-wrap; }
.ask form textarea { margin-top: 6px; }
.add-ask { margin: 4px 0 0; }
.asks .sec { margin: 6px 0 0; }
.asks .sec > summary { padding: 6px 4px; }
.box.value .value-num { display: block; font-size: 20px; margin: 4px 0 8px; }
.box.value input[type=range] { width: 100%; accent-color: var(--btn); }
.value-scale { display: grid; grid-template-columns: repeat(4, 1fr); font-size: 12px; color: var(--hint); text-align: center; margin-top: 4px; line-height: 1.3; }
.handover { display: flex; justify-content: space-between; gap: 8px; width: calc(100% - 24px); margin: 12px 12px 0; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--st-done) 45%, transparent);
  border-radius: 12px; background: color-mix(in srgb, var(--st-done) 12%, var(--section)); text-align: left; cursor: pointer; flex-wrap: wrap; }
.handover span { color: var(--hint); font-size: 14px; }
.progress { display: block; width: 100%; height: 8px; margin: 10px 0 4px; border: 0; border-radius: 4px; background: var(--bg2); overflow: hidden; accent-color: var(--st-done); appearance: none; }
.progress::-webkit-progress-bar { background: var(--bg2); border-radius: 4px; }
.progress::-webkit-progress-value { background: var(--st-done); border-radius: 4px; }
.progress::-moz-progress-bar { background: var(--st-done); }
.rate-list { margin-top: 8px; }
.rate-row { padding: 10px 14px; border-top: 1px solid var(--line); }
.rate-row:first-child { border-top: 0; }
.rate-row.empty { background: color-mix(in srgb, var(--st-check) 6%, transparent); }
.rate-row input[type=range] { width: 100%; accent-color: var(--btn); margin-top: 6px; }
.rate-row .row-head { justify-content: space-between; }
.value-num.small { font-size: 13px; }
