/* ==========================================================================
   Prototype Hub — stylesheet
   Drop-in replacement for public/assets/style.css
   Tokens are the Nocturne design system (dark, compact, outlined actions).
   Nothing here needs a build step; plain CSS on the markup in README.md.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  /* ground + text */
  --bg: #161826;
  --bg-rail: #13151f;
  --surface: #232532;
  --text: #e9e9ed;
  --divider: rgba(233,233,237,.16);

  /* accent (blurple) */
  --accent: #9184d9;
  --accent-100: #f5f4ff;
  --accent-200: #e7e5fe;
  --accent-300: #d2cefd;
  --accent-400: #b5abfc;
  --accent-700: #5d5294;
  --accent-800: #423a6a;
  --accent-900: #2b2741;

  /* neutrals */
  --n-100: #f3f5fe;
  --n-200: #e4e7f5;
  --n-300: #cfd3e5;
  --n-400: #b2b6ca;
  --n-500: #9397ab;
  --n-600: #75798c;
  --n-700: #595d6c;
  --n-800: #3f424d;
  --n-900: #292b31;

  /* danger (used only for destructive text/borders, never as a fill) */
  --danger: #f0968c;

  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* 0.70x density scale — use these, not raw px */
  --s1: 2.8px; --s2: 5.6px; --s3: 8.4px; --s4: 11.2px; --s6: 16.8px; --s8: 22.4px;

  --r-sm: 4px; --r-md: 8px; --r-lg: 14px;

  --shadow-sm: 0 0 0 1px #3f424d;
  --shadow-md: 0 0 0 1px #595d6c, 0 6px 18px rgba(0,0,0,.55);
  --shadow-lg: 0 0 0 1px #9397ab, 0 16px 40px rgba(0,0,0,.65);

  --rail-w: 236px;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font);
}

h1, h2, h3, h4, h5 {
  font-weight: 500; line-height: 1.12; letter-spacing: -.015em; margin: 0 0 var(--s2);
}
h1 { font-size: 26px; }   /* page title */
h2 { font-size: 20px; }
h3 { font-size: 17px; }
h4, h5 { font-size: 16px; }
p { margin: 0 0 var(--s3); }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-300); }
.mono, code { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--n-500); }
small { font-size: 12px; color: var(--n-500); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgba(145,132,217,.30); }

/* ------------------------------------------------------------------ shell -- */
/* body > .app { rail + main }. Signed-out pages use .centered instead. */
.app { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail-w); flex: none;
  display: flex; flex-direction: column; gap: var(--s8);
  padding: var(--s6) var(--s4);
  background: var(--bg-rail);
  border-right: 1px solid var(--divider);
}
.brand { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); }
.brand .mark {
  display: grid; place-items: center; width: 26px; height: 26px; flex: none;
  border-radius: 6px; background: var(--accent-800); color: var(--accent-200); font-size: 14px;
}
.brand .name { font-weight: 500; font-size: 15px; letter-spacing: -.01em; }

.rail-group { display: flex; flex-direction: column; gap: var(--s1); }
.rail-label {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--n-500); padding: 0 var(--s3) var(--s2);
}
.rail a {
  display: flex; align-items: center; gap: var(--s3);
  padding: 7px var(--s3); border-radius: var(--r-md);
  font-size: 14px; color: var(--n-300); text-decoration: none;
}
.rail a i { font-size: 16px; }
.rail a .n { margin-left: auto; font-size: 11px; color: var(--n-600); font-variant-numeric: tabular-nums; }
.rail a:hover { background: rgba(233,233,237,.06); color: var(--text); }
.rail a[aria-current="page"] {
  background: rgba(145,132,217,.14);
  color: var(--accent);
}
.rail a[aria-current="page"] .n { color: var(--accent-300); }

.rail-foot {
  margin-top: auto; display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3); border-top: 1px solid var(--divider);
}
.rail-foot .avatar {
  display: grid; place-items: center; width: 26px; height: 26px; flex: none;
  border-radius: 50%; background: var(--n-800); color: var(--n-200); font-size: 11px;
}
.rail-foot .who { min-width: 0; line-height: 1.25; }
.rail-foot .who div { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-foot .who a { font-size: 11px; color: var(--n-500); text-decoration: none; padding: 0; }

.main { flex: 1; min-width: 0; }
.page { padding: 28px 33.6px 56px; max-width: 1180px; }
.page.narrow { max-width: 1080px; }

/* page header: title + sub on the left, primary action right */
.page-head { display: flex; align-items: flex-end; gap: var(--s6); margin-bottom: var(--s6); }
.page-head h1 { margin: 0 0 4px; }
.page-head p { margin: 0; font-size: 13.5px; color: var(--n-500); }
.page-head .action { margin-left: auto; }

/* centered sign-in pages */
.centered { min-height: 100vh; display: grid; place-items: center; padding: 56px 33.6px; }
.centered .col { width: 100%; max-width: 380px; }

/* ---------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: var(--s2) calc(var(--s3) * 1.2);
  font: 500 14px/1.2 var(--font); white-space: nowrap; cursor: pointer;
  color: var(--text); text-decoration: none;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-md);
}
.btn i { font-size: 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { color: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: rgba(145,132,217,.12); color: var(--accent); }
.btn-primary:active { background: rgba(145,132,217,.22); }
.btn-secondary { border-color: var(--divider); }
.btn-secondary:hover { background: rgba(233,233,237,.07); color: var(--text); }
.btn-secondary:active { background: rgba(233,233,237,.14); }
.btn-ghost { color: var(--accent); padding-inline: var(--s1); }
.btn-ghost:hover { background: rgba(145,132,217,.10); }
.btn-icon { width: 32px; height: 32px; padding: 0; }
.btn-block { width: 100%; }
.btn-danger { color: var(--danger); border-color: rgba(240,150,140,.45); }
.btn-danger:hover { background: rgba(240,150,140,.12); color: var(--danger); }

/* ------------------------------------------------------------------ forms -- */
.field { display: block; }
.field > label {
  display: block; font-size: 12px; margin-bottom: 5px; font-weight: 400;
  color: rgba(233,233,237,.70);
}
.field .hint { font-size: 11px; color: var(--n-500); margin-top: 4px; }
.input, input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%; min-height: 36px; padding: 6px 10px;
  font: 400 14px/1.4 var(--font); color: var(--text); caret-color: var(--accent);
  background: var(--surface); border: 1px solid var(--divider); border-radius: var(--r-md);
}
.input:hover { border-color: rgba(233,233,237,.45); }
.input:focus-visible { border-color: var(--accent); outline-offset: 0; }
.input.mono { font-family: var(--mono); }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; cursor: pointer; }

/* search field: wrap an .input in .search and put <i class="ph ph-magnifying-glass"> first */
.search { position: relative; flex: 1; max-width: 280px; }
.search i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--n-500); }
.search .input { padding-left: 29px; }

/* segmented filter — radios inside labels, no JS */
.seg { display: inline-flex; overflow: hidden; border: 1px solid var(--divider); border-radius: var(--r-md); }
.seg-opt { display: inline-flex; align-items: center; padding: 7px 12px; font-size: 13px; white-space: nowrap; cursor: pointer; text-decoration: none; color: var(--text); }
.seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg-opt + .seg-opt { border-left: 1px solid var(--divider); }
.seg-opt:hover { background: rgba(233,233,237,.07); }
.seg-opt input:checked { /* styled via .seg-opt.is-on in markup if needed */ }
.seg-opt.is-on { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* -------------------------------------------------------------- surfaces --- */
.panel {
  padding: var(--s6); border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.panel + .panel { margin-top: var(--s6); }
.panel-head { display: flex; align-items: center; margin-bottom: var(--s4); }
.panel-head h2, .panel-head h3 { margin: 0; }

/* dashboard stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s4); margin-bottom: var(--s8); }
.stat {
  display: block; padding: 14px var(--s6); border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--shadow-sm); color: inherit; text-decoration: none;
}
.stat:hover { box-shadow: 0 0 0 1px var(--accent-700); color: inherit; }
.stat .k {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--n-500);
}
.stat .n { font-size: 30px; font-weight: 500; line-height: 1.15; margin-top: 6px; }
.stat .sub { font-size: 12px; color: var(--n-500); }
@media (max-width: 820px) { .stats { grid-template-columns: 1fr; } }

/* upload dropzone */
.dropzone {
  min-height: 150px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--s2);
  padding: var(--s8); text-align: center;
  border: 1px dashed var(--n-700); border-radius: var(--r-md);
}
.dropzone i.big { font-size: 26px; color: var(--accent); }
.dropzone .title { font-size: 14px; }
.dropzone .meta { font-size: 12px; color: var(--n-500); }
.dropzone.is-over { border-color: var(--accent); background: rgba(145,132,217,.08); }
.upload-grid { display: grid; grid-template-columns: 1fr 300px; gap: var(--s6); align-items: start; }
.upload-grid .col { display: flex; flex-direction: column; gap: var(--s4); }
@media (max-width: 900px) { .upload-grid { grid-template-columns: 1fr; } }

/* ----------------------------------------------------------------- tables -- */
.tablewrap { border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.tablewrap.scroll { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th {
  text-align: left; padding: var(--s2); white-space: nowrap;
  font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(233,233,237,.60);
}
table.list td { padding: 9px var(--s2); vertical-align: middle; }
table.list th:first-child, table.list td:first-child { padding-left: var(--s6); }
table.list th:last-child,  table.list td:last-child  { padding-right: var(--s6); text-align: right; }
table.list th.check, table.list td.check { width: 34px; }
/* row rules fade out at both ends — a Nocturne signature; painted per row, not per cell */
table.list thead tr {
  background: linear-gradient(to right, transparent, var(--divider) 48px,
    var(--divider) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
table.list tbody tr {
  background: linear-gradient(to right, transparent,
    rgba(233,233,237,.08) 48px,
    rgba(233,233,237,.08) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
table.list tbody tr:hover {
  background:
    linear-gradient(rgba(233,233,237,.04), rgba(233,233,237,.04)) no-repeat 0 0 / 100% 100%,
    linear-gradient(to right, transparent,
      rgba(233,233,237,.08) 48px,
      rgba(233,233,237,.08) calc(100% - 48px), transparent) no-repeat bottom / 100% 1px;
}
table.list .primary { font-size: 14px; }
table.list .secondary { font-size: 11.5px; color: var(--n-500); }
table.list .secondary.mono { font-family: var(--mono); }
table.list .when { font-size: 12.5px; color: var(--n-400); white-space: nowrap; }
.rowactions { display: flex; gap: var(--s1); justify-content: flex-end; }
.rowactions form { display: inline; margin: 0; }

/* bulk-selection bar, shown only when 1+ rows are checked */
.bulkbar {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); margin-bottom: var(--s3);
  border-radius: var(--r-md); background: var(--accent-900);
  box-shadow: inset 0 0 0 1px var(--accent-700);
}
.bulkbar .count { font-size: 13px; color: var(--accent-200); }
.bulkbar .acts { display: flex; gap: var(--s2); margin-left: auto; }

.toolbar { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.toolbar .count { margin-left: auto; font-size: 12px; color: var(--n-500); }

.empty {
  padding: 44px var(--s6); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: var(--s3);
}
.empty i { font-size: 26px; color: var(--n-600); }
.empty .title { font-size: 15px; }
.empty .body { font-size: 13px; color: var(--n-500); max-width: 46ch; }

/* ------------------------------------------------------------------- tags -- */
.tag {
  display: inline-flex; align-items: center; font-size: 11px; letter-spacing: .02em;
  padding: 3px 10px; border-radius: 6px; white-space: nowrap;
}
.tag-accent  { background: var(--accent-800); color: var(--accent-100); }
.tag-neutral { background: var(--n-800); color: var(--n-100); }
.tag-outline { border: 1px solid var(--accent); color: var(--accent); }

/* --------------------------------------------------------------- messages -- */
.msg {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: 9px var(--s4); margin-bottom: var(--s4);
  border-radius: var(--r-md); font-size: 13px;
}
.msg i { font-size: 16px; margin-top: 1px; }
.msg.ok  { background: rgba(145,132,217,.12);
           box-shadow: inset 0 0 0 1px var(--accent-700); color: var(--accent-200); }
.msg.err { background: rgba(240,150,140,.12);
           box-shadow: inset 0 0 0 1px rgba(240,150,140,.35); color: var(--danger); }
.msg .pw { font-family: var(--mono); font-size: 13px; color: var(--text); }

/* transient confirmation — for copy actions */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px 14px; border-radius: var(--r-md);
  background: var(--n-900); box-shadow: var(--shadow-md); font-size: 13px;
}
.toast i { color: var(--accent); }

/* ----------------------------------------------------------------- drawer -- */
/* Access editing. Same markup whether opened from a prototype or a tester. */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 40;
  display: flex; justify-content: flex-end;
  background: rgba(41,43,49,.55);
}
.drawer {
  width: 400px; max-width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.drawer-head { display: flex; align-items: flex-start; gap: var(--s4); padding: var(--s6); border-bottom: 1px solid var(--divider); }
.drawer-head .kicker { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.drawer-head .title { font-size: 18px; font-weight: 500; margin-top: 3px; }
.drawer-head .sub { font-size: 12px; color: var(--n-500); }
.drawer-head .btn { margin-left: auto; }
.drawer-search { padding: var(--s4) var(--s6); }
.drawer-list { flex: 1; overflow-y: auto; padding: 0 var(--s6); }
.drawer-row {
  display: flex; align-items: center; gap: var(--s4);
  padding: 9px 0; border-bottom: 1px solid var(--divider); cursor: pointer;
}
.drawer-row .t { font-size: 13.5px; }
.drawer-row .s { font-size: 11.5px; color: var(--n-500); }
.drawer-row .grow { flex: 1; min-width: 0; }
.drawer-foot { display: flex; align-items: center; gap: var(--s3); padding: var(--s6); border-top: 1px solid var(--divider); }
.drawer-foot .state { font-size: 12px; color: var(--n-500); }
.drawer-foot .btn { margin-left: auto; }

/* --------------------------------------------------------- access summary -- */
.access-row {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s4) var(--s6); border-bottom: 1px solid var(--divider);
}
.access-row:last-child { border-bottom: 0; }
.access-row .avatar {
  display: grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 50%; background: var(--n-800); color: var(--n-200); font-size: 11px;
}
.access-row .who { min-width: 170px; }
.access-row .who .e { font-size: 13.5px; }
.access-row .who .s { font-size: 11px; color: var(--n-500); }
.access-row .chips { display: flex; flex-wrap: wrap; gap: var(--s2); flex: 1; }
.access-row .chips .none { font-size: 12px; color: var(--n-600); }

/* ------------------------------------------------------ tester-side lists -- */
.tester-head { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s8); }
.tester-head .who { margin-left: auto; font-size: 12.5px; color: var(--n-500); }
.protolist { display: flex; flex-direction: column; gap: var(--s3); }
.protolist .item {
  display: flex; align-items: center; gap: var(--s6);
  padding: 14px var(--s6); border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.protolist .item .grow { flex: 1; min-width: 0; }
.protolist .item .name { font-size: 16px; font-weight: 500; }
.protolist .item .meta { font-size: 12px; color: var(--n-500); margin-top: 2px; }

/* ------------------------------------------------------- row being edited -- */
tr.is-editing td { background: rgba(145,132,217,.10); }

/* --------------------------------------------------------------- mobile ---- */
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .rail {
    width: 100%; flex-direction: row; align-items: center; gap: var(--s4);
    overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--divider);
  }
  .rail-group { flex-direction: row; }
  .rail-label, .rail a .n, .rail-foot .who { display: none; }
  .rail-foot { margin: 0 0 0 auto; border: 0; }
  .page { padding: var(--s6) var(--s4) 44px; }
  .drawer { width: 100%; }
}
