:root {
  --bg: #f2eee6;
  --surface: #fffdf8;
  --surface-soft: #f8f3ea;
  --ink-900: #1f1a16;
  --ink-700: #4d433d;
  --ink-500: #786f68;
  --line: #ddd3c8;
  --line-strong: #bcae9f;
  --brand: #1f6f66;
  --brand-hover: #17584f;
  --brand-soft: #e5f3ef;
  --danger: #b43f4a;
  --danger-soft: #fbeef0;
  --radius-lg: 14px;
  --radius-md: 10px;
  --shadow: 0 10px 30px rgba(31, 26, 22, 0.09), 0 2px 8px rgba(31, 26, 22, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "DM Sans", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(31, 111, 102, 0.06), transparent 45%),
    radial-gradient(circle at 90% 100%, rgba(188, 174, 159, 0.16), transparent 45%),
    var(--bg);
  color: var(--ink-900);
  min-height: 100vh;
}

.page {
  width: min(920px, calc(100vw - 24px));
  margin: 16px auto 28px;
  display: grid;
  gap: 12px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
  padding: 14px;
}

.eyebrow {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
}

h1 {
  margin: 5px 0 0;
  font-size: clamp(1.25rem, 4vw, 1.85rem);
  line-height: 1.1;
}

.hero-note {
  margin: 8px 0 0;
  color: var(--ink-700);
  font-size: 13px;
  line-height: 1.5;
}

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

.field {
  display: grid;
  gap: 5px;
}

.field span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink-700);
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink-900);
  font-size: 14px;
  padding: 0 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 111, 102, 0.14);
}

.pad-head h2 {
  margin: 0;
  font-size: 15px;
}

.pad-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-500);
}

canvas {
  margin-top: 10px;
  display: block;
  width: 100%;
  height: 220px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle, rgba(31, 111, 102, 0.06) 1px, transparent 1px),
    var(--surface-soft);
  background-size: 18px 18px;
  touch-action: none;
  cursor: crosshair;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 8px;
  margin-top: 10px;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

button:active {
  transform: translateY(1px);
}

button.ghost {
  background: var(--surface);
  color: var(--ink-700);
}

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

button.primary {
  border-color: var(--brand);
  background: linear-gradient(180deg, var(--brand), var(--brand-hover));
  color: #fff;
  box-shadow: 0 8px 18px rgba(31, 111, 102, 0.24);
}

button.primary:hover {
  background: linear-gradient(180deg, #228173, var(--brand-hover));
}

.status {
  margin: 10px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
}

.status.error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(180, 63, 74, 0.2);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}

@media (max-width: 760px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  canvas {
    height: 200px;
  }

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

@media (max-width: 420px) {
  .page {
    width: calc(100vw - 14px);
    margin: 8px auto 18px;
  }

  .card {
    padding: 10px;
  }

  canvas {
    height: 180px;
  }
}

/* Landscape: keep the 3 metadata fields in one row */
@media (orientation: landscape) {
  .form-card .field-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Landscape-only merged layout:
   move title + metadata into pad card and remove pad text headings */
@media (orientation: landscape) and (max-height: 560px) {
  body.landscape-merged .page {
    width: calc(100vw - 12px);
    margin: 6px auto;
    gap: 0;
  }

  body.landscape-merged .pad-card {
    min-height: calc(100vh - 12px);
    padding: 10px;
    display: grid;
    grid-template-rows: auto auto 1fr auto auto;
    align-content: start;
  }

  body.landscape-merged .hero,
  body.landscape-merged .form-card {
    border: none;
    box-shadow: none;
    background: transparent;
    border-radius: 0;
    padding: 0;
    margin: 0 0 8px;
  }

  body.landscape-merged .hero-note {
    display: none;
  }

  body.landscape-merged .eyebrow {
    font-size: 9px;
    letter-spacing: 0.1em;
  }

  body.landscape-merged h1 {
    margin-top: 1px;
    font-size: clamp(0.96rem, 1.9vw, 1.15rem);
  }

  body.landscape-merged .field-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  body.landscape-merged .field {
    gap: 4px;
  }

  body.landscape-merged .field span {
    font-size: 10.5px;
  }

  body.landscape-merged input,
  body.landscape-merged select {
    min-height: 36px;
    font-size: 13px;
  }

  body.landscape-merged .pad-head {
    display: none;
  }

  body.landscape-merged canvas {
    margin-top: 2px;
    height: clamp(220px, calc(100vh - 210px), 430px);
  }

  body.landscape-merged .actions {
    margin-top: 8px;
    grid-template-columns: 1fr 1fr;
  }

  body.landscape-merged button {
    min-height: 44px;
    font-size: 14px;
  }

  body.landscape-merged .status {
    margin-top: 6px;
    font-size: 11.5px;
  }
}
