:root {
  --bg: #0e1114;
  --bg-2: #161b21;
  --panel: #1a2129;
  --line: #2c3642;
  --ink: #e8eef4;
  --muted: #8b9aab;
  --amber: #e3a23a;
  --amber-dim: rgba(227, 162, 58, 0.16);
  --you: #e56b33;
  --ok: #5fad7e;
  --font: "Manrope", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(227, 162, 58, 0.12), transparent 50%),
    radial-gradient(700px 480px at 100% 0%, rgba(196, 92, 42, 0.1), transparent 45%),
    linear-gradient(180deg, #12161b, #0e1114 40%, #0b0e11);
}

.screen {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: none;
}

.screen.is-on {
  display: block;
}

.setup-inner,
.finale-inner,
.translator-inner {
  width: min(100%, 540px);
  margin: 0 auto;
  padding: 40px 22px 40px;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  border-radius: 12px;
  padding: 14px 16px;
  font: 500 1rem var(--font);
  line-height: 1.45;
  resize: vertical;
  min-height: 88px;
  text-transform: none;
  letter-spacing: 0;
}

.field textarea:focus {
  outline: 2px solid rgba(227, 162, 58, 0.35);
  border-color: var(--amber);
}

@media (max-width: 600px) {
  .mode-switch {
    grid-template-columns: 1fr;
  }
}

.mode-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 12px;
  padding: 11px 10px;
  font: 600 0.8rem var(--font);
  cursor: pointer;
}

.mode-btn.active {
  color: var(--ink);
  border-color: var(--amber);
  background: linear-gradient(90deg, var(--amber-dim), transparent 70%);
}

.field-hint {
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font);
  font-weight: 400;
  opacity: 0.75;
}

.brand {
  margin: 0 0 16px;
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.22em;
  font-size: 0.85rem;
  color: var(--amber);
}

.brand.dim { opacity: 0.7; }

h1 {
  margin: 0 0 18px;
  font-size: clamp(1.85rem, 6vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.08;
}

h2 {
  margin: 0 0 18px;
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.how {
  margin: 0 0 26px;
  padding: 16px 16px 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(26, 33, 41, 0.85);
}

.how p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

.how b {
  color: var(--ink);
  font-weight: 600;
}

.how u {
  color: var(--amber);
  text-decoration: none;
  border-bottom: 1px dashed rgba(227, 162, 58, 0.5);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field input,
.send-row input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  border-radius: 12px;
  padding: 14px 16px;
  font: 500 1.05rem var(--font);
}

.field input:focus,
.send-row input:focus {
  outline: 2px solid rgba(227, 162, 58, 0.35);
  border-color: var(--amber);
}

.field-label {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.gender {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 22px;
}

.gender-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 14px;
  padding: 14px 16px;
  font: 600 0.98rem var(--font);
  cursor: pointer;
}

.gender-btn:hover { border-color: #3d4b5c; }

.gender-btn.active {
  border-color: var(--amber);
  background: linear-gradient(90deg, var(--amber-dim), transparent 70%);
}

.tones {
  display: grid;
  gap: 8px;
  margin-bottom: 26px;
}

.tone {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
}

.tone:hover { border-color: #3d4b5c; }

.tone.active {
  border-color: var(--amber);
  background: linear-gradient(90deg, var(--amber-dim), transparent 70%);
}

.tone strong {
  display: block;
  font-size: 0.98rem;
  margin-bottom: 4px;
}

.tone span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  font: 700 0.95rem var(--font);
  cursor: pointer;
}

.btn.primary {
  width: 100%;
  background: var(--amber);
  color: #1a1205;
}

.btn.primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn.send {
  background: var(--you);
  color: #fff;
  padding-inline: 18px;
  flex: 0 0 auto;
}

.btn.enough {
  width: 100%;
  margin-top: 10px;
  background: transparent;
  color: var(--amber);
  border: 1px solid rgba(227, 162, 58, 0.35);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.fine {
  margin: 14px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--mono);
}

/* ——— chat: простой flex, без сюрпризов ——— */
.chat-screen.is-on {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  background: #12161b;
  border-inline: 1px solid var(--line);
  overflow: hidden;
}

.chat-top {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #161b21;
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.who-text { min-width: 0; }

.back {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
}

.who-name {
  margin: 0;
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.who-status {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ok);
}

.who-status.busy { color: var(--amber); }
.who-status.typing { color: var(--muted); }

.steam-wrap {
  display: grid;
  gap: 6px;
  min-width: 110px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.steam {
  height: 6px;
  border-radius: 999px;
  background: #2a3340;
  overflow: hidden;
}

.steam i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--ok), var(--amber), var(--you));
  transition: width 0.35s ease;
}

.thread {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #0e1114;
}

.msg {
  max-width: 85%;
  padding: 10px 12px 12px;
  border-radius: 16px;
  line-height: 1.45;
  font-size: 0.95rem;
  word-break: break-word;
}

.msg-body {
  white-space: pre-wrap;
}

.msg-reply {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-left: 3px solid var(--you);
  border-radius: 4px 8px 8px 4px;
  background: rgba(0, 0, 0, 0.22);
  min-width: 0;
}

.msg-reply-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--you);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.msg-reply-text {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-out {
  margin-left: auto;
  background: #e56b33;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.msg-out .msg-reply {
  border-left-color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.12);
}

.msg-out .msg-reply-name {
  color: #fff;
}

.msg-out .msg-reply-text {
  color: rgba(255, 255, 255, 0.82);
}

.msg-in {
  margin-right: auto;
  background: #243040;
  color: #e8eef4;
  border: 1px solid #2c3642;
  border-bottom-left-radius: 4px;
}

.msg-sys {
  margin: 0 auto;
  background: transparent;
  color: #8b9aab;
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 4px 8px;
  text-align: center;
}

.msg-soft {
  border-color: rgba(95, 173, 126, 0.45);
  background: #1e3228;
}

.composer {
  flex: 0 0 auto;
  padding: 12px 16px 18px;
  border-top: 1px solid var(--line);
  background: #161b21;
}

.yells {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
}

.yells::-webkit-scrollbar { display: none; }

.yell-chip {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  font: 500 0.8rem var(--font);
  cursor: pointer;
  white-space: nowrap;
}

.yell-chip:hover {
  border-color: var(--you);
}

.send-row {
  display: flex;
  gap: 8px;
}

.finale-kicker {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ok);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.finale-quotes {
  display: grid;
  gap: 10px;
  margin-bottom: 28px;
}

.finale-quotes .msg {
  max-width: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.translator-screen.is-on {
  display: block;
}

.translator-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.translator-title {
  margin: 4px 0 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.tr-block {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tr-block textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  border-radius: 14px;
  padding: 14px 16px;
  font: 500 1rem var(--font);
  line-height: 1.45;
  resize: vertical;
  min-height: 140px;
}

.tr-block textarea:focus {
  outline: 2px solid rgba(227, 162, 58, 0.35);
  border-color: var(--amber);
}

.tr-out {
  border: 1px solid rgba(95, 173, 126, 0.35);
  background: #1e3228;
  color: var(--ink);
  border-radius: 14px;
  padding: 16px;
  font: 500 0.98rem/1.55 var(--font);
  white-space: pre-wrap;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font);
  min-height: 140px;
}

.tr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.tr-actions .btn.primary,
.tr-actions .btn.ghost {
  width: auto;
  flex: 1 1 140px;
}

@media (max-width: 600px) {
  .chat-screen.is-on { border-inline: 0; }
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; }
}
