/* ═══════════════════════════════════════════════════════════════════
   GLASS BRIDGE — legacy class names → Liquid Glass
   ═══════════════════════════════════════════════════════════════════

   glass.css is a verbatim copy of the original design system and should
   stay that way, so nothing here edits it. This file adapts the class
   vocabulary the Workers rebuild happened to ship with.

   Two vocabularies need adapting:

     • The short names (.fld .tbl .top .ghost .sm .tile) that the Hub
       used and that I copied into the Portal and Tarly Admin.
     • The .admin-* / .auth-* / .sb-* names I invented for Site Admin.

   Aliasing rather than rewriting ~90 page files is a deliberate call:
   the pages themselves work, and find-and-replace across all of them is
   how subtle breakage gets introduced. New markup should use the glass
   names directly — everything below is a compatibility layer, and a
   name can be deleted from here once no page renders it.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Layout aliases ──────────────────────────────────────────────── */
/* The original had NO wrapper: body was the flex row, with .sidebar and
   .main as its direct children (glass.css still sets body{display:flex}).
   The rebuild wraps both in .shell, which therefore becomes a flex ITEM
   of body — and a flex item does not grow unless told to. Without flex:1
   it shrinks to its content width, so .main's own flex:1 resolves against
   a collapsed parent and the whole page renders as a narrow column beside
   the sidebar. That was the "acting weird" layout on 2026-08-05.
   min-width:0 lets wide tables scroll inside instead of forcing .shell
   wider than the viewport. */
.shell { display: flex; flex: 1; min-width: 0; min-height: 100vh; }
.shell > .main, .shell > main { min-width: 0; }
.side  { /* alias of .sidebar */
  width: 232px; min-height: 100vh; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 14px 12px 14px 14px;
  background: transparent; border: none; z-index: 5;
}
.side::before {
  content: ""; position: absolute; inset: 14px 0 14px 12px;
  background: var(--glass-1);
  border: 1px solid var(--edge); border-top-color: var(--edge-top);
  border-radius: var(--radius-lg);
  backdrop-filter: var(--blur-md); -webkit-backdrop-filter: var(--blur-md);
  box-shadow: var(--shadow-2), inset 0 1px 0 var(--edge-top);
  z-index: -1;
}
.side > * { position: relative; z-index: 1; }

/* Sidebar internals: .brand/.logo, plain <a>, .on, .side-foot, .who/.av */
.side .brand { padding: 18px 16px 14px; display: flex; align-items: center; gap: 10px; }
.side .brand b { font-family: Sora, sans-serif; font-size: 1rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); display: block; }
.side .brand small { color: var(--muted); font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; }
.side .brand .logo {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem; color: #1a1204;
  background: linear-gradient(145deg, var(--amber), var(--amber-strong));
  box-shadow: 0 0 14px var(--amber-dim);
}
.side nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 8px; flex: 1; overflow-y: auto; }
.side nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  color: var(--subtle); font-size: .84rem; font-weight: 500;
  text-decoration: none; border: 1px solid transparent;
  transition: background var(--dur-base), color var(--dur-base);
}
.side nav a:hover { background: var(--glass-2); color: var(--text); }
.side nav a.on {
  background: var(--glass-3); color: var(--text);
  border-color: var(--edge); border-top-color: var(--edge-top);
  box-shadow: inset 0 1px 0 var(--edge-top);
}
.side nav a.on svg { color: var(--amber); }
.side nav svg { width: 16px; height: 16px; flex-shrink: 0; }

.side-foot { padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.who {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: var(--radius);
  background: var(--glass-1); border: 1px solid var(--edge);
  border-top-color: var(--edge-top);
  font-size: .8rem; color: var(--subtle);
}
.av {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .72rem; color: #1a1204;
  background: linear-gradient(145deg, var(--amber), var(--amber-strong));
}
/* Rendered as a <button> inside a form. These four declarations used to be
   an inline style attribute on the element, which beat every rule below it —
   the control rendered as bare text. Keep them here, in the cascade. */
.logout {
  width: 100%; text-align: left; cursor: pointer; font: inherit;
  padding: 8px 11px; border-radius: var(--radius);
  background: var(--btn-ghost-bg); border: 1px solid var(--edge);
  color: var(--muted); font-size: .78rem; font-weight: 600;
  transition: background var(--dur-base), color var(--dur-base);
}
.logout:hover { background: var(--btn-ghost-hover); color: var(--red); }

/* .top was the old topbar; .main already exists in glass.css.
   The three .shell panels render page bodies straight into .main with no
   .page-content wrapper, so the gutter has to live on .main itself — which
   is why .top carries no horizontal padding of its own. */
.shell > .main, .shell > main { padding: 0 32px 32px; }
.top {
  padding: 18px 0 6px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.top h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.015em; color: var(--text); }
.top .sub, .top p { color: var(--muted); font-size: .84rem; }

/* ── Component aliases ───────────────────────────────────────────── */
.fld { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.fld > label, .lbl {
  font-size: .76rem; font-weight: 600; letter-spacing: .02em;
  text-transform: uppercase; color: var(--muted);
}
.fld input, .fld select, .fld textarea { width: 100%; }

.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }

/* Buttons: pages write class="btn ghost" / "btn sm" / "btn danger". */
.btn.ghost, a.ghost, button.ghost {
  background: var(--btn-ghost-bg); color: var(--text);
  border: 1px solid var(--edge); border-top-color: var(--edge-top);
  backdrop-filter: var(--blur-sm); -webkit-backdrop-filter: var(--blur-sm);
}
.btn.ghost:hover, a.ghost:hover, button.ghost:hover { background: var(--btn-ghost-hover); }
.btn.sm, a.sm, button.sm { padding: 6px 13px; font-size: .78rem; }
.btn.danger, a.danger, button.danger {
  background: var(--red-dim); color: var(--red);
  border: 1px solid rgba(248,113,113,.3);
}
.btn.danger:hover, a.danger:hover, button.danger:hover { background: rgba(248,113,113,.22); }

/* Tables: pages render a bare .tbl rather than .table-wrap > table. */
.tbl {
  width: 100%; border-collapse: collapse; font-size: .84rem;
  background: var(--glass-1);
  border: 1px solid var(--edge); border-top-color: var(--edge-top);
  border-radius: var(--radius-lg); overflow: hidden;
  backdrop-filter: var(--blur-sm); -webkit-backdrop-filter: var(--blur-sm);
  box-shadow: var(--shadow-1);
}
.tbl th {
  background: var(--thead-bg); color: var(--muted);
  font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  text-align: left; padding: 11px 14px;
  border-bottom: 1px solid var(--edge);
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--row-border); color: var(--subtle); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background var(--dur-base); }
.tbl tbody tr:hover { background: var(--hover-bg); }

/* Stat tiles → glass stat cards. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.tile {
  padding: 16px 18px; border-radius: var(--radius-lg);
  background: var(--glass-1);
  border: 1px solid var(--edge); border-top-color: var(--edge-top);
  backdrop-filter: var(--blur-md); -webkit-backdrop-filter: var(--blur-md);
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--edge-top);
  transition: transform var(--dur-base), background var(--dur-base), box-shadow var(--dur-base);
}
.tile:hover { transform: translateY(-2px); background: var(--glass-2); box-shadow: var(--shadow-2), inset 0 1px 0 var(--edge-top); }
.tile .big, .tile b { display: block; font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; color: var(--text); font-family: Sora, sans-serif; }
.tile .meta, .tile small { color: var(--muted); font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; }

.grid { display: grid; gap: 14px; }
.grid.wide, .wide { grid-column: 1 / -1; }
.empty {
  padding: 40px 20px; text-align: center; color: var(--muted); font-size: .88rem;
  background: var(--glass-1); border: 1px dashed var(--edge); border-radius: var(--radius-lg);
}
.err, .flash.err { color: var(--flash-error-text); }
.flash.ok { color: var(--flash-success-text); }
.tone { color: var(--muted); font-size: .8rem; }

/* ── Site Admin's admin-* / sb-* vocabulary ──────────────────────── */
.admin-body { margin: 0; }
.admin-sidebar { /* handled by .sidebar rules when present */ }
.admin-main { flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.admin-topbar { padding: 18px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -.015em; color: var(--text); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.admin-card {
  padding: 20px 22px; border-radius: var(--radius-lg);
  background: var(--glass-1);
  border: 1px solid var(--edge); border-top-color: var(--edge-top);
  backdrop-filter: var(--blur-md); -webkit-backdrop-filter: var(--blur-md);
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--edge-top);
  margin-bottom: 18px;
}
.admin-section-title { font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.admin-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.admin-label { font-size: .76rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.admin-help { color: var(--muted); font-size: .76rem; }
.admin-error-text { color: var(--red); font-size: .8rem; }
.admin-form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.admin-empty { padding: 40px 20px; text-align: center; color: var(--muted); background: var(--glass-1); border: 1px dashed var(--edge); border-radius: var(--radius-lg); }
.admin-flash { margin-bottom: 16px; }

.admin-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.admin-table-wrap {
  border-radius: var(--radius-lg); overflow: hidden;
  background: var(--glass-1);
  border: 1px solid var(--edge); border-top-color: var(--edge-top);
  backdrop-filter: var(--blur-sm); -webkit-backdrop-filter: var(--blur-sm);
  box-shadow: var(--shadow-1);
}
.admin-table th { background: var(--thead-bg); color: var(--muted); font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--edge); }
.admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--row-border); color: var(--subtle); }
.admin-table tbody tr:hover { background: var(--hover-bg); }
.admin-td-title { color: var(--text); font-weight: 600; }
.admin-td-slug { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; }
.admin-td-actions { display: flex; gap: 8px; justify-content: flex-end; }
.admin-status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--radius-pill); font-size: .72rem; font-weight: 600; background: var(--glass-2); border: 1px solid var(--edge); color: var(--subtle); }

.admin-select, .admin-textarea { width: 100%; }
.admin-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-pill);
  font-size: .86rem; font-weight: 600; letter-spacing: -.005em;
  border: 1px solid var(--edge); border-top-color: var(--edge-top);
  background: var(--btn-ghost-bg); color: var(--text);
  cursor: pointer; text-decoration: none;
  backdrop-filter: var(--blur-sm); -webkit-backdrop-filter: var(--blur-sm);
  transition: background var(--dur-base), transform var(--dur-base);
}
.admin-btn:hover { background: var(--btn-ghost-hover); }
.admin-btn:active { transform: translateY(1px); }
.admin-btn-primary {
  background: linear-gradient(145deg, var(--amber), var(--amber-strong));
  color: #1a1204; border-color: var(--amber-border);
  box-shadow: 0 4px 18px var(--amber-dim), inset 0 1px 0 rgba(255,255,255,.35);
}
.admin-btn-primary:hover { filter: brightness(1.06); background: linear-gradient(145deg, var(--amber), var(--amber-strong)); }
.admin-btn-ghost { background: var(--btn-ghost-bg); }
.admin-btn-danger { background: var(--red-dim); color: var(--red); border-color: rgba(248,113,113,.3); }
.admin-btn-sm { padding: 6px 13px; font-size: .78rem; }

.sb-icon { width: 16px; height: 16px; flex-shrink: 0; }
.sb-brand-logo {
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem; color: #1a1204;
  background: linear-gradient(145deg, var(--amber), var(--amber-strong));
  box-shadow: 0 0 14px var(--amber-dim);
}
.sb-brand-name { font-family: Sora, sans-serif; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.sb-brand-sub { color: var(--muted); font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; }
.sb-section-label { padding: 14px 14px 5px; font-size: .66rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); opacity: .75; }
.sb-divider { height: 1px; background: var(--edge); margin: 8px 12px; }
.sb-theme-btn { /* alias of .theme-toggle */ }

/* Site Admin renders .sb-item where the glass sidebar uses .sb-link. */
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  color: var(--subtle); font-size: .84rem; font-weight: 500;
  text-decoration: none; border: 1px solid transparent;
  transition: background var(--dur-base), color var(--dur-base);
}
.sb-item:hover { background: var(--glass-2); color: var(--text); }
.sb-item.active {
  background: var(--glass-3); color: var(--text);
  border-color: var(--edge); border-top-color: var(--edge-top);
  box-shadow: inset 0 1px 0 var(--edge-top);
}
.sb-item.active .sb-icon { color: var(--amber); }

/* ── Auth pages (login / 2FA / enrolment / first-run setup) ──────── */
/* Centred glass panel over the ambient background, matching the old
   Tarly login rather than the flat card the rebuild shipped. */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px; padding: 34px 32px;
  border-radius: var(--radius-lg);
  background: var(--glass-2);
  border: 1px solid var(--edge); border-top-color: var(--edge-top);
  backdrop-filter: var(--blur-lg); -webkit-backdrop-filter: var(--blur-lg);
  box-shadow: var(--shadow-3), inset 0 1px 0 var(--edge-top);
  animation: glassPanelIn .5s cubic-bezier(.22,1,.36,1) both;
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.auth-brand-logo {
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; color: #1a1204;
  background: linear-gradient(145deg, var(--amber), var(--amber-strong));
  box-shadow: 0 0 18px var(--amber-dim);
}
.auth-brand-name { font-family: Sora, sans-serif; font-weight: 800; font-size: 1.05rem; letter-spacing: -.02em; color: var(--text); }
.auth-brand-sub { color: var(--muted); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; }
.auth-title { font-family: Sora, sans-serif; font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; color: var(--text); margin-bottom: 6px; }
.auth-sub { color: var(--muted); font-size: .85rem; line-height: 1.55; margin-bottom: 20px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.auth-label { font-size: .76rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.auth-input, .auth-code-input {
  width: 100%; padding: 11px 14px; border-radius: var(--radius);
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--edge); border-top-color: var(--edge-top);
  font: inherit; font-size: .9rem;
  transition: border-color var(--dur-base), box-shadow var(--dur-base), background var(--dur-base);
}
.auth-input:focus, .auth-code-input:focus {
  outline: none; background: var(--glass-2);
  border-color: var(--amber-border);
  box-shadow: 0 0 0 3px var(--amber-dim);
}
.auth-code-input {
  text-align: center; letter-spacing: .5em; font-size: 1.4rem; font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; padding: 14px;
}
.auth-btn {
  width: 100%; margin-top: 6px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 12px 18px; border-radius: var(--radius-pill);
  font-size: .9rem; font-weight: 700; cursor: pointer;
  color: #1a1204; border: 1px solid var(--amber-border);
  background: linear-gradient(145deg, var(--amber), var(--amber-strong));
  box-shadow: 0 4px 20px var(--amber-dim), inset 0 1px 0 rgba(255,255,255,.35);
  transition: filter var(--dur-base), transform var(--dur-base);
}
.auth-btn:hover { filter: brightness(1.06); }
.auth-btn:active { transform: translateY(1px); }
.auth-error {
  padding: 10px 13px; border-radius: var(--radius); margin-bottom: 16px;
  background: var(--red-dim); border: 1px solid rgba(248,113,113,.28);
  color: var(--flash-error-text); font-size: .84rem;
}
.auth-foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: .78rem; }
.auth-foot a { color: var(--amber); text-decoration: none; }
.auth-qr {
  display: block; margin: 0 auto 16px; border-radius: var(--radius);
  background: #fff; padding: 10px;
}
.auth-secret, .code {
  display: block; padding: 10px 13px; border-radius: var(--radius);
  background: var(--input-bg); border: 1px solid var(--edge);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem; letter-spacing: .08em; color: var(--subtle);
  word-break: break-all; text-align: center;
}

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* The sidebar collapses to a scrollable strip along the top. It must NOT
     be display:none — the original replaced it with a fixed bottom nav plus
     a drawer, and none of the four panels render those yet. Hiding it here
     would leave phones with no navigation at all. */
  .shell { display: block; }
  .side, .admin-sidebar {
    width: auto; height: auto; min-height: 0;
    position: static; overflow: visible;
    padding: 10px 10px 0;
  }
  .side::before { inset: 10px 10px 0; }
  .side .brand, .sb-brand { padding: 12px 14px 10px; }
  /* Nav scrolls sideways rather than stacking to full screen height. */
  .side nav, .sb-nav {
    flex-direction: row; overflow-x: auto; gap: 6px;
    padding: 0 8px 8px; scrollbar-width: none;
  }
  .side nav::-webkit-scrollbar, .sb-nav::-webkit-scrollbar { display: none; }
  .side nav a, .sb-link, .sb-item { white-space: nowrap; flex-shrink: 0; }
  .side-foot, .sb-footer { flex-direction: row; align-items: center; gap: 8px; }
  .side-foot .who, .sb-user { flex: 1; }

  .shell > .main, .shell > main { padding: 0 16px 24px; }
  .top, .admin-topbar { padding: 16px 0 4px; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

/* glass.css draws the active-link accent bar as an absolutely positioned
   ::before, but never gives .sb-link a positioning context — so the bar
   escapes to the nearest positioned ancestor and lands at the page edge.
   Establishing the context here keeps glass.css verbatim. */
.sb-link, .sb-item, .side nav a { position: relative; }
