/* Шрифты лежат рядом — ничего не грузим с Google */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(fonts/inter-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(fonts/inter-latin-wght-normal.woff2) format("woff2"); 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: "Playfair Display"; font-style: normal; font-weight: 400 900; font-display: swap; src: url(fonts/playfair-display-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Playfair Display"; font-style: normal; font-weight: 400 900; font-display: swap; src: url(fonts/playfair-display-latin-wght-normal.woff2) format("woff2"); 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: "Playfair Display"; font-style: italic; font-weight: 400 900; font-display: swap; src: url(fonts/playfair-display-cyrillic-wght-italic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Playfair Display"; font-style: italic; font-weight: 400 900; font-display: swap; src: url(fonts/playfair-display-latin-wght-italic.woff2) format("woff2"); 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: "Caveat"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/caveat-cyrillic-700-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Caveat"; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/caveat-latin-700-normal.woff2) format("woff2"); 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: "Marck Script"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/marck-script-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Marck Script"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/marck-script-latin-400-normal.woff2) format("woff2"); 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; }

/* Палитра и шрифты — как у страницы-барабана ../slot */
:root {
  --bg: #1a110c;
  --brass: #e0b45c;
  --brass-lo: #9c7428;
  --cream: #f6ecd9;
  --ink: #2a1a10;
  --text-soft: #d9c7ad;
  --red: #e2503c;
  --panel: rgba(26, 17, 12, 0.5);
  --line: rgba(246, 236, 217, 0.2);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--cream); font-family: "Inter", system-ui, sans-serif; overscroll-behavior: none; }
body { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; touch-action: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.hidden { display: none !important; }

/* Видео на странице не показываем — его рисует холст. Но оно должно «играть», поэтому не display: none. */
#cam { position: absolute; left: 0; top: 0; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
#glass { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

/* Метка пальца — только на странице, в фото и клип не попадает */
.cursor { position: absolute; left: 0; top: 0; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 0 14px rgba(255, 255, 255, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.15s, width 0.15s, height 0.15s, margin 0.15s, border-color 0.15s; will-change: transform; }
.cursor::after { content: ""; position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); white-space: nowrap; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--cream); background: rgba(26, 17, 12, 0.72); opacity: 0; }
.cursor.write { opacity: 1; background: rgba(255, 255, 255, 0.35); }
.cursor.pause::after { content: "пауза"; opacity: 1; }
.cursor.palm::after { content: "стираю"; opacity: 1; }
.cursor.pause { opacity: 0.8; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-style: dashed; box-shadow: none; }
.cursor.palm { opacity: 0.7; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-color: var(--brass); }

/* ---------- Кнопки по краям ---------- */
.rail { position: absolute; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 10px; z-index: 5; }
.rail.left { left: calc(12px + var(--sl)); }
.rail.right { right: calc(12px + var(--sr)); }
.rb { position: relative; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22); transition: background 0.15s, transform 0.12s, border-color 0.15s; }
.rb svg { width: 22px; height: 22px; fill: none; stroke: var(--cream); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rb:hover { background: rgba(26, 17, 12, 0.72); border-color: rgba(224, 180, 92, 0.6); }
.rb:active { transform: scale(0.92); }
.rb:focus-visible, .go:focus-visible, .link:focus-visible, .sw:focus-visible, .breathe:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.rb[aria-expanded="true"] { background: rgba(224, 180, 92, 0.9); border-color: var(--brass); }
.rb[aria-expanded="true"] svg { stroke: var(--ink); }
.rb.rec .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--red); transition: border-radius 0.2s, transform 0.2s; }
.rb.rec { border-color: rgba(246, 236, 217, 0.55); }
body.recording .rb.rec .dot { border-radius: 4px; transform: scale(0.8); }
/* подписи к кнопкам — при наведении */
.rb::after { content: attr(data-tip); position: absolute; top: 50%; transform: translateY(-50%); white-space: nowrap; font-size: 12.5px; font-weight: 500; padding: 6px 10px; border-radius: 8px; background: rgba(26, 17, 12, 0.88); color: var(--cream); opacity: 0; pointer-events: none; transition: opacity 0.15s; }
.rail.left .rb::after { left: calc(100% + 10px); }
.rail.right .rb::after { right: calc(100% + 10px); }
@media (hover: hover) { .rb:hover::after { opacity: 1; } }
.rb[aria-expanded="true"]::after { display: none; }

/* ---------- Всплывающие панели ---------- */
.pop { position: absolute; left: calc(66px + var(--sl)); top: 50%; transform: translateY(-50%); z-index: 6; width: min(300px, calc(100vw - 132px - var(--sl) - var(--sr))); max-height: calc(100svh - 24px); overflow: auto; padding: 10px; border-radius: 18px; background: rgba(26, 17, 12, 0.78); border: 1px solid var(--line); -webkit-backdrop-filter: blur(22px) saturate(1.3); backdrop-filter: blur(22px) saturate(1.3); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45); touch-action: pan-y; }
.sw { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border-radius: 12px; text-align: left; font-size: 14.5px; font-weight: 600; }
.sw small, .tog small { display: block; font-size: 12px; font-weight: 400; color: var(--text-soft); margin-top: 1px; }
.sw:hover { background: rgba(246, 236, 217, 0.08); }
.sw[aria-checked="true"] { background: rgba(224, 180, 92, 0.16); box-shadow: inset 0 0 0 1px rgba(224, 180, 92, 0.6); }
.chip { flex: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); }
.chip.warm { background: radial-gradient(circle at 35% 35%, #fff, #e9e3d8 60%, #cbbfae); }
.chip.cold { background: radial-gradient(circle at 35% 35%, #f4fbff, #b9d8f4 60%, #7fa9d6); }
.chip.night { background: radial-gradient(circle at 70% 70%, #ffb054 0, #6b3a1a 22%, #14121c 60%); }
.row { display: block; padding: 8px 10px 10px; font-size: 13.5px; }
.row > span { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; color: var(--cream); }
.row b { color: var(--brass); font-weight: 600; font-variant-numeric: tabular-nums; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; touch-action: pan-x; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgba(246, 236, 217, 0.28); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(246, 236, 217, 0.28); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: var(--brass); border: 2px solid var(--bg); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--brass); border: 2px solid var(--bg); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 3px; border-radius: 10px; background: rgba(246, 236, 217, 0.1); }
.seg button { padding: 7px 0; border-radius: 8px; font-size: 13px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--brass); color: var(--ink); font-weight: 700; }
textarea { display: block; width: 100%; resize: none; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(246, 236, 217, 0.08); color: var(--cream); font: 500 17px/1.3 "Inter", system-ui, sans-serif; user-select: text; -webkit-user-select: text; touch-action: auto; }
textarea::placeholder { color: rgba(217, 199, 173, 0.55); }
textarea:focus { outline: 2px solid var(--brass); outline-offset: 1px; }
.fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0 4px; }
.fonts button { height: 42px; padding: 0 6px; border-radius: 10px; background: rgba(246, 236, 217, 0.08); white-space: nowrap; overflow: hidden; }
.fonts button[aria-checked="true"] { background: rgba(224, 180, 92, 0.18); box-shadow: inset 0 0 0 1px rgba(224, 180, 92, 0.7); color: var(--brass); }
#popText .go { margin-top: 6px; }
.tog { display: flex; align-items: center; gap: 12px; padding: 9px 10px; font-size: 13.5px; font-weight: 500; cursor: pointer; }
.tog input { position: absolute; opacity: 0; pointer-events: none; }
.tog i { flex: none; width: 40px; height: 24px; border-radius: 12px; background: rgba(246, 236, 217, 0.22); position: relative; transition: background 0.18s; }
.tog i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--cream); transition: transform 0.18s; }
.tog input:checked + i { background: var(--brass); }
.tog input:checked + i::after { transform: translateX(16px); }
.tog input:focus-visible + i { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ---------- Подсказка, статус, запись ---------- */
.bottom { position: absolute; left: 0; right: 0; bottom: calc(14px + var(--sb)); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 12px; z-index: 4; pointer-events: none; }
.hint { max-width: 100%; padding: 8px 16px; border-radius: 999px; font-size: 13.5px; line-height: 1.35; text-align: center; background: var(--panel); border: 1px solid var(--line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); color: var(--cream); text-wrap: balance; transition: opacity 0.6s; }
.hint.dim { opacity: 0.55; }
.breathe { pointer-events: auto; display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 999px; font-size: 15px; font-weight: 600; color: var(--ink); background: linear-gradient(#f0cb7c, #d6a548); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5); touch-action: none; }
.breathe svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
.breathe:active, .breathe.on { transform: scale(0.96); filter: brightness(1.08); }
.status, .recbadge, .toast { position: absolute; left: 50%; transform: translateX(-50%); z-index: 7; max-width: calc(100vw - 132px); padding: 7px 14px; border-radius: 999px; font-size: 13px; text-align: center; background: rgba(26, 17, 12, 0.7); border: 1px solid var(--line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); pointer-events: none; }
.status { top: calc(12px + var(--st)); }
.recbadge { top: calc(12px + var(--st)); display: flex; align-items: center; gap: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }
.recbadge i { width: 9px; height: 9px; border-radius: 50%; background: var(--red); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.toast { top: calc(56px + var(--st)); max-width: min(440px, calc(100vw - 32px)); border-radius: 14px; z-index: 30; }

/* «Скрыть интерфейс»: остаётся только картинка. Вернуть — клавиша H или угол экрана. */
.unhide { position: absolute; right: 0; top: 0; width: 72px; height: 72px; z-index: 8; display: none; opacity: 0; }
body.clean .ui, body.clean .cursor, body.in-start .ui { display: none !important; }
body.clean .unhide { display: block; }
body.clean #glass { cursor: none; }

/* ---------- Стартовый экран ---------- */
.start, .result, .fatal { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: calc(16px + var(--st)) calc(16px + var(--sr)) calc(16px + var(--sb)) calc(16px + var(--sl)); overflow: auto; touch-action: pan-y; }
.start { background: radial-gradient(ellipse at 50% 40%, rgba(26, 17, 12, 0.1), rgba(26, 17, 12, 0.55)); pointer-events: none; }
.card { pointer-events: auto; width: min(430px, 100%); padding: 28px 26px 22px; border-radius: 26px; text-align: center; background: rgba(26, 17, 12, 0.62); border: 1px solid var(--line); -webkit-backdrop-filter: blur(26px) saturate(1.25); backdrop-filter: blur(26px) saturate(1.25); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08); }
h1 { margin: 0 0 10px; font-family: "Playfair Display", Georgia, serif; font-weight: 600; font-style: italic; font-size: clamp(34px, 9vw, 46px); line-height: 1.05; letter-spacing: -0.01em; color: var(--cream); text-wrap: balance; }
h2 { margin: 0 0 10px; font-family: "Playfair Display", Georgia, serif; font-weight: 600; font-size: 24px; }
.lead { margin: 0 auto 18px; max-width: 34ch; font-size: 15.5px; line-height: 1.45; color: var(--text-soft); text-wrap: pretty; }
.steps { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; text-align: left; font-size: 14.5px; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; background: rgba(246, 236, 217, 0.07); }
.steps b { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; background: var(--brass); color: var(--ink); }
.go { display: block; width: 100%; padding: 16px 20px; border-radius: 16px; font-size: 18px; font-weight: 700; letter-spacing: 0.01em; color: var(--ink); text-decoration: none; text-align: center; background: linear-gradient(#f0cb7c, #d6a548); box-shadow: 0 8px 22px rgba(224, 180, 92, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.55); transition: transform 0.12s, filter 0.15s; }
.go:hover { filter: brightness(1.06); }
.go:active { transform: scale(0.98); }
.go[disabled] { opacity: 0.6; pointer-events: none; }
.go.small { padding: 13px 18px; font-size: 16px; border-radius: 14px; }
.go.ghost { background: rgba(246, 236, 217, 0.12); color: var(--cream); box-shadow: inset 0 0 0 1px var(--line); }
.link { display: block; margin: 12px auto 0; padding: 6px 10px; font-size: 14px; color: var(--text-soft); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(217, 199, 173, 0.45); }
.link:hover { color: var(--cream); }
.privacy { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 16px 0 0; font-size: 12.5px; line-height: 1.35; color: var(--text-soft); text-align: left; }
.privacy svg { flex: none; width: 17px; height: 17px; fill: none; stroke: var(--brass); stroke-width: 1.7; stroke-linecap: round; }
.err { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; text-align: left; font-size: 14px; line-height: 1.45; background: rgba(226, 80, 60, 0.16); border: 1px solid rgba(226, 80, 60, 0.5); }
.err p { margin: 0; }

/* ---------- Готовое фото или клип ---------- */
.result, .fatal { background: rgba(14, 9, 6, 0.72); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.fatal { z-index: 40; }
.fatal p { margin: 0 0 18px; color: var(--text-soft); line-height: 1.45; }
.sheet { width: min(560px, 100%); display: grid; gap: 14px; }
.preview { border-radius: 18px; overflow: hidden; background: #000; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55); display: grid; place-items: center; }
.preview img, .preview video { display: block; max-width: 100%; max-height: calc(100svh - 190px); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .link { grid-column: 1 / -1; margin-top: 2px; }
.actions .go:only-of-type, .actions.one .go { grid-column: 1 / -1; }

/* ---------- Маленькие экраны ---------- */
@media (max-height: 520px) {
  .rail { gap: 6px; }
  .rb { width: 40px; height: 40px; }
  .card { padding: 16px 20px 14px; width: min(620px, 100%); }
  h1 { font-size: 28px; margin-bottom: 4px; }
  .lead { margin-bottom: 10px; font-size: 14px; max-width: none; }
  .steps { grid-template-columns: repeat(3, 1fr); margin-bottom: 12px; font-size: 12.5px; }
  .steps li { padding: 7px 9px; gap: 8px; }
  .go { padding: 12px; font-size: 16px; }
  .link { margin-top: 6px; }
  .privacy { margin-top: 8px; }
  .hint { font-size: 12.5px; padding: 6px 12px; }
  .bottom { bottom: calc(8px + var(--sb)); }
  .preview img, .preview video { max-height: calc(100svh - 130px); }
  .actions .link { grid-column: auto; }
  .actions { grid-template-columns: 1fr 1fr auto; align-items: center; }
}
@media (max-width: 480px) {
  .rail.left { left: calc(8px + var(--sl)); }
  .rail.right { right: calc(8px + var(--sr)); }
  .pop { left: calc(60px + var(--sl)); width: calc(100vw - 120px - var(--sl) - var(--sr)); }
  .hint { font-size: 12.5px; }
  .bottom { padding: 0 60px; }
  .card { padding: 24px 20px 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
