:root {
  --ink: #0B1020;
  --ink-2: #0F1530;
  --surface: #131A38;
  --surface-2: #1A2347;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --teal: #15C8C8;
  --teal-bright: #28E7E0;
  --coral: #FF5A5F;
  --amber: #FFC24B;
  --text: #EAF0FF;
  --text-dim: #9AA6CC;
  --text-faint: #5E6A92;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.7);
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Archivo", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 12% -8%, rgba(21, 200, 200, 0.16), transparent 60%),
    radial-gradient(900px 600px at 96% 4%, rgba(255, 90, 95, 0.12), transparent 55%),
    var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, .brand-name {
  font-family: "Bricolage Grotesque", "Archivo", sans-serif;
  letter-spacing: -0.02em;
  line-height: 1.04;
  margin: 0;
}

/* ---------- TOP BAR ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 48px);
  background: rgba(11, 16, 32, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--teal); display: grid; place-items: center; }
.brand-name { font-size: 1.25rem; font-weight: 800; }
.brand-name span { color: var(--teal); }

.lang-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
}
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  min-height: 38px;
  transition: color 0.2s, background 0.2s, transform 0.15s;
}
.lang-btn .flag { font-size: 1rem; line-height: 1; }
.lang-btn.is-active {
  color: var(--ink);
  background: linear-gradient(135deg, var(--teal-bright), var(--teal));
}
.lang-btn:not(.is-active):hover { color: var(--text); }
.lang-btn:active { transform: scale(0.96); }

/* ---------- LAYOUT ---------- */
main { position: relative; z-index: 2; max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px); }

/* ---------- HERO ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(24px, 5vw, 56px);
  align-items: center;
  padding: clamp(36px, 7vw, 80px) 0 clamp(28px, 5vw, 56px);
}
.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--teal-bright);
  margin-bottom: 16px;
  animation: rise 0.6s 0.05s both;
}
.hero h1 {
  font-size: clamp(2.4rem, 6.2vw, 4.4rem);
  font-weight: 800;
  animation: rise 0.6s 0.12s both;
}
.hero h1 em { font-style: normal; color: var(--teal); }
.lede {
  margin: 20px 0 24px;
  font-size: clamp(1rem, 1.6vw, 1.18rem);
  color: var(--text-dim);
  max-width: 46ch;
  animation: rise 0.6s 0.2s both;
}
.hero-meta { display: flex; flex-wrap: wrap; gap: 10px; animation: rise 0.6s 0.28s both; }
.chip {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
}
.hero-art {
  position: relative;
  animation: rise 0.7s 0.18s both;
}
.hero-art img {
  width: 100%;
  height: auto;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  display: block;
}

/* ---------- STUDIO ---------- */
.studio {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(16px, 2.5vw, 28px);
  padding-bottom: 64px;
  align-items: start;
}
.panel {
  background: linear-gradient(180deg, var(--surface), var(--ink-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(18px, 2.5vw, 28px);
  box-shadow: var(--shadow);
}
.panel-output { position: sticky; top: 88px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.panel-head h2 { font-size: 1.3rem; font-weight: 700; }

.ghost-btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 38px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.ghost-btn:hover { color: var(--text); border-color: var(--teal); background: rgba(21, 200, 200, 0.08); }

/* ---------- FORM ---------- */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field-wide { grid-column: 1 / -1; }
.field span {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
}
input, select {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  min-height: 44px;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  width: 100%;
}
input::placeholder { color: var(--text-faint); }
input:focus, select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(21, 200, 200, 0.18);
  background: rgba(255, 255, 255, 0.06);
}

.repeater {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 0 0 18px;
}
.repeater legend {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--teal-bright);
  padding: 0 6px;
}
.repeater-rows { display: flex; flex-direction: column; gap: 10px; }
.scorer-row, .moment-row {
  display: grid;
  gap: 8px;
  align-items: center;
}
.scorer-row { grid-template-columns: 1fr 72px 1fr 38px; }
.moment-row { grid-template-columns: 72px 1fr 1fr 38px; }
.scorer-row input, .moment-row input, .moment-row select { min-height: 42px; padding: 9px 10px; font-size: 0.9rem; }
.remove-row {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--coral);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.1rem;
  min-height: 42px;
  line-height: 1;
  transition: background 0.18s, border-color 0.18s;
}
.remove-row:hover { background: rgba(255, 90, 95, 0.12); border-color: var(--coral); }

.add-row {
  margin-top: 12px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  width: 100%;
  transition: color 0.18s, border-color 0.18s;
}
.add-row:hover { color: var(--teal); border-color: var(--teal); }

.advanced {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  overflow: hidden;
}
.advanced summary {
  cursor: pointer;
  padding: 13px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before {
  content: "+";
  color: var(--teal);
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 0.2s;
}
.advanced[open] summary::before { content: "−"; }
.advanced-body { padding: 0 16px 16px; }

.generate-btn {
  position: relative;
  width: 100%;
  border: 0;
  cursor: pointer;
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: linear-gradient(135deg, var(--teal-bright), var(--teal));
  padding: 16px;
  border-radius: 14px;
  min-height: 56px;
  box-shadow: 0 14px 30px -10px rgba(21, 200, 200, 0.5);
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.generate-btn:hover { transform: translateY(-2px); box-shadow: 0 18px 38px -10px rgba(21, 200, 200, 0.6); }
.generate-btn:active { transform: translateY(0); }
.generate-btn:disabled { filter: grayscale(0.4) brightness(0.8); cursor: progress; transform: none; }
.btn-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(11, 16, 32, 0.3);
  border-top-color: var(--ink);
  border-radius: 50%;
  display: none;
  animation: spin 0.7s linear infinite;
}
.generate-btn.is-loading .btn-spinner { display: inline-block; }

.note {
  margin: 14px 0 0;
  font-size: 0.78rem;
  color: var(--text-faint);
  text-align: center;
}

/* ---------- OUTPUT ---------- */
.status-line {
  margin: 0 0 16px;
  font-size: 0.88rem;
  min-height: 1.2em;
  color: var(--text-dim);
}
.status-line.is-error { color: var(--coral); }
.status-line.is-ok { color: var(--teal-bright); }

.thread { display: flex; flex-direction: column; gap: 14px; }
.tweet-card {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  padding: 16px 16px 14px 18px;
  animation: rise 0.45s both;
}
.tweet-card::before {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  border-radius: 3px;
  background: var(--role-color, var(--teal));
}
.tweet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}
.role-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--role-color, var(--teal));
}
.role-num {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 7px;
  font-size: 0.75rem;
  color: var(--ink);
  background: var(--role-color, var(--teal));
}
.tweet-text { font-size: 0.97rem; color: var(--text); white-space: pre-wrap; }
.tweet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 11px;
}
.char-meter { font-size: 0.74rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.char-meter.over { color: var(--coral); font-weight: 700; }
.copy-one {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.74rem;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 34px;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
.copy-one:hover { color: var(--teal); border-color: var(--teal); }
.copy-one.copied { color: var(--ink); background: var(--teal); border-color: var(--teal); }

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 12px;
  padding: 48px 16px;
  color: var(--text-faint);
}
.empty-art {
  font-size: 2.4rem;
  color: var(--teal);
  opacity: 0.5;
  animation: float 3.4s ease-in-out infinite;
}
.empty-state p { margin: 0; max-width: 34ch; font-size: 0.92rem; }

/* ---------- FOOT ---------- */
.foot {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 28px 16px 40px;
  color: var(--text-faint);
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}
.foot .dot { margin: 0 8px; }

/* ---------- ANIMATIONS ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 920px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { order: -1; max-width: 460px; }
  .studio { grid-template-columns: 1fr; }
  .panel-output { position: static; }
}
@media (max-width: 540px) {
  .field-grid { grid-template-columns: 1fr; }
  .scorer-row { grid-template-columns: 1fr 60px 38px; }
  .scorer-row .scorer-team { grid-column: 1 / 3; }
  .moment-row { grid-template-columns: 60px 1fr 38px; }
  .moment-row .moment-player { grid-column: 1 / 3; }
  .topbar { padding: 12px 16px; }
  .brand-name { font-size: 1.1rem; }
}
