:root {
  --bg: #eef0f3;
  --surface: #ffffff;
  --ink: #212529;
  --muted: #5f6b76;
  --rule: #d5dae0;
  --accent: #1f3a60;
  --accent-soft: #e7eef7;
  --ok: #1e7b45;
  --warn: #9a5b00;
  --danger: #b42318;
  --radius: 10px;
  --topbar: 52px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2 { margin: 0; }
h2 { font-size: 15px; }

/* ---------- top bar ---------- */
.topbar {
  height: var(--topbar);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--accent); color: #fff;
}
.topbar h1 { font-size: 17px; white-space: nowrap; }
.badge { background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px; padding: 2px 10px; font-size: 12px; white-space: nowrap; }
.spacer { flex: 1; }

/* ---------- one-screen layout ---------- */
.workspace {
  height: calc(100vh - var(--topbar));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "preview side" "create side";
  gap: 12px;
  padding: 12px;
}
.preview-panel { grid-area: preview; display: flex; flex-direction: column; min-height: 0; }
.create-panel { grid-area: create; }
.sidebar { grid-area: side; overflow-y: auto; }

.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 14px; }
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }

/* ---------- preview ---------- */
.preview-scroll { flex: 1; min-height: 0; overflow: auto; background: #e3e6ea; border-radius: 6px; padding: 12px; }
.preview-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.preview-page { display: block; max-width: 100%; height: auto; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
.preview-empty { height: 100%; display: grid; place-content: center; text-align: center; color: var(--muted); max-width: 420px; margin: 0 auto; }
.preview-empty p { margin: 4px 0; }

/* ---------- create ---------- */
.create-grid { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 14px; }
.create-grid label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.create-grid label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); padding-bottom: 6px; }
.create-grid .primary { margin-left: auto; }

/* ---------- sidebar ---------- */
.sidebar section + section { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule); }
.sidebar h2 { margin-bottom: 8px; }
.sidebar .row { margin-bottom: 6px; }

.year { margin-top: 10px; }
.year h3 { margin: 0 0 4px; font-size: 13px; color: var(--accent); }
.slot { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 5px 8px; border: 1px solid var(--rule); border-radius: 6px; margin-bottom: 4px; }
.slot.filled { border-color: #b7dcc4; background: #f3faf5; }
.slot.report { box-shadow: inset 3px 0 0 var(--accent); }
.slot.dragover { border-color: var(--accent); background: var(--accent-soft); }
.slot-label { font-weight: 600; }
.slot-status { margin: 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.slot.filled .slot-status { color: var(--ok); }
.slot-status .tag { display: inline-block; font-size: 11px; color: #fff; background: var(--accent); border-radius: 4px; padding: 0 5px; margin-right: 4px; }
.slot-status .remove { margin-left: 4px; }

/* ---------- controls ---------- */
select, button, .button { font: inherit; }
select { padding: 5px 8px; border: 1px solid var(--rule); border-radius: 6px; background: #fff; max-width: 100%; color: var(--ink); }
button, .button { display: inline-block; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--rule); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; padding: 7px 18px; font-weight: 600; }
button.small, .slot .button { padding: 2px 10px; font-size: 13px; }
button.link { border: 0; padding: 0; background: none; color: var(--accent); text-decoration: underline; }
button.link.light { color: #fff; }
button.quiet { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.45); }
.button:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 4px; }

details { font-size: 13px; }
summary { cursor: pointer; color: var(--warn); font-weight: 600; }
details ul { margin: 6px 0 0; padding-left: 18px; max-height: 140px; overflow: auto; }
details[open] { flex-basis: 100%; }

.output-actions { margin: 10px 0 4px; }
ul.outputs { list-style: none; padding: 0; margin: 0; max-height: 120px; overflow: auto; }
ul.outputs li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; border-top: 1px solid var(--rule); font-size: 13px; }
ul.outputs .name { flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
ul.outputs .result { color: var(--ok); }
ul.outputs .result.error { color: var(--danger); }
ul.outputs a, .slot-status a { color: var(--accent); }

.status { min-height: 1.2em; margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.status.error { color: var(--danger); }

body.no-drive .drive-only { display: none; }
body:not(.no-drive) .no-drive-only { display: none; }

/* ---------- narrow screens: stack ---------- */
@media (max-width: 900px) {
  .workspace { height: auto; grid-template-columns: 1fr; grid-template-rows: auto; grid-template-areas: "side" "preview" "create"; }
  .preview-scroll { height: 70vh; flex: none; }
  .sidebar { overflow: visible; }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; }
}

/* ---------- privacy page ---------- */
.topbar a { color: #fff; text-decoration: none; }
.topbar a.top-link { font-size: 14px; text-decoration: underline; }
.doc { max-width: 760px; margin: 24px auto 48px; padding: 24px 28px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); font-size: 15px; line-height: 1.6; }
.doc h2 { font-size: 24px; }
.doc h3 { font-size: 17px; margin: 24px 0 6px; }
.doc a { color: var(--accent); }
.doc code { font-size: 13px; background: var(--bg); padding: 1px 4px; border-radius: 4px; overflow-wrap: anywhere; }
@media (max-width: 600px) { .doc { margin: 12px 16px 32px; padding: 18px; } }
