:root {
  --font-display: "Unbounded", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* CineStill 800T — тёплая ночная фотолаборатория */
  --bg: #0b0908;
  --bg-elevated: #120f0d;
  --surface: #171311;
  --surface-raised: #201b17;

  /* Три роли текста (тёплая слоновая кость) */
  --ink: #f4ebdd;
  --ink-sec: #a99e90;
  --ink-muted: #70665b;

  /* Тихие волосяные границы */
  --border: rgba(244, 235, 221, 0.09);
  --border-strong: rgba(244, 235, 221, 0.18);
  --border-warm: rgba(229, 169, 82, 0.34);

  /* Тёплая бумага для 35mm отпечатков */
  --paper: #ebe1cf;
  --paper-edge: #d8ccb6;
  --stage-bg: #151210;
  --ink-dark: #191512;
  --ink-dark-sec: #52483e;
  --ink-dark-muted: #776b5e;
  --border-paper: rgba(25, 21, 18, 0.14);
  --border-paper-strong: rgba(25, 21, 18, 0.3);

  /* Акценты: вольфрамовый свет и рубиновая галяция CineStill */
  --amber: #e5a952;
  --amber-soft: rgba(229, 169, 82, 0.12);
  --ruby: #d9432b;
  --ruby-soft: rgba(217, 67, 43, 0.14);

  /* Основная кнопка спуска затвора */
  --shutter-bg: #f4ebdd;
  --shutter-hover: #fff8ed;
  --shutter-edge: #9a8d7a;
  --shutter-ink: #14100d;

  --danger-bg: rgba(217, 67, 43, 0.14);
  --danger-ink: #f49b89;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

html, body {
  min-height: 100%;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Тончайшее плёночное зерно поверх тёмного фона */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.032;
  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");
}

a {
  color: inherit;
}

/* Узкая мобильная оболочка для /e, /create, /album, /privacy */
.shell {
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 20px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
}

/* Шапка */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
}

.brand-logo-lg {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ruby);
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.01em;
}

/* Переключатель ролей в шапке внутренних страниц */
.role-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 8px;
  background: rgba(11, 9, 8, 0.55);
  border: 1px solid var(--border-strong);
  gap: 2px;
}

.role-switch a {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-sec);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}

.role-switch a:hover {
  color: var(--ink);
}

.role-switch a.active {
  background: var(--surface-raised);
  color: var(--ink);
}

.frame-readout {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

/* Заголовок экрана */
.hero {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 6vw, 32px);
  line-height: 1.14;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
}

.event-subtitle {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-sec);
  text-wrap: pretty;
}

/* Счётчик плёнки */
.meter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.meter-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-sec);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.film-pips {
  display: flex;
  gap: 4px;
  flex: 1;
  max-width: 140px;
}

.film-pip {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  transition: background-color 200ms var(--ease);
}

.film-pip.filled {
  background: var(--amber);
}

/* 35mm фотоотпечаток на тёмном столе */
.print-card {
  background: var(--paper);
  color: var(--ink-dark);
  border-radius: 14px;
  padding: 12px 12px 12px;
  border: 1px solid rgba(255, 250, 240, 0.12);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.45),
    0 24px 48px rgba(0, 0, 0, 0.55);
  margin-bottom: 20px;
}

.print-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dark-muted);
  font-variant-numeric: tabular-nums;
}

.frame-stage {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--stage-bg);
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  outline: 1px solid rgba(25, 21, 18, 0.2);
  outline-offset: -1px;
  transition: background-color 150ms var(--ease);
}

.frame-stage:hover {
  background: #1c1714;
}

.frame-stage.has-file {
  aspect-ratio: auto;
}

/* Уголки видоискателя */
.vf-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
  z-index: 2;
  transition: opacity 150ms var(--ease);
}

.frame-stage.has-file .vf-corner {
  opacity: 0;
}

.vf-corner.tl {
  top: 14px;
  left: 14px;
  border-top: 1.5px solid rgba(229, 169, 82, 0.55);
  border-left: 1.5px solid rgba(229, 169, 82, 0.55);
}

.vf-corner.tr {
  top: 14px;
  right: 14px;
  border-top: 1.5px solid rgba(229, 169, 82, 0.55);
  border-right: 1.5px solid rgba(229, 169, 82, 0.55);
}

.vf-corner.bl {
  bottom: 14px;
  left: 14px;
  border-bottom: 1.5px solid rgba(229, 169, 82, 0.55);
  border-left: 1.5px solid rgba(229, 169, 82, 0.55);
}

.vf-corner.br {
  bottom: 14px;
  right: 14px;
  border-bottom: 1.5px solid rgba(229, 169, 82, 0.55);
  border-right: 1.5px solid rgba(229, 169, 82, 0.55);
}

.stage-empty {
  position: absolute;
  inset: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}

.crosshair-ring {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(229, 169, 82, 0.45);
  background: rgba(229, 169, 82, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.stage-icon {
  width: 20px;
  height: 20px;
  color: var(--amber);
}

.stage-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}

.stage-hint {
  font-size: 12.5px;
  color: var(--ink-sec);
}

.preview-wrap {
  position: relative;
}

.preview-wrap img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
}

.preview-change {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(11, 9, 8, 0.8);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 500;
  backdrop-filter: blur(8px);
}

/* Подпись на белой кромке отпечатка */
.caption-strip {
  padding: 10px 4px 2px;
}

.caption-strip input {
  width: 100%;
  height: 40px;
  padding: 0 2px;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--ink-dark);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  transition: border-color 150ms var(--ease);
}

.caption-strip input::placeholder {
  color: var(--ink-dark-muted);
}

.caption-strip input:focus {
  outline: none;
  border-bottom-color: var(--border-paper-strong);
}

/* Чекбокс согласия */
.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
  cursor: pointer;
  user-select: none;
}

.consent-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--ruby);
  cursor: pointer;
}

.consent-text {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-sec);
  text-wrap: pretty;
}

.consent-text a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
}

/* Ошибка */
.form-error {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--danger-bg);
  border: 1px solid rgba(217, 67, 43, 0.25);
  color: var(--danger-ink);
  font-size: 13px;
  line-height: 1.45;
}

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 0 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 150ms var(--ease),
    border-color 150ms var(--ease),
    transform 100ms var(--ease),
    opacity 150ms var(--ease);
}

.btn:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

.btn-shutter {
  background: var(--shutter-bg);
  color: var(--shutter-ink);
  border-color: rgba(255, 248, 237, 0.4);
  box-shadow:
    inset 0 1px 0 #ffffff,
    0 2px 0 var(--shutter-edge),
    0 12px 24px rgba(0, 0, 0, 0.45);
}

.btn-shutter:hover:not(:disabled) {
  background: var(--shutter-hover);
}

.btn-shutter:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 1px 0 var(--shutter-edge);
}

.btn-shutter:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.shutter-ring {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(20, 16, 13, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.shutter-ring::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ruby);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
  box-shadow: none;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-raised);
  border-color: var(--border-warm);
}

/* Вспышка затвора при успешной отправке */
.shutter-flash {
  position: fixed;
  inset: 0;
  background: #fff4e0;
  opacity: 0;
  pointer-events: none;
  z-index: 200;
}

.shutter-flash.fire {
  animation: shutterFlash 340ms var(--ease);
}

@keyframes shutterFlash {
  0% { opacity: 0; }
  18% { opacity: 0.28; }
  100% { opacity: 0; }
}

/* Анимация улетающего на плёнку кадра */
.print-card {
  will-change: transform, opacity;
}

.print-card.fly-to-film {
  animation: flyToFilm 480ms cubic-bezier(0.32, 0, 0.2, 1) forwards;
}

.print-card.next-frame-in {
  animation: nextFrameIn 360ms var(--ease) both;
}

@keyframes flyToFilm {
  0% {
    transform: translateY(0) scale(1) rotate(0deg);
    opacity: 1;
  }
  30% {
    transform: translateY(6px) scale(0.97) rotate(0.8deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-76px) scale(0.76) rotate(-2.2deg);
    opacity: 0;
  }
}

@keyframes nextFrameIn {
  0% {
    transform: translateY(18px) scale(0.97);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.film-pip.just-filled {
  animation: pipPulse 520ms var(--ease);
}

@keyframes pipPulse {
  0% { transform: scaleY(1); }
  40% { transform: scaleY(2.2); background: #ffd285; }
  100% { transform: scaleY(1); }
}

/* Финальная анимация перемотки 35mm кассеты */
.canister-stage {
  width: 100%;
  max-width: 310px;
  height: 92px;
  margin: 4px auto 10px;
  display: flex;
  align-items: center;
  position: relative;
}

.canister-body {
  width: 68px;
  height: 86px;
  border-radius: 10px;
  background: linear-gradient(180deg, #27211c 0%, #161210 100%);
  border: 1px solid var(--border-strong);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 245, 228, 0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  z-index: 3;
  flex-shrink: 0;
}

.canister-cap {
  position: absolute;
  top: -7px;
  width: 24px;
  height: 7px;
  border-radius: 3px 3px 0 0;
  background: #3a3129;
  border: 1px solid var(--border-strong);
  border-bottom: none;
}

.canister-spool {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px dashed var(--amber);
  margin-bottom: 4px;
}

.canister-stage.rewinding .canister-spool {
  animation: spin 0.55s linear 3;
}

.canister-label {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--amber);
  line-height: 1;
}

.canister-sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-sec);
  letter-spacing: 0.06em;
}

.film-track {
  flex: 1;
  height: 68px;
  overflow: hidden;
  position: relative;
  margin-left: -6px;
  z-index: 1;
}

.film-strip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 68px;
  padding: 10px 10px 10px 14px;
  background: #1d1814;
  border-top: 2px dashed rgba(244, 235, 221, 0.35);
  border-bottom: 2px dashed rgba(244, 235, 221, 0.35);
  border-right: 1px solid var(--border-strong);
  border-radius: 0 6px 6px 0;
  transform: translateX(0);
}

.canister-stage.rewinding .film-strip {
  animation: rewindFilm 1650ms cubic-bezier(0.45, 0.02, 0.25, 1) forwards;
}

.canister-stage.rewound .film-strip {
  transform: translateX(-86%);
  opacity: 0.55;
}

.film-mini-frame {
  width: 44px;
  height: 44px;
  border-radius: 3px;
  background: #2b231d;
  border: 1px solid rgba(229, 169, 82, 0.35);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--amber);
}

.film-mini-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@keyframes rewindFilm {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  15% {
    transform: translateX(4px);
    opacity: 1;
  }
  100% {
    transform: translateX(-86%);
    opacity: 0.55;
  }
}

@media (prefers-reduced-motion: reduce) {
  .print-card.fly-to-film,
  .print-card.next-frame-in,
  .canister-stage.rewinding .film-strip,
  .canister-stage.rewinding .canister-spool {
    animation: none !important;
  }
}

/* Блоки состояний */
.state-block {
  padding: 36px 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.state-block h2 {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.18;
  font-weight: 500;
  color: var(--ink);
  text-wrap: balance;
}

.state-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--amber);
}

.muted {
  color: var(--ink-sec);
  font-size: 14px;
  line-height: 1.55;
  text-wrap: pretty;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Уведомление */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: var(--paper);
  color: var(--ink-dark);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  z-index: 150;
}

.footer {
  margin-top: auto;
  padding-top: 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.footer a {
  color: var(--ink-sec);
  text-decoration: none;
}

.footer a:hover {
  color: var(--ink);
}

.back-link {
  font-size: 13px;
  color: var(--ink-sec);
  text-decoration: none;
  transition: color 150ms var(--ease);
}

.back-link:hover {
  color: var(--ink);
}

/* Страница /privacy */
.privacy-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.privacy-card h2 {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin-top: 4px;
}

.privacy-card h2:first-child {
  margin-top: 0;
}

.privacy-card p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-sec);
}

.privacy-card code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--amber);
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
