:root {
  --ui-bg: #f3f0eb;
  --ui-panel: #fffaf2;
  --ui-border: #d8cec0;
  --ui-text: #2d2b28;
  --ui-muted: #6f6a62;
  --accent: #18aaa6;
  --accent-dark: #0b807c;
  --paper: #f6f2ec;
  --ink: #352d27;
  --brown: #765237;
  --page-scale: 0.72;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

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

.editor-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px;
  border-right: 1px solid var(--ui-border);
  background: var(--ui-panel);
}

.brand-strip,
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-strip {
  margin-bottom: 22px;
}

.brand-strip h1,
.preview-toolbar h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.form-root {
  display: grid;
  gap: 12px;
}

.form-section {
  margin: 0 0 12px;
  padding: 14px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: #fffdf8;
}

.form-section h2 {
  margin: 0 0 14px;
  color: #4b4038;
  font-size: 15px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ui-text);
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 500;
}

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

.field input[type="color"] {
  height: 42px;
  padding: 5px;
}

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

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

.array-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #e9dfd1;
  border-radius: 8px;
  background: #fff9ef;
}

.array-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 800;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.command-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--ui-border);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ui-text);
  padding: 0 12px;
  font-weight: 800;
  cursor: pointer;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.command-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.command-button.danger {
  color: #9a382a;
}

.file-command {
  position: relative;
  overflow: hidden;
}

.file-command input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.preview-workspace {
  min-width: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px 28px 40px;
}

.preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -22px -28px 14px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--ui-border);
  background: rgba(243, 240, 235, 0.95);
  backdrop-filter: blur(12px);
}

.page-tabs {
  position: sticky;
  top: 77px;
  z-index: 4;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 0 14px;
}

.page-tabs button {
  flex: 0 0 auto;
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

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

.preview-root {
  display: grid;
  justify-content: center;
  gap: 28px;
  padding-bottom: 40px;
}

.sheet {
  position: relative;
  width: 210mm;
  height: 297mm;
  overflow: hidden;
  transform: scale(var(--page-scale));
  transform-origin: top center;
  margin-bottom: calc((297mm * var(--page-scale)) - 297mm);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 28px 70px rgba(42, 34, 25, 0.22);
  --theme-primary: #18aaa6;
  --theme-secondary: #765237;
  --theme-paper: #f6f2ec;
  --theme-ink: #342b25;
}

.sheet-inner {
  position: absolute;
  inset: 18mm;
}

.cover .sheet-inner {
  inset: 0;
}

.template-logo {
  position: absolute;
  left: 10mm;
  top: 10mm;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--theme-ink);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.logo-text small {
  display: block;
  color: var(--theme-primary);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0;
}

.cover-duration {
  position: absolute;
  right: 25mm;
  top: 26mm;
  color: var(--theme-primary);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  font-weight: 800;
}

.cover-title {
  position: absolute;
  left: 22mm;
  right: 22mm;
  top: 48mm;
  height: 18mm;
  color: var(--theme-secondary);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.08;
  text-align: center;
}

.cover-subtitle {
  position: absolute;
  left: 45mm;
  right: 45mm;
  top: 76mm;
  height: 20mm;
  color: var(--theme-primary);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.22;
  text-align: center;
}

.cover-photo {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18mm;
  height: 188mm;
}

.cover-footer,
.page-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18mm;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10mm;
  background: var(--theme-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.cover-footer span,
.page-footer span {
  min-width: 0;
}

.cover-footer span:nth-child(2),
.page-footer span:nth-child(2) {
  flex: 1;
  padding: 0 8mm;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-footer {
  height: 14mm;
  font-size: 10px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12mm;
}

.page-kicker {
  margin: 0 0 4px;
  color: var(--theme-primary);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.page-title {
  margin: 0;
  color: var(--theme-secondary);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  line-height: 1.05;
}

.page-number {
  color: var(--theme-primary);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 900;
}

.image-frame {
  overflow: hidden;
  background: #d8d0c4;
}

.image-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: 64mm 1fr;
  gap: 10mm;
}

.summary-photo {
  height: 205mm;
}

.booking-photo {
  height: 112mm;
  margin-top: 12mm;
}

.overview-box {
  height: 35mm;
  color: #50443d;
  font-size: 13px;
  line-height: 1.45;
}

.itinerary-list {
  display: grid;
  gap: 4mm;
  margin-top: 8mm;
}

.itinerary-row {
  display: grid;
  grid-template-columns: 18mm 1fr;
  gap: 5mm;
  min-height: 21mm;
  border-top: 1px solid rgba(118, 82, 55, 0.26);
  padding-top: 4mm;
}

.day-chip {
  color: var(--theme-primary);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 900;
}

.itinerary-row h3,
.day-block h3 {
  margin: 0 0 2mm;
  color: var(--theme-secondary);
  font-size: 15px;
  line-height: 1.15;
}

.itinerary-row p,
.day-block p {
  margin: 0;
  color: #544942;
  font-size: 11px;
  line-height: 1.4;
}

.route-page .sheet-inner {
  display: grid;
  grid-template-rows: auto 1fr;
}

.route-canvas {
  position: relative;
  min-height: 208mm;
  overflow: hidden;
}

.route-photo {
  position: absolute;
  inset: 0;
  opacity: 0.26;
}

.route-line {
  position: absolute;
  left: 30mm;
  top: 20mm;
  bottom: 20mm;
  width: 3px;
  border-radius: 99px;
  background: var(--theme-primary);
}

.route-stop {
  position: absolute;
  left: 22mm;
  display: grid;
  grid-template-columns: 18mm 1fr;
  gap: 7mm;
  align-items: center;
  width: 128mm;
}

.route-dot {
  width: 19mm;
  height: 19mm;
  border: 3px solid var(--theme-primary);
  border-radius: 50%;
  background: var(--theme-paper);
  color: var(--theme-secondary);
  display: grid;
  place-items: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 900;
}

.route-label {
  height: 18mm;
  display: flex;
  align-items: center;
  padding: 0 6mm;
  background: rgba(246, 242, 236, 0.88);
  color: var(--theme-secondary);
  font-size: 18px;
  font-weight: 900;
}

.day-grid {
  display: grid;
  gap: 9mm;
}

.day-block {
  display: grid;
  grid-template-columns: 62mm 1fr;
  gap: 8mm;
  min-height: 92mm;
}

.day-photo {
  height: 92mm;
}

.day-meta {
  display: flex;
  gap: 4mm;
  flex-wrap: wrap;
  margin: 3mm 0 4mm;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 8mm;
  padding: 0 4mm;
  border: 1px solid rgba(24, 170, 166, 0.35);
  color: var(--theme-primary);
  font-size: 10px;
  font-weight: 900;
}

.day-copy {
  height: 42mm;
  overflow: hidden;
}

.booking-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9mm;
}

.locked-panel {
  border-top: 2px solid var(--theme-primary);
  padding-top: 5mm;
}

.locked-panel h3 {
  margin: 0 0 5mm;
  color: var(--theme-secondary);
  font-size: 15px;
}

.price-table,
.payment-table {
  width: 100%;
  border-collapse: collapse;
  color: #4d423b;
  font-size: 11px;
}

.price-table td,
.payment-table td {
  border-bottom: 1px solid rgba(118, 82, 55, 0.2);
  padding: 4mm 0;
  vertical-align: top;
}

.price-table td:last-child,
.payment-table td:last-child {
  color: var(--theme-secondary);
  font-weight: 900;
  text-align: right;
}

.list-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12mm;
}

.brochure-list {
  display: grid;
  gap: 4mm;
  margin: 0;
  padding: 0;
  list-style: none;
}

.brochure-list li {
  position: relative;
  min-height: 9mm;
  padding-left: 7mm;
  color: #4e433c;
  font-size: 11px;
  line-height: 1.35;
}

.brochure-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.8mm;
  width: 3.2mm;
  height: 3.2mm;
  border-radius: 50%;
  background: var(--theme-primary);
}

.notes-box {
  margin-top: 12mm;
  height: 52mm;
  border-top: 1px solid rgba(118, 82, 55, 0.28);
  padding-top: 6mm;
  color: #50453f;
  font-size: 11px;
  line-height: 1.45;
}

.terms-list {
  display: grid;
  gap: 4.5mm;
  counter-reset: terms;
  margin: 0;
  padding: 0;
  list-style: none;
}

.terms-list li {
  counter-increment: terms;
  display: grid;
  grid-template-columns: 10mm 1fr;
  gap: 4mm;
  color: #4f443d;
  font-size: 11px;
  line-height: 1.42;
}

.terms-list li::before {
  content: counter(terms, decimal-leading-zero);
  color: var(--theme-primary);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
}

.fit-text {
  overflow: hidden;
}

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

  .editor-panel {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--ui-border);
  }

  .preview-workspace {
    height: auto;
  }
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  body {
    background: #fff;
  }

  .editor-panel,
  .preview-toolbar,
  .page-tabs {
    display: none !important;
  }

  .app-shell,
  .preview-workspace,
  .preview-root {
    display: block;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
  }

  .sheet {
    width: 210mm;
    height: 297mm;
    margin: 0;
    box-shadow: none;
    transform: none;
    break-after: page;
    page-break-after: always;
  }
}
