:root {
  --bg: #e9ecf1; --frame: #ffffff; --card: #f6f7f9; --fg: #1d2129; --muted: #6b7280; --line: #e1e4e9;
  --accent: #2563eb; --accent-fg: #fff; --accent-soft: rgba(37, 99, 235, .12);
  --danger: #c62828; --live: #d32f2f;
  --ok-bg: #e7f6ec; --ok-fg: #1b5e20; --err-bg: #fdecea; --err-fg: #8e1c1c;
  --shadow: 0 10px 40px rgba(20, 30, 50, .12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114; --frame: #181b20; --card: #20242b; --fg: #e6e8eb; --muted: #9aa1ab; --line: #2c3038;
    --accent: #4f8cff; --accent-soft: rgba(79, 140, 255, .16); --danger: #ef5350; --live: #ff5252;
    --ok-bg: #173323; --ok-fg: #9be3b0; --err-bg: #3a1c1c; --err-fg: #ffb4ab;
    --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body:has(.shell) { overflow: hidden; }
body { margin: 0; background: var(--bg); color: var(--fg); -webkit-text-size-adjust: 100%;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

/* ---------- фиксированный блок по центру ---------- */
.shell { max-width: 980px; height: calc(100dvh - 32px); margin: 16px auto;
  display: flex; flex-direction: column; background: var(--frame);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }

/* ---------- шапка: станция, эфир ---------- */
.bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.station-wrap { position: relative; min-width: 0; flex: 0 1 auto; }
.station { display: flex; align-items: center; gap: 12px; background: none; color: var(--fg); padding: 4px 8px 4px 4px;
  border-radius: 12px; text-align: left; min-width: 0; max-width: 100%; }
.station:hover { background: var(--card); }
.logo { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex: none; background: var(--card); }
.logo.sm { width: 36px; height: 36px; border-radius: 9px; }
.logo-ph { display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
  font-size: 22px; color: var(--accent); }
.logo.sm.logo-ph { font-size: 16px; }
.st-text { display: flex; flex-direction: column; min-width: 0; }
.st-name { font-weight: 650; line-height: 1.25; }
.caret { color: var(--muted); font-size: 12px; }
.st-meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-meta .on-air { color: var(--live); }
.st-menu { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 280px; max-width: 92vw;
  background: var(--frame); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
.st-menu form { margin: 0; }
.st-item { display: flex; align-items: center; gap: 10px; width: 100%; background: none; color: var(--fg);
  padding: 8px; border-radius: 8px; text-align: left; }
.st-item:hover, .st-item.cur { background: var(--accent-soft); }
.st-item span:not(.logo) { flex: 1; }
.tick { flex: none !important; color: var(--accent); font-weight: 700; }

.live-btn { display: inline-flex; align-items: center; gap: 8px; flex: none; border-radius: 999px;
  padding: 10px 18px 10px 14px; font-weight: 600; white-space: nowrap; }
.live-btn .i-pause, .live-btn .i-wait { display: none; }
.live-btn.playing .i-play, .live-btn.loading .i-play { display: none; }
.live-btn.playing .i-pause, .live-btn.loading .i-wait { display: inline; }
.live-btn.playing { background: var(--live); }
.clock { font-size: 30px; font-weight: 600; line-height: 1; letter-spacing: .02em; flex: none;
  font-variant-numeric: tabular-nums; color: var(--fg); padding: 0 4px; }
.logout { margin-left: auto; }

/* идущая запись: таймер */
.rec-item + .rec-item { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.rec-meta { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 6px; }
.rec-timer { margin: 8px 0 12px; }
.rec-nums { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.rec-nums span { display: flex; flex-direction: column; }
.rec-nums .right { text-align: right; align-items: flex-end; }
.rec-nums small { font-size: 12px; color: var(--muted); }
.rec-nums b { font-size: 26px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.rec-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 8px; }
.rec-bar div { height: 100%; width: 0; background: var(--live); transition: width 1s linear; }

/* действия с файлом: крупные и разнесённые, чтобы не промахиваться */
.file-acts { flex: 1 0 100%; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 18px;
  padding-left: 30px; margin-top: 6px; }
.file-acts form { margin: 0; }
.act { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; font-size: 14px;
  background: var(--accent-soft); color: var(--accent); text-decoration: none; cursor: pointer; border: 0;
  font-weight: 550; white-space: nowrap; list-style: none; }
.act::-webkit-details-marker { display: none; }
.act.primary { background: var(--accent); color: var(--accent-fg); }
.act.done { background: var(--ok-bg); color: var(--ok-fg); }
.act-menu[open] { flex: 1 0 100%; }
.act-menu[open] > summary { margin-bottom: 8px; }
.act-menu form { max-width: 520px; }

/* ---------- вкладки ---------- */
.tabs { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: transparent; color: var(--muted); font-weight: 600; padding: 9px 6px;
  border-radius: 10px; transition: background .25s, color .25s; white-space: nowrap; }
.tabs button:hover { background: var(--card); }
.tabs button.on { background: var(--accent); color: var(--accent-fg); }
.tabs .cnt { font-weight: 500; opacity: .7; font-size: 13px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--live);
  vertical-align: middle; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- книга: листы едут вбок ---------- */
.book { flex: 1; position: relative; overflow: hidden; }
.track { display: flex; height: 100%; transition: transform .55s cubic-bezier(.77, 0, .18, 1); will-change: transform; }
.track[data-page="records"] { transform: translateX(-100%); }
.track[data-page="clips"] { transform: translateX(-200%); }
.page { flex: 0 0 100%; height: 100%; overflow-y: auto; overflow-x: hidden; padding: 16px;
  overscroll-behavior: contain; transition: opacity .55s, transform .55s cubic-bezier(.77, 0, .18, 1); }
.track.turning .page { opacity: .55; transform: scale(.97); }
.track.turning .page.current { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .track, .page { transition: none; } }

.toasts { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 5;
  width: min(92%, 560px); pointer-events: none; }
.toasts .flash { box-shadow: var(--shadow); transition: opacity .4s, transform .4s; pointer-events: auto; }
.toasts .flash.hide { opacity: 0; transform: translateY(-10px); }

/* ---------- общие элементы ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 14px; }
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card.narrow { width: 100%; max-width: 360px; background: var(--frame); box-shadow: var(--shadow); }
h1, h2, h3 { margin: 0 0 12px; } h2 { font-size: 18px; } h3 { font-size: 15px; margin-top: 18px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.live { color: var(--live); font-weight: 600; }
.err-text { color: var(--danger); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-fg); }
.flash.err { background: var(--err-bg); color: var(--err-fg); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 8px 0; }
.stack { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
/* 16px в полях — иначе iOS увеличивает страницу при фокусе */
input, select { font: inherit; font-size: 16px; color: var(--fg); background: var(--frame); padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; min-width: 0; max-width: 100%; }
input[type="checkbox"] { width: 20px; height: 20px; flex: none; }
button { font: inherit; padding: 9px 14px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: var(--accent-fg); touch-action: manipulation; }
button.small { padding: 5px 10px; font-size: 13px; }
button.ghost { background: var(--accent-soft); color: var(--accent); }
button.danger { background: var(--danger); color: #fff; }
button.link { background: none; color: var(--accent); padding: 0; }
button.link.danger { color: var(--danger); background: none; }
button.wide { width: 100%; }
button:disabled { opacity: .45; cursor: default; }
details summary { cursor: pointer; color: var(--accent); }
details.inline { display: inline-block; }
code { background: var(--frame); padding: 1px 5px; border-radius: 4px; }

/* спойлеры-карточки */
details.spoiler > summary { list-style: none; display: flex; align-items: center; gap: 10px; color: var(--fg); }
details.spoiler > summary::-webkit-details-marker { display: none; }
details.spoiler > summary::before { content: "▸"; color: var(--accent); transition: transform .2s; }
details.spoiler[open] > summary::before { transform: rotate(90deg); }
details.spoiler > summary h2 { margin: 0; }
details.spoiler[open] > summary { margin-bottom: 12px; }
.spoiler-inline { margin-top: 14px; }
details.spoiler > summary .muted { margin-left: auto; text-align: right; }
.cnt-badge { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 11px; font-size: 13px;
  background: var(--accent); color: var(--accent-fg); text-align: center; vertical-align: middle; }
.stream-act { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.steps { padding-left: 20px; margin: 6px 0 10px; } .steps li { margin: 4px 0; }
textarea { font: 13px/1.4 ui-monospace, Consolas, monospace; color: var(--fg); background: var(--frame);
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; width: 100%; resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--fg); font-size: 14px; margin: 6px 0 10px; }
.file-act form { margin: 0; }
.file-act form button.small { white-space: nowrap; }
.rec-now { border-color: var(--live); }

/* ---------- расписание ---------- */
.sched { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 18px; align-items: start; }
.sched-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.times input { width: 100%; }
.sched-side select, .sched-side input { width: 100%; }
.summary { margin: 2px 0; font-weight: 600; min-height: 1.4em; }
.js .nojs-date { display: none; }
.cal { background: var(--frame); border: 1px solid var(--line); border-radius: 12px; padding: 10px; user-select: none; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 650; }
.cal-head button { width: 40px; height: 40px; padding: 0; font-size: 22px; line-height: 1;
  background: var(--accent-soft); color: var(--accent); border-radius: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-wd { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-wd.we { color: var(--danger); opacity: .8; }
.cal-day { position: relative; aspect-ratio: 1; min-height: 38px; max-height: 52px; padding: 0; border-radius: 10px;
  background: transparent; color: var(--fg); font-size: 15px; }
.cal-day.we { color: var(--danger); }
.cal-day:hover:not(:disabled) { background: var(--accent-soft); }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-day.sel { background: var(--accent); color: var(--accent-fg); }
.cal-day.busy::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 5px; height: 5px;
  margin-left: -2.5px; border-radius: 50%; background: var(--live); }
.cal-day:disabled { opacity: .3; }
.jobs, .streams, .files, .log { list-style: none; padding: 0; margin: 0 0 12px; }
.jobs li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.grow { flex: 1; min-width: 0; }

/* ---------- станции, журнал ---------- */
.streams li { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--line);
  border-radius: 8px; }
.streams li.cur { background: var(--accent-soft); }
.streams .url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--accent); color: var(--accent-fg); }
.log li { padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; }

/* ---------- списки файлов ---------- */
.files li { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 8px; border-bottom: 1px solid var(--line);
  border-radius: 8px; }
.files li:has(> input[type="checkbox"]) .file-acts { padding-left: 30px; }
.files li:not(:has(> input[type="checkbox"])) .file-acts { padding-left: 0; }
.files li.sel { background: var(--accent-soft); }
.files li.fresh { animation: fresh 2.4s ease-out 2; }
@keyframes fresh { 0%, 30% { background: color-mix(in srgb, var(--accent) 40%, transparent); } 100% { background: var(--accent-soft); } }
.play-link { display: flex; flex-direction: column; text-decoration: none; color: var(--fg); min-width: 0; }
.play-link .fname { color: var(--accent); font-weight: 550; overflow-wrap: anywhere; }
.file-act { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.file-act a { color: var(--accent); text-decoration: none; }
.file-act details[open] { position: relative; }
.file-act details form { min-width: 220px; }

/* ---------- плеер ---------- */
.player-card { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.pl audio { display: none; }
.pl-title { font-weight: 650; font-size: 16px; overflow-wrap: anywhere; }
.pl-sub { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.scrub { position: relative; height: 44px; cursor: pointer; touch-action: none; outline: none; }
.scrub-rail { position: absolute; left: 0; right: 0; top: 50%; height: 8px; margin-top: -4px;
  border-radius: 4px; background: var(--line); overflow: hidden; }
.scrub-fill { height: 100%; width: 0; background: var(--accent); }
.scrub-thumb { position: absolute; top: 50%; left: 0; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border-radius: 50%; background: var(--frame); border: 3px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform .15s; }
.scrub:focus-visible .scrub-thumb, .pl.dragging .scrub-thumb { transform: scale(1.2); }
.pl.fine .scrub-thumb { border-color: var(--live); }
.pl.fine .scrub-fill { background: var(--live); }
.scrub-tip { position: absolute; bottom: 100%; left: 0; transform: translateX(-50%); padding: 3px 8px;
  border-radius: 6px; background: var(--fg); color: var(--frame); font-size: 13px; font-variant-numeric: tabular-nums;
  opacity: 0; pointer-events: none; transition: opacity .15s; white-space: nowrap; }
.pl.dragging .scrub-tip { opacity: 1; }
.pl-times { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-variant-numeric: tabular-nums; font-size: 14px; }
.pl-hint { font-size: 12px; color: var(--muted); text-align: center; }
.pl.fine .pl-hint { color: var(--live); font-weight: 600; }
.pl-ctrl { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 10px; }
.pl-ctrl .ghost { min-width: 76px; padding: 10px 12px; font-weight: 600; }
.pl-ctrl .big { width: 60px; height: 60px; border-radius: 50%; font-size: 20px; padding: 0; }
.pl .i-pause { display: none; }
.pl.playing .i-play { display: none; }
.pl.playing .i-pause { display: inline; }

/* нарезка */
.cut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin-bottom: 10px; }
.cut-grid input { width: 100%; }
#cutform > label input { width: 100%; }
.cut-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.cut-actions button { flex: 1; min-width: 160px; }

/* ---------- телефон ---------- */
@media (max-width: 720px) {
  .sched { grid-template-columns: minmax(0, 420px); justify-content: center; }
}
@media (max-width: 640px) {
  .shell { height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .bar { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .station-wrap { flex: 1 0 calc(100% - 70px); }
  .logo { width: 44px; height: 44px; }
  .live-btn { order: 3; flex: 1 1 auto; justify-content: center; }
  .clock { order: 4; font-size: 26px; }
  .logout { margin-left: 0; }
  .file-acts, .files li:has(> input[type="checkbox"]) .file-acts { padding-left: 0; gap: 10px 14px; }
  .tabs { padding: 6px 8px; gap: 4px; }
  .tabs button { padding: 8px 4px; font-size: 14px; }
  .page { padding: 10px; }
  .card { padding: 12px; }
  .row > label, .row > button { width: 100%; }
  .row > label input { width: 100%; }
  .st-menu { position: fixed; top: 64px; left: 8px; right: 8px; min-width: 0; max-width: none; }
  .file-act { align-items: flex-end; }
  .file-act details[open] form { position: static; }
  .file-act details form { min-width: 0; }
  .files li { flex-wrap: wrap; }
  .files li:has(details[open]) .file-act { flex: 1 0 100%; align-items: stretch; }
  .pl-hint { display: none; }
}
