:root {
  --bg: #f8f6f1;
  --surface: #fdfcf8;
  --ink: #1a1a18;
  --muted: #74746b;
  --line: #e2ded4;
  --accent: #36423b;
  --accent-hover: #434f47;
  --accent-soft: #e4ebe6;
  --ink-panel-deep: #222b26;
  --on-dark: #f1efe8;
  --on-dark-muted: #9aa79d;
  --danger: #a6453c;
  --radius: 4px;
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tabbar-h: 48px;
}

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

html,
body {
  height: 100%;
}

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

body {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

a {
  color: var(--ink);
}

.screen[hidden] {
  display: none !important;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  padding: 0.78rem 1.4rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 180ms ease;
}

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

.btn-primary:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.78rem 1.4rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition:
    background 180ms ease,
    border-color 180ms ease;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg);
}

.btn-secondary:disabled {
  opacity: 0.35;
  cursor: default;
}

.btn-text {
  color: var(--ink);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  padding: 0.2rem 0;
}

.btn-text:hover {
  text-decoration: underline;
}

.btn-text.danger {
  color: var(--danger);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--serif);
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  line-height: 1;
}

.wordmark img {
  width: 26px;
  height: 26px;
  display: block;
  border-radius: 6px;
}

.wordmark.small {
  font-size: 1.15rem;
}

.wordmark.small img {
  width: 22px;
  height: 22px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 0;
}

.req {
  color: var(--danger);
}

label,
legend,
.field-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.01em;
  padding: 0;
}

input[type='text'],
input[type='email'],
input[type='url'],
input[type='date'],
input[type='time'],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}

textarea {
  min-height: 5.5rem;
  resize: vertical;
  line-height: 1.55;
}

select {
  appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2374746B'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 10px;
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--danger);
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.hint strong {
  font-weight: 500;
  color: var(--ink);
}

.error {
  font-size: 0.78rem;
  color: var(--danger);
  line-height: 1.5;
}

.error[hidden] {
  display: none;
}

.split {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  height: 100dvh;
  width: 100%;
}

.split-brand {
  position: relative;
  background: var(--ink-panel-deep);
  color: var(--on-dark);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(2rem, 4vw, 3.5rem);
  overflow: hidden;
}

.split-brand::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.05), transparent 45%),
    radial-gradient(circle at 76% 72%, rgba(255, 255, 255, 0.04), transparent 42%);
  pointer-events: none;
}

.split-brand > * {
  position: relative;
  z-index: 1;
}

.split-brand-body {
  max-width: 34rem;
}

.eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--on-dark-muted);
}

.brand-head {
  font-size: clamp(2.2rem, 4.4vw, 3.6rem);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin-top: 1rem;
}

.brand-head strong {
  font-weight: 600;
}

.brand-points {
  list-style: none;
  margin-top: clamp(2rem, 4vh, 3rem);
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.brand-points li {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
}

.brand-points strong {
  font-weight: 500;
  font-size: 0.95rem;
}

.brand-points p {
  font-size: 0.85rem;
  color: var(--on-dark-muted);
  line-height: 1.55;
  margin-top: 0.1rem;
  max-width: 34ch;
}

.tick {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 0.15rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  position: relative;
}

.tick::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 4px;
  width: 5px;
  height: 9px;
  border-right: 1.5px solid var(--on-dark);
  border-bottom: 1.5px solid var(--on-dark);
  transform: rotate(42deg);
}

.split-brand-foot {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--on-dark-muted);
  opacity: 0.75;
}

.split-brand-foot span {
  padding: 0 0.4rem;
  opacity: 0.5;
}

.split-form {
  background: var(--bg);
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2rem, 5vh, 4rem) clamp(1.5rem, 4vw, 3.5rem);
}

.split-form-inner {
  width: 100%;
  max-width: 27rem;
}

.form-head {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.lede {
  color: var(--muted);
  margin-top: 0.7rem;
  font-size: 0.9rem;
}

#gateForm {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
}

#gateForm > * + * {
  margin-top: 20px;
}

#gateForm .btn-primary {
  margin-top: 28px;
  width: 100%;
}

.form-foot {
  margin-top: 1.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
}

.workspace {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  height: 100dvh;
  width: 100%;
}

.tabbar {
  display: none;
}

.pane-form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-right: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
  min-height: 0;
}

.wiz-head {
  padding: 1.1rem 1.5rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.wiz-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.saved {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  transition: opacity 200ms ease;
}

.progress {
  display: flex;
  gap: 3px;
}

.progress button {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  padding: 0;
  transition: background 180ms ease;
  position: relative;
}

.progress button::after {
  content: '';
  position: absolute;
  inset: -7px 0;
}

.progress button.done {
  background: var(--accent-soft);
}

.progress button.current {
  background: var(--accent);
}

.progress button:hover:not(.current) {
  background: var(--muted);
}

.wiz-step {
  margin-top: 0.7rem;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.wiz-step strong {
  color: var(--ink);
  font-weight: 500;
}

.wiz-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.5rem;
}

.wiz-body > form > * + * {
  margin-top: 24px;
}

.step-head h2 {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.step-head p {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.35rem;
  line-height: 1.55;
}

.include-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.include-toggle input {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 0.15rem;
  accent-color: var(--accent);
}

.include-toggle label {
  font-size: 0.88rem;
  cursor: pointer;
}

.include-toggle .hint {
  margin-top: 0.15rem;
}

.step-fields.off {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(1);
}

.step-fields > * + * {
  margin-top: 24px;
}

.row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--surface);
}

.row + .row {
  margin-top: 0.75rem;
}

.row > * + * {
  margin-top: 16px;
}

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.row-n {
  font-size: 0.76rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.row-tools {
  display: flex;
  gap: 0.25rem;
}

.row-tools button {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1;
  background: var(--bg);
  display: grid;
  place-items: center;
  transition:
    color 180ms ease,
    border-color 180ms ease;
}

.row-tools button:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--muted);
}

.row-tools button:disabled {
  opacity: 0.3;
  cursor: default;
}

.row-tools button.remove:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger);
}

.repeater-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.repeater-note {
  font-size: 0.78rem;
  color: var(--muted);
}

.swatch-row {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
}

.swatch-row .field {
  flex: 1;
}

input[type='color'] {
  flex: none;
  width: 44px;
  height: 40px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.photo-field {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
}

.photo-field .field {
  flex: 1;
  min-width: 0;
}

.photo-thumb {
  flex: none;
  width: 56px;
  height: 56px;
  margin-top: 1.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface) center / cover no-repeat;
  display: grid;
  place-items: center;
  font-size: 0.6rem;
  color: var(--muted);
  text-align: center;
}

.photo-thumb.bad {
  border-color: var(--danger);
  color: var(--danger);
}

.checkbox-field {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.checkbox-field input {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

.checkbox-field label {
  font-size: 0.9rem;
  font-weight: 400;
}

.notes {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.notes summary {
  cursor: pointer;
  list-style: none;
  padding: 0.7rem 0.9rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.notes summary::-webkit-details-marker {
  display: none;
}

.notes summary:hover {
  color: var(--ink);
}

.notes-body {
  padding: 0 0.9rem 0.9rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--muted);
}

.notes-body > * + * {
  margin-top: 0.8rem;
}

.notes-body ol {
  margin-left: 1.1rem;
}

.notes-body li {
  margin-bottom: 0.3rem;
}

.notes-body pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.7rem;
  overflow-x: auto;
  font-size: 0.72rem;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink);
  white-space: pre;
}

.notes-body a {
  color: var(--accent);
}

.finish {
  text-align: center;
  padding: 0.5rem 0 0;
}

.finish h2 {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 400;
  line-height: 1.15;
}

.finish p.lede {
  margin-top: 0.5rem;
}

.finish .filename {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.7rem;
  word-break: break-all;
}

.steps {
  list-style: none;
  margin-top: 1.75rem;
  border-top: 1px solid var(--line);
  text-align: left;
}

.steps li {
  display: flex;
  gap: 0.9rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.step-n {
  flex: none;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  color: var(--muted);
}

.steps strong {
  font-weight: 500;
  display: block;
  font-size: 0.9rem;
}

.steps p {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.finish-actions {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.wiz-foot {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.wiz-foot .btn-secondary {
  flex: 0 0 auto;
}

.wiz-foot .btn-primary {
  flex: 1;
}

.pane-preview {
  position: relative;
  background: var(--bg);
  min-height: 0;
  overflow: hidden;
}

#previewFrame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--bg);
}

.preview-status {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--on-dark);
  background: rgba(34, 43, 38, 0.82);
  padding: 0.28rem 0.7rem;
  border-radius: 100px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
}

.preview-status.show {
  opacity: 1;
}

.preview-blocker {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

.preview-blocker[hidden] {
  display: none;
}

.preview-blocker p {
  max-width: 34ch;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .split {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
  }

  .split-brand {
    padding: 1.75rem 1.5rem 2rem;
    gap: 1.5rem;
  }

  .split-brand-body {
    max-width: none;
  }

  .brand-head {
    font-size: 2rem;
  }

  .brand-points {
    margin-top: 1.5rem;
    gap: 1rem;
  }

  .split-brand-foot {
    display: none;
  }

  .split-form {
    align-items: flex-start;
    padding: 2rem 1.5rem 3rem;
  }

  .split-form-inner {
    max-width: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: var(--tabbar-h) minmax(0, 1fr);
    height: 100dvh;
    overflow: hidden;
  }

  .tabbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
  }

  .tabbar button {
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    transition:
      color 180ms ease,
      border-color 180ms ease;
  }

  .tabbar button[aria-selected='true'] {
    color: var(--ink);
    border-bottom-color: var(--accent);
  }

  .pane-form {
    border-right: 0;
  }

  .pane-form[hidden],
  .pane-preview[hidden] {
    display: none;
  }

  .wiz-head-top .wordmark {
    display: none;
  }

  .wiz-head {
    padding: 0.9rem 1.15rem 0.8rem;
  }

  .wiz-head-top {
    margin-bottom: 0.75rem;
    justify-content: flex-end;
    min-height: 1rem;
  }

  .wiz-body {
    padding: 1.15rem;
  }

  .wiz-foot {
    padding: 0.85rem 1.15rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
  }

  .preview-status {
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
