/* Архив несуществующего дня — стили Saifer AI */
:root {
  --bg0: #050810;
  --bg1: #0a1128;
  --bg2: #121a36;
  --accent: #3b5bff;
  --accent2: #7fb0ff;
  --warm: #e8843c;
  --warm-dim: #b8652a;
  --text: #e8eefc;
  --muted: #8a96b8;
  --danger: #ff5a6a;
  --ok: #5ad4a0;
  --line: rgba(127, 176, 255, 0.18);
  --card: rgba(10, 17, 40, 0.92);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 20% -10%, #14204a 0%, var(--bg0) 55%), var(--bg0);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 14px calc(96px + env(safe-area-inset-bottom, 0px));
  width: 100%;
}

/* Brand */
.brandbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 4px 16px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #000 url('logo-s.png') center/cover no-repeat;
  box-shadow: 0 0 0 1px rgba(127,176,255,.35), 0 0 24px rgba(59,91,255,.35);
  flex: 0 0 auto;
}
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-name {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent2);
}
.brand-title {
  font-size: clamp(1rem, 2.8vw, 1.15rem);
  font-weight: 650;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}
.orion {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 4px 2px;
  border: none;
  border-radius: 0;
  background: transparent;
  flex: 0 0 auto;
  transform: rotate(-30deg);
  transform-origin: center center;
}
.orion i {
  border-radius: 50%;
  background: var(--accent2);
  display: block;
}
.orion i:nth-child(1) {
  width: 5px;
  height: 5px;
  box-shadow: 0 0 5px rgba(127,176,255,.75), 0 0 10px rgba(59,91,255,.35);
}
.orion i:nth-child(2) {
  width: 8px;
  height: 8px;
  box-shadow: 0 0 8px var(--accent2), 0 0 16px rgba(127,176,255,.5);
}
.orion i:nth-child(3) {
  width: 6px;
  height: 6px;
  box-shadow: 0 0 6px rgba(127,176,255,.85), 0 0 12px rgba(59,91,255,.4);
}
.splash .orion { margin-left: 0; }

.casechip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}
.chip {
  border: 1px solid var(--line);
  background: var(--bg1);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}
.chip strong { color: var(--text); font-weight: 600; }
.chip.warm { border-color: rgba(232,132,60,.45); color: var(--warm); }
.chip.accent { border-color: rgba(59,91,255,.5); color: var(--accent2); }
.debug-only,
#chipReject[hidden] { display: none; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) and (min-width: 701px) {
  .layout { grid-template-columns: 220px 1fr; }
}
@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; }
}

/* grid min-width guard */
.layout > * { min-width: 0; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toc {
  padding: 12px;
  position: sticky;
  top: 8px;
  max-height: calc(100vh - 16px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.toc h2 {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  flex: 0 0 auto;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.toc-list button {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: rgba(255,255,255,.02);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  cursor: pointer;
  font: inherit;
  display: grid;
  gap: 2px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(127,176,255,.25);
}
.toc-list button:hover { border-color: var(--line); background: rgba(59,91,255,.08); }
.toc-list button.active {
  border-color: rgba(59,91,255,.55);
  background: rgba(59,91,255,.16);
}
.toc-list .num {
  font-size: 11px;
  color: var(--accent2);
  letter-spacing: 0.06em;
}
.toc-list .ttl { font-size: 14px; }
.toc-list button.locked { opacity: 0.45; }
.toc-list button.has-red .ttl::after {
  content: " · правка";
  color: var(--danger);
  font-size: 11px;
}
.toc-list button.doc13 {
  border-color: rgba(232,132,60,.5);
  background: rgba(232,132,60,.08);
}

.stage { padding: 0; overflow: hidden; }
.doc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.doc-head h1 {
  margin: 0;
  font-size: clamp(1.05rem, 3.5vw, 1.25rem);
  font-weight: 650;
  min-width: 0;
  flex: 1 1 160px;
  overflow-wrap: anywhere;
}
.doc-clock {
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 0.04em;
  padding: 8px 14px;
  min-height: 44px;
  min-width: 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(127,176,255,.35);
  background: rgba(59,91,255,.12);
  cursor: default;
  user-select: none;
  flex: 0 0 auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(232,132,60,.3);
  transition: transform .25s ease, box-shadow .25s ease, color .25s ease, border-color .25s ease;
}
.doc-clock.jump {
  animation: clockJump .7s ease;
  color: var(--warm);
  border-color: rgba(232,132,60,.55);
}
.doc-clock.clickable {
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(232,132,60,.35), 0 0 20px rgba(232,132,60,.25);
  color: var(--warm);
  border-color: rgba(232,132,60,.55);
}
@keyframes clockJump {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 16px;
  background: rgba(0,0,0,.18);
  border-bottom: 1px solid var(--line);
}
@media (max-width: 560px) {
  .meta { grid-template-columns: 1fr; }
}
.meta .mk {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.meta .mv {
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
}
.meta .mv.rewritten {
  color: var(--warm);
  animation: metaFlash .8s ease;
}
@keyframes metaFlash {
  from { background: rgba(232,132,60,.25); }
  to { background: transparent; }
}

.red-edit {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--danger);
  background: rgba(255,90,106,.1);
  color: #ffc0c6;
  font-size: 14px;
  border-radius: 0 8px 8px 0;
  animation: redIn .45s ease;
}
@keyframes redIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.doc-body { padding: 14px 16px 18px; display: grid; gap: 8px; }
.line {
  margin: 0;
  padding: 12px 12px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255,255,255,.02);
  transition: border-color .15s, background .15s, transform .28s cubic-bezier(.2,.8,.2,1.4);
  position: relative;
  overflow-wrap: anywhere;
}
.line.linkable {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(232,132,60,.28);
}
.line.linkable:hover {
  border-color: rgba(127,176,255,.35);
  background: rgba(59,91,255,.08);
}
.line.linkable:active {
  border-color: rgba(232,132,60,.55);
  background: rgba(232,132,60,.14);
}
.line.selected {
  border-color: var(--warm);
  background: rgba(232,132,60,.12);
  box-shadow: inset 0 0 0 1px rgba(232,132,60,.25);
}
.line.linked {
  border-color: rgba(90,212,160,.45);
  background: rgba(90,212,160,.08);
}
.line.reject-shake {
  border-color: rgba(255,90,106,.75) !important;
  background: rgba(255,90,106,.14) !important;
  box-shadow: inset 0 0 0 1px rgba(255,90,106,.35);
  will-change: transform;
}
.line.bounce-left {
  animation: bounceLeft 520ms cubic-bezier(.36,.07,.19,.97) both;
}
.line.bounce-right {
  animation: bounceRight 520ms cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes bounceLeft {
  0%   { transform: translateX(0); }
  18%  { transform: translateX(-22px); }
  36%  { transform: translateX(-10px); }
  54%  { transform: translateX(-20px); }
  72%  { transform: translateX(-8px); }
  100% { transform: translateX(0); }
}
@keyframes bounceRight {
  0%   { transform: translateX(0); }
  18%  { transform: translateX(22px); }
  36%  { transform: translateX(10px); }
  54%  { transform: translateX(20px); }
  72%  { transform: translateX(8px); }
  100% { transform: translateX(0); }
}
.line .lid {
  display: inline-block;
  min-width: 1.6em;
  margin-right: 8px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.hint {
  margin: 0 16px 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(59,91,255,.1);
  border: 1px dashed rgba(127,176,255,.35);
  color: var(--accent2);
  font-size: 13px;
}

/* Reject A banner */
.reject-banner {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translateX(-50%) translateY(-160%);
  z-index: 50;
  background: #1a1020;
  color: #ffc0c6;
  border: 1px solid rgba(255,90,106,.55);
  border-radius: 12px;
  padding: 12px 18px;
  box-shadow: var(--shadow);
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform .28s ease, opacity .22s ease, visibility .22s ease;
  pointer-events: none;
  max-width: calc(100vw - 24px);
  text-align: center;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
}
.reject-banner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

/* Reason / finale */
.reason-box {
  margin: 0 16px 16px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(232,132,60,.45);
  background: linear-gradient(180deg, rgba(232,132,60,.12), rgba(0,0,0,.15));
}
.reason-box h3 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warm);
}
.reason-box p { margin: 0; font-size: 15px; }

.finale {
  margin: 0 16px 18px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(127,176,255,.35);
  background: rgba(59,91,255,.08);
  display: grid;
  gap: 12px;
}
.finale h3 { margin: 0; font-size: 1.05rem; }
.finale p { margin: 0; color: var(--muted); font-size: 14px; }
.finale-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  appearance: none;
  border: 1px solid rgba(127,176,255,.4);
  background: linear-gradient(180deg, #2a3fff, var(--accent));
  color: white;
  border-radius: 12px;
  padding: 12px 16px;
  min-height: 48px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(59,91,255,.25);
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(127,176,255,.3);
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary {
  background: transparent;
  color: var(--accent2);
  box-shadow: none;
}
.btn.warm {
  background: linear-gradient(180deg, #f0a05a, var(--warm));
  border-color: rgba(232,132,60,.55);
  box-shadow: 0 8px 20px rgba(232,132,60,.22);
}

/* Result cover */
.result {
  display: none;
  padding: 20px 16px 24px;
}
.result.show { display: block; }
.stage.done .doc-view { display: none; }
.cover {
  border: 1px solid rgba(127,176,255,.3);
  border-radius: 16px;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(59,91,255,.12), transparent 40%),
    linear-gradient(320deg, rgba(232,132,60,.1), transparent 35%),
    var(--bg1);
  position: relative;
  overflow: hidden;
}
.cover::before, .cover::after {
  content: "";
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--danger), transparent);
  left: 8%;
  right: 8%;
  opacity: .75;
}
.cover::before { top: 28%; transform: rotate(-8deg); }
.cover::after { top: 62%; transform: rotate(6deg); }
.cover-status {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-bottom: 12px;
}
.cover-status.closed { background: rgba(90,212,160,.15); color: var(--ok); border: 1px solid rgba(90,212,160,.4); }
.cover-status.left { background: rgba(232,132,60,.15); color: var(--warm); border: 1px solid rgba(232,132,60,.45); }
.cover h2 { margin: 0 0 6px; font-size: 1.4rem; position: relative; }
.cover .case { color: var(--muted); margin-bottom: 16px; position: relative; }
.quotes {
  display: grid;
  gap: 10px;
  position: relative;
}
.qpair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}
@media (max-width: 560px) {
  .qpair {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .qpair b { justify-self: center; }
}
.qpair span {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0,0,0,.25);
  border: 1px solid var(--line);
}
.qpair b { color: var(--danger); font-weight: 700; }
.cover-actions { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px; position: relative; }

/* Cookie */
.cookie {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: rgba(5,8,16,.96);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  transform: translateY(110%);
  transition: transform .3s ease;
}
.cookie.show { transform: translateY(0); }
.cookie p { margin: 0; color: var(--muted); font-size: 14px; }
.cookie .btn { padding: 8px 14px; font-size: 14px; }

/* Footer */
.site-footer {
  margin-top: 18px;
  padding: 14px 4px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Splash first seconds */
.splash {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: radial-gradient(800px 400px at 50% 30%, #14204a, var(--bg0));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: opacity .5s ease, visibility .5s ease;
}
.splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.splash .brand-mark { width: 72px; height: 72px; }
.splash h1 {
  margin: 0;
  font-size: clamp(1.3rem, 4vw, 1.8rem);
  text-align: center;
  padding: 0 16px;
}
.splash .sub { color: var(--muted); font-size: 14px; }

/* Admin */
.admin-grid { display: grid; gap: 14px; }
.admin-card { padding: 16px; }
.admin-card h2 { margin: 0 0 10px; font-size: 1.05rem; }
.field { display: grid; gap: 6px; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg0);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stat { font-size: 14px; color: var(--muted); }
.stat b { color: var(--text); }
.canon-list { font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
.canon-list code { color: var(--accent2); }
.doc-preview {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(0,0,0,.2);
}
.doc-preview h3 { margin: 0 0 6px; font-size: 14px; }
.doc-preview .small { color: var(--muted); font-size: 12px; }

.toast-ok {
  position: fixed;
  right: 14px;
  bottom: 80px;
  background: #102418;
  border: 1px solid rgba(90,212,160,.45);
  color: var(--ok);
  padding: 10px 14px;
  border-radius: 10px;
  z-index: 45;
  opacity: 0;
  transform: translateY(8px);
  transition: .25s ease;
  max-width: calc(100vw - 28px);
}
.toast-ok.show { opacity: 1; transform: none; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 10px;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.back-link:hover { color: var(--accent2); }

/* === Мультидевайс: phone / tablet / laptop / desktop === */

/* Phone: оглавление сверху вертикальным списком со своей прокруткой */
@media (max-width: 700px) {
  .layout {
    min-width: 0;
    width: 100%;
  }
  .layout > .toc {
    order: 0;
    position: sticky;
    top: 0;
    z-index: 5;
    max-height: min(42vh, calc(100vh - 8px));
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    padding: 10px 10px 8px;
  }
  .layout > .stage {
    order: 1;
    min-width: 0;
    max-width: 100%;
  }
  .toc h2 { margin-bottom: 8px; flex: 0 0 auto; }
  .toc-list {
    display: grid;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(min(42vh, 100vh - 8px) - 36px);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 2px 0;
  }
  .toc-list li {
    list-style: none;
    max-width: none;
  }
  .toc-list button {
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 48px;
    touch-action: manipulation;
  }

  .finale-actions .btn {
    flex: 1 1 100%;
    width: 100%;
  }
  .cover-actions .btn,
  .cover-actions a.btn {
    flex: 1 1 100%;
    text-align: center;
  }
  .brandbar .orion { margin-left: 0; }
  .casechip { gap: 6px; }
  .chip { padding: 6px 10px; font-size: 12px; }
  .hint { font-size: 12.5px; }
  .doc-body { padding: 12px; }
  .meta { padding: 10px 12px; }
  .red-edit { margin: 10px 12px 0; }
  .reason-box, .finale, .hint { margin-left: 12px; margin-right: 12px; }

}

@media (max-width: 900px) {
  .admin-card .row .btn { flex: 1 1 auto; min-width: 140px; }
  .admin-card .field input,
  .admin-card .field select,
  .admin-card .field textarea {
    font-size: 16px;
  }
}

@media (min-width: 701px) and (max-width: 1100px) {
  .toc-list button { min-height: 46px; }
}

@media (min-width: 1366px) {
  .wrap { padding-left: 18px; padding-right: 18px; }
}

@media (hover: none) and (pointer: coarse) {
  .line.linkable:hover {
    border-color: transparent;
    background: rgba(255,255,255,.02);
  }
  .toc-list button:hover {
    border-color: transparent;
    background: rgba(255,255,255,.02);
  }
  .line.linkable:active {
    border-color: rgba(232,132,60,.55);
    background: rgba(232,132,60,.14);
  }
  .toc-list button:active {
    border-color: rgba(59,91,255,.55);
    background: rgba(59,91,255,.16);
  }
}
