:root {
  --ink: #f4f3ed;
  --muted: #8c938e;
  --line: #282d2a;
  --panel: #111513;
  --panel-raised: #171c19;
  --black: #090b0a;
  --acid: #c8ff3d;
  --acid-deep: #9bd800;
  --danger: #ff6c62;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--black); color: var(--ink); }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  background:
    radial-gradient(circle at 75% 4%, rgba(200, 255, 61, 0.075), transparent 27rem),
    var(--black);
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

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

.topbar {
  height: 76px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
}

.brand {
  color: var(--ink);
  text-decoration: none;
  display: flex;
  gap: 13px;
  align-items: center;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-mark { height: 23px; display: flex; gap: 3px; align-items: center; }
.brand-mark i { display: block; width: 3px; border-radius: 3px; background: var(--acid); }
.brand-mark i:nth-child(1), .brand-mark i:nth-child(5) { height: 8px; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4) { height: 16px; }
.brand-mark i:nth-child(3) { height: 23px; }

.connection { display: flex; align-items: center; gap: 9px; color: var(--muted); font: 12px var(--mono); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #555; box-shadow: 0 0 0 4px rgba(255,255,255,.03); }
.status-dot.online { background: var(--acid); box-shadow: 0 0 12px rgba(200,255,61,.7); }

main { max-width: 1240px; margin: 0 auto; padding: 0 24px 60px; }

.hero {
  min-height: 390px;
  display: grid;
  grid-template-columns: 1.65fr 0.75fr;
  align-items: end;
  gap: 60px;
  padding: 76px 0 66px;
}

.eyebrow, .step {
  color: var(--acid);
  font: 500 11px var(--mono);
  letter-spacing: .13em;
  margin: 0 0 18px;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(52px, 7vw, 96px); line-height: .91; letter-spacing: -.065em; margin: 0; font-weight: 600; }
h1 em { color: var(--acid); font-weight: 500; font-style: normal; }
h2 { font-size: 25px; letter-spacing: -.035em; margin-bottom: 0; }
.hero-copy { color: var(--muted); line-height: 1.75; font-size: 15px; margin: 0; max-width: 390px; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .85fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.panel { background: var(--panel); padding: clamp(24px, 4vw, 46px); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 38px; }
.panel-heading .step { margin-bottom: 10px; }
.badge, .count { border: 1px solid var(--line); color: var(--muted); border-radius: 99px; font: 10px var(--mono); padding: 8px 11px; white-space: nowrap; }
.count { color: var(--acid); min-width: 32px; text-align: center; }

label { display: flex; justify-content: space-between; color: #b8bdb9; font: 11px var(--mono); letter-spacing: .04em; margin: 0 0 9px; }
label output { color: var(--acid); }
input:not([type="range"]):not([type="checkbox"]), select, textarea {
  width: 100%; color: var(--ink); background: #0b0e0c; border: 1px solid #303531; border-radius: 2px; outline: none; padding: 13px 14px; transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus { border-color: #75823d; box-shadow: 0 0 0 3px rgba(200,255,61,.06); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #7f877f 50%),linear-gradient(135deg,#7f877f 50%,transparent 50%); background-position: calc(100% - 17px) 18px,calc(100% - 12px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { min-height: 156px; resize: vertical; line-height: 1.65; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 22px 0; align-items: end; }
input[type="range"] { width: 100%; accent-color: var(--acid); margin: 9px 0 12px; }
.textarea-meta { color: #636a65; font: 10px var(--mono); display: flex; justify-content: space-between; gap: 18px; margin: 8px 0 24px; }

.button { border: 0; border-radius: 2px; text-decoration: none; display: inline-flex; justify-content: center; align-items: center; gap: 14px; min-height: 42px; padding: 0 17px; font-size: 12px; font-weight: 700; transition: transform .15s, background .15s, color .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: wait; transform: none; }
.button-primary { background: var(--acid); color: #11150b; }
.button-primary:hover { background: #d6ff70; }
.button-secondary { border: 1px solid #394039; background: transparent; color: var(--ink); }
.button-secondary:hover, .button-quiet:hover { border-color: #697269; color: var(--ink); }
.button-quiet { border: 1px solid var(--line); color: var(--muted); background: transparent; min-height: 34px; font: 10px var(--mono); }
.button-wide { width: 100%; justify-content: space-between; min-height: 49px; padding-inline: 18px; }

.audio-result { border-top: 1px solid var(--line); margin-top: 30px; padding-top: 25px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; }
.audio-result[hidden] { display: none; }
.audio-result p { font-size: 12px; margin: 0 0 4px; }
.audio-result span { color: var(--muted); font: 9px var(--mono); }
audio { width: 100%; height: 37px; filter: invert(.9) hue-rotate(40deg); }

.library-panel { display: flex; flex-direction: column; min-height: 590px; }
.voice-list { display: flex; flex-direction: column; gap: 8px; flex: 1; max-height: 422px; overflow-y: auto; margin-bottom: 25px; }
.empty-state { text-align: center; margin: auto; color: var(--muted); }
.empty-state p { margin: 8px 0 4px; color: #c3c7c3; font-size: 13px; }
.empty-state small { font: 9px var(--mono); }
.empty-wave { font-size: 58px; color: #343a35; }
.voice-card { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; border: 1px solid var(--line); padding: 12px; background: #0d100e; }
.voice-avatar { width: 36px; height: 36px; display: grid; place-items: center; color: var(--acid); background: #1c2416; font: 500 13px var(--mono); }
.voice-name { font-size: 12px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-meta { color: #656b66; font: 8px var(--mono); }
.voice-actions { display: flex; gap: 4px; }
.icon-button { border: 0; width: 29px; height: 29px; color: #89908a; background: transparent; border-radius: 50%; }
.icon-button:hover { color: var(--acid); background: #1d231f; }
.icon-button.danger:hover { color: var(--danger); }

.api-strip { min-height: 150px; border: 1px solid var(--line); border-top: 0; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 44px; padding: 30px 46px; }
.api-strip .step { margin-bottom: 10px; }
.api-strip h2 { font-size: 20px; }
.api-strip code { color: var(--acid); background: #111611; border: 1px solid #2a3425; padding: 14px 17px; font: 11px var(--mono); }
.text-link { color: #c5c9c5; font: 10px var(--mono); text-decoration: none; }
.text-link:hover { color: var(--acid); }

dialog { color: var(--ink); width: min(520px, calc(100% - 30px)); border: 1px solid #343a35; padding: 0; background: var(--panel-raised); box-shadow: 0 30px 100px #000; }
dialog::backdrop { background: rgba(0,0,0,.78); backdrop-filter: blur(6px); }
.dialog-card { padding: 38px; position: relative; }
.dialog-card h2 { font-size: 30px; margin-bottom: 10px; }
.dialog-card .muted { color: var(--muted); font-size: 13px; line-height: 1.65; margin-bottom: 25px; }
.dialog-card > input { margin-bottom: 21px; }
.dialog-card > textarea { min-height: 84px; margin-bottom: 21px; }
.dialog-card label span { color: #667068; font-size: 9px; }
.dialog-close { position: absolute; right: 18px; top: 16px; border: 0; background: none; color: var(--muted); font-size: 24px; }
.file-drop { min-height: 90px; border: 1px dashed #444c45; background: #0d100e; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; text-align: center; cursor: pointer; margin-bottom: 20px; padding: 14px; }
.file-drop:hover { border-color: var(--acid-deep); }
.file-drop small { color: #697069; font: 9px var(--mono); }
#referenceAudio {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.consent-row { display: grid; grid-template-columns: 17px 1fr; gap: 11px; line-height: 1.5; align-items: start; font-family: var(--sans); font-size: 11px; margin-bottom: 25px; }
.consent-row input { accent-color: var(--acid); margin: 1px 0; }

.toast { position: fixed; z-index: 20; bottom: 24px; left: 50%; transform: translate(-50%, 20px); color: var(--ink); background: #1d231f; border: 1px solid #394139; padding: 13px 18px; font: 11px var(--mono); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: min(520px, calc(100% - 30px)); }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { color: #ffd4d0; border-color: #613833; }

@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; min-height: 0; padding-block: 60px; gap: 32px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .api-strip { grid-template-columns: 1fr; gap: 20px; padding: 30px 24px; }
  .api-strip code { overflow-x: auto; }
  .audio-result { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .topbar { padding-inline: 15px; }
  .connection #statusText { display: none; }
  main { padding-inline: 12px; }
  h1 { font-size: 50px; }
  .field-row { grid-template-columns: 1fr; }
  .panel { padding: 24px 18px; }
  .dialog-card { padding: 32px 22px 24px; }
  .textarea-meta span:first-child { display: none; }
  .textarea-meta { justify-content: flex-end; }
}
