:root {
  color-scheme: light;
  --bg: #f4efe5;
  --bg-alt: #e8dfcf;
  --paper: rgba(255, 250, 242, 0.78);
  --text: #1e252b;
  --muted: #5a6772;
  --line: rgba(30, 37, 43, 0.12);
  --accent: #b64926;
  --accent-deep: #8f3519;
  --accent-soft: rgba(182, 73, 38, 0.1);
  --success: #1f7a52;
  --danger: #d90429;
  --danger-strong: #a4001d;
  --danger-soft: rgba(217, 4, 41, 0.12);
  --shadow: 0 20px 70px rgba(30, 37, 43, 0.08);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

[x-cloak] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(182, 73, 38, 0.16), transparent 25%),
    linear-gradient(140deg, var(--bg-alt), var(--bg) 40%, #efe6d9 100%);
}

body:has(.reading-gate[x-cloak="false"]),
body:has(.reading-gate[style*="display: block"]),
body:has(.busy-gate[x-cloak="false"]),
body:has(.busy-gate[style*="display: block"]) {
  overflow: hidden;
}

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

textarea {
  resize: vertical;
}

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
}

.hero-copy,
.hero-panel,
.panel,
.tabs,
.artifact-card,
.history-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 24px 26px;
}

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

h1,
h2,
h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
}

h1 {
  font-size: clamp(2.2rem, 5.2vw, 3.6rem);
  line-height: 1;
}

.lead,
.muted,
.prose p,
.prose li {
  color: var(--muted);
}

.lead {
  max-width: 48rem;
  margin-top: 10px;
  font-size: 0.98rem;
  line-height: 1.55;
}

.hero-actions,
.inline-actions,
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

a {
  text-decoration: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.solid {
  background: var(--accent);
  color: #fff;
}

.solid:hover {
  background: var(--accent-deep);
}

.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.ghost:hover {
  background: var(--accent-soft);
}

.linklike {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 12px 18px;
}

.linkline {
  color: var(--accent-deep);
  margin-right: 8px;
}

.shop-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  line-height: 1.75;
}

.shop-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid rgba(217, 4, 41, 0.36);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(217, 4, 41, 0.14), rgba(182, 73, 38, 0.18));
  color: var(--danger-strong);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  box-shadow: 0 10px 26px rgba(164, 0, 29, 0.12);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.shop-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(164, 0, 29, 0.18);
  background: linear-gradient(135deg, rgba(217, 4, 41, 0.2), rgba(182, 73, 38, 0.24));
}

.stat-card,
.panel.inset {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
}

.stat-card strong,
.section-head p {
  display: block;
  margin-bottom: 6px;
}

.tabs {
  margin: 14px 0;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tabs button {
  background: transparent;
  color: var(--muted);
}

.tabs button.active {
  background: var(--accent);
  color: #fff;
}

.page-grid {
  display: grid;
  gap: 20px;
}

.panel {
  padding: 28px;
}

.section-head {
  margin-bottom: 20px;
}

.section-head p {
  margin-top: 8px;
}

.prose ul {
  margin: 12px 0 0;
  padding-left: 18px;
}

.prose h3 {
  margin-top: 24px;
  margin-bottom: 12px;
}

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

.stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.step-chip {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.48);
  color: var(--muted);
}

.step-chip span {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(30, 37, 43, 0.08);
  color: var(--text);
  font-weight: 700;
}

.step-chip.active,
.step-chip.done {
  border-color: rgba(182, 73, 38, 0.28);
}

.step-chip.active {
  background: rgba(182, 73, 38, 0.12);
  color: var(--text);
}

.step-chip.active span,
.step-chip.done span {
  background: var(--accent);
  color: #fff;
}

.status-line {
  margin: 0 0 18px;
}

.wizard-card {
  margin-top: 18px;
  padding: 22px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.42);
}

.wizard-card.locked {
  opacity: 0.64;
}

.wizard-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.section-kicker {
  margin: 0 0 6px;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

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

.wide {
  width: 100%;
}

.summary-card {
  margin-top: 16px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.callout {
  margin: 14px 0;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(182, 73, 38, 0.22);
  background: rgba(182, 73, 38, 0.08);
}

.callout strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-deep);
}

.callout p {
  margin: 0;
  color: var(--muted);
}

.danger-text,
.danger-text strong {
  color: var(--danger);
}

.danger-callout {
  border-color: rgba(217, 4, 41, 0.36);
  background: var(--danger-soft);
}

.danger-callout strong {
  color: var(--danger);
}

.summary-title {
  margin: 0 0 10px;
}

.compact-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.compact-list li + li {
  margin-top: 8px;
}

.top-gap {
  margin-top: 14px;
}

.quote-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.table-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.code-area {
  overflow: hidden;
  transition: max-height 180ms ease, opacity 180ms ease;
  max-height: 240px;
}

.code-area.collapsed {
  max-height: 92px;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 136px;
  padding: 18px;
  border: 1px dashed var(--accent);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.38);
  text-align: center;
  color: var(--accent-deep);
  cursor: pointer;
}

.dropzone input {
  display: none;
}

.section-block {
  margin-top: 18px;
}

.showcase-card,
.showcase-result {
  display: grid;
  gap: 16px;
}

.showcase-warning-stack {
  display: grid;
  gap: 12px;
}

.showcase-warning {
  border-width: 2px;
  box-shadow: 0 16px 40px rgba(164, 0, 29, 0.12);
}

.showcase-warning p {
  color: var(--danger-strong);
  font-weight: 700;
  line-height: 1.75;
}

.showcase-warning .compact-list,
.danger-callout .compact-list {
  color: var(--danger-strong);
}

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

.stacked input,
.stacked select,
.stacked textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
}

.inline-compact {
  display: inline-grid;
  gap: 6px;
}

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

.admin-layout-grid {
  grid-template-columns: 1fr;
  align-items: start;
}

.admin-form-fields,
.showcase-quote-grid {
  display: grid;
  gap: 14px;
}

.admin-form-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-form-wide {
  grid-column: 1 / -1;
}

.admin-form-card {
  margin-top: 0;
}

.admin-code-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(44px, 1fr));
  gap: 8px;
  min-width: 220px;
}

.admin-job-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(40px, 1fr));
  gap: 8px;
  min-width: 180px;
}

.compact-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}

.compact-actions .icon-button,
.compact-actions a {
  flex: 0 0 auto;
}

.admin-code-actions button {
  width: 100%;
  padding: 10px 8px;
}

.admin-job-actions .icon-button,
.admin-job-actions a {
  width: 100%;
  padding: 10px 8px;
}

.icon-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.token-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  overflow: hidden;
}

.token-button {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--text);
  cursor: pointer;
}

.token-button:hover {
  background: var(--accent-soft);
}

.token-button code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 17, 14, 0.56);
  backdrop-filter: blur(8px);
}

.admin-modal {
  width: min(760px, 100%);
  max-height: min(88vh, 980px);
  overflow: auto;
  padding: 24px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.98);
  box-shadow: 0 24px 80px rgba(30, 37, 43, 0.22);
}

.admin-modal-wide {
  width: min(980px, 100%);
}

.admin-job-modal {
  width: min(1180px, 100%);
}

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

.table-card {
  margin-top: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  font-size: 0.92rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.artifact-list,
.history-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.site-footer {
  margin-top: 24px;
  padding: 18px 8px 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.94rem;
}

.site-footer p {
  margin: 0;
}

.footer-shop-line {
  justify-content: center;
  margin-top: 12px;
}

.artifact-card,
.history-card {
  padding: 18px;
}

.artifact-head,
.history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.history-item {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.preview {
  overflow: auto;
  margin: 14px 0 0;
  padding: 16px;
  border-radius: 18px;
  background: #181d22;
  color: #edf2f7;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.6;
}

.masked-preview {
  white-space: pre-wrap;
  word-break: break-word;
}

.reading-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 17, 14, 0.72);
  backdrop-filter: blur(10px);
}

.busy-gate {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 17, 14, 0.58);
  backdrop-filter: blur(10px);
}

.busy-dialog {
  width: min(420px, 100%);
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 28px 24px;
  border-radius: 28px;
  border: 1px solid rgba(182, 73, 38, 0.26);
  background: rgba(255, 250, 242, 0.98);
  box-shadow: 0 28px 90px rgba(20, 17, 14, 0.28);
  text-align: center;
}

.busy-dialog h2 {
  color: var(--accent-deep);
}

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

.busy-spinner {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  border: 4px solid rgba(182, 73, 38, 0.14);
  border-top-color: var(--accent);
  border-right-color: var(--accent-deep);
  animation: busy-spin 0.9s linear infinite;
}

@keyframes busy-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.reading-dialog {
  width: min(760px, 100%);
  padding: 28px;
  border-radius: 28px;
  border: 1px solid rgba(217, 4, 41, 0.42);
  background: rgba(255, 255, 255, 0.985);
  box-shadow: 0 28px 90px rgba(20, 17, 14, 0.32);
}

.reading-dialog h2 {
  color: var(--danger-strong);
}

.reading-dialog .danger-callout p {
  margin: 0 0 10px;
  color: var(--danger-strong);
  font-size: 1.02rem;
  font-weight: 700;
  opacity: 0.16;
  text-shadow: 0 0 0 rgba(0, 0, 0, 0);
  transition: opacity 700ms ease;
}

.reading-dialog .danger-callout p.visible {
  opacity: 1;
}

code {
  font-family: Consolas, "Courier New", monospace;
}

.highlight-unanswered {
  background: #fff0f0;
}

.highlight-unanswered td:first-child {
  border-left: 3px solid #dc3545;
}

.message-admin {
  border-left: 3px solid var(--color-primary, #0d6efd);
}

.message-user {
  border-left: 3px solid var(--color-muted, #6c757d);
}

.success-text {
  color: var(--color-success, #198754);
  font-weight: 600;
}

@media (max-width: 980px) {
  .hero,
  .stepper,
  .upload-grid,
  .result-grid,
  .choice-row,
  .wait-grid {
    grid-template-columns: 1fr;
  }

  .admin-form-fields,
  .showcase-quote-grid,
  .admin-code-actions {
    grid-template-columns: 1fr;
  }

  .shell {
    width: min(100vw - 20px, 1280px);
  }

  .hero-copy,
  .panel {
    padding: 18px;
  }
}
