:root {
  --bg-parchment: #FAF7F2;
  --bg-card: #FFFDF9;
  --bg-inset: #F3EDE2;
  --bg-code: #231D19;
  --border-stone: #E4DDD3;
  --border-dashed: #C9BEB0;
  --ink-espresso: #1F1A17;
  --ink-muted: #6B5E54;
  --ink-subtle: #8C7D70;
  --accent-terracotta: #B45309;
  --accent-terracotta-hover: #92400E;
  --accent-terracotta-soft: #FEF3C7;
  --sage-pass: #2D6A4F;
  --sage-bg: #EAF4EE;
  --sage-border: #B7DEC8;
  --warn-ink: #9A5B13;
  --warn-bg: #FDF3E3;
  --warn-border: #F2D29B;
  --danger-ink: #991B1B;
  --danger-bg: #FEE2E2;
  --shadow-card: 0 1px 2px rgba(31, 26, 23, 0.04), 0 8px 24px rgba(31, 26, 23, 0.05);
  --shadow-book: 0 16px 32px -8px rgba(31, 26, 23, 0.28), 0 4px 10px -2px rgba(31, 26, 23, 0.14);
  --font-serif: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 7px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--bg-parchment);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(180, 83, 9, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 88% 12%, rgba(45, 106, 79, 0.04) 0%, transparent 45%);
  color: var(--ink-espresso);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  overflow-x: hidden;
}

a {
  color: var(--accent-terracotta);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.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;
}

/* Header */
.studio-header {
  border-bottom: 1px solid var(--border-stone);
  background: rgba(255, 253, 249, 0.88);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: linear-gradient(145deg, #2D231E 0%, #1F1A17 100%);
  color: #FAF7F2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(31, 26, 23, 0.18);
  border: 1px solid rgba(180, 83, 9, 0.4);
}

.brand-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-terracotta);
  line-height: 1.2;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink-espresso);
  line-height: 1.25;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--sage-bg);
  border: 1px solid var(--sage-border);
  color: var(--sage-pass);
  font-size: 12px;
  font-weight: 600;
}

/* Main Container */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 20px 56px;
}

/* Editorial Hero */
.hero-banner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.hero-copy {
  max-width: 780px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.hero-eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-terracotta);
}

h1 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: clamp(1.65rem, 2.7vw, 2.35rem);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.015em;
  color: var(--ink-espresso);
}

.hero-subtitle {
  margin: 0;
  color: var(--ink-muted);
  font-size: 15.5px;
  line-height: 1.55;
}

.hero-quick-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-stone);
  background: var(--bg-card);
  color: var(--ink-espresso);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--bg-inset);
  border-color: #CFC5B7;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-terracotta);
  border-color: var(--accent-terracotta);
  color: #FFFDF9;
  box-shadow: 0 2px 6px rgba(180, 83, 9, 0.24);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-terracotta-hover);
  border-color: var(--accent-terracotta-hover);
}

.btn-sage {
  background: var(--sage-pass);
  border-color: var(--sage-pass);
  color: #FFFDF9;
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.24);
}

.btn-sage:hover:not(:disabled) {
  background: #23533D;
  border-color: #23533D;
}

.btn-pro {
  background: #241D19;
  border-color: #241D19;
  color: #FDE68A;
}

.btn-pro:hover:not(:disabled) {
  background: #352B25;
  border-color: #352B25;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 15px;
  width: 100%;
}

/* Workbench Grid */
.workbench-grid {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.workbench-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-stone);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px;
  min-width: 0;
}

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

.step-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-family: var(--font-serif);
  font-size: 16.5px;
  font-weight: 700;
  color: var(--ink-espresso);
}

.step-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-inset);
  border: 1px solid var(--border-stone);
  color: var(--accent-terracotta);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border-stone);
  background: var(--bg-inset);
  color: var(--ink-muted);
}

.badge-pass {
  background: var(--sage-bg);
  border-color: var(--sage-border);
  color: var(--sage-pass);
}

.badge-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-ink);
}

.badge-danger {
  background: var(--danger-bg);
  border-color: #FCA5A5;
  color: var(--danger-ink);
}

/* Dropzone */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--border-dashed);
  border-radius: var(--radius-md);
  background: var(--bg-parchment);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent-terracotta);
  background: #FDF6EC;
}

.dropzone-icon {
  color: var(--accent-terracotta);
  margin-bottom: 6px;
}

.dropzone-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-espresso);
  margin-bottom: 3px;
}

.dropzone-sub {
  font-size: 12.5px;
  color: var(--ink-muted);
}

.dropzone-actions {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.loaded-file-bar {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border-stone);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
}

.loaded-file-meta {
  min-width: 0;
}

.loaded-file-name {
  font-weight: 700;
  color: var(--ink-espresso);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loaded-file-sub {
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

/* Tabs */
.segmented-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-inset);
  border: 1px solid var(--border-stone);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 12px;
}

.segmented-tab {
  border: 0;
  background: transparent;
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.segmented-tab.is-active {
  background: var(--bg-card);
  color: var(--ink-espresso);
  box-shadow: 0 1px 3px rgba(31, 26, 23, 0.08);
}

/* Form Controls */
.field-group {
  margin-bottom: 12px;
}

.field-group:last-child {
  margin-bottom: 0;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-espresso);
  margin-bottom: 5px;
}

.field-hint {
  font-weight: 400;
  font-size: 11.5px;
  color: var(--ink-subtle);
}

.text-input,
.select-input {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-stone);
  background: var(--bg-card);
  color: var(--ink-espresso);
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus,
.select-input:focus {
  outline: none;
  border-color: var(--accent-terracotta);
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.12);
}

.two-col-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Preset Pills */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preset-btn {
  text-align: left;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-stone);
  background: var(--bg-parchment);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.preset-btn:hover {
  border-color: #C9BEB0;
}

.preset-btn.is-active {
  border-color: var(--accent-terracotta);
  background: #FEF7EC;
  box-shadow: inset 0 0 0 1px var(--accent-terracotta);
}

.preset-name {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-espresso);
}

.preset-dims {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* Palette Swatches */
.palette-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.palette-swatch {
  padding: 7px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-stone);
  background: var(--bg-parchment);
  cursor: pointer;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
}

.palette-swatch.is-active {
  border-color: var(--accent-terracotta);
  box-shadow: inset 0 0 0 1px var(--accent-terracotta);
}

.swatch-chip {
  display: block;
  width: 100%;
  height: 16px;
  border-radius: 4px;
  margin-bottom: 4px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

/* Checkboxes */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-espresso);
  cursor: pointer;
  margin-top: 8px;
}

.check-row input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--accent-terracotta);
  flex-shrink: 0;
}

/* Right Pane: Before vs After Cover Stage */
.stage-card {
  padding: 20px;
}

.stage-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.stage-column {
  background: var(--bg-parchment);
  border: 1px solid var(--border-stone);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.stage-col-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
}

.stage-col-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.book-mockup-wrap {
  width: 100%;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px 12px;
}

.book-frame {
  position: relative;
  max-width: 220px;
  width: 100%;
  border-radius: 3px 7px 7px 3px;
  overflow: hidden;
  box-shadow: var(--shadow-book);
  background: #E8E0D4;
  border: 1px solid rgba(31, 26, 23, 0.14);
}

/* Realistic bookbinding spine crease */
.book-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.18) 0%,
    rgba(0, 0, 0, 0.22) 2.5%,
    rgba(255, 255, 255, 0.18) 5%,
    rgba(0, 0, 0, 0.05) 7.5%,
    transparent 12%,
    transparent 98%,
    rgba(255, 255, 255, 0.25) 100%
  );
}

.book-frame img,
.book-frame canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 330px;
  object-fit: contain;
}

.book-empty-placeholder {
  width: 190px;
  height: 285px;
  border-radius: 3px 7px 7px 3px;
  border: 1.5px dashed var(--border-dashed);
  background: rgba(255, 253, 249, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  color: var(--ink-subtle);
  font-size: 12.5px;
  gap: 8px;
}

.stage-specs {
  width: 100%;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-stone);
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-muted);
  gap: 8px;
  flex-wrap: wrap;
}

.export-bar {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-stone);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.export-status-note {
  font-size: 13px;
  color: var(--ink-muted);
  flex: 1 1 240px;
}

.export-btn-wrap {
  flex: 0 1 280px;
  min-width: 220px;
}

/* Compliance & Diagnostics */
.diag-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.diag-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-stone);
  background: var(--bg-parchment);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.diag-item-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-espresso);
}

.diag-item-detail {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
  word-break: break-word;
}

.xml-inspector {
  margin-top: 14px;
  border: 1px solid var(--border-stone);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.xml-inspector summary {
  padding: 9px 12px;
  background: var(--bg-inset);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-espresso);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.xml-code {
  margin: 0;
  padding: 12px;
  background: var(--bg-code);
  color: #F5EBE0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  overflow-x: auto;
  max-height: 260px;
}

/* Status Toast / Alert */
.status-banner {
  margin-top: 12px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid transparent;
  display: none;
}

.status-banner.is-visible {
  display: block;
}

.status-banner.is-success {
  background: var(--sage-bg);
  border-color: var(--sage-border);
  color: var(--sage-pass);
}

.status-banner.is-error {
  background: var(--danger-bg);
  border-color: #FCA5A5;
  color: var(--danger-ink);
}

.status-banner.is-info {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-ink);
}

/* Editorial Content & FAQ */
.editorial-section {
  margin-top: 32px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 22px;
}

.editorial-card h2 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 19px;
  color: var(--ink-espresso);
}

.editorial-card p {
  margin: 0 0 12px;
  color: var(--ink-muted);
  font-size: 14px;
}

.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.spec-table th,
.spec-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-stone);
}

.spec-table th {
  font-weight: 700;
  color: var(--ink-espresso);
  background: var(--bg-parchment);
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-item {
  border: 1px solid var(--border-stone);
  border-radius: var(--radius-sm);
  background: var(--bg-parchment);
  padding: 10px 13px;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink-espresso);
}

.faq-item p {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 26, 23, 0.55);
  backdrop-filter: blur(3px);
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-panel {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border-stone);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px rgba(31, 26, 23, 0.25);
  padding: 22px;
}

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

.modal-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 20px;
}

.modal-close {
  border: 1px solid var(--border-stone);
  background: var(--bg-parchment);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 16px;
}

.modal-list {
  margin: 10px 0 16px;
  padding-left: 18px;
  font-size: 13.5px;
  color: var(--ink-muted);
}

.modal-list li {
  margin-bottom: 6px;
}

/* Footer */
.studio-footer {
  margin-top: 38px;
  padding-top: 18px;
  border-top: 1px solid var(--border-stone);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-subtle);
}

/* Responsive */
@media (max-width: 980px) {
  .workbench-grid {
    grid-template-columns: 1fr;
  }

  .editorial-section {
    grid-template-columns: 1fr;
  }
}

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

  .header-inner {
    padding: 10px 12px;
  }

  .card {
    padding: 14px;
  }

  .stage-comparison {
    grid-template-columns: 1fr;
  }

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

  .two-col-fields,
  .preset-grid {
    grid-template-columns: 1fr;
  }

  .palette-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .export-btn-wrap {
    width: 100%;
    flex-basis: 100%;
  }
}
