:root {
  color-scheme: dark;
  --bg: #0d1017;
  --panel: rgba(22, 27, 38, 0.78);
  --panel-strong: rgba(30, 36, 50, 0.92);
  --line: rgba(238, 220, 174, 0.14);
  --text: #f7f0df;
  --muted: #aaa492;
  --soft: #696d75;
  --gold: #f2ca7e;
  --gold-strong: #ffd98e;
  --teal: #7bd8bd;
  --red: #e77e7e;
  --shadow: rgba(0, 0, 0, 0.42);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(80, 61, 25, 0.32), transparent 32rem),
    radial-gradient(circle at 86% 24%, rgba(38, 104, 91, 0.24), transparent 30rem),
    linear-gradient(145deg, #0b0e14 0%, #111621 48%, #0b0d12 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.site-header,
main,
footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 0 18px;
}

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

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(242, 202, 126, 0.18), rgba(123, 216, 189, 0.08));
  color: var(--gold);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand-mark path {
  fill: none;
  stroke: currentColor;
  stroke-width: 9;
  stroke-linecap: round;
}

.status-pill,
.mono-note,
.section-kicker {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  background: rgba(255, 255, 255, 0.03);
}

.hero {
  max-width: 890px;
  padding: 68px 0 46px;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--teal);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 24px;
  font-size: clamp(2.55rem, 7vw, 5.9rem);
  line-height: 0.98;
  letter-spacing: -0.065em;
}

.lede {
  max-width: 760px;
  color: #c9c2b0;
  font-size: clamp(1rem, 2vw, 1.18rem);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.35fr);
  gap: 20px;
  align-items: stretch;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.018)), var(--panel);
  box-shadow: 0 24px 80px var(--shadow);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 229, 176, 0.34), transparent);
}

.composer-panel,
.output-panel,
.glyph-lab {
  padding: 24px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.panel-heading.wide {
  align-items: end;
}

.panel-heading h2,
.editor-card h3,
.lab-grid h3 {
  margin-bottom: 0;
}

h2 {
  font-size: 1.35rem;
  letter-spacing: -0.025em;
}

h3 {
  font-size: 0.94rem;
  color: #e9dfc9;
}

.section-kicker {
  margin-bottom: 6px;
  color: var(--gold);
}

textarea {
  width: 100%;
  border: 1px solid rgba(242, 202, 126, 0.18);
  border-radius: 18px;
  outline: none;
  background: rgba(5, 8, 13, 0.68);
  color: var(--text);
  resize: vertical;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea:focus {
  border-color: rgba(242, 202, 126, 0.58);
  box-shadow: 0 0 0 4px rgba(242, 202, 126, 0.08);
}

#sourceText {
  min-height: 190px;
  padding: 17px;
  font-size: 1.03rem;
  line-height: 1.75;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.controls.compact {
  margin: 12px 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid rgba(242, 202, 126, 0.22);
  border-radius: 999px;
  padding: 0 17px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: rgba(242, 202, 126, 0.52);
  background: rgba(255, 255, 255, 0.075);
}

.button.primary {
  background: linear-gradient(135deg, #f0c575, #c9903f);
  color: #17110a;
  font-weight: 800;
}

.button.ghost {
  color: var(--muted);
}

.button.danger {
  border-color: rgba(231, 126, 126, 0.32);
  color: #f0a2a2;
}

.button.small {
  min-height: 34px;
  padding: 0 13px;
  font-size: 0.85rem;
}

.copy-state {
  min-height: 1.5em;
  margin: 10px 0 0;
  color: var(--teal);
  font-size: 0.9rem;
}

.script-frame {
  min-height: 284px;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 22px;
  padding: clamp(18px, 4vw, 34px);
  background:
    radial-gradient(circle at 20% 12%, rgba(242, 202, 126, 0.08), transparent 20rem),
    linear-gradient(150deg, rgba(3, 5, 8, 0.58), rgba(12, 16, 23, 0.66));
}

.rendered-output {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  row-gap: 14px;
  column-gap: 5px;
  min-height: 212px;
}

.glyph-box,
.punctuation-box,
.unknown-box,
.space-box {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 62px;
}

.copy-text {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  color: transparent;
  font-size: 1px;
  line-height: 1;
  white-space: pre;
  user-select: text;
}

.glyph-box {
  width: 46px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), transparent);
}

.glyph-box svg {
  width: 42px;
  height: 58px;
  overflow: visible;
}

.glyph-path {
  fill: none;
  stroke: var(--gold-strong);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 7px rgba(242, 202, 126, 0.12));
}

.glyph-box.vowel .glyph-path {
  stroke: var(--teal);
  filter: drop-shadow(0 0 7px rgba(123, 216, 189, 0.12));
}

.punctuation-box {
  width: 24px;
  color: rgba(247, 240, 223, 0.62);
  font-size: 1.6rem;
}

.unknown-box {
  width: 36px;
  border: 1px dashed rgba(255,255,255,0.2);
  border-radius: 10px;
  color: var(--soft);
}

.space-box {
  width: 22px;
}

.line-break {
  position: relative;
  flex-basis: 100%;
  height: 0;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.glyph-lab {
  margin-top: 20px;
}

.lab-summary {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.lab-grid {
  display: grid;
  grid-template-columns: 250px minmax(330px, 1fr) minmax(280px, 0.82fr);
  gap: 22px;
  margin-top: 20px;
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
}

.letter-button {
  aspect-ratio: 1;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(255,255,255,0.035);
  color: var(--muted);
  cursor: pointer;
}

.letter-button:hover,
.letter-button.active {
  border-color: rgba(242, 202, 126, 0.62);
  color: var(--gold);
  background: rgba(242, 202, 126, 0.09);
}

.letter-button.customized::after {
  content: "";
  display: block;
  width: 4px;
  height: 4px;
  margin: 1px auto 0;
  border-radius: 50%;
  background: var(--teal);
}

.editor-card {
  border: 1px solid rgba(255,255,255,0.075);
  border-radius: 20px;
  padding: 16px;
  background: rgba(255,255,255,0.025);
}

.editor-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.editor-split {
  display: grid;
  grid-template-columns: 106px 1fr;
  gap: 14px;
  align-items: stretch;
}

.glyph-preview {
  display: grid;
  place-items: center;
  min-height: 142px;
  border: 1px solid rgba(242, 202, 126, 0.14);
  border-radius: 16px;
  background:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px),
    rgba(4, 7, 11, 0.48);
  background-size: 20px 20px;
}

.glyph-preview svg {
  width: 82px;
  height: 112px;
  overflow: visible;
}

.glyph-editor {
  min-height: 142px;
  padding: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.55;
}

.import-box {
  margin-top: 12px;
  color: var(--muted);
}

.import-box summary {
  cursor: pointer;
  color: var(--text);
}

.import-box textarea {
  min-height: 120px;
  margin: 12px 0 10px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 22px 0 46px;
}

.notes article {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.notes h2 {
  font-size: 1.05rem;
}

.notes p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 20px 0 28px;
  color: var(--soft);
  font-size: 0.84rem;
}

code {
  color: var(--gold);
}

@media (max-width: 980px) {
  .workspace,
  .lab-grid,
  .notes {
    grid-template-columns: 1fr;
  }

  .letter-grid {
    grid-template-columns: repeat(13, 1fr);
  }
}

@media (max-width: 620px) {
  .site-header,
  main,
  footer {
    width: min(100% - 24px, 1180px);
  }

  .hero {
    padding-top: 40px;
  }

  .composer-panel,
  .output-panel,
  .glyph-lab {
    padding: 17px;
    border-radius: 22px;
  }

  .panel-heading,
  .panel-heading.wide {
    display: block;
  }

  .mono-note {
    display: block;
    margin-top: 7px;
  }

  .letter-grid {
    grid-template-columns: repeat(7, 1fr);
  }

  .editor-split {
    grid-template-columns: 1fr;
  }

  .glyph-box {
    width: 38px;
    height: 54px;
  }

  .glyph-box svg {
    width: 35px;
    height: 50px;
  }
}
