/* ==========================================================================
   Knight Out Admin — Liquid Glass on deep neutral, Material grid & rails
   ========================================================================== */
:root {
  --bg: #121214;
  --bg-2: #1A1A1E;
  --text: #ECE9E4;
  --text-2: #A8A39B;
  --text-3: #75716B;
  --glass: rgba(255, 255, 255, .055);
  --glass-2: rgba(255, 255, 255, .09);
  --edge: rgba(255, 255, 255, .12);
  --spec: rgba(255, 255, 255, .55);
  --amber: #F2A65A;
  --garnet: #D9536F;
  --peacock: #2FB7A9;
  --sapphire: #6E8FE0;
  --amethyst: #A68AE6;
  --ok: #4FD1A1;
  --warn: #F2C14E;
  --err: #FF6B7A;
  --r: 22px;
  --r-sm: 14px;
  --font: "Inter", -apple-system, "SF Pro Text", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --rail: 248px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0; min-height: 100vh; color: var(--text); font: 400 15px/1.55 var(--font);
  background: var(--bg) var(--admin-bg, none) center / cover fixed no-repeat;
}
a { color: var(--peacock); text-decoration: none; }
a:hover { color: #6FE0D3; }
code { font: 500 .85em ui-monospace, "SF Mono", Menlo, monospace; background: rgba(255,255,255,.08); padding: .1em .45em; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 10px; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Ambient warm under-glows */
.ambient { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.ambient i { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .55; }
.ambient i:nth-child(1) { width: 46vw; height: 46vw; left: -12vw; top: -14vw; background: radial-gradient(circle, rgba(242,166,90,.55), transparent 65%); }
.ambient i:nth-child(2) { width: 40vw; height: 40vw; right: -10vw; top: 20vh; background: radial-gradient(circle, rgba(217,83,111,.38), transparent 65%); }
.ambient i:nth-child(3) { width: 44vw; height: 44vw; left: 30vw; bottom: -22vw; background: radial-gradient(circle, rgba(47,183,169,.32), transparent 65%); }
body[style*="--admin-bg"] .ambient i { opacity: .3; }

/* Liquid glass surface: blur + refraction tint + 1px specular edge */
.glass {
  position: relative;
  background: linear-gradient(160deg, rgba(255,255,255,.10), rgba(255,255,255,.03) 42%, rgba(255,255,255,.05));
  backdrop-filter: blur(28px) saturate(170%); -webkit-backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid var(--edge);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), inset 0 -1px 0 rgba(0,0,0,.25), 0 24px 60px -30px rgba(0,0,0,.8);
}
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; padding: 1px;
  background: linear-gradient(135deg, var(--spec), transparent 28%, transparent 70%, rgba(255,255,255,.25));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}

/* ---------- Rail ---------- */
.rail {
  position: fixed; left: 14px; top: 14px; bottom: 14px; width: var(--rail); border-radius: 28px; padding: 18px 12px;
  display: flex; flex-direction: column; gap: 6px; z-index: 40; overflow-y: auto;
}
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; color: var(--text); }
.rail-crest { width: 34px; height: 38px; }
.rail-brand b { display: block; font: 400 1.6rem/1 "Pinyon Script", cursive; letter-spacing: .01em; }
.rail-brand small { font-size: .68rem; letter-spacing: .2em; text-transform: uppercase; color: var(--text-3); }
.rail nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rail-link { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 999px; color: var(--text-2); font-weight: 500; font-size: .92rem; transition: background .2s, color .2s; position: relative; }
.rail-link:hover { background: rgba(255,255,255,.06); color: var(--text); }
.rail-link.on { color: #1A1206; background: linear-gradient(180deg, rgba(255,255,255,.45), rgba(255,255,255,0) 60%), linear-gradient(120deg, #F6C27E, var(--amber)); box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 8px 24px -8px rgba(242,166,90,.7); }
.rail-foot { border-top: 1px solid var(--edge); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }

/* ---------- Main ---------- */
.main { margin-left: calc(var(--rail) + 28px); padding: 14px 18px 60px 0; min-height: 100vh; }
.topbar { position: sticky; top: 14px; z-index: 30; display: flex; align-items: center; gap: 12px; border-radius: 999px; padding: 8px 8px 8px 22px; margin-bottom: 18px; }
.page-title { font-size: 1.15rem; font-weight: 600; margin: 0 auto 0 0; letter-spacing: -.01em; }
.rail-toggle { display: none; }
.user-pill { display: flex; align-items: center; gap: 10px; padding: 4px 14px 4px 4px; border-radius: 999px; background: rgba(255,255,255,.06); color: var(--text); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #1A1206; background: linear-gradient(140deg, #FFD9A6, var(--amber)); box-shadow: inset 0 1px 0 rgba(255,255,255,.7); }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta b { font-size: .86rem; font-weight: 600; }
.role { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
.role-admin { color: var(--amber); } .role-editor { color: var(--peacock); } .role-viewer { color: var(--sapphire); }
.content { display: grid; gap: 18px; }

/* ---------- Grid & cards ---------- */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.c-12 { grid-column: span 12; } .c-8 { grid-column: span 8; } .c-7 { grid-column: span 7; } .c-6 { grid-column: span 6; }
.c-5 { grid-column: span 5; } .c-4 { grid-column: span 4; } .c-3 { grid-column: span 3; }
.card { border-radius: var(--r); padding: 22px; }
.card-h { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; }
.card-h h2 { font-size: 1rem; font-weight: 600; margin: 0 auto 0 0; letter-spacing: -.005em; }
.card-sub { color: var(--text-2); font-size: .88rem; margin: -10px 0 16px; }
.muted { color: var(--text-2); }
.tiny { font-size: .78rem; color: var(--text-3); }

/* Stat tiles */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }
.stat-val { font-size: 2.1rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: .82rem; color: var(--text-3); }
.glow-amber { box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 30px 60px -36px rgba(242,166,90,.9); }
.glow-teal { box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 30px 60px -36px rgba(47,183,169,.9); }
.glow-garnet { box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 30px 60px -36px rgba(217,83,111,.9); }
.meter { height: 6px; border-radius: 9px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--amber), #FFD9A6); }

/* Hero card on dashboard */
.hero-card { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: center; padding: 28px; overflow: hidden; }
.hero-card .eyebrow { font-size: .74rem; letter-spacing: .22em; text-transform: uppercase; color: var(--amber); margin: 0 0 6px; }
.hero-card h2 { font: italic 500 2.4rem/1.05 "Cormorant Garamond", serif; margin: 0 0 8px; }
.cd { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cd div { border-radius: 18px; padding: 14px 6px; text-align: center; background: rgba(255,255,255,.05); border: 1px solid var(--edge); }
.cd b { display: block; font-size: 1.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.cd span { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-2); }

/* ---------- Chips & pills ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; font-size: .84rem; font-weight: 500; color: var(--text); background: rgba(255,255,255,.07); border: 1px solid var(--edge); cursor: pointer; white-space: nowrap; }
.chip .ic { width: 16px; height: 16px; }
.chip:hover { background: rgba(255,255,255,.12); color: var(--text); }
.chip-sm { padding: 3px 10px; font-size: .76rem; font-family: ui-monospace, Menlo, monospace; }
.chip-glow { border-color: rgba(242,166,90,.45); box-shadow: 0 0 22px -6px rgba(242,166,90,.6); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; letter-spacing: .03em; }
.badge-ok { color: var(--ok); background: rgba(79,209,161,.12); }
.badge-warn { color: var(--warn); background: rgba(242,193,78,.12); }
.badge-off { color: var(--text-3); background: rgba(255,255,255,.06); }
.badge-amber { color: var(--amber); background: rgba(242,166,90,.14); }

/* ---------- Gel buttons ---------- */
.btn {
  --c1: #FFD9A6; --c2: var(--amber); --glow: rgba(242,166,90,.75); --tx: #1A1206;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; white-space: nowrap;
  font: 600 .9rem var(--font); padding: 11px 20px; border-radius: 999px; color: var(--tx); position: relative;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), filter .2s;
}
.btn .ic { width: 17px; height: 17px; }
.btn-gel {
  background: linear-gradient(180deg, rgba(255,255,255,.65) 0%, rgba(255,255,255,.12) 48%, rgba(255,255,255,0) 52%), linear-gradient(140deg, var(--c1), var(--c2));
  box-shadow: inset 0 1px 1px rgba(255,255,255,.9), inset 0 -3px 8px rgba(0,0,0,.18), 0 10px 26px -8px var(--glow), 0 0 0 1px rgba(255,255,255,.18);
}
.btn-gel:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: inset 0 1px 1px rgba(255,255,255,.9), inset 0 -3px 8px rgba(0,0,0,.18), 0 16px 34px -8px var(--glow), 0 0 0 1px rgba(255,255,255,.25); color: var(--tx); }
.btn-gel:active { transform: translateY(1px); }
.btn-teal { --c1: #8BF0E4; --c2: var(--peacock); --glow: rgba(47,183,169,.75); --tx: #04201D; }
.btn-garnet { --c1: #FF9AAE; --c2: var(--garnet); --glow: rgba(217,83,111,.75); --tx: #2A060E; }
.btn-glass { color: var(--text); background: rgba(255,255,255,.07); box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 0 0 1px var(--edge); }
.btn-glass:hover { background: rgba(255,255,255,.12); color: var(--text); }
.btn-sm { padding: 7px 13px; font-size: .82rem; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; border: 0; cursor: pointer; color: var(--text-2); background: rgba(255,255,255,.06); box-shadow: inset 0 0 0 1px var(--edge); }
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.12); }
.icon-btn.danger:hover { color: var(--err); }
.icon-btn .ic { width: 17px; height: 17px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions.end { justify-content: flex-end; }
button:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none !important; }

/* ---------- Forms ---------- */
.fs { border: 0; padding: 0; margin: 0; min-width: 0; }
.fs[disabled] input, .fs[disabled] textarea, .fs[disabled] select { opacity: .7; }
.readonly-note { display: flex; gap: 8px; align-items: center; font-size: .85rem; color: var(--sapphire); background: rgba(110,143,224,.1); border-radius: 12px; padding: 9px 12px; margin: 0 0 14px; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px 16px; }
.f { display: flex; flex-direction: column; gap: 6px; grid-column: span 12; }
.f.half { grid-column: span 6; } .f.third { grid-column: span 4; } .f.quarter { grid-column: span 3; }
label, .lbl { font-size: .8rem; font-weight: 500; color: var(--text-2); }
.hint { font-size: .78rem; color: var(--text-3); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=date], input[type=time], input[type=number], input:not([type]), select, textarea {
  width: 100%; font: 400 .94rem var(--font); color: var(--text); background: rgba(0,0,0,.28); border: 1px solid var(--edge); border-radius: var(--r-sm);
  padding: 11px 14px; transition: border-color .2s, box-shadow .2s, background .2s; color-scheme: dark;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: rgba(242,166,90,.7); box-shadow: 0 0 0 4px rgba(242,166,90,.15); background: rgba(0,0,0,.36); }
input[type=file] { color: var(--text-2); font-size: .85rem; }
input[type=file]::file-selector-button { font: 600 .82rem var(--font); border: 0; border-radius: 999px; padding: 8px 14px; margin-right: 10px; cursor: pointer; color: var(--text); background: rgba(255,255,255,.1); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .9rem; color: var(--text); }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: 99px; background: rgba(255,255,255,.12); position: relative; cursor: pointer; transition: background .2s; box-shadow: inset 0 0 0 1px var(--edge); flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: linear-gradient(180deg, #fff, #D9D6D0); box-shadow: 0 2px 6px rgba(0,0,0,.4); transition: transform .25s var(--ease); }
.switch input:checked { background: linear-gradient(120deg, #F6C27E, var(--amber)); box-shadow: 0 0 16px -4px rgba(242,166,90,.8); }
.switch input:checked::after { transform: translateX(18px); }
fieldset legend { font-weight: 600; font-size: .9rem; padding: 0; margin-bottom: 10px; }
.token-help { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.token-help span { font-size: .76rem; color: var(--text-3); }
.divider { border: 0; border-top: 1px solid var(--edge); margin: 18px 0; }

/* ---------- Lists / tables ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item-sub { font-size: .82rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb { width: 54px; height: 42px; border-radius: 10px; object-fit: contain; background: rgba(255,255,255,.9); flex: none; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
.t th { text-align: left; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); font-weight: 600; padding: 8px 10px; }
.t td { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.07); vertical-align: middle; }
.t tr:hover td { background: rgba(255,255,255,.025); }
.table-wrap { overflow-x: auto; }
details.edit { border-radius: 16px; background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.08); }
details.edit[open] { background: rgba(255,255,255,.055); }
details.edit > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
details.edit > summary::-webkit-details-marker { display: none; }
details.edit > summary .chev { margin-left: auto; transition: transform .25s; color: var(--text-3); }
details.edit[open] > summary .chev { transform: rotate(180deg); }
details.edit > .body { padding: 4px 16px 16px; }

/* Art grid */
.art-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.art-card { border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.art-prev { aspect-ratio: 16 / 9; background: #F6F1E7; display: grid; place-items: center; position: relative; }
.art-prev img { width: 100%; height: 100%; object-fit: contain; }
.art-prev .empty { color: #8C857A; font-size: .85rem; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.art-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.prompt { font-size: .82rem; line-height: 1.5; color: var(--text-2); background: rgba(0,0,0,.25); border-radius: 12px; padding: 10px 12px; max-height: 120px; overflow: auto; border: 1px solid rgba(255,255,255,.06); }

/* Media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.media-tile { border-radius: 16px; overflow: hidden; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); }
.media-tile img { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #F6F1E7; }
.media-tile .mt-body { padding: 8px 10px; display: flex; align-items: center; gap: 6px; }
.media-tile .mt-name { font-size: .76rem; color: var(--text-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Permission matrix */
.matrix td:not(:first-child), .matrix th:not(:first-child) { text-align: center; width: 110px; }

/* Checklist */
.check { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid rgba(255,255,255,.06); font-size: .9rem; }
.check:first-child { border-top: 0; }
.dotc { width: 20px; height: 20px; border-radius: 50%; flex: none; display: grid; place-items: center; margin-top: 1px; }
.dotc.ok { background: rgba(79,209,161,.18); color: var(--ok); }
.dotc.todo { background: rgba(242,193,78,.15); color: var(--warn); }
.dotc .ic { width: 13px; height: 13px; stroke-width: 2.4; }

/* Alerts */
.flash-stack { display: grid; gap: 8px; margin-bottom: 4px; }
.alert { border-radius: 14px; padding: 11px 16px; font-size: .9rem; border: 1px solid; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.alert.ok { color: #BDF5E0; background: rgba(79,209,161,.12); border-color: rgba(79,209,161,.3); }
.alert.warn { color: #FBE3A7; background: rgba(242,193,78,.12); border-color: rgba(242,193,78,.3); }
.alert.err { color: #FFC5CC; background: rgba(255,107,122,.12); border-color: rgba(255,107,122,.3); }
.alert.info { color: #CCD8FA; background: rgba(110,143,224,.12); border-color: rgba(110,143,224,.3); }

/* Link preview rows */
.linkrow { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid rgba(255,255,255,.06); font-size: .88rem; }
.linkrow:first-child { border-top: 0; }
.linkrow .lbl { width: 130px; flex: none; }
.linkrow a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Auth */
.auth-page { display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); border-radius: 30px; padding: 34px 30px; }
.auth-title { font: italic 500 2.2rem/1.1 "Cormorant Garamond", serif; margin: 0 0 6px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; margin-bottom: 22px; }
.auth-brand .rail-crest { width: 52px; height: 58px; }
.auth-brand b { font: 400 2.6rem/1 "Pinyon Script", cursive; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack .btn { width: 100%; padding: 13px; }

/* Responsive */
@media (max-width: 1100px) {
  .c-8, .c-7, .c-6, .c-5, .c-4 { grid-column: span 12; }
  .c-3 { grid-column: span 6; }
  .hero-card { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .rail { transform: translateX(-110%); transition: transform .3s var(--ease); }
  body.rail-open .rail { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .3s; }
  body.rail-open .scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; padding: 10px 10px 60px; }
  .topbar { top: 10px; padding-left: 8px; }
  .rail-toggle { display: inline-grid; }
  .user-meta { display: none; }
  .user-pill { padding: 3px; }
  .f.half, .f.third, .f.quarter { grid-column: span 12; }
  .c-3 { grid-column: span 12; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.item > .fs { flex: 1; min-width: 0; }

/* Official wordmark in the admin (same lockup as the public site) */
.rail-heart { width: auto; height: 40px; color: #C09B62; flex: none; }
.rail-brand > span { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.auth-brand { gap: 2px; }

/* Official logo in the admin, in cream on the dark glass */
.pko-logo { display: block; height: auto; color: #EFE6D4; }
.rail-logo { width: 180px; }
.rail-brand { flex-direction: column; align-items: flex-start; }
.rail-brand > span { gap: 6px; }
.auth-logo { width: 280px; margin: 0 auto 8px; }
.rail-heart, .rail-crest { display: none; }
.rail-logo { width: 208px; }
