:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #6b7785;
  --accent: #305496;
  --accent2: #4e79a7;
  --border: #d8dee6;
  --error: #b3261e;
  --ok: #1b7f3b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* Phase 3 branding — pre-auth background image, scoped to the login/register/
   verify/confirm pages via the .auth-wrap hook (present on those 4 pages only,
   never on an in-app page). The .auth-card sits on an opaque var(--card) surface
   so its content stays legible over any image. */
body:has(.auth-wrap) {
  background-image: url("/static/img/bg-preauth.png");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

/* Honeypot decoy field — pushed off-screen (NOT display:none, which some bots
   skip). Present in the DOM & fillable by bots, invisible to humans. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* White scrim between the pre-auth background and the auth card: mutes the
   image so the .auth-card (lifted above via z-index) stays legible. */
body:has(.auth-wrap)::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  pointer-events: none;
  z-index: 0;
}
body:has(.auth-wrap) .auth-wrap {
  position: relative;
  z-index: 1;
}

header {
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: baseline;
  gap: 14px;
}
header h1 { font-size: 18px; margin: 0; }
header .sub { font-size: 12px; opacity: 0.85; }

/* Phase 3 branding — logo in the in-app headers (lobby/app/admin). Capped to the
   header bar height; sits just left of the <h1> text. */
header .brand-logo { height: 30px; width: auto; vertical-align: middle;
  margin-right: 12px; align-self: center; }

.layout {
  display: flex;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 90px);
}

.panel {
  width: 340px;
  flex: 0 0 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.card h2 { font-size: 14px; margin: 0 0 10px; color: var(--accent); }

.dims { display: flex; gap: 8px; }
.dims label {
  display: flex; flex-direction: column; font-size: 12px;
  color: var(--muted); gap: 4px; flex: 1;
}
.dims input { width: 100%; }

input[type="number"], select {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 5px;
  font-size: 14px;
}
input[type="file"] { width: 100%; font-size: 13px; }

.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.hint code { background: #eef1f5; padding: 1px 4px; border-radius: 3px; }

button {
  cursor: pointer; border: 1px solid var(--border); background: #fff;
  padding: 8px 14px; border-radius: 6px; font-size: 14px;
}
button:hover { background: #f0f3f7; }
button.primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  margin-top: 10px; width: 100%;
}
button.primary:hover { background: #26417a; }
button:disabled { opacity: 0.5; cursor: default; }

.busy { font-size: 12px; color: var(--muted); margin-left: 8px; }

#summary { font-size: 13px; line-height: 1.5; }
#summary table { width: 100%; border-collapse: collapse; margin: 6px 0; }
#summary th, #summary td {
  text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--border);
  font-size: 12px;
}
#summary th { color: var(--muted); font-weight: 600; }
.util-bar {
  height: 7px; background: #e6eaf0; border-radius: 4px; overflow: hidden;
  margin-top: 2px;
}
.util-bar > span { display: block; height: 100%; background: var(--accent2); }

.badge { display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 11px; font-weight: 600; }
.badge.ok { background: #e1f3e7; color: var(--ok); }
.badge.bad { background: #fde8e7; color: var(--error); }

#exportBtn { margin-top: 12px; }

.card.error h2 { color: var(--error); }
#errors { font-size: 12px; color: var(--error); }
#errors ul { margin: 4px 0 0; padding-left: 18px; }
.warn-block { color: #8a5b00; }

.viewer {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden;
}
.viewer-controls {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: #fbfcfd;
}
.viewer-controls > label { font-size: 12px; color: var(--muted); }
.step-controls { display: flex; align-items: center; gap: 8px; }
#stepSlider { width: 220px; }
.step-label { font-size: 13px; font-weight: 600; min-width: 90px; }

.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-left: auto; }
.legend .item { display: flex; align-items: center; gap: 5px; font-size: 12px; }
.legend .swatch { width: 13px; height: 13px; border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.2); }

#canvasWrap { flex: 1; position: relative; min-height: 0; }
#canvasWrap canvas { display: block; width: 100%; height: 100%; }
.placeholder {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; text-align: center; color: var(--muted);
  padding: 40px; font-size: 14px;
}
.viewer-help {
  padding: 6px 14px; font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--border); background: #fbfcfd;
}
