:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #5d6972;
  --panel: #ffffff;
  --surface: #f4f1eb;
  --line: #d7d0c5;
  --accent: #0b6b61;
  --accent-strong: #09554d;
  --warn: #b45309;
  --danger: #b42318;
  --paper: #fffdf8;
  --shadow: 0 20px 45px rgba(23, 32, 38, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(11, 107, 97, 0.08), transparent 32%),
    linear-gradient(315deg, rgba(180, 83, 9, 0.08), transparent 28%),
    var(--surface);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  min-height: 100vh;
}

.control-panel {
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid var(--line);
  padding: 24px;
  overflow-y: auto;
}

.brand-block {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.55rem, 1.8vw, 2rem);
  line-height: 1.15;
}

.settings-form {
  display: grid;
  gap: 18px;
}

.control-section {
  display: grid;
  gap: 12px;
}

.section-heading {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2 {
  font-size: 0.94rem;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.8rem;
}

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

label {
  color: var(--muted);
  display: grid;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 650;
}

input,
select {
  width: 100%;
  border: 1px solid #c9c1b7;
  border-radius: var(--radius);
  background: #fffdfa;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 10px;
  outline: 0;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 107, 97, 0.16);
}

.check-row {
  align-items: center;
  color: var(--ink);
  display: flex;
  gap: 9px;
  margin-top: 2px;
}

.check-row input {
  accent-color: var(--accent);
  min-height: auto;
  width: 18px;
  height: 18px;
}

.custom-paper[hidden] {
  display: none;
}

.action-row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-top: 4px;
}

.primary-button,
.secondary-button {
  align-items: center;
  border-radius: var(--radius);
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  min-height: 46px;
  padding: 10px 14px;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: white;
  font-weight: 750;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: #fffdfa;
  border: 1px solid #c9c1b7;
  color: var(--ink);
  font-weight: 700;
}

.secondary-button:hover {
  border-color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
}

.workspace-bar {
  align-items: center;
  background: rgba(244, 241, 235, 0.9);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px;
}

.workspace-bar h2 {
  font-size: 1.15rem;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pill {
  border: 1px solid transparent;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 750;
}

.pill.ok {
  background: rgba(11, 107, 97, 0.11);
  color: #075248;
}

.pill.warn {
  background: rgba(180, 83, 9, 0.12);
  color: var(--warn);
}

.pill.error {
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

.preview-wrap {
  overflow: auto;
  padding: 28px;
}

.print-area {
  display: grid;
  gap: 28px;
  justify-content: start;
}

.print-page {
  background: var(--paper);
  box-shadow: var(--shadow);
  color: #111;
  overflow: hidden;
  position: relative;
}

.print-page svg {
  display: block;
  height: 100%;
  width: 100%;
}

.cut-line {
  fill: rgba(230, 244, 241, 0.55);
  stroke: #111;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 0.28;
}

.fold-line {
  fill: none;
  stroke: #0b6b61;
  stroke-dasharray: 3 1.8;
  stroke-linecap: round;
  stroke-width: 0.22;
}

.assist-line {
  fill: none;
  stroke: #b45309;
  stroke-dasharray: 1.4 1.8;
  stroke-linecap: round;
  stroke-width: 0.18;
}

.trim-line {
  fill: none;
  stroke: #999;
  stroke-dasharray: 1 1.6;
  stroke-width: 0.16;
}

.dimension-line {
  fill: none;
  stroke: #4c5560;
  stroke-linecap: round;
  stroke-width: 0.16;
}

.svg-label {
  fill: #172026;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.muted-label {
  fill: #5d6972;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pills {
    justify-content: flex-start;
  }

  .preview-wrap {
    padding: 18px;
  }
}

@media (max-width: 460px) {
  .field-grid,
  .paper-grid,
  .action-row {
    grid-template-columns: 1fr;
  }

  .control-panel {
    padding: 18px;
  }
}

@media print {
  html,
  body {
    background: white;
    min-height: 0;
  }

  .app-shell,
  .workspace,
  .preview-wrap,
  .print-area {
    display: block;
    padding: 0;
    margin: 0;
    overflow: visible;
  }

  .control-panel,
  .workspace-bar {
    display: none;
  }

  .print-page {
    box-shadow: none;
    break-after: page;
    page-break-after: always;
    margin: 0;
  }

  .print-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}
