:root {
  color-scheme: light;
  --ink: #202833;
  --muted: #65707d;
  --panel: #ffffff;
  --line: #d9e0e7;
  --wash: #eef4f8;
  --accent: #227c8d;
  --accent-strong: #145d6b;
  --danger: #ba4e45;
  --shadow: 0 18px 45px rgba(33, 43, 54, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #edf2f4;
  color: var(--ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
.file-btn {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

button:hover,
.file-btn:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button:active,
.file-btn:active {
  transform: translateY(1px);
}

button.ghost {
  background: #fff;
  color: var(--accent-strong);
  border-color: #a8c7ce;
}

button.ghost:hover {
  background: #eaf5f7;
}

.file-btn input {
  display: none;
}

.topbar {
  min-height: 84px;
  padding: 18px clamp(16px, 3vw, 36px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: #f8fbfc;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.preview-toolbar h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(24px, 3vw, 36px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

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

.controls {
  padding: 20px;
  overflow: auto;
  max-height: calc(100vh - 84px);
}

section + section {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

h2 {
  font-size: 17px;
  margin: 0 0 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbd6df;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
}

input[type="color"] {
  padding: 3px;
}

input[type="range"] {
  padding: 0;
}

.two-col,
.margin-grid,
.swatches,
.inline-check {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

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

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

.inline-check {
  align-items: end;
}

.inline-check label:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.inline-check input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

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

.preview-toolbar {
  min-height: 86px;
  padding: 18px clamp(18px, 3vw, 34px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfc;
}

.preview-toolbar h2 {
  font-size: clamp(19px, 2vw, 26px);
}

#paperMeta {
  color: var(--muted);
  margin: 0;
  font-weight: 700;
}

.preview-stage {
  min-height: 0;
  overflow: auto;
  padding: clamp(18px, 3vw, 42px);
  display: grid;
  place-items: start center;
}

.paper-preview {
  width: min(100%, 760px);
  display: grid;
  place-items: center;
}

.paper-preview svg {
  width: 100%;
  height: auto;
  background: #fff;
  border-radius: 2px;
  box-shadow: var(--shadow);
}

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

  .controls {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-stage {
    place-items: start center;
  }
}

@media (max-width: 620px) {
  .topbar,
  .preview-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-col,
  .margin-grid,
  .swatches,
  .inline-check {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .controls,
  .preview-toolbar {
    display: none;
  }

  .app-shell,
  .workspace,
  .preview-stage,
  .paper-preview {
    display: block;
    padding: 0;
    min-height: auto;
  }

  .paper-preview svg {
    width: 100vw;
    box-shadow: none;
  }
}
