:root {
  --bg: #070a12;
  --panel: rgba(15, 22, 38, 0.78);
  --panel-strong: rgba(18, 28, 48, 0.92);
  --line: rgba(255, 255, 255, 0.11);
  --text: #eef4ff;
  --muted: #98a7c0;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(139, 92, 246, 0.22), transparent 32rem),
    radial-gradient(circle at top right, rgba(34, 211, 238, 0.18), transparent 30rem),
    linear-gradient(135deg, #070a12 0%, #0c1220 55%, #070a12 100%);
  overflow-x: hidden;
}

.aurora {
  position: fixed;
  width: 28rem;
  height: 28rem;
  border-radius: 999px;
  filter: blur(90px);
  opacity: 0.28;
  pointer-events: none;
  animation: float 11s ease-in-out infinite alternate;
}

.aurora-one { background: var(--accent); top: -9rem; left: -8rem; }
.aurora-two { background: var(--accent-2); right: -8rem; bottom: 5rem; animation-delay: -4s; }

@keyframes float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(3rem, 2rem, 0) scale(1.08); }
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 28px rgba(34, 211, 238, 0.65);
}

.telegram,
.download,
.generate,
button {
  border: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.telegram {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 14px;
  color: white;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: transform 0.18s ease, background 0.18s ease;
  white-space: nowrap;
}

.telegram:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.12); }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 20px;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.composer-panel,
.control-panel,
.generate-panel,
.result-panel { padding: 22px; }

.composer-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.counter {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--accent-2);
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.18);
  font-weight: 800;
  white-space: nowrap;
}

textarea,
.select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  outline: none;
  border-radius: 20px;
  background: rgba(4, 7, 14, 0.58);
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea:focus,
.select:focus {
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.1);
  background: rgba(4, 7, 14, 0.74);
}

#textInput {
  min-height: 500px;
  padding: 18px;
  resize: vertical;
  font-size: 16px;
  line-height: 1.75;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin: 16px 0 8px;
}

.select {
  height: 48px;
  padding: 0 14px;
}

.select option,
.select optgroup { color: #0b1020; }

.micro-status {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 6px;
  margin-bottom: 4px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
}

.segment {
  padding: 11px 8px;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.segment.active {
  color: white;
  background: rgba(139, 92, 246, 0.55);
}

.segment:hover { transform: translateY(-1px); }

.slider-row { margin-top: 20px; }

.slider-row label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.slider-row b { color: var(--text); }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-2);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.toolbar.stacked { display: grid; grid-template-columns: 1fr 1fr; }

.ghost,
.download {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.18s ease, background 0.18s ease;
}

.ghost:hover,
.download:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.11); }

.generate-panel {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(34, 211, 238, 0.12)), var(--panel-strong);
}

.generate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(100%, 360px);
  min-height: 58px;
  border-radius: 18px;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 20px 52px rgba(139, 92, 246, 0.28);
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}

.generate:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.07); }
.generate:disabled { cursor: not-allowed; opacity: 0.72; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  display: none;
  animation: spin 0.8s linear infinite;
}

.generate.processing .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

#statusText {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.result-panel { margin-top: 20px; }
.hidden { display: none; }

.result-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.result-title-row h2 {
  margin: 0;
  font-size: 20px;
}

.result-title-row p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

audio { width: 100%; margin: 4px 0 16px; }

.download-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.download { width: 100%; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(24px);
  opacity: 0;
  pointer-events: none;
  min-width: min(440px, calc(100% - 32px));
  padding: 13px 16px;
  border-radius: 16px;
  color: white;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
  transition: transform 0.22s ease, opacity 0.22s ease;
  text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 920px) {
  .grid { grid-template-columns: 1fr; }
  .generate-panel { flex-direction: column; }
  .telegram { justify-content: center; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1180px); padding-top: 16px; }
  .panel { border-radius: 22px; }
  .toolbar.stacked, .download-row { grid-template-columns: 1fr; }
  .generate { width: 100%; }
  #textInput { min-height: 360px; }
  .result-title-row { align-items: flex-start; flex-direction: column; }
  .result-title-row p { text-align: left; }
}
