:root {
  --bg: #fafaf8;
  --panel: #ffffff;
  --ink: #1a1d29;
  --soft: #5d5f6a;
  --line: #e3e0d6;
  --accent: #ff5a3c;
  --accent-soft: #ffe9e4;
  --radius: 10px;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* MUST come before any rule that sets display on .gate / #app.
   [hidden] is a UA style at specificity 0,0,1 — any class or id selector that
   sets `display` silently beats it, so `el.hidden = true` sets the attribute
   and changes nothing on screen. That produced a sign-in screen that stayed
   put after a correct password. */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

h1 { font-size: 1.35rem; margin: 0; letter-spacing: -0.02em; }
.muted { color: var(--soft); }
.small { font-size: 0.85em; }
.spacer { flex: 1; }

/* gate */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* shell */
.topbar {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  gap: 24px;
  padding: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel, .preview {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  /* Grid items default to min-width:auto, which lets them grow to fit their
     content — here that means the 794px page forces the column wide and the
     whole page scrolls sideways. */
  min-width: 0;
}
.panel { display: flex; flex-direction: column; gap: 16px; }

/* form */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 0.9em; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input[type="text"], input[type="password"], select, textarea {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  width: 100%;
}
textarea { resize: vertical; min-height: 140px; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

button {
  font: inherit;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  padding: 9px 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--soft); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.primary, .gate-card button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  padding: 12px;
}
.primary:hover:not(:disabled) { filter: brightness(1.06); }
.ghost { font-size: 0.9em; padding: 6px 10px; }
.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
}

/* drop zone */
.drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.drop p { margin: 0 0 4px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.file-name {
  margin: 8px 0 0;
  font-size: 0.85em;
  color: var(--soft);
  word-break: break-all;
}

/* messages */
.status, .error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.9em;
}
.status { background: var(--accent-soft); }
.error { background: #fdecea; color: #8c1d13; }

/* preview */
.preview { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.preview-bar { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.stage {
  min-width: 0;
  background: #ebe9e4;
  border-radius: 8px;
  padding: 16px;
  min-height: 480px;
  display: grid;
  place-items: start center;
  overflow: auto;
  max-height: calc(100vh - 200px);
}
/* Sized from JS to the scaled page footprint. */
.page {
  width: 794px;
  height: 1123px;
  overflow: hidden;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.12);
  background: #fff;
}
/* Sized and scaled from JS per format — never max-width'd, which would squash
   the page and misrepresent the layout. */
#frame {
  width: 794px;
  height: 1123px;
  border: 0;
  background: #fff;
  display: block;
}

details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  font-size: 0.9em;
}
summary { cursor: pointer; font-weight: 600; }
#report-body p { margin: 8px 0 0; color: var(--soft); }
#report-body strong { color: var(--ink); }
