:root {
  --bg: #0a0a0c;
  --bg-soft: #131317;
  --line: #26262d;
  --text: #f2f1ee;
  --muted: #8f8f9c;
  --accent: #ffb648;
  --accent-ink: #1b1400;
  --danger: #ff6b5e;
  --radius: 20px;
  --pad: 20px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}

body {
  background-image: radial-gradient(120% 60% at 50% -10%, #1d1a17 0%, var(--bg) 60%);
}

.screen {
  min-height: 100dvh;
  padding: calc(var(--safe-t) + var(--pad)) var(--pad) calc(var(--safe-b) + var(--pad));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.screen[hidden] { display: none; }
.screen.center { align-items: center; justify-content: center; text-align: center; }

/* --- главная --- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 620;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--muted);
}

.hero { margin-top: auto; }

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(30px, 9vw, 40px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 680;
}

.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { margin: 0; color: var(--muted); max-width: 28ch; }

.actions { margin-top: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }

/* --- кнопки --- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 62px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
  background: var(--bg-soft);
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { border: 1px solid var(--line); justify-content: flex-start; text-align: left; overflow: hidden; }
.btn[disabled] { opacity: 0.42; cursor: default; }
.btn[disabled]:active { transform: none; }

.btn-label { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.btn-label span, .btn-label small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-label small { color: var(--muted); font-weight: 450; font-size: 13px; }

.dot {
  margin-left: auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgb(255 182 72 / 0.18);
}

.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.link {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  padding: 8px 2px;
  cursor: pointer;
}

.link:active { color: var(--text); }

/* --- камера --- */

.fullbleed { padding: 0; background: #000; position: relative; overflow: hidden; }

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cam-top {
  position: absolute;
  top: calc(var(--safe-t) + 12px);
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 2;
}

.pill {
  background: rgb(0 0 0 / 0.45);
  backdrop-filter: blur(8px);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: #fff;
}

.round {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.45);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 17px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.round.big { width: 54px; height: 54px; }
.round.done { background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 19px; }

.cam-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-b) + 22px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  padding: 0 26px;
  z-index: 2;
}

.cam-bottom > :first-child { justify-self: start; }
.cam-bottom > :last-child { justify-self: end; }

.shutter {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 4px solid rgb(255 255 255 / 0.85);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.shutter i { width: 60px; height: 60px; border-radius: 50%; background: #fff; transition: transform 0.1s ease; }
.shutter:active i { transform: scale(0.86); }

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

.flash.on { animation: blink 0.24s ease; }
@keyframes blink { from { opacity: 0.85; } to { opacity: 0; } }

/* --- проверка снимков --- */

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bar h2 { margin: 0; font-size: 17px; font-weight: 620; }
.bar-space { width: 64px; }

.bar.sticky {
  position: sticky;
  top: calc(var(--safe-t) * -1);
  margin: calc(var(--safe-t) * -1 - var(--pad)) calc(var(--pad) * -1) 0;
  padding: calc(var(--safe-t) + 10px) var(--pad) 10px;
  background: rgb(10 10 12 / 0.82);
  backdrop-filter: blur(12px);
  z-index: 5;
}

.thumbs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-soft);
}

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

.thumb button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
  cursor: pointer;
}

.note { display: grid; gap: 8px; font-size: 14px; color: var(--muted); }
.note small { opacity: 0.7; }

.note input {
  height: 52px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
}

.note input:focus { outline: 2px solid rgb(255 182 72 / 0.5); outline-offset: -1px; }

/* --- ожидание --- */

.pulse { display: grid; place-items: center; animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.1); opacity: 1; } }

.center h2 { margin: 4px 0 0; font-size: 22px; font-weight: 640; letter-spacing: -0.02em; }
.muted { color: var(--muted); margin: 0; max-width: 30ch; }
.timer { color: var(--accent); font-variant-numeric: tabular-nums; font-size: 15px; margin: 0; }

.sad {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgb(255 107 94 / 0.14);
  color: var(--danger);
  font-size: 26px;
  font-weight: 700;
}

.center .actions { width: 100%; max-width: 420px; }

/* --- ответ --- */

.strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip img { width: 68px; height: 68px; border-radius: 12px; object-fit: cover; flex: none; }

.md { font-size: 16.5px; line-height: 1.62; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3 { line-height: 1.25; letter-spacing: -0.02em; margin: 26px 0 10px; }
.md h1 { font-size: 24px; }
.md h2 { font-size: 20px; color: var(--accent); }
.md h3 { font-size: 17px; }
.md p { margin: 0 0 14px; }
.md ul, .md ol { margin: 0 0 14px; padding-left: 22px; }
.md li { margin: 6px 0; }
.md strong { font-weight: 640; }
.md a { color: var(--accent); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.md blockquote { margin: 0 0 14px; padding-left: 14px; border-left: 3px solid var(--line); color: var(--muted); }
.md code { background: var(--bg-soft); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }
.md pre { background: var(--bg-soft); padding: 14px; border-radius: 14px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 15px; }
.md th, .md td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }

/* --- всплывашка --- */

.toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-t) + 14px);
  transform: translateX(-50%);
  background: #22222a;
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.5);
  padding: 12px 18px;
  border-radius: 999px;
  max-width: calc(100vw - 40px);
  text-align: center;
  font-size: 14px;
  z-index: 20;
  animation: rise 0.2s ease;
}

@keyframes rise { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (min-width: 640px) {
  .screen { max-width: 620px; margin: 0 auto; }
  .thumbs { grid-template-columns: repeat(3, 1fr); }
}

/* --- главная: история и очистка --- */

.row { display: flex; gap: 10px; align-items: stretch; min-width: 0; }
.row .btn-ghost { flex: 1; min-width: 0; }

.btn-icon {
  width: 62px;
  flex: none;
  justify-content: center;
  border: 1px solid var(--line);
  position: relative;
}

.count {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--line);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  font-style: normal;
  display: grid;
  place-items: center;
}

.wipe { align-self: center; margin-top: 2px; font-size: 14px; }
.wipe.armed { color: var(--danger); }

/* --- шторка истории --- */

.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-back { position: absolute; inset: 0; background: rgb(0 0 0 / 0.6); backdrop-filter: blur(2px); }

.sheet-card {
  position: relative;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  background: var(--bg-soft);
  border-top: 1px solid var(--line);
  border-radius: 24px 24px 0 0;
  padding: 10px var(--pad) calc(var(--safe-b) + 16px);
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: sheet-up 0.22s ease;
}

@keyframes sheet-up { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet-grip { width: 42px; height: 4px; border-radius: 2px; background: var(--line); align-self: center; }
.sheet-card h3 { margin: 0; font-size: 17px; font-weight: 620; }
.sheet-list { overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.sheet-close { min-height: 52px; }

.entry {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.entry:active { border-color: var(--accent); }
.entry img { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: none; background: var(--bg-soft); }
.entry .entry-text { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.entry b { font-weight: 560; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry small { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .dot { margin: 0; }
.entry.empty { justify-content: center; color: var(--muted); cursor: default; }

/* --- очередь --- */

.queue {
  margin: 0;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
}

/* --- диалог под ответом --- */

.thread { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 22px; }
.thread:empty { margin: 0; }

.ask-bubble {
  justify-self: end;
  max-width: 88%;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 11px 15px;
  border-radius: 18px 18px 4px 18px;
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.reply { min-width: 0; border-left: 2px solid var(--line); padding-left: 14px; }
.reply .md { font-size: 16px; }

.reply-pending, .reply-failed {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 15px;
  padding-left: 16px;
}

.reply-failed { color: var(--danger); }

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  flex: none;
}

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

.composer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 20px calc(var(--pad) * -1) 0;
  padding: 12px var(--pad) calc(var(--safe-b) + 12px);
  background: rgb(10 10 12 / 0.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.composer textarea {
  flex: 1;
  min-height: 52px;
  max-height: 160px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  resize: none;
  overflow-y: auto;
}

.composer textarea:focus { outline: 2px solid rgb(255 182 72 / 0.5); outline-offset: -1px; }

.send {
  width: 52px;
  height: 52px;
  flex: none;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.send:disabled { opacity: 0.4; cursor: default; }
