:root {
  --bg: #eceef1;
  --side: #ffffff;
  --ink: #15171c;
  --ink-2: #4b5563;
  --muted: #8a919c;
  --line: #e3e6ea;
  --line-strong: #cfd4da;
  --accent: #1f6feb;
  --accent-soft: #eaf2ff;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --radius: 8px;
  --side-w: 272px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: linear-gradient(160deg, #eef0f3 0%, #ecebf2 55%, #e9e6f1 100%) fixed;
  color: var(--ink);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }

/* ---------- frame ---------- */
.app { display: flex; min-height: 100vh; }
.side {
  width: var(--side-w);
  flex: none;
  background: var(--side);
  border-right: 1px solid var(--line);
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.stage { flex: 1; min-width: 0; padding: 28px 32px 48px; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.brand h1 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.brand .ver { color: var(--muted); font-size: 11px; }
.brand .tagline { flex-basis: 100%; color: var(--ink-2); font-size: 12px; line-height: 1.4; margin-top: 2px; }
.brand .privacy { flex-basis: 100%; color: var(--muted); font-size: 11px; line-height: 1.4; margin-top: 6px; }

/* ---------- groups ---------- */
.group { display: flex; flex-direction: column; gap: 7px; }
.group h2 {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* file */
.drop {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
  color: var(--ink-2);
  transition: border-color .15s, background .15s;
}
.drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop input { display: none; }
.drop-icon { color: var(--accent); display: inline-flex; flex: none; }
.drop-text { font-size: 12px; line-height: 1.35; }
.drop-text b { color: var(--ink); font-weight: 600; }

.file-info { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.file-info .kind { display: inline-flex; align-self: flex-start; font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; border-radius: 999px; padding: 2px 8px; margin-bottom: 3px; }
.file-info .kind.classlist { background: #e7f6ec; color: #166534; }
.file-info .kind.waitlist { background: #fff1e6; color: #9a3412; }
.file-info .kind.generic { background: #eef0f3; color: var(--ink-2); }
.file-info .title { font-weight: 600; line-height: 1.3; }
.file-info .meta { color: var(--ink-2); font-size: 12px; }
.file-info .meta b { font-weight: 600; color: var(--ink); }
.file-info .fname { color: var(--muted); font-size: 11px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status { font-size: 12px; line-height: 1.4; min-height: 0; }
.status:empty { display: none; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.error { color: var(--err); }

/* fields */
.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field label, .field-label { color: var(--ink-2); }
input[type="number"] {
  width: 64px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 5px 8px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  text-align: right;
}
input[type="number"]:focus, .drop:focus-within { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  border-left: 1px solid var(--line-strong);
  user-select: none;
}
.seg label:first-child span { border-left: 0; }
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.check { display: flex; align-items: center; gap: 8px; color: var(--ink-2); cursor: pointer; }
.check input[type="checkbox"] { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.swatches { display: flex; gap: 6px; padding-left: 23px; align-items: center; }
.swatches[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.swatch {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.12);
  background: var(--c, #fff);
  padding: 0;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.6);
}
.swatch.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--ink); }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch.custom {
  display: inline-flex;
  background: conic-gradient(from 180deg, #f8c4c4, #fde6b3, #d8f0c0, #c4e3f8, #ddd2f7, #f8c4c4);
}
.swatch.custom.selected { background: var(--c); }
.swatch.custom::after {
  content: "+";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: rgba(0,0,0,.55); line-height: 1;
}
.swatch.custom.selected::after { content: ""; }
.swatch.custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }

/* action */
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.summary { display: flex; gap: 6px; color: var(--muted); font-size: 12px; }
.summary span + span::before { content: "·"; margin: 0 6px 0 0; }
.fit { font-size: 12px; color: var(--warn); line-height: 1.35; }
.fit:empty { display: none; }

.side-links { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.side-links a { color: var(--accent); text-decoration: none; font-weight: 500; }
.side-links a:hover { text-decoration: underline; }

/* ---------- preview ---------- */
#pages { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.page {
  position: relative;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 8px 24px rgba(15,23,42,.10);
  overflow: hidden;
  color: #000;
}
.page .heading { position: absolute; white-space: nowrap; font-family: Helvetica, Arial, sans-serif; }
.page .gen { position: absolute; font-family: Helvetica, Arial, sans-serif; }
.page .folio { position: absolute; font-family: Helvetica, Arial, sans-serif; color: #555; }
.page table { position: absolute; border-collapse: collapse; table-layout: fixed; font-family: Helvetica, Arial, sans-serif; }
.page th, .page td { border: 1px solid #bebebe; overflow: hidden; white-space: nowrap; padding: 0; }
.page th { background: #f0f1f4; font-weight: 700; }
.page td > div, .page th > div { display: flex; align-items: center; height: 100%; }

.empty-wrap { max-width: 420px; margin: 14vh auto 0; display: flex; flex-direction: column; gap: 32px; }
.legacy-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 18px;
  border: 2px dashed var(--line-strong);
  border-radius: 14px;
  text-align: center;
  text-decoration: none;
  color: var(--ink-2);
  background: #f5f6f8;
  transition: border-color .15s, background .15s;
  opacity: 0;
  animation: legacy-in .6s ease-out 3s forwards; /* fade in after a beat, for anyone surprised by the new UI */
}
@keyframes legacy-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .legacy-box { animation: none; opacity: 1; } }
.legacy-box b { color: var(--ink); font-weight: 600; }
.legacy-box:hover { border-color: var(--accent); background: #fff; }
.empty {
  padding: 40px 32px;
  text-align: center;
  color: var(--ink-2);
  line-height: 1.5;
  border: 2px dashed var(--line-strong);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-icon { color: var(--accent); margin-bottom: 4px; }
.empty h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink); }
.empty p { color: var(--ink-2); }
.btn.ghost { width: auto; margin-top: 6px; padding: 7px 14px; font-weight: 500; color: var(--accent); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--accent-soft); border-color: var(--accent); }

.side-links .credit a { color: var(--accent); font-weight: 700; }

/* whole-page drop */
.drop-overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(31,111,235,.08);
  border: 3px dashed var(--accent);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.drop-overlay div { background: #fff; color: var(--accent); font-weight: 600; padding: 10px 18px; border-radius: 999px; box-shadow: 0 4px 16px rgba(0,0,0,.12); }

/* ---------- narrow screens ---------- */
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .side { width: auto; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .stage { padding: 18px 12px 36px; }
}
