:root {
  --bg-0: #0d0b1c;
  --bg-1: #171233;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-brd: rgba(255, 255, 255, 0.1);
  --field: rgba(255, 255, 255, 0.06);
  --field-brd: rgba(255, 255, 255, 0.14);
  --txt: #f3f0ff;
  --txt-soft: #b6aed6;
  --accent: #ffd23f;
  --twitch: #9146ff;
  --good: #57e389;
  --warn: #ffc145;
  --bad: #ff6b7a;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Outfit', system-ui, sans-serif;
  color: var(--txt);
  background:
    radial-gradient(1100px 700px at 90% -10%, rgba(145, 70, 255, 0.28), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(255, 93, 177, 0.16), transparent 60%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
}

a { color: #c9b4ff; }
code, kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 0.1em 0.4em;
}
kbd { border: 1px solid rgba(255, 255, 255, 0.18); border-bottom-width: 2px; }
em { font-style: normal; color: var(--txt-soft); font-weight: 400; }

/* ------------------------------------------------------------------ hero */

.hero {
  max-width: 1320px;
  margin: 0 auto;
  padding: 40px 24px 12px;
  display: flex;
  gap: 22px;
  align-items: center;
}
.hero h1 {
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1.05;
}
.hero p { margin-top: 8px; color: var(--txt-soft); max-width: 62ch; font-size: 1.05rem; }
.hero__mark {
  flex: none;
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--twitch), #ff5db1);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 7px;
  box-shadow: 0 14px 40px -12px rgba(145, 70, 255, 0.8);
  overflow: hidden;
}
.hero__mark span { display: block; height: 6px; border-radius: 6px; background: #fff; animation: credits 3.2s linear infinite; }
.hero__mark span:nth-child(1) { width: 34px; }
.hero__mark span:nth-child(2) { width: 26px; opacity: 0.85; }
.hero__mark span:nth-child(3) { width: 18px; opacity: 0.7; }
@keyframes credits { from { transform: translateY(26px); } to { transform: translateY(-26px); } }
@media (prefers-reduced-motion: reduce) { .hero__mark span { animation: none; } }

/* ---------------------------------------------------------------- layout */

.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 24px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 28px;
  align-items: start;
}
.steps { display: grid; gap: 20px; min-width: 0; }

.preview { position: sticky; top: 20px; min-width: 0; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .preview { position: relative; top: 0; order: -1; }
}

/* ----------------------------------------------------------------- steps */

.step {
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: var(--radius);
  padding: 22px 22px 24px;
  display: grid;
  gap: 16px;
  min-width: 0;
}
.step h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Unbounded', sans-serif;
  font-weight: 600;
  font-size: 1.12rem;
  letter-spacing: 0.02em;
}
.num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--accent);
  color: #241a00;
  font-size: 0.9rem;
  font-weight: 800;
}

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------- fields */

.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-weight: 600; font-size: 0.92rem; }
.field input:not([type='checkbox']):not([type='radio']):not([type='color']):not([type='range']),
.field select {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 0.98rem;
  color: var(--txt);
  background: var(--field);
  border: 1px solid var(--field-brd);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.field select option { background: #1b1535; }
.field input:focus, .field select:focus { border-color: var(--twitch); background: rgba(145, 70, 255, 0.08); }
.field input[type='range'] { width: 100%; accent-color: var(--accent); margin-top: 8px; }
.field output { color: var(--accent); font-weight: 700; margin-left: 6px; }
.field--check { grid-template-columns: auto 1fr; align-items: center; gap: 10px; align-self: end; padding-bottom: 10px; }
.field--check input { width: 20px; height: 20px; accent-color: var(--accent); }
.field--check > span { font-weight: 600; }
.field--inline > span em { font-weight: 400; }

.color { display: flex; gap: 8px; align-items: center; }
.color input[type='color'] {
  flex: none;
  width: 44px;
  height: 42px;
  border: 1px solid var(--field-brd);
  border-radius: 12px;
  background: var(--field);
  padding: 4px;
  cursor: pointer;
}
.color input:not([type='color']) { flex: 1; }

fieldset { border: 0; display: grid; gap: 10px; min-width: 0; }
legend { font-weight: 600; font-size: 0.92rem; margin-bottom: 8px; }

/* themes */
.themes { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.themes legend { grid-column: 1 / -1; }
.theme {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 10px 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--field-brd);
  background: var(--field);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.theme:hover { transform: translateY(-2px); }
.theme input { position: absolute; opacity: 0; pointer-events: none; }
.theme:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.theme input:focus-visible ~ .theme__swatch { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme b { font-size: 0.98rem; }
.theme small { color: var(--txt-soft); font-size: 0.8rem; line-height: 1.3; }
.theme__swatch {
  display: block;
  height: 54px;
  border-radius: 10px;
  margin-bottom: 6px;
  background-size: cover;
}
.theme--glass .theme__swatch {
  background:
    linear-gradient(rgba(12, 10, 26, 0.7), rgba(12, 10, 26, 0.7)) center 34px / 70% 12px no-repeat,
    linear-gradient(#fff, #fff) center 14px / 64% 10px no-repeat,
    linear-gradient(var(--accent), var(--accent)) center 28px / 36% 3px no-repeat,
    linear-gradient(135deg, #3b6fb6, #7c4fa8 55%, #d56aa0);
}
.theme--kawaii .theme__swatch {
  background:
    linear-gradient(#fff, #fff) center 34px / 70% 12px no-repeat,
    linear-gradient(#ff6fae, #ff6fae) center 14px / 64% 10px no-repeat,
    linear-gradient(135deg, #ffc7e1, #d9cfff);
}
.theme--cinema .theme__swatch {
  background:
    linear-gradient(#fff, #fff) center 14px / 56% 6px no-repeat,
    linear-gradient(#e8c77a, #e8c77a) center 28px / 30% 3px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)) 30% 38px / 22% 3px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.9)) 72% 38px / 22% 3px no-repeat,
    #000;
}
@media (max-width: 520px) { .themes { grid-template-columns: minmax(0, 1fr); } }

/* section chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--field-brd);
  background: var(--field);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--txt-soft);
  transition: all 0.15s ease;
}
.chip input:checked + span { color: #241a00; background: var(--accent); border-color: var(--accent); }
.chip input:focus-visible + span { outline: 2px solid #fff; outline-offset: 2px; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  color: #241a00;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn:active { transform: translateY(0); }
.btn--ghost { color: var(--txt); background: var(--field); border-color: var(--field-brd); }
.btn--twitch { color: #fff; background: var(--twitch); justify-self: start; padding: 12px 20px; font-size: 1rem; }
.btn--twitch svg { width: 20px; height: 20px; }
.btn--tiny { padding: 5px 10px; font-size: 0.82rem; border-radius: 9px; }

/* --------------------------------------------------------------- account */

.account {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(87, 227, 137, 0.08);
  border: 1px solid rgba(87, 227, 137, 0.35);
}
.account img { width: 46px; height: 46px; border-radius: 50%; flex: none; }
.account__text { flex: 1; min-width: 0; display: grid; }
.account__text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account__text span { color: var(--txt-soft); font-size: 0.88rem; }
.account[hidden], #connect-form[hidden], .field[hidden], .help[hidden], .error[hidden], .warn[hidden], .hint[hidden] { display: none; }
#connect-form { display: grid; gap: 12px; }

/* ------------------------------------------------------------ text bits */

.hint { color: var(--txt-soft); font-size: 0.88rem; }
.error { color: var(--bad); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; font-size: 0.92rem; }

.help {
  border: 1px solid var(--panel-brd);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.16);
  padding: 10px 14px;
}
.help summary { cursor: pointer; font-weight: 600; color: #d8cbff; }
.help ol, .help ul { margin: 10px 0 4px 20px; display: grid; gap: 8px; font-size: 0.93rem; color: var(--txt-soft); }
.help b { color: var(--txt); }

.copyline { display: flex; gap: 8px; align-items: center; margin-top: 6px; min-width: 0; }
.copyline code { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 6px 8px; }

.urlbox {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--field-brd);
}
.urlbox code { display: block; background: none; padding: 0; color: #d8cbff; overflow-wrap: anywhere; font-size: 0.82rem; line-height: 1.5; }
.urlbox__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.urlbox.is-demo { border-style: dashed; }

.howto { margin-left: 20px; display: grid; gap: 8px; color: var(--txt-soft); }
.howto b { color: var(--txt); }

.demo-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--txt-soft); font-size: 0.92rem; }

/* --------------------------------------------------------------- preview */

.preview__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--panel-brd);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.9);
  background: #000;
}
/* a stand-in "camera scene" so transparent themes look like they will on stream */
.preview__scene {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(30% 45% at 50% 100%, rgba(255, 214, 196, 0.55), transparent 70%),
    radial-gradient(14% 22% at 50% 62%, rgba(255, 220, 205, 0.6), transparent 70%),
    radial-gradient(40% 60% at 18% 30%, rgba(255, 64, 200, 0.55), transparent 70%),
    radial-gradient(45% 60% at 85% 25%, rgba(40, 200, 255, 0.5), transparent 70%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.05) 0 18px, transparent 18px 40px),
    linear-gradient(160deg, #1d3d8f, #3a2a86 50%, #12224f);
  filter: saturate(1.1);
}
.preview__frame[data-bg='solid'] .preview__scene { display: none; }
.preview iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  border: 0;
  transform-origin: 0 0;
  background: transparent;
  color-scheme: light; /* must match the framed page or Chrome paints an opaque backdrop */
}
.preview__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  color: var(--txt-soft);
  font-size: 0.88rem;
}

/* ------------------------------------------------------------------ misc */

.foot { text-align: center; color: var(--txt-soft); font-size: 0.85rem; padding: 10px 24px 40px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 18px;
  border-radius: 999px;
  background: #fff;
  color: #1a1433;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  .hero { flex-direction: column; align-items: flex-start; padding-top: 28px; }
  .layout, .hero { padding-left: 16px; padding-right: 16px; }
  .step { padding: 18px 16px 20px; }
}
