:root {
  --paper: #e7e1d8;
  --card: rgba(251, 248, 243, 0.9);
  --ink: #141311;
  --cream: #f4efe6;
  --muted: #6f685f;
  --line: #e0d6ca;
  --vermilion: #ef4d32;
  --chartreuse: #d2ee6a;
  --moss: #1e6b52;
  --field: #fffdf9;
  --track: #efe8de;
  --dock: #f6f1e8;
  --placeholder: #c3b8ab;
  --warning: #9a3412;
  --panel-border: rgba(255, 255, 255, 0.7);
  --fill: #141311;
  --on-fill: #f6f1e8;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
}

:root[data-theme="dark"] {
  --paper: #171411;
  --card: rgba(32, 28, 25, 0.94);
  --ink: #f6f1e8;
  --cream: #f6f1e8;
  --muted: #b7aea3;
  --line: #433d37;
  --field: #241f1c;
  --track: #2c2723;
  --dock: #211d1a;
  --placeholder: #8d8378;
  --warning: #ffb199;
  --panel-border: rgba(255, 255, 255, 0.08);
  --fill: #f4efe6;
  --on-fill: #171411;
  --vermilion: #ff6a4d;
  --moss: #3ecf8e;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --paper: #171411;
    --card: rgba(32, 28, 25, 0.94);
    --ink: #f6f1e8;
    --cream: #f6f1e8;
    --muted: #b7aea3;
    --line: #433d37;
    --field: #241f1c;
    --track: #2c2723;
    --dock: #211d1a;
    --placeholder: #8d8378;
    --warning: #ffb199;
    --panel-border: rgba(255, 255, 255, 0.08);
    --fill: #f4efe6;
    --on-fill: #171411;
    --vermilion: #ff6a4d;
    --moss: #3ecf8e;
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(239, 77, 50, 0.16), transparent 55%),
    radial-gradient(760px 380px at 100% 0%, rgba(210, 238, 106, 0.38), transparent 52%),
    var(--paper);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

::selection {
  background: #ffd0c4;
}

.frame {
  height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--ink);
  color: var(--cream);
  padding: 8px 12px;
  border-radius: 999px;
  z-index: 5;
}

.skip:focus {
  top: 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.mark {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: #141311;
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 0 10px;
  flex: none;
}

.mark i {
  display: block;
  height: 3px;
  border-radius: 99px;
}

.mark i:nth-child(1) {
  width: 100%;
  background: #ef4d32;
}

.mark i:nth-child(2) {
  width: 72%;
  background: #f4efe6;
}

.mark i:nth-child(3) {
  width: 46%;
  background: #d2ee6a;
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 560;
  letter-spacing: -0.045em;
  line-height: 0.9;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.35;
  white-space: nowrap;
}

.pill {
  margin: 6px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(20, 19, 17, 0.08);
  background: rgba(255, 253, 249, 0.62);
  border-radius: 999px;
  padding: 8px 12px;
  color: #4e4942;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--moss);
}

.shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#studio {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.preset-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 8px;
}

.preset-row::-webkit-scrollbar {
  height: 8px;
}

.preset-row::-webkit-scrollbar-thumb {
  background: #d5cdc2;
  border-radius: 99px;
}

.preset {
  flex: 1 0 148px;
  text-align: left;
  border: 1px solid rgba(20, 19, 17, 0.06);
  background: var(--card);
  border-radius: 16px;
  padding: 12px 12px 13px;
  box-shadow: 0 8px 20px rgba(48, 32, 18, 0.04);
}

.preset strong {
  display: block;
  font-size: 15px;
}

.preset small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.preset:hover {
  border-color: var(--line);
}

.preset.active {
  background: var(--fill);
  color: var(--on-fill);
  border-color: var(--fill);
}

.preset.active small {
  color: color-mix(in srgb, var(--on-fill) 72%, transparent);
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 16px;
}

.panel,
.stage {
  min-width: 0;
  min-height: 0;
}

.panel {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: 0 16px 40px rgba(48, 32, 18, 0.05);
}

.panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 18px 12px;
}

.panel-dock {
  flex: none;
  border-top: 1px solid var(--line);
  padding: 6px 18px 12px;
  background: var(--dock);
  border-radius: 0 0 27px 27px;
}

.panel-dock .switch {
  padding: 5px 0;
}

.block + .block {
  border-top: 1px solid var(--line);
  margin-top: 8px;
}

.panel h2,
.eyebrow {
  margin: 16px 0 10px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 650;
  color: var(--muted);
}

.block > .segmented + .stack {
  margin-top: 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metrics .metric-top {
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
}

.metrics .metric input[type="number"] {
  width: 84px;
}

.segmented {
  display: flex;
  gap: 8px;
  padding: 6px;
  background: var(--track);
  border-radius: 14px;
}

.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  min-height: 36px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 8px;
}

.segmented button[aria-checked="true"] {
  background: var(--field);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(20, 19, 17, 0.08);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--field);
  border-radius: 999px;
  min-height: 36px;
  padding: 0 12px;
  font-weight: 600;
}

.chip[aria-pressed="true"] {
  background: var(--fill);
  color: var(--on-fill);
  border-color: var(--fill);
}

.field,
.metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span,
.field > .field-label,
.metric label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field input[type="text"],
.field textarea,
.metric input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--field);
  border-radius: 12px;
}

.field input[type="text"],
.metric input[type="number"] {
  height: 44px;
  padding: 0 12px;
}

.metric-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.metric input[type="number"] {
  width: 84px;
  text-align: center;
  font-family: var(--mono);
}

.field textarea {
  min-height: 112px;
  padding: 12px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
}

.field textarea.charset {
  min-height: 0;
  height: calc(4.5em + 24px);
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
  font-style: italic;
  opacity: 1;
}

.field input:focus-visible,
.field textarea:focus-visible,
.metric input:focus-visible,
.savebar input:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(239, 77, 50, 0.18);
}

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

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: #ddd4c8;
  border-radius: 99px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--field);
  box-shadow: 0 1px 2px rgba(20, 19, 17, 0.25);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  background: #ddd4c8;
  border-radius: 99px;
  border: 0;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--field);
}

.hint,
.warning {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.hint {
  color: var(--muted);
}

.warning {
  color: var(--warning);
}

.picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.key {
  width: 28px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}

.key.out {
  color: #b3a89c;
  background: #f3ece4;
  text-decoration: line-through;
}

.used {
  margin: 0;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--field);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alphabet {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  overflow-wrap: anywhere;
  max-height: 7.4em;
  overflow: auto;
}

.cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 88px;
  overflow: auto;
}

.cloud li {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
}

.switch {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.switch-label {
  display: block;
  font-weight: 650;
}

.switch-help {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.knob {
  width: 44px;
  height: 26px;
  border-radius: 99px;
  background: #ddd4c8;
  position: relative;
  flex: none;
}

.knob::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  top: 3px;
  left: 3px;
  transition: transform 160ms ease;
}

.switch[aria-checked="true"] .knob {
  background: var(--moss);
}

.switch[aria-checked="true"] .knob::after {
  transform: translateX(18px);
}

.panel-foot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-top: 8px;
}

.text-btn {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--muted);
  font-weight: 650;
}

.text-btn:hover {
  color: var(--ink);
}

.theme-btn {
  margin-top: 4px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
}

.theme-btn .icon {
  display: none;
  width: 18px;
  height: 18px;
}

html[data-theme="auto"] .theme-btn .icon-auto,
html:not([data-theme]) .theme-btn .icon-auto,
html[data-theme="light"] .theme-btn .icon-light,
html[data-theme="dark"] .theme-btn .icon-dark {
  display: block;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.info {
  position: relative;
  display: inline-flex;
}

.info-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--muted);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

.info-tip {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: 280px;
  max-width: 70vw;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--fill);
  color: var(--on-fill);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: 0 12px 30px rgba(20, 19, 17, 0.18);
  opacity: 0;
  visibility: hidden;
  z-index: 8;
  pointer-events: none;
}

.info:hover .info-tip,
.info:focus-within .info-tip {
  opacity: 1;
  visibility: visible;
}

.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: 28px;
  padding: 22px 22px 16px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--panel-border);
  box-shadow: 0 16px 40px rgba(48, 32, 18, 0.05);
}

.stage .eyebrow {
  margin: 0;
  color: var(--muted);
}

.stage h2 {
  margin: 4px 0 8px;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 560;
  letter-spacing: -0.03em;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.meta i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line);
  display: inline-block;
  margin: 0 10px 1px;
}

.strength {
  font-style: normal;
  font-weight: 650;
}

.strength.fixed,
.strength.light {
  color: var(--vermilion);
}

.strength.solid {
  color: var(--ink);
}

.strength.deep {
  color: var(--moss);
}

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 16px 0 14px;
}

.btn {
  height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 650;
}

.btn:disabled {
  opacity: 0.45;
}

.btn.primary {
  background: var(--vermilion);
  color: #1a100d;
}

.btn.primary:hover:not(:disabled) {
  background: #ff6248;
}

.btn.ghost {
  background: var(--field);
  color: var(--ink);
  border-color: var(--line);
}

.btn.ghost:hover:not(:disabled) {
  border-color: var(--ink);
}

.shortcut {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-left: 4px;
}

kbd {
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 7px;
  padding: 3px 6px;
  color: var(--muted);
}

.stage-head {
  grid-row: 1;
}

.batch-scroll {
  grid-row: 2;
}

.savebar {
  grid-row: 3;
}

.stage > .toast {
  grid-row: 1;
}

.batch-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-color: var(--line) transparent;
}

.banner {
  margin: 0 0 12px;
  background: rgba(239, 77, 50, 0.1);
  color: var(--ink);
  border: 1px solid rgba(239, 77, 50, 0.35);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
}

.batch {
  list-style: none;
  margin: 0;
  padding: 0 4px 8px 0;
  animation: rise 320ms ease;
}

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
}

.idx {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  padding-top: 4px;
}

.value {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.row button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
}

.row button[data-copied="true"] {
  background: var(--chartreuse);
  color: var(--ink);
  border-color: var(--chartreuse);
}

.empty {
  max-width: 32ch;
  margin-top: 18px;
}

.empty strong {
  display: block;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 560;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.empty p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.savebar {
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
  background: transparent;
  padding-top: 14px;
  margin-top: 8px;
}

.file-name {
  flex: 1;
  min-width: 0;
}

.savebar input[type="text"] {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 14px;
}

.savebar input::placeholder {
  color: var(--placeholder);
}

.ending {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  flex: none;
}

.ending button {
  background: transparent;
  color: var(--muted);
  border: 0;
  height: 42px;
  padding: 0 12px;
  font-weight: 650;
}

.ending button[aria-pressed="true"] {
  background: var(--fill);
  color: var(--on-fill);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  background: var(--cream);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 650;
  box-shadow: 0 12px 30px rgba(20, 19, 17, 0.2);
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 4;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes rise {
  from {
    transform: translateY(4px);
  }
  to {
    transform: none;
  }
}

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

@media (max-height: 900px) and (min-width: 901px) {
  .frame {
    padding: 12px 18px 10px;
    gap: 10px;
  }

  .brand h1 {
    font-size: 30px;
  }

  .brand p {
    display: none;
  }

  .shell {
    gap: 8px;
  }

  .preset {
    padding: 8px 10px;
  }

  .preset small {
    display: none;
  }

  .stage {
    padding: 16px 16px 12px;
  }

  .stage h2 {
    font-size: 28px;
    margin-bottom: 4px;
  }

  .stage-actions {
    margin: 10px 0 8px;
  }
}

@media (max-width: 900px) {
  .frame {
    height: auto;
    min-height: 100%;
  }

  .shell,
  #studio,
  .workspace {
    flex: none;
    min-height: auto;
  }

  .workspace {
    display: flex;
    flex-direction: column;
  }

  .stage {
    order: -1;
    min-height: 0;
    max-height: calc(100dvh - 300px);
  }

  .panel {
    overflow: visible;
  }

  .brand h1 {
    font-size: 32px;
  }
}

@media (max-width: 640px) {
  .frame {
    padding: 16px;
  }

  .topbar {
    flex-direction: column;
  }

  .pair,
  .metrics {
    grid-template-columns: 1fr;
  }

  .savebar {
    flex-wrap: nowrap;
  }

  .ending button,
  .savebar .btn {
    padding-inline: 10px;
  }

  .stage h2 {
    font-size: 28px;
  }

  .shortcut {
    display: none;
  }
}

.batch { animation: none; }
