/* Dalmanutha admin. Same tokens as the site and the members app so the three
   read as one product — but this is a workbench, so it is denser, colder, and
   every row is a control rather than something to read.

   ⚠️ NO INLINE STYLES ANYWHERE. The CSP is style-src 'self', which blocks
   `el.style.width = …` through the CSSOM exactly like a style="" attribute —
   Chrome logs "Applying inline style violates…" and silently drops it. Anything
   that would want a computed style gets a generated class instead. */

@font-face {
  font-family: 'Newsreader';
  src: url('/assets/fonts/newsreader.woff2') format('woff2-variations');
  font-weight: 200 700; font-display: swap;
}
@font-face {
  font-family: 'InterVar';
  src: url('/assets/fonts/inter.woff2') format('woff2-variations');
  font-weight: 100 900; font-display: swap;
}

:root {
  --paper: #FCF8F4;
  --paper-2: #F6F1EA;
  --paper-rgb: 252, 248, 244;
  --ink-rgb: 13, 56, 41;
  --ink: #0D3829;
  --deep: #0E2528;
  --sage: #646D63;
  --muted: #4C5B50;
  --hair: rgba(var(--ink-rgb), .14);
  --hair-2: rgba(var(--ink-rgb), .07);
  --raised: #fff;
  --danger: #8E2F20;
  --warn: #8A6A1F;
  --ok: #2C6A4A;
  --radius: 10px;
}

/* Dark keeps the measured contrast relationships rather than inverting: the
   same ratios the light theme documents, on the brand's own --deep canvas. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E2528; --paper-2: #081619; --paper-rgb: 14, 37, 40;
    --ink: #F2EDE6; --ink-rgb: 242, 237, 230;
    --sage: #8C9F92; --muted: #9DB0A3; --raised: #132E31;
    --hair: rgba(var(--ink-rgb), .16); --hair-2: rgba(var(--ink-rgb), .08);
    --danger: #E08A79; --warn: #D9B45E; --ok: #7FCBA4;
  }
}
:root[data-theme="dark"] {
  --paper: #0E2528; --paper-2: #081619; --paper-rgb: 14, 37, 40;
  --ink: #F2EDE6; --ink-rgb: 242, 237, 230;
  --sage: #8C9F92; --muted: #9DB0A3; --raised: #132E31;
  --hair: rgba(var(--ink-rgb), .16); --hair-2: rgba(var(--ink-rgb), .08);
  --danger: #E08A79; --warn: #D9B45E; --ok: #7FCBA4;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper); color: var(--ink);
  font-family: InterVar, system-ui, sans-serif;
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }

.boot { display: grid; place-items: center; min-height: 100vh; }
.boot-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sage); animation: pulse 1.1s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .boot-dot { animation: none; opacity: .6; } }

/* ── gate ─────────────────────────────────────────────────────────────────── */
.gate { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.gate-card { width: 100%; max-width: 360px; }
.gate-title { font-family: Newsreader, serif; font-size: 1.7rem; font-weight: 500; margin: 0 0 4px; }
.gate-sub { color: var(--muted); font-size: .9rem; margin: 0 0 22px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: .74rem; letter-spacing: .07em; text-transform: uppercase; color: var(--sage); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; min-height: 44px;
  background: var(--raised); border: 1px solid var(--hair); border-radius: var(--radius);
}
.field textarea { min-height: 120px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--sage); outline-offset: 1px; }
.gate-msg { min-height: 20px; font-size: .85rem; color: var(--danger); margin: 6px 0 0; }
.gate-msg:empty { min-height: 0; margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius);
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink);
  cursor: pointer; font-weight: 500;
}
/* ⚠️ A :hover that hardcodes a colour is a theme bug waiting to happen — in dark
   mode --paper IS dark, so a hardcoded dark hover background made the label
   vanish. #fff is 15.06:1 on this green and works in both themes. */
.btn:hover { background: #0A2C20; color: #fff; border-color: #0A2C20; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--hair); }
.btn-ghost:hover { background: rgba(var(--ink-rgb), .06); color: var(--ink); border-color: var(--hair); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: .82rem; }
.btn-wide { width: 100%; }

/* ── shell ────────────────────────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: rgba(var(--paper-rgb), .92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--hair);
}
.brand { font-family: Newsreader, serif; font-size: 1.1rem; min-height: 44px; display: inline-flex; align-items: center; background: none; border: 0; cursor: pointer; }
.brand em { font-style: normal; color: var(--sage); font-size: .78rem; margin-left: 8px; letter-spacing: .08em; text-transform: uppercase; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.tab {
  min-height: 44px; padding: 0 11px; background: none; border: 0; cursor: pointer;
  color: var(--muted); border-radius: 8px; font-size: .9rem;
}
.tab:hover { background: rgba(var(--ink-rgb), .05); color: var(--ink); }
.tab.is-on { color: var(--ink); background: rgba(var(--ink-rgb), .08); font-weight: 500; }
.who { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; color: var(--sage); font-size: .84rem; }
.theme-btn { min-width: 40px; min-height: 40px; display: grid; place-items: center; background: none; border: 1px solid var(--hair); border-radius: 8px; cursor: pointer; }

main { padding: 22px 20px 60px; max-width: 1180px; margin: 0 auto; }
.vhead { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.vtitle { font-family: Newsreader, serif; font-size: 1.5rem; font-weight: 500; margin: 0; }
.vsub { color: var(--muted); font-size: .86rem; }

/* ── stat tiles ───────────────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 26px; }
.tile { background: var(--raised); border: 1px solid var(--hair); border-radius: var(--radius); padding: 13px 14px; }
.tile-n { font-family: Newsreader, serif; font-size: 1.7rem; line-height: 1.1; }
.tile-l { font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; color: var(--sage); margin-top: 3px; }
.tile-sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }

/* ── tables ───────────────────────────────────────────────────────────────── */
.card { background: var(--raised); border: 1px solid var(--hair); border-radius: var(--radius); overflow: hidden; margin-bottom: 22px; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--hair-2); }
.card-title { font-weight: 500; }
.card-title small { color: var(--sage); font-weight: 400; margin-left: 6px; }
.card-body { padding: 14px; }
.spacer { flex: 1; }

/* Wide tables scroll inside their own box; the page itself must never scroll
   sideways on a phone. */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th { text-align: left; font-size: .7rem; letter-spacing: .07em; text-transform: uppercase; color: var(--sage); font-weight: 500; padding: 9px 14px; white-space: nowrap; }
td { padding: 9px 14px; border-top: 1px solid var(--hair-2); vertical-align: top; }
tr:hover td { background: rgba(var(--ink-rgb), .03); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84em; }
.dim { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.rowacts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .74rem; border: 1px solid var(--hair); }
.pill-ok { color: var(--ok); border-color: currentColor; }
.pill-warn { color: var(--warn); border-color: currentColor; }
.pill-bad { color: var(--danger); border-color: currentColor; }

.empty { padding: 30px 14px; text-align: center; color: var(--muted); font-size: .9rem; }

/* ── forms / editor ───────────────────────────────────────────────────────── */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.editor { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; align-items: start; }
.preview { background: var(--raised); border: 1px solid var(--hair); border-radius: var(--radius); padding: 16px; }
.preview h4 { font-family: Newsreader, serif; font-size: 1.2rem; font-weight: 500; margin: 0 0 6px; }
.preview .pv-body { font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.preview .pv-body p { margin: 0 0 .8em; }
.hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.formrow { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.formrow .field { flex: 1; min-width: 160px; margin-bottom: 0; }

.msg { font-size: .85rem; margin: 10px 0 0; }
.msg-ok { color: var(--ok); }
.msg-bad { color: var(--danger); }

/* A minted code is shown ONCE and never again — it is not stored in clear —
   so it gets a box that is hard to miss and easy to copy. */
.reveal { border: 1px dashed var(--sage); border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; }
.reveal-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.15rem; letter-spacing: .04em; }

@media (max-width: 900px) {
  .editor, .grid2, .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  main { padding: 16px 14px 50px; }
  .top { padding: 8px 14px; }
  th, td { padding: 8px 10px; }
  .tabs { order: 3; flex-basis: 100%; }
}

/* ── imported identity + uploads ──────────────────────────────────────────── */
.ident { border: 1px solid var(--hair); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; background: var(--raised); }
.ident-banner { width: 100%; height: 96px; object-fit: cover; display: block; }
.ident-row { display: flex; align-items: center; gap: 11px; padding: 10px 12px; }
.ident-logo { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; border: 1px solid var(--hair); }
.ident-name { font-weight: 500; }
.ident-meta { font-size: .78rem; color: var(--sage); }

.uploads { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.upl { position: relative; display: inline-flex; }
.upl img { width: 74px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--hair); display: block; }
.upl-x {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--danger); color: #fff; border: 0; cursor: pointer; line-height: 1; font-size: 13px;
}
.upl-add {
  width: 74px; height: 56px; border: 1px dashed var(--hair); border-radius: 8px;
  display: grid; place-items: center; cursor: pointer; color: var(--sage); font-size: 20px;
}
.upl-add:hover { border-color: var(--sage); color: var(--ink); }
