:root {
  --bg: #f3efe7;
  --paper: rgba(255, 251, 245, 0.82);
  --paper-strong: rgba(255, 252, 248, 0.94);
  --ink: #191816;
  --muted: rgba(25, 24, 22, 0.58);
  --muted-strong: rgba(25, 24, 22, 0.74);
  --line: rgba(31, 24, 15, 0.1);
  --line-strong: rgba(31, 24, 15, 0.16);
  --accent: #c46f3a;
  --accent-deep: #8e4720;
  --accent-soft: rgba(196, 111, 58, 0.11);
  --panel-shadow: 0 24px 80px rgba(53, 36, 20, 0.11);
  --panel-shadow-strong: 0 34px 120px rgba(53, 36, 20, 0.16);
  --danger: #bf4b3f;
  --sidebar: #1c1b19;
  --sidebar-soft: rgba(28, 27, 25, 0.9);
  --sidebar-line: rgba(255, 250, 244, 0.09);
  --sidebar-text: #f7f1e8;
  --sidebar-muted: rgba(247, 241, 232, 0.66);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(233, 186, 150, 0.5), transparent 24%),
    radial-gradient(circle at top right, rgba(125, 131, 179, 0.24), transparent 22%),
    linear-gradient(180deg, #f6f1e8 0%, #efe7d9 100%);
  font-family: "Manrope", "Segoe UI Variable", "Helvetica Neue", sans-serif;
}

body {
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(28, 27, 25, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 27, 25, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at center, black 42%, transparent 88%);
  pointer-events: none;
}

.ambient {
  position: fixed;
  border-radius: 999px;
  filter: blur(80px);
  pointer-events: none;
  opacity: 0.56;
}

.ambient-a {
  top: 80px;
  right: -60px;
  width: 220px;
  height: 220px;
  background: rgba(224, 169, 114, 0.38);
}

.ambient-b {
  left: -80px;
  bottom: 10vh;
  width: 280px;
  height: 280px;
  background: rgba(138, 152, 214, 0.22);
}

.admin-body .page-shell {
  width: min(1480px, calc(100vw - 36px));
}

.admin-gate {
  position: static;
  inset: auto;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
}

.admin-gate-card {
  margin: 0 auto;
}

.admin-shell {
  min-height: calc(100vh - 36px);
}

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
}

.admin-sidebar,
.admin-main {
  display: grid;
  gap: 18px;
}

.admin-summary .hero-stats {
  width: 100%;
}

.admin-stats-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.admin-field-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.issued-panel {
  min-height: 280px;
}

.issued-codes {
  min-height: 180px;
  margin: 0;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(28, 27, 25, 0.94);
  color: var(--sidebar-text);
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 0.94rem;
  line-height: 1.75;
  overflow: auto;
  white-space: pre-wrap;
}

.issued-codes.empty {
  color: var(--sidebar-muted);
}

.admin-list-panel {
  min-height: 540px;
}

.admin-toolbar {
  align-items: end;
}

.admin-table-shell {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper-strong);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.admin-table th,
.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.admin-table tbody tr:hover {
  background: rgba(196, 111, 58, 0.05);
}

.admin-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-status-pill.is-active {
  color: #1f6f43;
  background: rgba(58, 171, 103, 0.12);
  border-color: rgba(58, 171, 103, 0.18);
}

.admin-status-pill.is-used {
  color: #5f4a0f;
  background: rgba(209, 169, 55, 0.18);
  border-color: rgba(209, 169, 55, 0.22);
}

.admin-status-pill.is-expired {
  color: #855522;
  background: rgba(196, 111, 58, 0.16);
  border-color: rgba(196, 111, 58, 0.18);
}

.admin-status-pill.is-revoked {
  color: #9d2b2b;
  background: rgba(191, 75, 63, 0.14);
  border-color: rgba(191, 75, 63, 0.18);
}

.admin-empty-cell {
  padding: 32px 16px !important;
  color: var(--muted);
  text-align: center !important;
}

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

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.page-shell {
  position: relative;
  width: min(1560px, calc(100vw - 36px));
  margin: 18px auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 34px;
  background: rgba(255, 251, 245, 0.46);
  backdrop-filter: blur(26px);
  box-shadow: var(--panel-shadow-strong);
}

.trial-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 18, 16, 0.56);
  backdrop-filter: blur(18px);
}

.trial-gate-card {
  width: min(540px, calc(100vw - 28px));
  max-height: min(90svh, 720px);
  overflow: auto;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 28px;
  background: rgba(255, 250, 244, 0.94);
  box-shadow: var(--panel-shadow-strong);
}

.trial-gate-head {
  display: grid;
  gap: 10px;
}

.trial-gate-card h2 {
  margin: 8px 0 10px;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 0.95;
}

.trial-gate-copy {
  margin: 0 0 18px;
  color: var(--muted-strong);
  line-height: 1.72;
}

.trial-gate-form {
  display: grid;
  gap: 16px;
}

.trial-policy {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.trial-policy-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(31, 24, 15, 0.08);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding: 6px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 245, 233, 0.95), rgba(224, 180, 135, 0.45)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), transparent 55%);
  border: 1px solid rgba(196, 111, 58, 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 18px 30px rgba(166, 110, 65, 0.18);
}

.brand-mark span {
  position: absolute;
  inset: 11px;
  border-radius: 999px;
  border: 2px solid rgba(123, 71, 35, 0.8);
}

.brand-mark span:last-child {
  inset: 19px 8px 8px 19px;
}

.brand-lockup h1,
.hero-copy h2,
.render-copy h2,
.empty-state h3,
.settings-panel h2,
.section-heading h3 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand-lockup h1 {
  font-size: clamp(2rem, 3vw, 2.8rem);
}

.eyebrow,
.mini-label,
.chip-label {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
}

.topbar-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-chip,
.badge,
.ghost-button,
.secondary-button,
.link-button {
  border-radius: 999px;
}

.topbar-chip {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.topbar-chip strong {
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.93rem;
}

.badge,
.ghost-button,
.secondary-button,
.link-button,
.primary-button,
.history-item,
.preset-chip,
.thumb-button {
  border: 0;
  appearance: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(32, 149, 91, 0.08);
  color: #24694a;
  border: 1px solid rgba(36, 105, 74, 0.16);
  font-weight: 700;
}

.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.badge.is-danger,
.status-text.is-danger,
.result-meta-chip.is-danger {
  color: var(--danger);
}

.badge.is-danger {
  background: rgba(191, 75, 63, 0.1);
  border-color: rgba(191, 75, 63, 0.16);
}

.ghost-button,
.secondary-button,
.link-button,
.preset-chip,
.thumb-button,
.history-item,
.primary-button {
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease;
}

.ghost-button,
.secondary-button,
.link-button,
.preset-chip,
.thumb-button {
  cursor: pointer;
}

.ghost-button {
  padding: 11px 14px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.48);
}

.ghost-button:hover,
.secondary-button:hover,
.link-button:hover,
.preset-chip:hover,
.thumb-button:hover,
.history-item:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.secondary-button {
  padding: 13px 16px;
  color: var(--sidebar-text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--sidebar-line);
}

.secondary-button.small {
  padding: 10px 14px;
}

.primary-button {
  padding: 15px 20px;
  border-radius: 18px;
  cursor: pointer;
  color: #fff9f3;
  font-weight: 800;
  background: linear-gradient(135deg, #a55228, #d5844d);
  box-shadow: 0 18px 34px rgba(164, 82, 40, 0.25);
}

.link-button {
  padding: 8px 12px;
  color: var(--muted-strong);
  background: transparent;
}

.mobile-quick-nav,
.mobile-action-bar {
  display: none;
}

.quick-nav-button {
  border: 0;
  appearance: none;
  cursor: pointer;
  padding: 11px 12px;
  border-radius: 16px;
  color: var(--sidebar-text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.workspace {
  display: grid;
  grid-template-areas:
    "control render"
    "history render";
  grid-template-columns: minmax(390px, 460px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100svh - 160px);
}

.control-stage {
  grid-area: control;
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  gap: 18px;
  padding: 18px;
  color: var(--sidebar-text);
  background:
    linear-gradient(180deg, rgba(33, 31, 28, 0.96), rgba(24, 23, 21, 0.98)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 24%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hero-card,
.composer-panel,
.history-strip,
.render-stage,
.settings-panel {
  border-radius: 24px;
}

.hero-card {
  display: grid;
  gap: 18px;
  padding: 20px;
  background:
    radial-gradient(circle at top right, rgba(212, 129, 75, 0.22), transparent 26%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 22%),
    rgba(255, 255, 255, 0.02);
  border: 1px solid var(--sidebar-line);
}

.hero-copy h2,
.render-copy h2 {
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 0.94;
}

.intro-copy {
  margin: 12px 0 0;
  color: var(--sidebar-muted);
  line-height: 1.7;
  max-width: 40ch;
}

.inline-code {
  padding: 0.16rem 0.46rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text);
  font-family: "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat-tile {
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--sidebar-line);
}

.stat-tile span {
  color: var(--sidebar-muted);
  font-size: 0.78rem;
}

.stat-tile strong {
  font-size: 1rem;
  line-height: 1.3;
}

.composer-panel,
.history-strip {
  border: 1px solid var(--sidebar-line);
  background: rgba(255, 255, 255, 0.03);
  padding: 18px;
}

.composer-panel {
  display: grid;
  gap: 16px;
}

.section-heading,
.render-hero,
.dialog-header,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading.tight {
  align-items: flex-start;
}

.section-heading h3 {
  font-size: 1.48rem;
}

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

.field > span {
  font-size: 0.84rem;
  color: var(--sidebar-muted);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 14px 16px;
  color: var(--sidebar-text);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.18);
  outline: none;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.field textarea {
  resize: vertical;
  min-height: 124px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(223, 154, 105, 0.58);
  box-shadow: 0 0 0 4px rgba(223, 154, 105, 0.12);
  background: rgba(0, 0, 0, 0.26);
}

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

.prompt-presets {
  display: grid;
  gap: 10px;
}

.template-library {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.disclosure-card {
  overflow: hidden;
}

.disclosure-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
  cursor: pointer;
}

.disclosure-summary::-webkit-details-marker {
  display: none;
}

.disclosure-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--sidebar-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.disclosure-meta::after {
  content: "▾";
  font-size: 0.9em;
  transition: transform 180ms ease;
}

.disclosure-card[open] .disclosure-meta::after {
  transform: rotate(180deg);
}

.disclosure-body {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.template-copy {
  margin: 0;
  color: var(--sidebar-muted);
  line-height: 1.65;
  font-size: 0.92rem;
}

.template-category-list {
  display: flex;
  gap: 10px;
  overflow: auto;
  padding-bottom: 4px;
}

.template-category-chip {
  display: grid;
  gap: 4px;
  min-width: 132px;
  padding: 12px 14px;
  text-align: left;
  border-radius: 18px;
  color: var(--sidebar-text);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.template-category-chip strong {
  font-size: 0.92rem;
}

.template-category-chip span {
  color: var(--sidebar-muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

.template-category-chip.is-active {
  background: rgba(196, 111, 58, 0.16);
  border-color: rgba(223, 154, 105, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.template-list {
  display: grid;
  gap: 10px;
  max-height: 340px;
  overflow: auto;
  padding-right: 4px;
}

.template-card,
.template-empty {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.template-card-head {
  display: grid;
  gap: 6px;
}

.template-tag {
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.template-card p,
.template-empty span {
  margin: 0;
  color: var(--sidebar-muted);
  line-height: 1.6;
}

.template-meta {
  display: grid;
  gap: 10px;
}

.template-meta > div {
  display: grid;
  gap: 4px;
}

.template-meta span {
  color: var(--sidebar-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.template-meta strong {
  font-size: 0.88rem;
  line-height: 1.55;
  font-weight: 500;
}

.template-apply {
  justify-self: start;
}

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

.preset-chip {
  padding: 10px 12px;
  border-radius: 999px;
  color: var(--sidebar-text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.preset-chip:hover {
  background: rgba(196, 111, 58, 0.14);
  border-color: rgba(196, 111, 58, 0.28);
}

.config-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

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

.recipe-pill {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.recipe-pill span {
  display: block;
  color: var(--sidebar-muted);
  font-size: 0.76rem;
  margin-bottom: 4px;
}

.recipe-pill strong {
  display: block;
  line-height: 1.45;
  word-break: break-word;
}

.history-strip {
  grid-area: history;
  display: grid;
  grid-template-rows: auto;
  align-content: start;
  min-height: 280px;
  gap: 12px;
  padding: 18px;
  color: var(--sidebar-text);
  border: 1px solid var(--sidebar-line);
  background:
    linear-gradient(180deg, rgba(33, 31, 28, 0.96), rgba(24, 23, 21, 0.98)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 18%);
}

.history-heading {
  margin-bottom: 2px;
}

.history-toolbar {
  display: grid;
  gap: 10px;
}

.history-search {
  display: grid;
  gap: 6px;
}

.history-search span {
  color: var(--sidebar-muted);
  font-size: 0.76rem;
}

.history-search input {
  width: 100%;
  padding: 12px 14px;
  color: var(--sidebar-text);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.18);
  outline: none;
}

.history-filters,
.history-stats,
.history-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-filter-chip,
.history-stat-pill,
.history-action {
  padding: 9px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.history-filter-chip,
.history-action {
  color: var(--sidebar-text);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.history-filter-chip.is-active,
.history-item.is-favorite {
  border-color: rgba(223, 154, 105, 0.28);
  background: rgba(223, 154, 105, 0.08);
}

.history-stat-pill {
  color: var(--sidebar-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.history-stat-pill strong {
  color: var(--sidebar-text);
}

.history-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.history-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: 18px;
  color: var(--sidebar-text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
}

.history-main {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
  background: transparent;
  border: 0;
}

.history-item:hover,
.history-main:hover {
  border-color: rgba(223, 154, 105, 0.22);
  background: rgba(223, 154, 105, 0.08);
}

.history-action.danger {
  color: #ffb7ae;
}

.history-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.history-time,
.history-size {
  color: var(--sidebar-muted);
  font-size: 0.76rem;
}

.history-model {
  font-size: 0.92rem;
}

.history-prompt {
  color: var(--sidebar-muted);
  line-height: 1.55;
}

.render-stage {
  grid-area: render;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(255, 255, 255, 0.36)),
    rgba(255, 251, 245, 0.7);
  box-shadow: var(--panel-shadow);
  min-height: 0;
}

.render-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-text {
  color: var(--muted-strong);
  font-size: 0.95rem;
}

.result-meta-chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(31, 24, 15, 0.08);
  color: var(--muted-strong);
  font-size: 0.9rem;
}

.result-stage {
  position: relative;
  min-height: 560px;
  border-radius: 30px;
  overflow: hidden;
  border: 1px solid rgba(31, 24, 15, 0.08);
  background:
    radial-gradient(circle at top left, rgba(226, 196, 161, 0.44), transparent 23%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(246, 239, 230, 0.88));
}

.result-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(28, 27, 25, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 27, 25, 0.04) 1px, transparent 1px);
  background-size: 46px 46px;
  opacity: 0.25;
  pointer-events: none;
}

.result-stage.empty {
  display: grid;
  place-items: center;
}

.empty-state,
.error-state,
.loading-shell,
.results-layout {
  position: relative;
  z-index: 1;
}

.empty-state,
.error-state {
  max-width: 520px;
  padding: 36px;
  text-align: center;
}

.empty-art,
.error-art {
  width: 146px;
  height: 146px;
  margin: 0 auto 22px;
  border-radius: 34px;
  box-shadow: 0 24px 48px rgba(64, 40, 23, 0.14);
}

.empty-art {
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.9), transparent 18%),
    linear-gradient(145deg, rgba(238, 196, 149, 0.72), rgba(155, 169, 222, 0.3)),
    rgba(255, 255, 255, 0.38);
}

.error-art {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.92), transparent 18%),
    linear-gradient(145deg, rgba(225, 120, 112, 0.72), rgba(101, 54, 67, 0.28)),
    rgba(255, 255, 255, 0.38);
}

.empty-state p,
.error-state p {
  margin: 10px auto 0;
  color: var(--muted);
  line-height: 1.72;
  max-width: 42ch;
}

.loading-shell {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 34px;
}

.loading-shell > div {
  text-align: center;
}

.loading-orb {
  width: 144px;
  height: 144px;
  margin: 0 auto;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 32%, rgba(255, 255, 255, 0.92), transparent 18%),
    conic-gradient(from 0deg, rgba(196, 111, 58, 0.08), rgba(196, 111, 58, 0.82), rgba(161, 176, 220, 0.34), rgba(196, 111, 58, 0.08));
  box-shadow: 0 28px 54px rgba(196, 111, 58, 0.16);
  animation: pulse-spin 2.4s linear infinite;
}

.loading-copy {
  margin-top: 18px;
}

.loading-copy p {
  margin: 8px 0 0;
  color: var(--muted);
}

.results-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 360px);
  gap: 18px;
  min-height: 100%;
  padding: 18px;
}

.feature-card,
.gallery-card,
.insight-card {
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(31, 24, 15, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.feature-card {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  overflow: hidden;
}

.feature-image {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 480px;
  object-fit: cover;
  background: rgba(228, 216, 202, 0.4);
}

.feature-meta {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.feature-meta-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}

.feature-meta p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.feature-actions .ghost-button,
.feature-actions .secondary-button {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(31, 24, 15, 0.1);
}

.gallery-card {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  min-height: 0;
}

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

.thumb-button {
  display: block;
  width: 100%;
  padding: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.4);
  box-shadow: 0 12px 22px rgba(54, 36, 20, 0.08);
}

.thumb-button.is-active {
  border-color: rgba(196, 111, 58, 0.34);
  box-shadow: 0 18px 28px rgba(196, 111, 58, 0.16);
}

.thumb-button img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.gallery-copy {
  display: grid;
  gap: 10px;
  align-content: start;
}

.gallery-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.insight-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.insight-grid {
  display: grid;
  gap: 10px;
}

.insight-row {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(31, 24, 15, 0.07);
}

.insight-row span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-bottom: 5px;
}

.insight-row strong {
  display: block;
  line-height: 1.5;
  word-break: break-word;
}

.settings-dialog {
  width: min(600px, calc(100vw - 24px));
  padding: 0;
  border: 1px solid rgba(31, 24, 15, 0.12);
  border-radius: 30px;
  background: rgba(255, 251, 245, 0.96);
  color: var(--ink);
  box-shadow: var(--panel-shadow-strong);
}

.settings-dialog::backdrop {
  background: rgba(18, 13, 9, 0.26);
  backdrop-filter: blur(10px);
}

.settings-panel {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.settings-panel .field > span {
  color: var(--muted);
}

.settings-panel .field input {
  color: var(--ink);
  border-color: rgba(31, 24, 15, 0.1);
  background: rgba(255, 255, 255, 0.78);
}

.settings-panel .field input:focus {
  border-color: rgba(196, 111, 58, 0.44);
  background: rgba(255, 255, 255, 0.96);
}

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

@keyframes pulse-spin {
  0% {
    transform: rotate(0deg) scale(0.96);
  }
  50% {
    transform: rotate(180deg) scale(1);
  }
  100% {
    transform: rotate(360deg) scale(0.96);
  }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-areas:
      "control"
      "render"
      "history";
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .admin-workspace {
    grid-template-columns: 1fr;
  }

  .control-stage,
  .render-stage {
    min-height: auto;
  }

  .results-layout {
    grid-template-columns: 1fr;
  }

  .feature-image {
    min-height: 420px;
  }

  .history-strip {
    min-height: 0;
  }
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100vw - 18px, 100%);
    margin: 9px auto;
    padding: 10px;
    border-radius: 24px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 4px;
  }

  .mobile-quick-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  .topbar-meta {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .topbar-chip,
  .badge,
  .topbar-meta > .ghost-button {
    width: 100%;
  }

  .badge,
  .topbar-meta > .ghost-button {
    justify-content: center;
  }

  .hero-stats,
  .field-grid,
  .admin-field-grid,
  .admin-stats-grid,
  .recipe-summary,
  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .template-category-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .control-stage,
  .render-stage,
  .history-strip {
    padding: 14px;
    border-radius: 22px;
  }

  .feature-image {
    min-height: 300px;
  }

  .feature-meta-head,
  .render-hero,
  .section-heading,
  .dialog-header,
  .action-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .render-status,
  .feature-actions {
    justify-content: flex-start;
  }

  .composer-panel {
    order: 1;
  }

  .hero-card {
    order: 2;
  }

  .section-heading .link-button,
  .action-row > button,
  .template-apply {
    width: 100%;
    justify-content: center;
  }

  .disclosure-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .disclosure-meta {
    align-self: stretch;
    justify-content: center;
  }

  .result-stage {
    min-height: 420px;
    border-radius: 24px;
  }

  .results-layout {
    gap: 14px;
    padding: 14px;
  }

  .empty-state,
  .error-state,
  .loading-shell {
    padding: 24px;
  }

  .history-toolbar {
    gap: 12px;
  }

  .history-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-filter-chip {
    width: 100%;
    justify-content: center;
  }

  .mobile-action-bar {
    position: sticky;
    bottom: 0;
    z-index: 12;
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    gap: 10px;
    margin-top: 14px;
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(243, 239, 231, 0), rgba(243, 239, 231, 0.92) 24%, rgba(243, 239, 231, 0.98));
  }

  .mobile-action {
    min-height: 52px;
    justify-content: center;
  }

  .admin-table {
    min-width: 720px;
  }
}

@media (max-width: 640px) {
  .ambient-a,
  .ambient-b {
    opacity: 0.34;
    filter: blur(64px);
  }

  .page-shell {
    width: calc(100vw - 12px);
    margin: 6px auto;
    padding: 8px 8px 18px;
    border-radius: 18px;
  }

  .workspace {
    grid-template-areas:
      "render"
      "control"
      "history";
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .brand-lockup {
    gap: 12px;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  .brand-mark span {
    inset: 9px;
  }

  .brand-mark span:last-child {
    inset: 15px 7px 7px 15px;
  }

  .brand-lockup h1 {
    font-size: 1.75rem;
    line-height: 0.95;
  }

  .endpoint-chip {
    display: none;
  }

  .topbar-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .quota-chip {
    grid-column: 1 / -1;
  }

  .topbar-chip {
    min-height: 0;
    padding: 10px 12px;
  }

  .topbar-chip strong {
    max-width: none;
  }

  .badge,
  .topbar-action {
    min-height: 46px;
    padding-inline: 12px;
    font-size: 0.92rem;
  }

  .trial-gate {
    align-items: end;
    padding: 10px;
  }

  .trial-gate-card {
    width: 100%;
    max-height: min(92svh, 760px);
    padding: 22px 16px 18px;
    border-radius: 24px 24px 18px 18px;
  }

  .trial-gate-card h2 {
    margin: 4px 0 6px;
    font-size: 2rem;
    line-height: 0.98;
  }

  .trial-gate-copy {
    margin-bottom: 14px;
    font-size: 0.94rem;
    line-height: 1.62;
  }

  .trial-policy {
    margin-bottom: 14px;
  }

  .trial-gate-form .field input {
    padding: 16px 14px;
    border-radius: 16px;
    font-size: 1rem;
    text-align: center;
    letter-spacing: 0.12em;
  }

  .trial-gate-form .action-row,
  .trial-gate-form .primary-button {
    width: 100%;
  }

  .control-stage,
  .render-stage,
  .history-strip,
  .hero-card,
  .composer-panel,
  .settings-panel {
    border-radius: 18px;
  }

  .control-stage,
  .render-stage,
  .history-strip,
  .composer-panel {
    padding: 12px;
  }

  .control-stage {
    gap: 12px;
  }

  .render-stage {
    order: 1;
  }

  .hero-card {
    padding: 16px;
  }

  .hero-copy h2,
  .render-copy h2 {
    font-size: 1.95rem;
    line-height: 0.98;
  }

  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .intro-copy {
    display: none;
  }

  .render-hero {
    align-items: stretch;
    gap: 10px;
  }

  .render-copy h2 {
    font-size: 1.68rem;
  }

  .render-status {
    width: 100%;
  }

  .status-text,
  .result-meta-chip {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .intro-copy,
  .template-copy,
  .gallery-copy p,
  .empty-state p,
  .error-state p {
    font-size: 0.93rem;
    line-height: 1.6;
  }

  .stat-tile {
    min-height: auto;
    padding: 12px;
  }

  .stat-tile strong {
    font-size: 0.94rem;
  }

  .field textarea {
    min-height: 112px;
  }

  .template-library,
  .config-card,
  .gallery-card,
  .feature-meta,
  .insight-card {
    padding: 12px;
  }

  .prompt-presets {
    gap: 8px;
  }

  .preset-list {
    flex-wrap: nowrap;
    overflow: auto;
    padding-bottom: 4px;
    margin-inline: -2px;
  }

  .preset-chip {
    white-space: nowrap;
  }

  .disclosure-body {
    gap: 10px;
    margin-top: 10px;
  }

  .template-category-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .template-list,
  .history-list {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .history-item,
  .template-card,
  .template-empty {
    padding: 12px;
    border-radius: 16px;
  }

  .history-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-stats .stat-tile:nth-child(n + 3) {
    display: none;
  }

  .render-stage {
    gap: 14px;
  }

  .result-stage {
    min-height: 340px;
  }

  .results-layout {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  .gallery-card {
    order: 2;
  }

  .feature-card {
    order: 1;
  }

  .feature-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .feature-actions > * {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .feature-image {
    min-height: 220px;
  }

  .empty-art,
  .error-art,
  .loading-orb {
    width: 110px;
    height: 110px;
  }

  .feature-meta-head,
  .gallery-card,
  .feature-actions {
    gap: 10px;
  }

  .settings-dialog {
    width: calc(100vw - 12px);
    border-radius: 22px;
  }

  .settings-panel {
    padding: 16px;
  }

  .mobile-quick-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-nav-button {
    min-height: 44px;
    font-size: 0.92rem;
  }

  .mobile-action-bar {
    grid-template-columns: 1fr 1.25fr;
    gap: 8px;
    margin-top: 12px;
  }
}

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