:root {
  --bg0: #121a17;
  --bg1: #1c2a24;
  --bg2: #243530;
  --ink: #f4efe6;
  --muted: #9aada3;
  --accent: #d4a574;
  --accent-deep: #c4895a;
  --panel: rgba(22, 32, 28, 0.78);
  --panel-solid: #1a2621;
  --line: rgba(244, 239, 230, 0.1);
  --line-strong: rgba(244, 239, 230, 0.18);
  --ok: #6fbf95;
  --danger: #e07a5f;
  --bad: #e07a5f;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  --font: "Manrope", "Segoe UI", sans-serif;
  --display: "Sora", "Manrope", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
.hidden,
[hidden] {
  display: none !important;
}
a.btn.is-disabled,
a.btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
}
body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg0);
  background-image:
    radial-gradient(ellipse 100% 70% at 85% -10%, rgba(212, 165, 116, 0.16), transparent 55%),
    radial-gradient(ellipse 80% 55% at -5% 90%, rgba(111, 191, 149, 0.1), transparent 50%),
    linear-gradient(168deg, var(--bg0) 0%, var(--bg1) 48%, #152019 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1680px, calc(100% - 32px));
  margin: 12px auto 32px;
  animation: shellIn 0.55s var(--ease) both;
}
body:has(#view-3:not(.hidden)) .shell,
body:has(#view-4:not(.hidden)) .shell {
  width: min(1920px, calc(100% - 16px));
}
@keyframes shellIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* —— header —— */
.top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 700;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #1a1612;
  letter-spacing: -0.04em;
  box-shadow: 0 6px 16px rgba(212, 165, 116, 0.22);
  transition: transform 0.35s var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-3deg) scale(1.04); }
.brand h1 {
  font-family: var(--display);
  font-size: clamp(1.35rem, 2.2vw, 1.65rem);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.045em;
  line-height: 1.05;
}
.brand h1 .dot { color: var(--accent); }
.tag {
  margin: 2px 0 0;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
}

.top-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  justify-content: flex-end;
}
/* компактный переключатель Текст/Картинки в шапке (только шаг 4) */
.post-switch {
  display: inline-flex;
  align-items: stretch;
  padding: 3px;
  gap: 2px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.28);
}
.post-switch.hidden { display: none !important; }
.post-switch-btn {
  appearance: none;
  border: 0;
  margin: 0;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 999px;
  font: 600 0.78rem var(--font);
  color: var(--muted);
  background: transparent;
  transition: 0.2s var(--ease);
  white-space: nowrap;
}
.post-switch-btn:hover { color: var(--ink); }
.post-switch-btn.on {
  color: #1a1612;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 4px 12px rgba(212, 165, 116, 0.28);
}
#btnFinishPatient:not(.hidden) {
  border-color: rgba(224, 122, 95, 0.4);
  color: #f0b8a8;
}

/* steps as progress track */
.steps {
  list-style: none;
  display: flex;
  gap: 0;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
  align-items: center;
}
.steps li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 2px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.3s var(--ease);
  position: relative;
}
.steps li + li::before {
  content: "";
  width: 16px;
  height: 1px;
  margin-right: 8px;
  background: var(--line-strong);
  transition: background 0.3s;
}
.steps li.done + li::before,
.steps li.on + li::before { background: rgba(212, 165, 116, 0.45); }
.steps li span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.2);
  transition: 0.3s var(--ease);
}
.steps li.on {
  color: var(--ink);
}
.steps li.on span {
  background: var(--accent);
  border-color: transparent;
  color: #1a1612;
  box-shadow: 0 0 0 4px rgba(212, 165, 116, 0.18);
}
.steps li.done { color: var(--accent); }
.steps li.done span {
  background: rgba(212, 165, 116, 0.18);
  border-color: rgba(212, 165, 116, 0.4);
  color: var(--accent);
}

/* —— panels —— */
.panel {
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px 18px;
  box-shadow: var(--shadow);
  animation: panelIn 0.45s var(--ease) both;
}
.panel.hidden { display: none; animation: none; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.panel-head h2 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 2.2vw, 1.7rem);
}
.panel-head p {
  margin: 0 0 22px;
  color: var(--muted);
  max-width: 52ch;
  line-height: 1.5;
}
code {
  font-family: ui-monospace, Consolas, monospace;
  background: rgba(244, 239, 230, 0.06);
  padding: 2px 6px;
  border-radius: 6px;
}

/* —— upload (step 1): pick + memo —— */
.upload-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 12px;
}
.upload-zone {
  position: relative;
  border: 1.5px dashed rgba(212, 165, 116, 0.35);
  border-radius: calc(var(--radius) - 2px);
  padding: clamp(20px, 3.5vw, 36px) 22px;
  min-height: min(200px, 28vh);
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    radial-gradient(ellipse 70% 80% at 50% 40%, rgba(212, 165, 116, 0.08), transparent 70%),
    rgba(0, 0, 0, 0.22);
  margin: 0;
  transition: border-color 0.25s, background 0.25s, transform 0.25s var(--ease);
  overflow: hidden;
}
.upload-zone::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 40%, rgba(212, 165, 116, 0.06) 50%, transparent 60%);
  transform: translateX(-100%);
  pointer-events: none;
}
.upload-zone:hover::after {
  animation: sheen 1.1s var(--ease);
}
@keyframes sheen {
  to { transform: translateX(100%); }
}
.upload-zone.drag {
  border-color: var(--accent);
  background: rgba(212, 165, 116, 0.12);
  transform: scale(1.01);
}
.upload-zone .btn.primary {
  min-width: min(280px, 100%);
  padding: 12px 22px;
  font-size: 0.98rem;
}
.upload-zone .hint {
  margin: 12px auto 0;
  max-width: 42ch;
  line-height: 1.45;
  font-size: 0.86rem;
}
.upload-progress { margin-top: 14px; text-align: left; max-width: 420px; margin-left: auto; margin-right: auto; width: 100%; }

.upload-rules {
  margin: 0;
  padding: 16px 18px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.upload-rules h3 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}
.upload-rules ol {
  margin: 0;
  padding: 0 0 0 1.15rem;
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.upload-rules ol b { color: var(--ink); font-weight: 600; }
.upload-rules code {
  font-size: 0.84em;
  color: var(--ink);
  background: rgba(212, 165, 116, 0.12);
  border: 1px solid rgba(212, 165, 116, 0.2);
}
.upload-roles {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
  word-break: break-word;
}
.upload-roles:empty { display: none; }

.patient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.card {
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(244, 239, 230, 0.03);
  border-radius: 14px;
  padding: 16px 18px;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease);
}
.card:hover {
  border-color: rgba(212, 165, 116, 0.5);
  background: rgba(212, 165, 116, 0.1);
  transform: translateY(-2px);
}
.card h3 {
  font-family: var(--display);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.card .meta { color: var(--muted); font-size: 0.88rem; line-height: 1.45; }

/* —— forms —— */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  margin: 8px 0 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
}
label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}
input[type="text"],
input[type="password"],
input[type="date"],
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.42);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font: 500 0.95rem/1.45 var(--font);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus {
  border-color: rgba(212, 165, 116, 0.55);
  box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.12);
}
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chips > span { color: var(--muted); font-size: 0.84rem; margin-right: 2px; }
.chip {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.15);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font: 600 0.88rem var(--font);
  transition: 0.2s var(--ease);
}
.chip:hover { border-color: rgba(212, 165, 116, 0.4); }
.chip.on {
  background: rgba(212, 165, 116, 0.22);
  border-color: rgba(212, 165, 116, 0.55);
  color: var(--ink);
}
.check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  grid-column: 1 / -1;
  color: var(--ink);
  font-size: 0.9rem;
}
.toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  grid-column: 1 / -1;
  cursor: pointer;
  user-select: none;
  margin: 2px 0 0;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(160deg, #f4efe6 0%, #c9c0b4 100%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s var(--ease), background 0.25s var(--ease);
}
.toggle-text {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
}
.toggle:hover .toggle-track {
  border-color: rgba(212, 165, 116, 0.45);
}
.toggle input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.18);
  border-color: rgba(212, 165, 116, 0.55);
}
.toggle input:checked + .toggle-track {
  background: linear-gradient(135deg, rgba(212, 165, 116, 0.55), rgba(196, 137, 90, 0.72));
  border-color: rgba(212, 165, 116, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
  background: linear-gradient(160deg, #fff8ef 0%, #f0e2d0 100%);
}
.path-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.path-row input { flex: 1; min-width: 220px; }

.date-pair { display: flex; gap: 8px; }
.date-pair input[type="date"] {
  flex: 0 0 168px;
  color-scheme: dark;
}
.date-pair input[type="text"] { flex: 1; min-width: 0; }

/* —— scan —— */
.scan-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.scan-summary .count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font: 600 0.9rem var(--font);
}
.scan-summary .count.ok {
  color: #0f1f16;
  background: var(--ok);
  border-color: transparent;
}
.scan-summary .count.weak {
  color: #1a1612;
  background: var(--accent);
  border-color: transparent;
}
.scan-summary .count.missing {
  color: #2a100c;
  background: var(--danger);
  border-color: transparent;
}

.excel-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: rgba(244, 239, 230, 0.03);
  font-size: 0.92rem;
}
.excel-status.ok {
  border-color: rgba(111, 191, 149, 0.4);
  background: rgba(111, 191, 149, 0.08);
}
.excel-status.bad {
  border-color: rgba(224, 122, 95, 0.4);
  background: rgba(224, 122, 95, 0.08);
}
.excel-status .dot { font-size: 1.05rem; line-height: 1; }

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding: 2px 2px 14px;
  margin-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 165, 116, 0.35) transparent;
}
.check-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(244, 239, 230, 0.03);
  font-size: 0.84rem;
  transition: border-color 0.2s, transform 0.2s var(--ease);
  animation: chipIn 0.35s var(--ease) both;
}
.check-chip.instant {
  animation: none !important;
  opacity: 1;
  transform: none;
}
@keyframes chipIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.check-chip:hover { border-color: var(--line-strong); }
.check-chip .dot {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #1a1612;
}
.check-chip .info { display: flex; flex-direction: column; min-width: 0; }
.check-chip .role { font-weight: 600; color: var(--ink); }
.check-chip .file {
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.check-chip.ok { border-color: rgba(111, 191, 149, 0.3); }
.check-chip.ok .dot { background: var(--ok); }
.check-chip.weak { border-color: rgba(212, 165, 116, 0.4); }
.check-chip.weak .dot { background: var(--accent); }
.check-chip.missing {
  border-color: rgba(224, 122, 95, 0.4);
  background: rgba(224, 122, 95, 0.06);
}
.check-chip.missing .dot { background: var(--danger); color: #2a100c; }
.check-chip.optional { opacity: 0.5; }
.check-chip.optional .dot { background: rgba(244, 239, 230, 0.18); }

.checklist-raw {
  margin: 0 0 16px;
  max-height: 260px;
  overflow: auto;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  color: var(--muted);
  font: 400 0.82rem/1.45 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
}
.checklist-raw.hidden { display: none; }

.rename-box {
  margin: 6px 0 14px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(212, 165, 116, 0.3);
  background: linear-gradient(135deg, rgba(212, 165, 116, 0.1), rgba(212, 165, 116, 0.04));
}
.rename-box.hidden { display: none; }
.rename-box h3 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.rename-box ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rename-box li {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-size: 0.88rem;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
}
.rename-box .from { color: var(--ink); font-weight: 600; }
.rename-box .to { color: var(--accent); font-weight: 700; }

/* —— text editors —— */
.panel-text { padding-top: 20px; }
.panel-head-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 12px;
}
.panel-head-compact h2 { margin-bottom: 4px; }
.panel-head-compact p { margin: 0; }
.panel-head-compact .text-actions { margin: 0; }

.editors {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 18px;
  min-height: calc(100vh - 220px);
}
@media (max-width: 1100px) {
  .editors { grid-template-columns: 1fr; min-height: auto; }
}
.editor-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.editors h3 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 0.88rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.slide-frame {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: stretch;
  min-height: calc(100vh - 250px);
  padding: 20px 16px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.18)),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 11px,
      rgba(244, 239, 230, 0.015) 11px,
      rgba(244, 239, 230, 0.015) 12px
    );
  border: 1px solid var(--line);
}
.slide-frame textarea,
#detailed,
#summary {
  width: min(100%, 692px);
  min-height: calc(100vh - 286px);
  height: 100%;
  resize: vertical;
  margin: 0 auto;
  padding: 24px 28px;
  border-radius: 3px;
  border: 1px solid rgba(26, 36, 32, 0.08);
  background: #f3eee5;
  color: #1a1814;
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-align: justify;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  tab-size: 4;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  transition: box-shadow 0.25s;
}
.slide-frame-summary textarea,
#summary {
  width: min(100%, 646px);
  text-align: left;
}
.slide-frame textarea:focus,
#detailed:focus,
#summary:focus {
  border-color: rgba(212, 165, 116, 0.65);
  outline: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28), 0 0 0 3px rgba(212, 165, 116, 0.2);
}
.text-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.status { color: var(--muted); font-size: 0.88rem; }
.issues {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 6px;
}
.issues li {
  font-size: 0.88rem;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(212, 165, 116, 0.1);
  border: 1px solid rgba(212, 165, 116, 0.22);
  color: #f0d4b8;
}

/* —— actions / buttons —— */
.actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}
.btn {
  border: 1px solid var(--line);
  background: rgba(244, 239, 230, 0.05);
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 18px;
  font: 700 0.92rem var(--font);
  cursor: pointer;
  transition: transform 0.18s var(--ease), filter 0.15s, background 0.2s, border-color 0.2s, opacity 0.15s, box-shadow 0.2s;
}
.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  border-color: var(--line-strong);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: wait; transform: none; filter: none; }
.btn.primary {
  background: linear-gradient(145deg, var(--accent), var(--accent-deep));
  color: #1a1612;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(212, 165, 116, 0.28);
}
.btn.primary:hover { box-shadow: 0 8px 24px rgba(212, 165, 116, 0.38); }
.btn.ghost {
  background: transparent;
  outline: none;
}
.btn-sm { padding: 7px 12px; font-size: 0.84rem; border-radius: 10px; }
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}

.hint { color: var(--muted); font-size: 0.88rem; margin-top: 14px; line-height: 1.45; }

/* —— done / post-edit —— */
.done { text-align: left; padding: 4px 0 8px; }
.post-edit {
  margin-top: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.post-edit.hidden { display: none !important; }
.post-section {
  padding: 14px 16px 16px;
}
.post-section.hidden,
.post-section[hidden] {
  display: none !important;
}
/* страховка: на вкладке «Картинки» текст не должен просвечивать */
body.post-tab-images #postTextSection,
body.post-tab-text #postImagesSection {
  display: none !important;
}
.post-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  margin-bottom: 12px;
}
.post-section-head .hint {
  margin: 0;
  max-width: 62ch;
  font-size: 0.86rem;
}
.post-section-head .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.editors-host-compact .editors,
#editorsBlock.editors-compact {
  margin-top: 0;
}
#editorsBlock.editors-compact .slide-frame {
  min-height: 220px;
  padding: 12px 10px;
}
#editorsBlock.editors-compact #detailed,
#editorsBlock.editors-compact #summary {
  min-height: 200px;
  padding: 16px 18px;
  font-size: 13px;
}
@media (max-width: 900px) {
  .post-section-head { flex-direction: column; align-items: stretch; }
  .post-section-head .btn { width: 100%; }
}
.done-compact .done-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  margin-bottom: 4px;
}
.done-status {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: min(100%, 360px);
}
.done-copy h2 {
  font-family: var(--display);
  font-size: clamp(1.25rem, 2.2vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 2px;
}
.done-copy p {
  color: var(--muted);
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  max-width: 56ch;
}
.done .path {
  margin: 6px 0 0;
  max-width: 100%;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
}
.done .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  flex: 1 1 auto;
}
.spinner {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  margin: 0;
  border-radius: 50%;
  border: 3px solid rgba(244, 239, 230, 0.1);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}
.spinner.off { display: none; }
.progress-wrap {
  width: min(480px, 100%);
  height: 7px;
  margin: 10px 0 4px;
  border-radius: 999px;
  background: rgba(244, 239, 230, 0.08);
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-wrap.hidden { display: none; }
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  transition: width 0.35s var(--ease);
}
.progress-label {
  min-height: 1.1em;
  font-size: 0.84rem;
  color: var(--muted);
  margin: 0 0 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.preview-warnings {
  list-style: none;
  margin: 10px 0 12px;
  padding: 0;
  display: grid;
  gap: 6px;
}
.preview-warnings:empty { display: none; }
.preview-warnings li {
  font-size: 0.86rem;
  color: #f0b8a8;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(224, 122, 95, 0.12);
  border: 1px solid rgba(224, 122, 95, 0.25);
}
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.preview-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, transform 0.2s var(--ease);
  animation: chipIn 0.4s var(--ease) both;
}
.preview-card:hover {
  border-color: rgba(212, 165, 116, 0.4);
  transform: translateY(-2px);
}
.preview-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #0c110f;
  display: block;
  cursor: zoom-in;
}
.preview-card .meta {
  padding: 10px 12px 12px;
  display: grid;
  gap: 8px;
  font-size: 0.8rem;
}
.preview-card .meta .role { font-weight: 700; color: var(--ink); }
.preview-card .meta .slide { color: var(--muted); }
.preview-card .card-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 2px;
}
.preview-card .refit-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink);
}
.preview-card .refit-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.preview-card .refit-track {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.28);
  flex: 0 0 auto;
  transition: 0.2s var(--ease);
}
.preview-card .refit-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e8e0d4;
  transition: transform 0.2s var(--ease);
}
.preview-card .refit-toggle input:checked + .refit-track {
  background: linear-gradient(135deg, rgba(212, 165, 116, 0.55), rgba(196, 137, 90, 0.72));
  border-color: rgba(212, 165, 116, 0.7);
}
.preview-card .refit-toggle input:checked + .refit-track::after {
  transform: translateX(16px);
}
.preview-card .btn-replace {
  padding: 5px 10px;
  font-size: 0.76rem;
  border-radius: 8px;
}
.preview-card.warn { border-color: rgba(224, 122, 95, 0.5); }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 48px 16px 24px;
  background: rgba(6, 10, 8, 0.88);
  backdrop-filter: blur(6px);
}
.lightbox.hidden,
.lightbox[hidden] { display: none !important; }
.lightbox-figure {
  margin: 0;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.lightbox-figure img {
  max-width: min(96vw, 1100px);
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  background: #0c110f;
}
.lightbox-figure figcaption {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
}
.lightbox-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-nav {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(212, 165, 116, 0.18);
  color: var(--ink);
  font-size: 1.6rem;
  cursor: pointer;
  transition: 0.2s var(--ease);
}
.lightbox-nav:hover {
  border-color: rgba(212, 165, 116, 0.55);
  background: rgba(212, 165, 116, 0.28);
}
.lightbox-nav:disabled {
  opacity: 0.35;
  cursor: default;
}

/* —— login —— */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px 20px;
  position: relative;
  z-index: 1;
}
.login-card {
  position: relative;
  width: min(420px, 100%);
  padding: 36px 30px 28px;
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: left;
  animation: panelIn 0.5s var(--ease) both;
}
.login-card .brand {
  margin-bottom: 6px;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}
.login-card .brand-mark {
  width: 60px;
  height: 60px;
  font-size: 1.25rem;
  border-radius: 18px;
}
.login-card .brand h1 {
  font-size: clamp(2rem, 5vw, 2.4rem);
}
.login-form { display: grid; gap: 14px; margin-top: 26px; }
.login-form label {
  display: grid;
  gap: 7px;
  font-size: 0.88rem;
  color: var(--muted);
}
.login-form input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.45);
  color: var(--ink);
  font: inherit;
}
.login-form .btn.primary {
  width: 100%;
  margin-top: 6px;
  padding: 1rem 1.5rem;
  font-size: 1.02rem;
  border-radius: 12px;
}
.login-error { color: var(--danger); margin: 0; font-size: 0.9rem; }
.login-card > .hint {
  margin-top: 18px;
  text-align: center;
  font-size: 0.8rem;
}

body.mode-remote .local-only { display: none !important; }
body.mode-local #uploadZone { display: none !important; }
body.mode-local .upload-layout {
  grid-template-columns: 1fr;
}

.reveal { animation: panelIn 0.45s var(--ease) both; }

@media (max-width: 900px) {
  .upload-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .upload-zone {
    min-height: 0;
    padding: 28px 18px;
  }
}

@media (max-width: 640px) {
  .shell { width: calc(100% - 16px); margin: 12px auto 28px; }
  .panel { padding: 18px 16px 16px; }
  .top { align-items: flex-start; }
  .steps li { font-size: 0.78rem; }
  .steps li span { width: 22px; height: 22px; }
  .upload-zone { padding: 24px 14px; }
  .done .actions { flex-direction: column; align-items: stretch; }
  .done .actions .btn { width: 100%; }
}
