:root {
  --bg: #1f232b;
  --bg-elevated: #171b22;
  --panel: #262b36;
  --panel-strong: #2d3340;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 110, 66, 0.4);
  --hairline: rgba(255, 255, 255, 0.05);
  --text: rgba(255, 255, 255, 0.87);
  --muted: rgba(255, 255, 255, 0.62);
  --accent: #ef5552;
  --accent-2: #ff6e42;
  --surface-soft: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.06);
  --input-bg: rgba(15, 18, 24, 0.72);
  --warning-bg: rgba(255, 193, 7, 0.1);
  --warning-text: #ffd79a;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
  --shadow-soft: 0 8px 20px rgba(0, 0, 0, 0.18);
  --shadow-hover: 0 22px 48px rgba(0, 0, 0, 0.4);
  --focus-ring: 0 0 0 4px rgba(255, 110, 66, 0.14);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color-scheme: dark;
  background:
    radial-gradient(circle at top left, rgba(239, 85, 82, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 110, 66, 0.14), transparent 24%),
    linear-gradient(180deg, #252a34 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.03), transparent 0 22%),
    radial-gradient(circle at 78% 10%, rgba(255, 255, 255, 0.025), transparent 0 16%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 24%);
  opacity: 0.9;
}

::selection {
  background: rgba(255, 110, 66, 0.3);
  color: #fff;
}

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

.app-shell {
  width: min(1560px, calc(100vw - 32px));
  margin: 16px auto 32px;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background:
    linear-gradient(135deg, rgba(38, 43, 54, 0.96), rgba(29, 33, 41, 0.92)),
    linear-gradient(90deg, rgba(239, 85, 82, 0.08), rgba(255, 110, 66, 0.08));
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent);
}

.topbar h1,
.panel-section h2,
.dynamic-group h3,
.notes-card h3 {
  margin: 0;
  font-family: "Roboto", "Segoe UI", sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.topbar-note {
  padding: 10px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(500px, 1fr) minmax(500px, 1fr);
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

.panel {
  min-width: 0;
}

.controls-panel,
.output-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-section {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(38, 43, 54, 0.98), rgba(30, 34, 43, 0.96));
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.panel-section::before,
.notes-card::before,
.dynamic-group::before {
  content: "";
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hairline), transparent);
  pointer-events: none;
}

.panel-section:hover {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow-hover);
}

.section-heading {
  margin-bottom: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field-stack,
.dynamic-zone {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-full {
  grid-column: 1 / -1;
}

.field span,
.dynamic-group h3,
.note-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  background: var(--input-bg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease, transform 120ms ease;
}

textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.45;
}

.textarea-compact {
  min-height: 72px;
}

select {
  min-height: 46px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.6) 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.6) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% - 2px),
    calc(100% - 14px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-2);
  background-color: rgba(18, 22, 29, 0.88);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    var(--focus-ring);
}

textarea::placeholder {
  color: rgba(255, 255, 255, 0.34);
}

.notes-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 110, 66, 0.18);
  background: linear-gradient(180deg, rgba(35, 40, 50, 0.94), rgba(29, 33, 41, 0.92));
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.notes-card h3 {
  margin-bottom: 12px;
}

.note-block + .note-block {
  margin-top: 12px;
}

.note-values {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.note-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 110, 66, 0.14);
  color: var(--text);
  font-size: 0.86rem;
  border: 1px solid rgba(255, 110, 66, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

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

.selection-meta {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel-strong);
  border: 1px solid var(--hairline);
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.dynamic-group {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.dynamic-group h3 {
  margin-bottom: 12px;
}

.dynamic-list,
.checkbox-list {
  display: grid;
  gap: 10px;
}

.option-row {
  display: grid;
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
  transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
}

.checkbox-item:hover {
  border-color: rgba(255, 110, 66, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.checkbox-item input {
  margin-top: 2px;
  accent-color: var(--accent-2);
}

.checkbox-item span {
  line-height: 1.45;
  word-break: break-word;
}

.empty-state {
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.is-hidden {
  display: none !important;
}

.output-sticky {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 18px;
}

.footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 20px;
  padding: 18px 20px 6px;
  color: var(--muted);
}

.footer a {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 700;
  transition: color 120ms ease, opacity 120ms ease;
}

.footer a:hover {
  color: #ff8a66;
}

.summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
}

.ratio-value {
  min-width: 120px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(239, 85, 82, 0.18), rgba(38, 43, 54, 0.92));
  color: var(--accent-2);
  border: 1px solid rgba(255, 110, 66, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 8px 24px rgba(0, 0, 0, 0.22);
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.warning-panel {
  border-color: rgba(255, 193, 7, 0.24);
  background:
    linear-gradient(180deg, rgba(59, 44, 19, 0.64), rgba(40, 31, 15, 0.58));
}

.warning-header {
  margin-bottom: 10px;
}

.warning-list {
  display: grid;
  gap: 10px;
}

.warning-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid rgba(255, 193, 7, 0.14);
  line-height: 1.5;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.copy-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  cursor: pointer;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 10px 24px rgba(239, 85, 82, 0.18);
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.copy-button:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 14px 28px rgba(239, 85, 82, 0.24);
}

.copy-button:active {
  transform: translateY(0);
}

.copy-button:focus-visible {
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 14px 28px rgba(239, 85, 82, 0.24),
    var(--focus-ring);
}

#output-prompt {
  min-height: 72vh;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95rem;
  background: var(--input-bg);
  border-color: rgba(255, 255, 255, 0.14);
  line-height: 1.58;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 0 0 1px rgba(0, 0, 0, 0.08),
    0 10px 28px rgba(0, 0, 0, 0.16);
}

textarea,
#output-prompt {
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  scrollbar-width: thin;
}

textarea::-webkit-scrollbar,
#output-prompt::-webkit-scrollbar {
  width: 10px;
}

textarea::-webkit-scrollbar-thumb,
#output-prompt::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

textarea::-webkit-scrollbar-thumb:hover,
#output-prompt::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.26);
  background-clip: padding-box;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .output-sticky {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 16px, 100%);
    margin: 8px auto 20px;
  }

  .topbar {
    padding: 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .panel-section {
    padding: 18px;
  }

  .output-header,
  .summary-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .ratio-value {
    width: 100%;
  }

  .footer {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
}
