/* Sovpali Today — premium clean, selective glass. No legacy. */

@font-face {
  font-family: "Onest";
  src: url("fonts/onest-regular-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-regular-cyrillic.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-medium-latin.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-medium-cyrillic.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-semibold-latin.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-semibold-cyrillic.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-bold-latin.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-bold-cyrillic.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  --canvas: #F3F4F6;
  --canvas-elevated: #F8F8FA;
  --surface-floating: #FFFFFF;
  --surface-solid: #FFFFFF;
  --surface-muted: #EDEEF2;
  --surface-glass: rgba(248, 249, 251, 0.72);

  --ink: #16181D;
  --ink-secondary: #626772;
  --ink-muted: #9297A1;
  --ink-on-media: #FFFFFF;

  --primary: #4963D8;
  --primary-pressed: #3F56BF;
  --primary-soft: rgba(73, 99, 216, 0.10);
  --on-primary: #FFFFFF;

  --border: rgba(22, 24, 29, 0.08);
  --border-strong: rgba(22, 24, 29, 0.14);
  --glass-border: rgba(255, 255, 255, 0.62);

  --rating: #B98219;
  --success: #43845F;

  --shadow-card: 0 8px 28px rgba(31, 35, 48, 0.06);
  --shadow-soft: 0 4px 16px rgba(31, 35, 48, 0.04);
  --shadow-glass:
    0 12px 36px rgba(31, 35, 48, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);

  --media-scrim: linear-gradient(
    to top,
    rgba(8, 10, 14, 0.88) 0%,
    rgba(8, 10, 14, 0.40) 48%,
    rgba(8, 10, 14, 0.06) 78%,
    transparent 100%
  );

  --radius-control: 14px;
  --radius-card: 18px;
  --radius-media: 20px;
  --radius-sheet: 26px;

  /* floating pill dock: content clearance = pill + float gap + safe */
  --dock-h: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  --font:
    "Onest",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    system-ui,
    sans-serif;

  --type-display: 30px;
  --type-title: 22px;
  --type-section: 17px;
  --type-body: 15px;
  --type-meta: 13px;
  --type-label: 12px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.48;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.app-shell {
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--canvas);
  position: relative;
  padding-bottom: calc(var(--dock-h) + var(--safe-bottom) + 20px);
}

/* Older markup still uses these names; both now render as opaque paper. */
.glass-shell {
  background: var(--canvas-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.glass-surface {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

@media (prefers-reduced-transparency: reduce) {
  .glass-shell, .glass-surface {
    background: var(--canvas-elevated);
  }
}

/* Minimal brand top — not a heavy card */
.app-top {
  padding: calc(10px + var(--safe-top)) 16px 6px;
  text-align: center;
  background: transparent;
}

.brand {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: var(--ink-muted);
}

.brand-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 400;
}

.app-main {
  padding: 4px 0 28px;
}

.section {
  padding: 0 16px;
  margin-top: 22px;
}

.section-rail {
  padding-right: 0;
  margin-top: 10px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-right: 16px;
}

.section-title {
  margin: 0;
  font-size: var(--type-section);
  font-weight: 600;
  line-height: 1.25;
}

.screen-title {
  margin: 0 0 8px;
  font-size: var(--type-title);
  font-weight: 700;
  line-height: 1.16;
}

.body-text {
  margin: 0;
  font-size: var(--type-body);
  color: var(--ink);
  line-height: 1.5;
}

.body-text.muted,
.muted { color: var(--ink-secondary); }

.meta {
  margin: 0;
  font-size: var(--type-label);
  font-weight: 500;
  color: var(--ink-muted);
  line-height: 1.35;
}

.hint {
  margin: 10px 0 0;
  font-size: var(--type-meta);
  color: var(--ink-secondary);
  text-align: center;
}

.soft-top { margin-top: 16px; }

/* ===== Rail — hero afisha ===== */
.rail {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-x;
}

.rail::-webkit-scrollbar { display: none; }

.rail-track {
  display: flex;
  gap: 12px;
  padding: 2px 16px 8px;
  width: max-content;
}

.rail-card {
  width: min(86vw, 430px);
  max-width: 430px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-media);
  overflow: hidden;
  position: relative;
  scroll-snap-align: start;
  flex: 0 0 auto;
  background: var(--surface-muted);
  box-shadow: var(--shadow-card);
  border: none;
  padding: 0;
  text-align: left;
  color: var(--ink-on-media);
}

.rail-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* faces / key art on TMDB backdrops sit slightly above geometric center */
  object-position: var(--focus-x, 50%) var(--focus-y, 50%);
}

.rail-card--image-fallback {
  background:
    radial-gradient(circle at 78% 20%, rgba(255, 255, 255, 0.2), transparent 32%),
    linear-gradient(135deg, #495064 0%, #262b38 55%, #191c25 100%);
}

.rail-card .media-scrim {
  position: absolute;
  inset: 0;
  background: var(--media-scrim);
  pointer-events: none;
}

.rail-card__content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 16px 16px;
  z-index: 1;
}

.rail-card__title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rail-card__meta {
  margin: 5px 0 0;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.9;
}

.rail-card__why {
  margin: 7px 0 0;
  font-size: 13px;
  line-height: 1.35;
  opacity: 0.92;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rail-card.skeleton {
  background: linear-gradient(90deg, #e6e7ec 0%, #f1f2f5 50%, #e6e7ec 100%);
  background-size: 200% 100%;
  animation: shimmer 1.25s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.section-caption,
.rail-taste {
  margin: -4px 16px 10px 0;
  padding-right: 16px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink-secondary);
}

/* Match Launcher — product CTA, not generic button */
.section-actions__row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(132px, 0.8fr);
  gap: 10px;
  align-items: stretch;
}

.match-launch {
  width: 100%;
  min-height: 80px;
  padding: 15px 14px 15px 18px;
  display: grid;
  grid-template-columns: 1fr 46px;
  align-items: center;
  gap: 14px;
  border: none;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  text-align: left;
  box-shadow: 0 14px 30px rgba(106, 71, 95, 0.24);
  cursor: pointer;
  font: inherit;
}

.match-launch:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.match-launch__copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.match-launch__copy strong {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.1;
}

.match-launch__copy span {
  font-size: 13px;
  line-height: 1.3;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.78);
}

.match-launch__action {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
}

.match-launch__action img,
.match-launch__action svg {
  display: block;
  color: #fff;
  opacity: 0.95;
}
.match-launch__action img {
  filter: brightness(0) invert(1);
}

.decide-launch {
  min-width: 0;
  min-height: 80px;
  padding: 14px 13px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface-solid);
  color: var(--ink);
  text-align: left;
  font: inherit;
  box-shadow: var(--shadow-soft);
}

.decide-launch strong {
  font-size: 15px;
  line-height: 1.15;
  font-weight: 700;
}

.decide-launch span {
  color: var(--ink-secondary);
  font-size: var(--type-label);
  line-height: 1.3;
}

.decide-launch:not(:disabled):active { transform: translateY(1px); }
.decide-launch:disabled { opacity: 0.58; cursor: not-allowed; }
.decide-hint { margin-top: 9px; }

/* Кинопочерк — free block, not glass card */
.handwriting {
  padding: 4px 0 2px;
}

.handwriting__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.handwriting__chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  background: rgba(22, 24, 29, 0.06);
  border: 1px solid rgba(22, 24, 29, 0.06);
}

.handwriting__headline {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}

.handwriting__summary {
  margin: 0;
  font-size: var(--type-body);
  line-height: 1.45;
  color: var(--ink-secondary);
}

.handwriting__secondary {
  margin: 10px 0 0;
  font-size: var(--type-meta);
  line-height: 1.4;
  color: var(--ink-tertiary, #8b8f99);
}

.rail-msg {
  margin: 4px 16px 0 0;
  padding-right: 16px;
  font-size: 14px;
  color: var(--ink-secondary);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.rail-retry {
  border: 1px solid rgba(22, 24, 29, 0.14);
  background: #fff;
  border-radius: 12px;
  padding: 8px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-primary, #16181d);
  cursor: pointer;
}

.rail-retry:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ===== Resume / taste / past ===== */
.resume-card,
.past-card {
  background: #fff;
  border: 1px solid rgba(22, 24, 29, 0.08);
  box-shadow: var(--shadow-soft);
  border-radius: var(--radius-card);
}
.resume-card {
  width: 100%;
  min-width: 0;
  padding: 16px;
  overflow: hidden;
}
.taste-card {
  border-radius: var(--radius-card);
  padding: 14px 16px;
}

.resume-live {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.resume-card__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.resume-card__sub {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-secondary);
}

.resume-progress__row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 48px;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.resume-progress__label {
  font-size: 12px;
  color: var(--ink-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.resume-progress__count {
  font-size: 12px;
  text-align: right;
  color: var(--ink-secondary);
}

.resume-card__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.resume-card__actions .btn-primary {
  width: 100%;
}
.resume-card__actions .btn-danger {
  width: auto;
  min-height: 38px;
  padding: 6px 10px;
  align-self: center;
}

.section-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  min-height: 50px;
  padding: 13px 18px;
  border-radius: var(--radius-control);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.985); }

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 8px 22px rgba(106, 71, 95, 0.22);
}

.btn-primary:active { background: var(--primary-pressed); }

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  border: 1px solid var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  min-height: 40px;
  padding: 8px 0;
  font-weight: 600;
}

.btn-block { width: 100%; }

/* No heavy default outline when a button is focused programmatically (e.g. sheet
   open); show a soft ring only for real keyboard navigation. */
.btn:focus {
  outline: none;
}
.btn:focus-visible {
  outline: 3px solid rgba(106, 71, 95, 0.34);
  outline-offset: 2px;
}

.past-card {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  border-radius: var(--radius-card);
  padding: 12px;
  text-align: left;
}

.past-card__img {
  width: 56px;
  height: 84px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--surface-muted);
  flex-shrink: 0;
}

.past-card__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.past-card__meta,
.past-card__fb {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-secondary);
}

.empty-inline {
  margin: 0;
  font-size: 14px;
  color: var(--ink-muted);
}

.detail-decide-accept { margin-top: 16px; }

@media (max-width: 360px) {
  .section-actions__row { grid-template-columns: 1fr; }
  .decide-launch { min-height: 58px; }
}

/* ===== Couple surfaces: quiet editorial timeline + identity ===== */
.companion-screen {
  padding: 0 0 calc(var(--dock-h) + var(--safe-bottom) + 28px);
}

.companion-head {
  padding: 28px 18px 22px;
  border-bottom: 1px solid var(--border);
}

.companion-head .tastes-back {
  margin: -8px 0 18px;
}

.tastes-screen .companion-section {
  padding-top: 20px;
}

.companion-kicker {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.companion-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.08;
  font-weight: 700;
}

.companion-lede {
  max-width: 420px;
  margin: 9px 0 0;
  color: var(--ink-secondary);
  font-size: 14px;
  line-height: 1.45;
}

.companion-section {
  padding: 22px 18px 24px;
  border-bottom: 1px solid var(--border);
}

.companion-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.companion-section__head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.companion-section__head span {
  color: var(--ink-muted);
  font-size: 12px;
}

.history-list {
  display: block;
}

.history-item {
  width: 100%;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px 2px;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  text-align: left;
  transition: background 0.15s ease;
}

button.history-item { cursor: pointer; }
button.history-item:hover { background: rgba(106, 71, 95, 0.05); }
button.history-item:active { background: rgba(106, 71, 95, 0.09); }
.history-item:last-child { border-bottom: 0; }
.history-item:focus { outline: none; }
.history-item:focus-visible {
  outline: 3px solid rgba(106, 71, 95, 0.28);
  outline-offset: 2px;
}

.history-item__media {
  width: 66px;
  height: 94px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface-muted);
}

.history-item__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-item__placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 6px;
  color: var(--ink-muted);
  font-size: 10px;
  line-height: 1.25;
  text-align: center;
}

.history-item__body { min-width: 0; }
.history-item__title {
  display: block;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.history-item__meta,
.history-item__context {
  display: block;
  margin: 5px 0 0;
  color: var(--ink-secondary);
  font-size: 12px;
  line-height: 1.35;
}
.history-item__context { color: var(--ink-muted); }
.history-item__arrow {
  color: var(--ink-muted);
  font-size: 22px;
  line-height: 1;
}

.history-load-more {
  width: 100%;
  min-height: 44px;
  margin: 12px 0 0;
  padding: 10px 2px;
  border-top: 1px solid var(--border);
  color: var(--primary);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.history-load-more:disabled {
  color: var(--ink-muted);
  cursor: wait;
}

.companion-state {
  padding: 28px 0;
  color: var(--ink-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.couple-state {
  padding: 28px 18px;
  color: var(--ink-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.companion-state:empty,
.couple-state:empty { display: none; }

.state-panel {
  display: grid;
  gap: 10px;
  max-width: 440px;
}
.state-panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: 19px;
  line-height: 1.25;
}
.state-panel p { margin: 0; }
.state-panel .btn { margin-top: 4px; }

.couple-content { padding-bottom: 12px; }
.couple-identity {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px 18px 16px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.couple-avatars {
  display: flex;
  align-items: center;
  justify-content: center;
}
.couple-avatar {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid var(--canvas);
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 24px;
  font-weight: 700;
}
.couple-avatar + .couple-avatar { margin-left: -12px; }
.couple-avatar img { width: 100%; height: 100%; object-fit: cover; }
.couple-link {
  width: 24px;
  height: 1px;
  margin: 0 4px;
  background: rgba(106, 71, 95, 0.35);
}
.couple-identity h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
}
.couple-identity p {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 13px;
}

.couple-actions {
  display: grid;
  padding: 0 18px 22px;
  border-bottom: 1px solid var(--border);
}
.couple-dissolve {
  margin: 10px 18px 16px;
  width: calc(100% - 36px);
  color: #a63a32;
}

.section-action {
  min-height: 32px;
  padding: 4px 0;
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
}

.couple-tastes {
  padding-top: 20px;
}

.taste-settings {
  margin-top: 20px;
  border-top: 1px solid var(--border);
}

.taste-settings summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  color: var(--ink-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  list-style: none;
}

.taste-settings summary::-webkit-details-marker { display: none; }
.taste-settings summary::after {
  content: "›";
  color: var(--ink-muted);
  font-size: 22px;
  line-height: 1;
  transition: transform 0.15s ease;
}
.taste-settings[open] summary::after { transform: rotate(90deg); }
.taste-settings form {
  display: grid;
  gap: 22px;
  padding: 4px 0 4px;
}
.taste-settings .tastes-fieldset legend { margin-bottom: 10px; }
.taste-setting h3 {
  margin: 0 0 10px;
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 600;
}
.taste-settings .tastes-save { margin-top: -2px; }

@media (min-width: 520px) {
  .history-item { grid-template-columns: 76px minmax(0, 1fr) auto; }
  .history-item__media { width: 76px; height: 108px; }
}

/* ===== Dock — compact floating navigation, available throughout a match ===== */
.dock {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(8px + var(--safe-bottom));
  width: calc(100% - 32px);
  max-width: 496px;
  min-height: var(--dock-h);
  padding: 6px 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  z-index: 60;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-floating);
  box-shadow: 0 10px 26px rgba(64, 45, 47, 0.14), 0 1px 0 rgba(255, 253, 248, 0.9) inset;
}

@media (min-width: 521px) {
  .dock {
    left: 50%;
    right: auto;
    width: 496px;
    transform: translateX(-50%);
  }
}

/* Compatibility hook for legacy markup that still adds glass-shell to the dock. */
.dock.glass-shell {
    background: var(--surface-floating);
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 46px;
  border-radius: 12px;
  color: var(--ink-muted);
  padding: 6px 4px;
  transition: color 0.15s ease;
}

.dock-item.is-active {
  color: var(--primary);
  background: transparent;
  box-shadow: inset 0 -2px 0 var(--primary);
}

.dock-item.is-muted {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.dock-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.dock-icon {
  display: flex;
}

.dock-icon--badged { position: relative; }
.dock-badge {
  position: absolute;
  top: -3px;
  right: -5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c0392b;
  box-shadow: 0 0 0 2px rgba(248, 248, 250, 0.96);
}

/* ===== My tastes ===== */
.tastes-screen {
  padding: 0 0 calc(var(--dock-h) + var(--safe-bottom) + 34px);
}
.tastes-head {
  padding: 28px 18px 24px;
  border-bottom: 1px solid rgba(22, 24, 29, 0.09);
}
.tastes-kicker {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.tastes-title {
  margin-top: 5px;
  font-size: 30px;
  line-height: 1.08;
  font-weight: 700;
}
.tastes-readiness {
  margin: 14px 0 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-secondary);
  font-size: 14px;
}
.tastes-readiness::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c0392b;
  flex: 0 0 auto;
}
.tastes-readiness.is-ready::before { background: #27875f; }
.tastes-group {
  padding: 22px 18px 24px;
  border-bottom: 1px solid rgba(22, 24, 29, 0.09);
}
.tastes-group__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.tastes-group__head h2 { font-size: 18px; line-height: 1.2; }
.tastes-group__head span { color: var(--ink-muted); font-size: 13px; }
.tastes-expand {
  margin-left: auto;
  padding: 3px 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.tastes-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.tastes-pick { min-width: 0; }
.tastes-pick img,
.tastes-pick__empty {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #dde0e6;
}
.tastes-pick p {
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.tastes-empty {
  grid-column: 1 / -1;
  color: var(--ink-muted);
  font-size: 14px;
  padding: 8px 0;
}
.tastes-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.tastes-fieldset legend,
.tastes-reconfigure h2 {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
}
.tastes-era-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.tastes-era-option {
  position: relative;
  min-width: 0;
}
.tastes-era-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.tastes-era-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 6px;
  border: 1px solid rgba(22, 24, 29, 0.14);
  border-radius: 7px;
  color: var(--ink-secondary);
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.tastes-era-option input:checked + span {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(106, 71, 95, 0.1);
}
.tastes-era-option input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.tastes-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tastes-chip {
  min-height: 36px;
  max-width: 100%;
  padding: 7px 11px;
  border: 1px solid rgba(22, 24, 29, 0.13);
  border-radius: 999px;
  color: var(--ink-secondary);
  background: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.tastes-chip[aria-pressed="true"] {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(106, 71, 95, 0.11);
}
.tastes-chips--excluded .tastes-chip[aria-pressed="true"] {
  border-color: #a63a32;
  color: #8d2f29;
  background: rgba(192, 57, 43, 0.09);
}
.tastes-save { margin-top: 20px; }
.tastes-save-status {
  min-height: 18px;
  margin-top: 8px;
  color: var(--ink-muted);
  font-size: 12px;
  text-align: center;
}
.tastes-reconfigure { padding-bottom: 8px; }
.onboard-close { margin-bottom: 12px; }

.dock-icon img {
  display: block;
  opacity: 0.9;
  width: 20px;
  height: 20px;
}

@media (prefers-reduced-transparency: reduce) {
  .dock {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ===== Sheets ===== */
.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overscroll-behavior: none;
  /* do NOT use touch-action:none — blocks pan-y inside detail sheet in TG WebView */
  touch-action: manipulation;
}

.sheet-scrim {
  position: absolute;
  inset: 0;
  background: rgba(16, 18, 24, 0.38);
  touch-action: none;
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: min(90dvh, 820px);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 1;
  animation: sheet-up 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  touch-action: pan-y;
  will-change: transform;
}

.sheet--solid {
  background: var(--canvas-elevated);
  box-shadow: 0 -8px 40px rgba(64, 45, 47, 0.12);
}

/*
 * Movie detail sheet = THE scrollport (not a nested flex child).
 * Telegram WebView often fails nested overflow; scrolling the sheet itself is reliable.
 */
.sheet--detail {
  background: var(--canvas);
  box-shadow: 0 -8px 40px rgba(64, 45, 47, 0.12);
  height: min(92dvh, 860px);
  max-height: min(92dvh, 860px);
  display: block; /* override .sheet flex — one column document */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 0 0 calc(16px + var(--safe-bottom));
}

.sheet.is-dragging {
  animation: none;
  transition: none;
}

.sheet.is-returning {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet.is-dismissing {
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sheet-up {
  from { transform: translateY(28px); opacity: 0.7; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-chrome {
  position: sticky;
  top: 0;
  z-index: 5;
  flex-shrink: 0;
  min-height: 32px;
  padding: 10px 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  background: var(--canvas);
}

.sheet--detail .sheet-chrome {
  /* stays visible while the movie card (incl. image) scrolls under it */
  background: linear-gradient(180deg, var(--canvas) 70%, rgba(244, 240, 232, 0));
}

.sheet-handle {
  width: 40px;
  height: 5px;
  border-radius: 99px;
  background: rgba(22, 24, 29, 0.18);
  flex-shrink: 0;
  pointer-events: none;
}

/* Feedback / past: simple body scroll */
.sheet-body {
  padding: 10px 16px calc(22px + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
  background: var(--canvas-elevated);
  touch-action: pan-y;
}

/* Unified movie card: image + text in one flow, scrolls with sheet--detail.
   Gray gutter around the card is intentional — full-bleed image = old cached CSS. */
.movie-detail-card {
  display: block;
  margin: 0 14px 12px;
  overflow: hidden;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-media);
  box-shadow: var(--shadow-card);
  position: relative;
  /* never sticky / fixed as a whole */
  top: auto !important;
  bottom: auto !important;
}

/* 16:9 framed hero — in document flow, scrolls away with the card */
.movie-detail-card__media {
  display: block;
  margin: 0;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(42vw, 220px);
  overflow: hidden;
  background: #16181D;
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  float: none !important;
}

.movie-detail-card__media img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  object-fit: cover;
  object-position: 50% 28%;
  position: absolute !important;
  inset: 0;
}

.movie-detail-card__content {
  display: block;
  padding: 14px 16px 22px;
  position: relative;
  background: #fff;
}

.detail-why-block {
  margin: 16px 0 4px;
}

.detail-why-heading {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
}

.detail-why-list {
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--ink-secondary);
  font-size: 14px;
  line-height: 1.45;
}

.detail-why-list li {
  margin: 0 0 6px;
}

.detail-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.18;
}

.detail-meta {
  margin: 6px 0 12px;
  font-size: 13px;
  color: var(--ink-secondary);
}

.detail-synopsis {
  color: var(--ink-secondary);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
}

.detail-synopsis.is-expanded {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.link-more {
  border: none;
  background: none;
  padding: 0;
  margin: 4px 0 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

.detail-why {
  font-weight: 500;
}

.pair-fit {
  border-radius: 14px;
  padding: 14px 14px;
  margin: 14px 0 0;
  background: var(--canvas-elevated);
  border: 1px solid var(--border);
}

.pair-fit__label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}

.pair-fit__value {
  margin: 8px 0 0;
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
}

.pair-fit__value.is-low {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-secondary);
  line-height: 1.45;
  letter-spacing: 0;
}

.pair-fit__reason {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--ink-secondary);
  line-height: 1.45;
}

/* Past match sheet media: landscape backdrop by default, portrait poster fallback */
.past-media {
  margin: 0 0 14px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface-muted);
}
.past-media__img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.past-media--portrait {
  max-width: 160px;
}
.past-media--portrait .past-media__img {
  aspect-ratio: 2 / 3;
}

.past-context {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--text-muted, #6b7280);
}

/* Stars */
.stars {
  display: flex;
  gap: 6px;
  margin: 16px 0 8px;
}

.star {
  font-size: 32px;
  line-height: 1;
  color: #d8dae0;
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
}

.star.is-on { color: var(--rating); }

.stars-hint { margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  padding: 12px;
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
  min-height: 88px;
  margin-bottom: 14px;
  background: var(--surface-solid);
  color: var(--ink);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(92vw, 400px);
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  box-shadow: 0 12px 32px rgba(31, 35, 48, 0.18);
}

/* Body lock when sheet open — prevent whole-app drag */
html.sheet-open,
html.sheet-open body {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
  height: 100%;
}

body.sheet-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
}

body.sheet-open .app-shell {
  pointer-events: none;
}

body.sheet-open .sheet-root {
  pointer-events: auto;
}

/* ===== Onboarding preferences ===== */
.onboard {
  position: fixed;
  inset: 0;
  z-index: 80;
  overflow: auto;
  background: var(--canvas);
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  --onboard-actions-clearance: 148px;
}
.onboard-inner {
  max-width: 440px;
  margin: 0 auto;
  padding-bottom: 40px;
}
.onboard-kicker {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  margin: 8px 0 4px;
}
.onboard-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
}
.onboard-search {
  margin: 16px 0 12px;
}
.onboard-input {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  border-radius: var(--radius-control);
  padding: 14px 16px;
  font: inherit;
  font-size: 16px;
  outline: none;
  box-sizing: border-box;
}
.onboard-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.onboard-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 36px; /* reduce jump when first chip appears */
}
.onboard-selected-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin: 0 0 10px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--ink-secondary);
  background: var(--surface-solid);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.onboard-selected-toggle[aria-expanded="true"] { color: var(--ink); }
.onboard-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 13px;
  font-weight: 500;
  max-width: 100%;
}
.onboard-chip button {
  border: 0;
  background: transparent;
  color: var(--on-primary);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
/* The first choices stay large enough to inspect, not a wall of posters. */
.onboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  min-height: 160px;
  margin-bottom: 12px;
  padding-bottom: var(--onboard-actions-clearance);
}
@media (min-width: 420px) {
  .onboard-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
.onboard-tile {
  position: relative;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  font: inherit;
  text-align: left;
  aspect-ratio: 2 / 3;
  box-shadow: 0 4px 14px rgba(31, 35, 48, 0.08);
  -webkit-tap-highlight-color: transparent;
}
.onboard-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: linear-gradient(145deg, #e5e7eb, #f3f4f6);
}
.onboard-tile__ph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 8px;
  background: linear-gradient(160deg, #e8eaf0, #f5f3ff);
  color: #4b5563;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
}
.onboard-tile__cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 6px 6px;
  background: linear-gradient(transparent, rgba(15, 17, 24, 0.88));
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  max-height: 42%;
  overflow: hidden;
}
.onboard-tile__check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(15, 17, 24, 0.35);
  color: transparent;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}
.onboard-tile__rating {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 3px 7px;
  border-radius: 8px;
  background: rgba(15, 17, 24, 0.72);
  color: #fbbf24;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  backdrop-filter: blur(4px);
  z-index: 1;
}
.onboard-tile:focus {
  outline: none;
}
.onboard-tile:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.onboard-tile.is-on {
  outline: 2.5px solid var(--primary);
  outline-offset: 1px;
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.onboard-tile.is-on .onboard-tile__check {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.onboard-loading {
  text-align: center;
  font-size: 13px;
  color: #6b7280;
  margin: 0 0 8px;
}
.onboard-actions {
  position: sticky;
  bottom: 0;
  z-index: 12;
  isolation: isolate;
  margin: 0;
  padding: 10px 6px calc(8px + var(--safe-bottom));
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: var(--canvas);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
body.onboard-open .app-main,
body.onboard-open .dock,
body.onboard-open .app-top {
  visibility: hidden;
}
.section-action:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 4px;
}
.taste-detail {
  margin: 14px 0 0;
  color: var(--ink-secondary);
  font-size: 13px;
}

.taste-detail::first-letter { color: var(--ink-muted); }
