:root {
  --bg: #F3F5F7;
  --surface: #FFFFFF;
  --ink: #18212D;
  --muted: #66707C;
  --line: #DDE2E8;
  --accent: #F5B700;
  --accent-press: #DCA400;
  --accent-ink: #231A00;
  --ok: #2E8A57;
  --err: #C2412D;
  --radius-lg: 14px;
  --radius-sm: 8px;
  --pad: 16px;
  font-family: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; font-size: 16px; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 500; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.error-text { color: var(--err); font-size: 14px; min-height: 1.2em; margin: 6px 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* вход */
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--pad); }
.login-box { width: 100%; max-width: 340px; display: grid; gap: 8px; }
.login-box h1 { margin-bottom: 20px; }
.login-box label { font-size: 14px; color: var(--muted); }

input, select, textarea {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 12px; width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; }

.btn {
  font: inherit; font-weight: 600; border: 0; cursor: pointer;
  border-radius: var(--radius-sm); padding: 12px 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; color: var(--ink); min-height: 46px;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:active { background: var(--accent-press); }
.btn-quiet { background: transparent; border: 1px solid var(--line); font-weight: 500; }
.btn-quiet:active { background: var(--line); }
.btn-small { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 40px; height: 40px; border-radius: var(--radius-sm); font-size: 16px;
}
.icon-btn:active { background: var(--line); }

/* шапка */
.top {
  max-width: 760px; margin: 0 auto; padding: 18px var(--pad) 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.tabs { display: flex; gap: 2px; background: var(--line); border-radius: 10px; padding: 3px; }
.tabs button {
  font: inherit; font-size: 14px; font-weight: 500; border: 0; background: transparent;
  color: var(--muted); padding: 7px 12px; border-radius: 8px; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); }

main { max-width: 760px; margin: 0 auto; padding: 0 var(--pad) 120px; }
main section { margin-top: 28px; }
main section > h2 { margin-bottom: 12px; }

/* состояние службы */
.status { margin-top: 10px; font-size: 15px; }
.status-line { display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.busy { background: var(--accent); }
.dot.down { background: var(--err); }
.bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ink); width: 0; transition: width .4s ease; }

/* очередь и ошибки */
.list { background: var(--surface); border-radius: var(--radius-lg); }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-top: 1px solid var(--line); min-height: 56px;
}
.list-row:first-child { border-top: 0; }
.list-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.list-row .meta { color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list-row.err { flex-wrap: wrap; }
.list-row.err .why { flex-basis: 100%; color: var(--err); font-size: 14px; overflow-wrap: anywhere; }
.list-row .actions { display: flex; gap: 6px; }
.mini-bar { flex-basis: 100%; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.mini-bar > i { display: block; height: 100%; background: var(--accent); }

/* готовые: исходник и полоса из версий */
.day { margin-bottom: 26px; }
.day-title { color: var(--muted); font-size: 14px; margin: 0 0 10px; font-weight: 500; }
.source { background: var(--surface); border-radius: var(--radius-lg); padding: 14px; margin-bottom: 12px; }
.source-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.source-head .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-head .meta { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.version { display: grid; gap: 6px; min-width: 0; }
.thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 9 / 16; border: 0; padding: 0;
  border-radius: var(--radius-sm); overflow: hidden; background: var(--line); cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .play {
  position: absolute; inset: auto 6px 6px auto; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255, 255, 255, .9); display: grid; place-items: center;
}
.thumb .play::before {
  content: ""; margin-left: 2px; border-left: 8px solid var(--ink);
  border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}
.version .label { font-size: 13px; font-weight: 600; }
.version .sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: -4px; }
.version a.dl { font-size: 13px; color: var(--ink); }
.source-foot { display: flex; justify-content: flex-end; margin-top: 10px; }
.link-btn { font: inherit; font-size: 14px; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }

.empty { background: var(--surface); border-radius: var(--radius-lg); padding: 28px 20px; color: var(--muted); }
.empty b { color: var(--ink); display: block; margin-bottom: 4px; font-weight: 600; }

/* загрузка */
.upload-bar {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 12px var(--pad) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(243, 245, 247, 0));
  display: flex; justify-content: center;
}
.btn-upload { width: 100%; max-width: 728px; font-size: 17px; min-height: 54px; }
.btn-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.btn-upload:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }
.drop-hint {
  position: fixed; inset: 12px; border: 3px dashed var(--ink); border-radius: var(--radius-lg);
  background: rgba(243, 245, 247, .92); display: grid; place-items: center; font-size: 20px; font-weight: 600;
  pointer-events: none; z-index: 20;
}

/* настройки */
.group { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; display: grid; gap: 14px; }
.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.field > input, .field > select, .field > textarea { color: var(--ink); font-size: 16px; }
.salt { margin: 0; font-size: 14px; color: var(--muted); }
.salt b { color: var(--ink); font-weight: 600; }
.plaque-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 10px; }
.plaque-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.save-bar { margin-top: 20px; }
.save-bar .btn { width: 100%; }
#tab-settings .group + .group { margin-top: 14px; }

.switch { position: relative; width: 50px; height: 30px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 15px; transition: background .2s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(24, 33, 45, .25); transition: transform .2s;
}
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* плеер */
.player {
  border: 0; padding: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--ink);
  width: min(420px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
}
.player::backdrop { background: rgba(24, 33, 45, .6); }
.player-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 12px; gap: 8px; }
.player-tabs { display: flex; gap: 4px; overflow-x: auto; }
.player-tabs button {
  font: inherit; font-size: 14px; border: 1px solid var(--line); background: transparent; color: var(--ink);
  padding: 6px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.player-tabs button[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.player video { display: block; width: 100%; max-height: calc(100dvh - 150px); background: #000; aspect-ratio: 9 / 16; }
.player-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; }

.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); font-size: 15px;
  z-index: 30; max-width: calc(100vw - 32px);
}
.toast.bad { background: var(--err); }

@media (min-width: 640px) {
  .strip { gap: 12px; }
  .version .label { font-size: 14px; }
}
@media (max-width: 520px) {
  .source { padding: 12px; }
  .strip { gap: 6px; }
  .version .label { font-size: 12px; }
  .version .size { display: none; }
  .version a.dl { font-size: 12px; }
  .thumb .play { width: 22px; height: 22px; inset: auto 4px 4px auto; }
}
@media (max-width: 340px) {
  .strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 380px) {
  .plaque-row { grid-template-columns: 1fr 1fr; }
  .plaque-row .remove { grid-column: 2; justify-self: end; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
