:root {
  --bg: #101114;
  --bg-raise: #17191f;
  --ink: #f3efe7;
  --muted: #c4beb4;
  --line: rgba(243, 239, 231, 0.12);
  --brass: #e7b15a;
  --brass-ink: #1a1408;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Liberation Serif", "Times New Roman", serif;
  --sans: "Avenir Next", "Segoe UI", "Liberation Sans", "Noto Sans CJK SC", "Noto Sans CJK JP", "Noto Sans CJK KR", "WenQuanYi Micro Hei", "Droid Sans Fallback", sans-serif;
  --mono: "SFMono-Regular", "Liberation Mono", "Noto Sans Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-padding-top: 56px; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse 70% 36% at 8% -12%, rgba(231, 177, 90, 0.09), transparent 52%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}

a { color: #f0d7a4; }
a:hover { color: #fff6e4; }

button, input, summary { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--brass); color: var(--brass-ink); }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--brass);
  color: var(--brass-ink);
  padding: 6px 10px;
  border-radius: 8px;
  z-index: 40;
}
.skip:focus { top: 8px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: rgba(16, 17, 20, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-width: 0;
}
.brand svg { display: block; flex: 0 0 auto; }

.lang-menu { position: relative; flex: 0 0 auto; }
.lang-menu summary {
  list-style: none;
  height: 28px;
  min-width: 52px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #14161b;
  cursor: pointer;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu ul {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  margin: 0;
  padding: 6px;
  list-style: none;
  min-width: 148px;
  background: #1c1e24;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.lang-menu a {
  display: block;
  padding: 6px 8px;
  border-radius: 7px;
  color: var(--ink);
  text-decoration: none;
}
.lang-menu a:hover,
.lang-menu a[aria-current="page"] { background: rgba(231, 177, 90, 0.16); }

.first-screen {
  align-content: start;
  display: grid;
  gap: 8px;
  padding: 10px 16px 8px;
  min-height: 0;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  line-height: 32px;
  letter-spacing: -0.025em;
}

.studio {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.stage-column {
  min-width: 0;
  display: grid;
  gap: 8px;
  align-content: start;
}
.export-bar,
.code-preview,
.panel,
.hint { min-width: 0; }

.stage { min-width: 0; }
.stage svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  border: 1px solid rgba(243, 239, 231, 0.14);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.export-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.export-bar button,
.ghost,
.mode-switch button,
.palette button {
  border: 1px solid var(--line);
  background: #14161b;
  border-radius: 8px;
}
.export-bar button {
  height: 36px;
  padding: 0 8px;
  white-space: nowrap;
}
#copy-svg {
  background: var(--brass);
  color: var(--brass-ink);
  border-color: var(--brass);
  font-weight: 650;
}
.export-bar button:hover,
.ghost:hover,
.palette button:hover { border-color: rgba(231, 177, 90, 0.7); }
#copy-svg:hover { filter: brightness(1.05); }

.code-preview {
  margin: 0;
  max-height: 56px;
  overflow: auto;
  padding: 8px 10px;
  border-radius: 10px;
  background: #0c0d11;
  color: #ddd6c8;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre;
  max-width: 100%;
}

.panel {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px 10px;
  display: grid;
  gap: 7px;
  align-content: start;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}
.mode-switch button {
  height: 32px;
  padding: 0 4px;
}
.mode-switch button[aria-checked="true"] {
  background: var(--brass);
  color: var(--brass-ink);
  border-color: var(--brass);
  font-weight: 650;
}

.hint {
  margin: 0;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seed-row {
  display: grid;
  grid-template-columns: auto 86px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}
.seed-row label { font-size: 12px; color: var(--muted); }
.seed-row input,
.ghost {
  height: 32px;
  border-radius: 8px;
}
.seed-row input {
  width: 86px;
  background: #101114;
  border: 1px solid var(--line);
  padding: 0 6px;
}
.ghost {
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.params { display: grid; gap: 4px; }
.slider {
  display: grid;
  grid-template-columns: minmax(72px, 0.9fr) minmax(0, 1.2fr) 36px;
  gap: 6px;
  align-items: center;
  min-height: 26px;
  font-size: 12px;
}
.slider output {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: #3c3933;
  border-radius: 999px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--brass);
  border: 2px solid #101114;
}
input[type="range"]::-moz-range-track {
  height: 2px;
  background: #3c3933;
  border: 0;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brass);
  border: 2px solid #101114;
}

.flip {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 6px;
  align-items: center;
  min-height: 26px;
  font-size: 12px;
}
.flip span { color: var(--muted); }
.flip label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14161b;
}
.flip input { accent-color: var(--brass); }

.group-label {
  margin: 2px 0 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.palette { display: grid; gap: 4px; }
.palette button {
  height: 26px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  font-size: 12px;
}
.palette button[aria-pressed="true"] { border-color: var(--brass); }
.pname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dots { display: flex; gap: 3px; flex: 0 0 auto; }
.dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: block;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.color-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101114;
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 5px; }

.site-foot {
  height: 32px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  color: #ddd6c8;
  font-size: 12px;
}
.site-foot p {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.below {
  padding: 42px 20px 72px;
  display: grid;
  gap: 28px;
}
.below section { max-width: 760px; }
.below h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 500;
}
.below ol, .below ul { margin: 0; padding-left: 1.15em; }
.below li + li { margin-top: 6px; }
.note { margin: 12px 0 0; color: var(--muted); max-width: 68ch; }
.qa { padding-top: 10px; }
.qa h3 { margin: 0 0 4px; font-size: 16px; }
.qa p { margin: 0; color: var(--muted); max-width: 68ch; }
.qa + .qa { margin-top: 12px; }

.disclosure {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid rgba(231, 177, 90, 0.5);
  border-radius: 10px;
  background: rgba(231, 177, 90, 0.1);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  max-width: 70ch;
}
.partners ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.partners li { color: var(--muted); }
.partners a { font-weight: 650; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%);
  z-index: 50;
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: #1e2a22;
  color: #d8f5e4;
  border: 1px solid #3e6b52;
  font-size: 13px;
}
.toast[hidden] { display: none !important; }

.missing {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 8px;
  padding: 32px 20px;
}
.missing h1 { white-space: normal; }
.lang-list { display: flex; flex-wrap: wrap; gap: 10px 14px; padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  h1 { font-size: 24px; line-height: 1.2; }
  .export-bar { grid-template-columns: 1fr 1fr; }
  .seed-row { grid-template-columns: auto 86px; }
  .seed-row button { grid-column: 1 / -1; }
  .slider { grid-template-columns: 1fr auto; }
  .slider input[type="range"] { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}

@media (min-width: 1100px) {
  .hero-wrap {
    height: calc(100vh - 48px);
    display: grid;
    grid-template-rows: minmax(0, 1fr) 32px;
  }
  h1 { white-space: nowrap; }
  .missing h1 { white-space: normal; }
  .studio {
    grid-template-columns: minmax(0, 1fr) 304px;
    align-items: start;
  }
  .stage svg {
    width: min(100%, calc((100vh - 236px) * 16 / 9));
    height: auto;
  }
}
