/* ============================================================================
   Muster design system
   Token-driven theming. All colors/effects read from CSS variables so that:
     - light / dark / system themes swap one set of tokens,
     - guild overrides later just set a few variables on the app shell.
   ============================================================================ */

/* ---- Base reset ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg-base);
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
img { max-width: 100%; }

/* ---- Design tokens: LIGHT (sky / cloud) ---------------------------------- */
:root {
    --accent: #2563eb;
    --accent-soft: #38bdf8;
    --text: #0f2747;
    --text-muted: #44597b;
    --surface: rgba(255, 255, 255, 0.66);

    --glass-bg: rgba(255, 255, 255, 0.42);
    --glass-border: rgba(255, 255, 255, 0.85);
    --glass-highlight: rgba(255, 255, 255, 0.65);
    --glass-shadow: 0 10px 34px rgba(31, 73, 145, 0.20);
    --glass-blur: 18px;

    --bg-base: #bfe0ff;
    /* Sky with soft "clouds" + tinted light blooms for the frost to pick up */
    --bg-image:
        radial-gradient(45% 40% at 12% 10%, rgba(255, 255, 255, 0.95) 0%, transparent 60%),
        radial-gradient(40% 36% at 88% 16%, rgba(125, 211, 252, 0.55) 0%, transparent 58%),
        radial-gradient(50% 45% at 95% 85%, rgba(167, 199, 255, 0.6) 0%, transparent 60%),
        radial-gradient(60% 55% at 30% 100%, rgba(186, 230, 253, 0.85) 0%, transparent 62%),
        linear-gradient(160deg, #aed6ff 0%, #d9efff 55%, #eaf6ff 100%);

    --radius: 16px;
    --radius-sm: 10px;
    --border: rgba(15, 39, 71, 0.12);
    --danger: #dc2626;

    /* Content cards (shop/listing tiles): a calmer, near-opaque surface so a grid of them reads as distinct
       objects against the textured background — vs the translucent .glass used for page-level panels. */
    --card-bg: rgba(255, 255, 255, 0.92);
    --card-border: rgba(15, 39, 71, 0.10);
    --card-shadow: 0 1px 2px rgba(31, 73, 145, 0.06), 0 6px 16px rgba(31, 73, 145, 0.10);
    --card-shadow-hover: 0 4px 10px rgba(31, 73, 145, 0.12), 0 14px 30px rgba(31, 73, 145, 0.18);
}

/* ---- Design tokens: DARK (deep blue) ------------------------------------- */
:root[data-theme="dark"] {
    --accent: #60a5fa;
    --accent-soft: #3b82f6;
    --text: #e8effc;
    --text-muted: #9fb3d4;
    --surface: rgba(28, 50, 96, 0.45);

    --glass-bg: rgba(42, 70, 128, 0.30);
    --glass-border: rgba(150, 185, 255, 0.30);
    --glass-highlight: rgba(255, 255, 255, 0.12);
    --glass-shadow: 0 12px 40px rgba(0, 8, 28, 0.55);
    --glass-blur: 20px;

    --bg-base: #081225;
    /* Vivid, multi-hue blooms so the frosted blur has something to reveal */
    --bg-image:
        radial-gradient(48% 42% at 10% 6%, rgba(56, 130, 246, 0.55) 0%, transparent 60%),
        radial-gradient(42% 38% at 90% 12%, rgba(99, 102, 241, 0.45) 0%, transparent 56%),
        radial-gradient(38% 34% at 96% 78%, rgba(34, 211, 238, 0.22) 0%, transparent 60%),
        radial-gradient(55% 50% at 35% 108%, rgba(37, 99, 235, 0.35) 0%, transparent 60%),
        linear-gradient(160deg, #06122b 0%, #0b1f48 55%, #0a1838 100%);

    --border: rgba(159, 179, 212, 0.20);

    --card-bg: rgba(30, 52, 96, 0.92);
    --card-border: rgba(150, 185, 255, 0.16);
    --card-shadow: 0 1px 2px rgba(0, 8, 28, 0.40), 0 8px 20px rgba(0, 8, 28, 0.45);
    --card-shadow-hover: 0 4px 10px rgba(0, 8, 28, 0.50), 0 16px 34px rgba(0, 8, 28, 0.62);
}

/* System mode (no explicit data-theme) follows the OS dark preference. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --accent: #60a5fa;
        --accent-soft: #3b82f6;
        --text: #e8effc;
        --text-muted: #9fb3d4;
        --surface: rgba(18, 36, 71, 0.55);
        --glass-bg: rgba(30, 54, 102, 0.38);
        --glass-border: rgba(120, 160, 230, 0.22);
        --glass-shadow: 0 10px 36px rgba(0, 8, 28, 0.55);
        --glass-blur: 16px;
        --bg-base: #081225;
        --bg-image:
            radial-gradient(55% 45% at 18% 12%, rgba(56, 102, 196, 0.45) 0%, rgba(56, 102, 196, 0) 60%),
            radial-gradient(45% 40% at 85% 20%, rgba(37, 99, 235, 0.30) 0%, rgba(37, 99, 235, 0) 55%),
            radial-gradient(70% 60% at 75% 95%, rgba(14, 35, 80, 0.8) 0%, rgba(14, 35, 80, 0) 60%),
            linear-gradient(180deg, #07142e 0%, #0d2148 100%);
        --border: rgba(159, 179, 212, 0.18);

        --card-bg: rgba(26, 46, 88, 0.92);
        --card-border: rgba(150, 185, 255, 0.15);
        --card-shadow: 0 1px 2px rgba(0, 8, 28, 0.40), 0 8px 20px rgba(0, 8, 28, 0.45);
        --card-shadow-hover: 0 4px 10px rgba(0, 8, 28, 0.50), 0 16px 34px rgba(0, 8, 28, 0.62);
    }
}

/* ---- Fixed background layer --------------------------------------------- */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: var(--bg-image);
    background-attachment: fixed;
}

/* ---- Glass utility ------------------------------------------------------- */
.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    /* outer depth shadow + a bright inset top edge sells the "pane of glass" look */
    box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
    backdrop-filter: blur(var(--glass-blur)) saturate(160%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
}

/* ---- App shell / layout -------------------------------------------------- */
.app-shell { display: flex; flex-direction: column; min-height: 100dvh; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    margin: 0.75rem;
    border-radius: var(--radius);
}
.topbar .brand {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.02em;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    line-height: 0;
}
.topbar .brand:hover { text-decoration: none; }
.brand-lockup { height: 2.1rem; width: auto; display: block; }
/* Light variant by default; dark variant shows only when data-theme="dark" or OS dark + no explicit light. */
.brand-lockup-dark { display: none; }
:root[data-theme="dark"] .brand-lockup-light { display: none; }
:root[data-theme="dark"] .brand-lockup-dark { display: block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .brand-lockup-light { display: none; }
    :root:not([data-theme="light"]) .brand-lockup-dark { display: block; }
}
.topbar nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.topbar nav .user { color: var(--text-muted); font-size: 0.9rem; }

.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
    flex: 1;
}

.panel { padding: 1.5rem 1.75rem; margin-bottom: 1.25rem; }

.footer {
    padding: 1.25rem;
    margin: 0.75rem;
    border-radius: var(--radius);
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--text); }
.footer-brand { font-weight: 600; color: var(--text); }
.footer-tagline { color: var(--text-muted); }
.footer-links { margin-left: auto; display: flex; gap: 1rem; }

/* ---- Hero (public) ------------------------------------------------------- */
.hero { text-align: center; padding: 3rem 1.5rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
.hero p { color: var(--text-muted); font-size: 1.1rem; max-width: 40ch; margin: 0.5rem auto 1.5rem; }

/* ---- Buttons ------------------------------------------------------------- */
.btn, button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.05s ease;
}
.btn:hover, button[type="submit"]:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active, button[type="submit"]:active { transform: translateY(1px); }
.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}
.btn-warn { background: #d97706; color: #fff; border-color: transparent; }
.btn-warn:hover { filter: brightness(1.08); }
.btn-danger { background: #dc2626; color: #fff; border-color: transparent; }
.btn-danger:hover { filter: brightness(1.08); }
/* Positive primary (e.g. self check-in). */
.btn-success { background: #16a34a; color: #fff; border-color: transparent; }
.btn-success:hover { filter: brightness(1.08); }
/* Quiet destructive: red outline that fills on hover — for removals that aren't the primary destructive action. */
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.btn-danger-ghost:hover { background: var(--danger); color: #fff; border-color: transparent; }
.btn .material-symbols-outlined { font-size: 1.05rem; }

/* ---- Theme toggle (segmented) ------------------------------------------- */
/* Segmented icon control (system / light / dark), Claude-desktop style. Inline by default (fits the public
   topbar); stretched to fill only in the guild sidebar footer. */
.theme-toggle { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.foot-row .theme-toggle { display: flex; width: 100%; }
.theme-toggle button {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    padding: 0.4rem 0;
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s ease, color 0.12s ease;
}
.theme-toggle button .material-symbols-outlined { font-size: 1.2rem; }
.theme-toggle button:hover { color: var(--text); }
.theme-toggle button[aria-pressed="true"] { background: var(--card-bg); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }

/* ---- Lists / cards ------------------------------------------------------- */
.guild-list, .admin-links { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.guild-list li, .admin-links li {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.guild-list a, .admin-links a { font-weight: 600; }

.badge {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: #04122b;
}

/* ---- Tables -------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
table.leaderboard th, table.leaderboard td,
table.approvals th, table.approvals td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
}
table th { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* ---- Forms --------------------------------------------------------------- */
form label { display: block; margin-bottom: 0.9rem; color: var(--text-muted); font-size: 0.9rem; }
/* Themed inputs/selects everywhere (not just inside <form>) — interactive pages drop the form wrapper and
   drive actions via @onclick + bound state, so the theme can't depend on the wrapper. Width is intentionally
   NOT set here so inline inputs (note fields, search) keep their content width; <form>-wrapped inputs get
   full-width via the rule below. The checkbox switch styling further down overrides via its own selector. */
input:not([type="checkbox"]):not([type="radio"]),
select {
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
form input:not([type="checkbox"]):not([type="radio"]),
form select {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
}

/* ---- Checkboxes render as toggle switches (global) ----------------------- */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: 2.4rem;
    height: 1.35rem;
    margin: 0;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--border);
    cursor: pointer;
    vertical-align: middle;
    transition: background 0.15s ease, border-color 0.15s ease;
}
input[type="checkbox"]::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 2px;
    transform: translateY(-50%);
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: left 0.15s ease;
}
input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: transparent;
}
input[type="checkbox"]:checked::before {
    left: calc(100% - 1.05rem - 2px);
}
input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
/* <FocusOnNavigate Selector="h1"> programmatically focuses the page heading after each navigation (so screen
   readers announce it). A heading isn't keyboard-tabbable, so the only focus it ever gets is this script focus —
   drop the ring unconditionally (some browsers treat the programmatic focus as :focus-visible, so the guard above
   wasn't enough). */
h1:focus { outline: none; box-shadow: none; }

/* Label wrapping a toggle: lay the switch beside its text. */
label.checkbox {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
}

/* ---- Markdown editor (Discord-flavored toolbar + preview) ---------------- */
.md-editor { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.md-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 60%, var(--border)); }
.md-toolbar button { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; padding: 0; border: 0; background: transparent; color: var(--text-muted); border-radius: 6px; cursor: pointer; transition: background 0.12s ease, color 0.12s ease; }
.md-toolbar button:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); }
.md-toolbar button.active { background: var(--accent); color: #fff; }
.md-toolbar .material-symbols-outlined { font-size: 1.2rem; }
.md-toolbar .md-sep { width: 1px; height: 1.3rem; background: var(--border); margin: 0 4px; }
.md-toolbar .md-spacer { flex: 1; }
.md-editor .md-textarea { display: block; width: 100%; border: 0; border-radius: 0; background: transparent; padding: 0.6rem 0.7rem; resize: vertical; font: inherit; line-height: 1.5; color: var(--text); }
.md-editor .md-textarea:focus { outline: none; }
.md-preview { padding: 0.6rem 0.7rem; min-height: 4.5rem; line-height: 1.5; }
.md-preview > :first-child { margin-top: 0; }
.md-preview > :last-child { margin-bottom: 0; }
.md-preview-empty { color: var(--text-muted); font-style: italic; }

/* ---- .mform: clean stacked field grid for settings/config forms ---------- */
/* Interactive pages drop the <form> wrapper, so labels would render inline — stack them explicitly.
   Shared by the muster settings panes and the template add/edit page. */
.mform { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem 1.5rem; max-width: 680px; }
.mform .field { display: flex; flex-direction: column; gap: 0.35rem; margin: 0; }
.mform .field.span2 { grid-column: 1 / -1; }
.mform .field > label { color: var(--text); font-size: 0.9rem; font-weight: 600; margin: 0; }
.mform .field .hint { color: var(--text-muted); font-size: 0.8rem; margin: 0; }
/* Full width for value inputs/selects, but NOT the checkbox switch (it has a fixed track width). */
.mform input:not([type="checkbox"]), .mform select, .mform textarea { width: 100%; }
.mform .suffixed { display: flex; align-items: center; gap: 0.5rem; }
.mform .suffixed input { width: 7rem; }
.mform .suffixed span { color: var(--text-muted); font-size: 0.85rem; }
.mform label.checkbox { font-weight: 600; color: var(--text); cursor: pointer; }
@media (max-width: 640px) { .mform { grid-template-columns: 1fr; } }
.message {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

/* Notification box: a clean toast-style status banner with an icon, accent left bar, and a dismiss control. */
.notice {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.7rem 0.85rem; margin-bottom: 1rem;
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
    color: var(--text);
}
.notice .notice-icon { color: var(--accent); font-size: 1.3rem; flex: 0 0 auto; }
.notice .notice-text { flex: 1 1 auto; min-width: 0; }
.notice .notice-text .muted { color: var(--text-muted); font-size: 0.85rem; }
.notice .notice-close { margin-left: auto; flex: 0 0 auto; }

/* Reward + quest-level toolbar strip on the quest detail. Sits below the header's bottom border and above
   the content panels — reward on the left, available actions on the right. Coupled tight to the header
   (pull the .sess-head's bottom margin in when this strip follows it) so the line separates header from
   strip without a yawning gap. */
.sess-head:has(+ .quest-strip) { margin-bottom: 0.35rem; }
.quest-strip {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    padding: 0.5rem 0.25rem 0.9rem;
    margin-bottom: 1rem;
}
.quest-strip-reward { display: inline-flex; align-items: center; gap: 0.5rem; }
.quest-strip-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-left: auto; }
.quest-strip-actions .tier-select, .quest-strip-actions .note-input { width: auto; min-width: 11rem; margin-top: 0; }
.quest-strip-actions .checkbox { display: inline-flex; align-items: center; gap: 0.3rem; }

/* Warning variant: amber accents (e.g. a disputed quest, a paused/AFK situation). */
.notice.notice-warn {
    border-color: color-mix(in srgb, #d97706 45%, var(--border));
    border-left-color: #d97706;
    background: color-mix(in srgb, #d97706 10%, var(--surface));
}
.notice.notice-warn .notice-icon { color: #d97706; }

/* ---- Page header --------------------------------------------------------- */
.page-head { margin-bottom: 1.25rem; }
.page-head .back-link { display: inline-block; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.4rem; }
.page-head h1 { margin: 0; }
.page-head .subtitle { color: var(--text-muted); margin: 0.25rem 0 0; }
.page-head .actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Breadcrumb-style page title: parent crumbs link out, the last is the current page. */
.page-breadcrumb { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap;
    font-size: 1.6rem; font-weight: 700; line-height: 1.25; margin: 0; }
.page-breadcrumb a { color: var(--text-muted); }
.page-breadcrumb a:hover { color: var(--accent); text-decoration: none; }
.page-breadcrumb .crumb-current { color: inherit; }
.page-breadcrumb .crumb-sep { color: var(--text-muted); font-weight: 400; }

/* Sub-nav / action toolbar that sits under the breadcrumb. */
.page-toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
    margin-top: 0.85rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }

/* ---- Accordion ----------------------------------------------------------- */
.accordion { display: flex; flex-direction: column; gap: 0.85rem; margin-bottom: 1.25rem; }
.acc-item { overflow: hidden; }   /* .glass supplies the surface, border, radius + blur */
.acc-header { width: 100%; display: flex; align-items: center; gap: 0.6rem;
    padding: 1rem 1.25rem; background: none; border: none; cursor: pointer; color: inherit;
    font-family: inherit; font-size: 1.05rem; font-weight: 600; text-align: left; }
.acc-header:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.acc-icon { color: var(--text-muted); font-size: 1.2rem; }
.acc-title { flex: 1; }
.acc-summary { color: var(--text-muted); font-weight: 400; font-size: 0.85rem; }
.acc-chevron { color: var(--text-muted); transition: transform 0.15s ease; }
.acc-item.open .acc-chevron { transform: rotate(180deg); }
.acc-body { padding: 0 1.25rem 1.25rem; }

/* ---- Scrollbars (themed) ------------------------------------------------- */
* { scrollbar-width: auto; scrollbar-color: var(--text-muted) transparent; }
*::-webkit-scrollbar { width: 14px; height: 14px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 999px;
    border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: padding-box; }
*::-webkit-scrollbar-corner { background: transparent; }

/* ---- Save / status pill -------------------------------------------------- */
.save-pill { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.75rem;
    border-radius: 999px; font-size: 0.8rem; font-weight: 600; animation: save-pop 0.15s ease; }
.save-pill.is-saving { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.save-pill.is-saved { background: color-mix(in srgb, #22c55e 22%, transparent); color: #22c55e; }
.save-pill.is-error { background: color-mix(in srgb, #ef4444 22%, transparent); color: #ef4444; }
.save-pill .material-symbols-outlined { font-size: 1rem; }
@keyframes save-pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---- Card grids ---------------------------------------------------------- */
.card-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.feature-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 1.75rem; }
.card { padding: 1.25rem 1.4rem; display: block; color: var(--text); }
.card h3 { margin: 0 0 0.35rem; }
.card p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
a.card { transition: transform 0.12s ease; }
a.card:hover { text-decoration: none; transform: translateY(-2px); }
.card-row { display: flex; align-items: center; gap: 0.85rem; }

/* ---- Avatar (initial) ---------------------------------------------------- */
.avatar {
    width: 2.4rem; height: 2.4rem; border-radius: 50%;
    display: inline-grid; place-items: center; flex: 0 0 auto;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    color: #fff; font-weight: 700;
}

/* ---- Stat tiles ---------------------------------------------------------- */
.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 1.25rem; }
.stat { padding: 1rem 1.25rem; display: flex; flex-direction: column; }
.stat .label { color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .num { font-size: 1.6rem; font-weight: 700; margin-top: 0.15rem; }
.stat .subtitle { margin: 0.1rem 0 0; font-size: 0.75rem; }
table.leaderboard td.pos { color: #4ade80; font-weight: 600; }
table.leaderboard td.neg { color: var(--danger); font-weight: 600; }

/* ---- Leaderboard medals -------------------------------------------------- */
table.leaderboard td.rank { font-weight: 700; width: 3rem; }
.rank-1 { color: #f6c343; }
.rank-2 { color: #c2ccd8; }
.rank-3 { color: #d8954f; }
table.leaderboard tbody tr:hover { background: var(--surface); }

/* ---- Empty state --------------------------------------------------------- */
.empty { color: var(--text-muted); text-align: center; padding: 2.5rem 1rem; }

/* ---- Forms --------------------------------------------------------------- */
.form-grid { max-width: 480px; }

/* Toggle utility — !important so it beats `form label { display:block }`. */
.is-hidden { display: none !important; }

/* Segmented tabs for picking the quest kind (player vs guild). */
.kind-tabs { display: flex; gap: 0.5rem; margin-bottom: 0.4rem; }
.kind-tab {
    flex: 1;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font: inherit; font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.kind-tab:hover { color: var(--text); }
.kind-tab.active { background: var(--accent); border-color: transparent; color: #fff; }
.kind-tab .material-symbols-outlined { font-size: 1.1rem; }
.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.25rem; }
.apikey {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    overflow-x: auto;
    user-select: all;
}

/* ---- Filter bar / pager (server-driven grid) ----------------------------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.filter-bar input, .filter-bar select { width: auto; margin-top: 0; }
.filter-bar input[type="search"] { min-width: 12rem; flex: 1; }
.pager { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; color: var(--text-muted); font-size: 0.9rem; }
table.leaderboard th a { color: var(--text-muted); }

/* ---- Quest board grid ---------------------------------------------------- */
.btn-sm { padding: 0.32rem 0.62rem; font-size: 0.82rem; }
.quest-tabs { margin-bottom: 1rem; }
.quest-tabs a {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.9rem;
}
.quest-tabs a.active { background: var(--accent); color: #fff; border-color: transparent; }
/* Generic link-based pill tabs (server-loaded panels, unlike the CSS-only radio .tabs). */
.pill-tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.pill-tabs a, .pill-tabs button {
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font: inherit;
    font-size: 0.9rem;
    background: transparent;
    cursor: pointer;
}
.pill-tabs a.active, .pill-tabs button.active { background: var(--accent); color: #fff; border-color: transparent; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; max-width: none; margin: 0; }
.row-actions label { margin: 0; }
.badge.status-open { background: var(--accent-soft); color: #04122b; }
.badge.status-scheduled { background: #f6c343; color: #04122b; }
.badge.status-disputed { background: var(--danger); color: #fff; }
.badge.status-closed { background: #4ade80; color: #04122b; }
.badge.status-cancelled, .badge.status-expired { background: var(--text-muted); color: #fff; }

/* Desktop = table; below 760px each row collapses into a card. */
@media (max-width: 760px) {
    table.quest-grid thead { display: none; }
    table.quest-grid, table.quest-grid tbody, table.quest-grid tr, table.quest-grid td { display: block; width: 100%; }
    table.quest-grid tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface);
        padding: 0.6rem 0.85rem;
        margin-bottom: 0.85rem;
    }
    table.quest-grid td { border: 0; padding: 0.25rem 0; display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
    table.quest-grid td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.74rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        flex: 0 0 auto;
    }
    table.quest-grid td[data-label="Actions"],
    table.quest-grid td[data-label="Quest"] { display: block; }
    table.quest-grid td[data-label="Actions"]::before,
    table.quest-grid td[data-label="Quest"]::before { display: block; margin-bottom: 0.35rem; }
}

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 640px) {
    .topbar { flex-wrap: wrap; gap: 0.6rem; }
    .topbar nav { width: 100%; margin-left: 0; justify-content: space-between; gap: 0.6rem; }
    .container { padding: 1rem 0.9rem 2.5rem; }
    .panel { padding: 1.1rem 1.1rem; }
}

/* ---- Material Symbols ---------------------------------------------------- */
.material-symbols-outlined {
    font-family: "Material Symbols Outlined";
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: "liga";
    -webkit-font-smoothing: antialiased;
    font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
    font-size: 1.25rem;
    vertical-align: middle;
    user-select: none;
}

/* ============================================================================
   Guild shell: desktop sidebar + mobile bottom tabs
   ============================================================================ */
.guild-shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    gap: 0.9rem;
    padding: 0.9rem;
    min-height: 100dvh;
    align-items: start;
}

.sidebar {
    position: sticky;
    top: 0.9rem;
    height: calc(100dvh - 1.8rem);
    padding: 1.1rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    padding: 0.2rem 0.5rem 0.6rem;
}
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand-mark { color: var(--accent); }
.sidebar .brand-mark-img { width: 2rem; height: 2rem; display: block; flex: 0 0 auto; }
.sidebar .brand-wordmark { letter-spacing: -0.01em; }

.nav-label {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.8rem 0.6rem 0.3rem;
}

.server-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 600;
}
.server-card:hover { text-decoration: none; filter: brightness(1.03); }
.server-avatar {
    width: 2rem; height: 2rem; border-radius: 8px; flex: 0 0 auto;
    display: inline-grid; place-items: center;
    background: linear-gradient(135deg, #f97316, #fb923c);
    color: #fff; font-weight: 800; font-size: 0.8rem;
}

.side-nav { display: flex; flex-direction: column; gap: 0.15rem; }
.side-nav a, .nav-soon {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 500;
}
.side-nav a:hover { text-decoration: none; background: var(--surface); color: var(--text); }
.side-nav a.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.nav-ico { font-size: 1.2rem; opacity: 0.85; flex: 0 0 auto; }
.nav-soon { color: var(--text-muted); opacity: 0.55; cursor: default; }
.nav-soon .pill {
    margin-left: auto;
    font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    padding: 0.05rem 0.35rem; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border);
}

.sidebar-foot {
    margin-top: auto;
    padding-top: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.me-card {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    min-width: 0;
}
.foot-row { display: flex; }

/* Reusable avatar + name chip (sidebar, quest cards, …). */
.user-chip { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.user-chip-name { font-size: 0.88rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-name b { font-weight: 600; }
.user-chip-name .sub { color: var(--text-muted); font-weight: 400; }

.app-main {
    min-width: 0;
    padding: 0.6rem 0.8rem 2rem;
    max-width: 1180px;
}

/* Pages that want the full available width (quests board, etc.) drop the cap by marking any child .full-bleed.
   Mobile already has max-width: none below. */
@media (min-width: 861px) {
    .app-main:has(.full-bleed) { max-width: none; }
}

/* Bottom tabs: hidden on desktop, fixed bar on mobile. */
.bottom-tabs { display: none; }

@media (max-width: 860px) {
    .guild-shell { grid-template-columns: 1fr; padding: 0; gap: 0; }
    .sidebar { display: none; }
    .app-main { padding: 0.9rem 0.9rem 5.5rem; max-width: none; }
    .bottom-tabs {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        position: fixed;
        left: 0.6rem; right: 0.6rem; bottom: 0.6rem;
        z-index: 20;
        padding: 0.4rem;
        border-radius: var(--radius);
    }
    .bottom-tabs a {
        display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
        padding: 0.35rem 0;
        color: var(--text-muted);
        font-size: 0.68rem; font-weight: 600;
        border-radius: var(--radius-sm);
    }
    .bottom-tabs a:hover { text-decoration: none; }
    .bottom-tabs a.active { color: var(--accent); background: var(--surface); }
    .bottom-tabs a.disabled { opacity: 0.4; pointer-events: none; }
    .bottom-tabs .tab-ico { font-size: 1.4rem; }
}

/* ============================================================================
   Quest board cards
   ============================================================================ */
.board-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.board-head .eyebrow {
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--accent);
}
.board-head h1 { margin: 0.15rem 0 0; }
.board-head .summary { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.2rem; }
.board-head .head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.board-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.7rem 0.9rem;
    margin-bottom: 1rem;
}
.board-toolbar .search { flex: 1; min-width: 12rem; }
.board-toolbar .search input { margin-top: 0; }
.seg {
    display: inline-flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.15rem;
    gap: 0.1rem;
}
.seg a {
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}
.seg a:hover { text-decoration: none; color: var(--text); }
.seg a.active { background: var(--accent); color: #fff; }
.board-toolbar .sort-by { margin-left: auto; display: flex; align-items: center; gap: 0.4rem; }
.board-toolbar .sort-by .lbl { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; }
.board-toolbar .sort-by select { width: auto; margin-top: 0; }

.quest-board {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    align-items: stretch; /* equal-height cards within a row */
}
/* List view: one full-width card per row. */
.quest-board.is-list { grid-template-columns: 1fr; }
.quest-board.is-list .quest-card { max-width: 760px; }

/* View toggle (icon buttons reusing the segmented control look). */
.seg.view-toggle button {
    background: none; border: 0; cursor: pointer;
    padding: 0.3rem 0.55rem; color: var(--text-muted);
    display: grid; place-items: center; border-radius: 7px;
}
.seg.view-toggle button:hover { color: var(--text); }
.seg.view-toggle button.active { background: var(--accent); color: #fff; }
.seg.view-toggle .material-symbols-outlined { font-size: 1.15rem; }

/* ---- Shop / listing tiles ------------------------------------------------ */
/* Opaque card surface (vs translucent .glass) so a dense grid stays legible over the textured background. */
.shop-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* Storefront title-crumb — the breadcrumb rolled into the store name (Shops › <store>), matching the quest hero. */
.store-titlecrumb { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.45rem; min-width: 0; }
.store-titlecrumb a { font-size: 0.95rem; font-weight: 500; color: var(--text-muted); text-decoration: none; white-space: nowrap; }
.store-titlecrumb a:hover { color: var(--text); }
.store-crumb-sep { color: var(--text-muted); opacity: 0.6; }
.store-title { margin: 0; font-size: clamp(1.5rem, 3.5vw, 2rem); font-weight: 700; line-height: 1.15; color: var(--text); }
/* Over the banner image: white treatment with a legibility shadow. */
.store-titlecrumb-onbanner a { color: rgba(255, 255, 255, 0.82); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7); }
.store-titlecrumb-onbanner a:hover { color: #fff; }
.store-titlecrumb-onbanner .store-crumb-sep { color: rgba(255, 255, 255, 0.75); }
.store-titlecrumb-onbanner .store-title { color: #fff; text-shadow: 0 2px 14px rgba(0, 0, 0, 0.7); }

/* Price + stock badges — shared by the listing card, the item modal, and the listing detail page. */
.shop-price { font-weight: 700; white-space: nowrap; color: #b45309; }
:root[data-theme="dark"] .shop-price { color: #fdba74; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .shop-price { color: #fdba74; } }
.shop-stock { color: #0f9d6b; font-size: 0.74rem; }
:root[data-theme="dark"] .shop-stock { color: #6ee7b7; }
.shop-stock.out { color: var(--danger); }

/* Item badges (featured / new) — shared by the listing card and the item modal. */
.shop-badge {
    font-size: 0.66rem; font-weight: 700; letter-spacing: 0.03em; border-radius: 6px; padding: 2px 7px;
    display: inline-flex; align-items: center; gap: 0.2rem; box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.shop-badge.feat { background: rgba(246, 196, 83, 0.94); color: #1c1407; }
.shop-badge.new  { background: rgba(59, 130, 246, 0.94); color: #fff; }
.shop-badge .material-symbols-outlined { font-size: 0.85rem; line-height: 1; }
.hero-dot { opacity: 0.5; }

/* Store-type chip (storefront header + store card). */
.chip-type { background: rgba(20, 184, 166, 0.16); color: #0c7d70; }
:root[data-theme="dark"] .chip-type { color: #7ff0df; }
.chip-type .material-symbols-outlined { font-size: 0.9rem; vertical-align: -2px; }

/* Active-filter summary chips (shop grids). */
.filter-summary { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.1rem 0 0.65rem; }
.filter-chip { display: inline-flex; align-items: center; gap: 0.3rem; }
.filter-chip-x { border: none; background: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }
.filter-chip-x:hover { color: var(--danger); }

/* Quantity stepper (item modal buy row) — only shown when a listing has more than one in stock. */
.qty-step { display: inline-flex; align-items: center; gap: 0.1rem; border: 1px solid var(--border); border-radius: 8px; padding: 1px; vertical-align: middle; }
.qty-step .icon-btn { width: 1.7rem; height: 1.7rem; }
.qty-val { min-width: 1.6rem; text-align: center; font-weight: 600; font-size: 0.9rem; }

/* Shop quick-view item modal. Centered card on desktop; full-screen sheet on mobile. */
.shop-modal-backdrop {
    position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
    padding: 1.5rem; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(3px);
}
.shop-modal {
    position: relative; width: min(920px, 100%); max-height: 90vh; overflow: hidden;
    display: grid; grid-template-columns: minmax(0, 380px) 1fr;
    background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
/* Lock the page behind any open modal (no bleed-through scrollbar). */
html.modal-open { overflow: hidden; }
/* Item-modal body: breadcrumb, title, price row, and buyer/seller action rows. */
.smi-crumb { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; font-size: 0.78rem; color: var(--text-muted); }
.smi-crumb a { color: var(--text-muted); text-decoration: none; }
.smi-crumb a:hover { color: var(--text); }
.smi-crumb-sep { opacity: 0.5; }
.smi-title { margin: 0.1rem 0 0; font-size: 1.3rem; line-height: 1.25; }
.smi-price-row { display: flex; align-items: baseline; gap: 0.7rem; flex-wrap: wrap; margin: 0.25rem 0 0.1rem; }
.smi-price { font-size: 1.5rem; }
.smi-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.smi-row { display: contents; }
/* On desktop the groups flow as one row; the owner controls float to the right, away from the Buy CTA. */
.smi-seller > :first-child, .smi-mod > :first-child { margin-left: auto; }
.smi-status { align-self: center; }
.smi-offer { max-width: 8rem; }
/* Single-column compact dialog (quick-create form). */
.shop-modal.sm { grid-template-columns: 1fr; width: min(440px, 100%); }
.shop-modal.sm .shop-modal-body { gap: 0.7rem; }
.shop-modal.sm h2 { margin: 0; font-size: 1.15rem; }
.shop-modal-img { background: var(--surface); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.shop-modal-img img { width: 100%; height: 100%; object-fit: cover; }
.shop-modal-img.placeholder .material-symbols-outlined { font-size: 3rem; opacity: 0.4; }
.shop-modal-body { padding: 1.1rem 1.3rem 1.3rem; overflow: auto; display: flex; flex-direction: column; gap: 0.55rem; }
.shop-modal-close {
    position: absolute; top: 0.6rem; right: 0.6rem; z-index: 2;
    width: 32px; height: 32px; padding: 0; border: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.45); color: #fff; border-radius: 50%;
    transition: background 0.12s ease, color 0.12s ease;
}
.shop-modal-close:hover { background: rgba(0, 0, 0, 0.65); }
.shop-modal-close .material-symbols-outlined { font-size: 1.2rem; }
/* On the imageless compact dialog a black disc looks alien — use the site's ghost-icon treatment. */
.shop-modal.sm .shop-modal-close { background: var(--surface); color: var(--text-muted); border: 1px solid var(--card-border); }
.shop-modal.sm .shop-modal-close:hover { background: var(--card-border); color: var(--text); }
@media (max-width: 760px) {
    .shop-modal-backdrop { padding: 0; }
    .shop-modal {
        grid-template-columns: 1fr; grid-template-rows: auto 1fr;
        width: 100%; height: 100%; max-height: 100%; border-radius: 0; border: none;
    }
    .shop-modal-img { max-height: 36vh; }
}

/* Quest-type icon picker — a visual palette (each swatch shows its Material glyph), not a text dropdown. */
.qt-palette { display: flex; flex-wrap: wrap; gap: 4px; max-width: 360px; }
.qt-ico {
    display: grid; place-items: center;
    width: 2rem; height: 2rem;
    border-radius: 9px; cursor: pointer;
    background: var(--surface); color: var(--text-muted);
    border: 1px solid var(--border);
}
.qt-ico .material-symbols-outlined { font-size: 1.15rem; }
.qt-ico:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.qt-ico.sel {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

/* Quest title + bonus-points + issuer chip — shared by the board cards and the table view. */
.qc-title { color: var(--text); font-size: 1.05rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.qc-title:hover { color: var(--accent); }
.qc-pts { font-size: 0.78rem; font-weight: 700; color: #1d4ed8; white-space: nowrap; }
:root[data-theme="dark"] .qc-pts { color: #93c5fd; }
.qc-issuer { display: inline-flex; align-items: center; gap: 0.25rem; }
.qc-issuer .material-symbols-outlined { font-size: 1rem; }

/* Board: primary tabs (sit by the layout toggle) + table (list) view. */
.board-tabs { flex: 0 0 auto; }
.quest-table .qt-cell { display: inline-flex; align-items: center; gap: 0.4rem; }
.quest-table .qt-cell .material-symbols-outlined { font-size: 1.1rem; color: var(--accent); }
.quest-table .qt-tier-col { width: 3.5rem; }
.quest-table .qc-reward { font-size: 0.9rem; }
.quest-table .dg-muted { color: var(--text-muted); }
.qt-row-actions { display: flex; gap: 0.25rem; justify-content: flex-end; }

/* The board / table fill the remaining viewport height (desktop) via the shared .dg-fill marker. */
.quest-fill { display: flex; flex-direction: column; gap: 1rem; min-height: 0; }
/* Top padding so a card's hover lift (translateY + shadow) isn't clipped behind the sticky toolbar. */
.quest-fill > .dg-scroll { flex: 1 1 auto; min-height: 0; padding-top: 0.5rem; }
.quest-fill > .quest-board { flex: 1 1 auto; align-content: start; min-height: 0; overflow: auto; padding-top: 0.5rem; }
.quest-fill > .panel.empty { flex: 1 1 auto; }
.quest-fill > .dg-footer { flex: 0 0 auto; }

/* Action modal — text (submit/revise/reject note) or tier (intake) input, shared by card + table buttons. */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 1rem; }
.qmodal { width: min(440px, 100%); padding: 1.4rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); }
.qmodal h3 { margin: 0; font-size: 1.15rem; font-weight: 700; }
.qmodal-field { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.qmodal-field textarea, .qmodal-field select {
    width: 100%; font: inherit; font-size: 0.9rem; color: var(--text);
    background: var(--surface); border: 1px solid var(--card-border); border-radius: 8px; padding: 0.55rem 0.7rem;
}
.qmodal-field textarea { resize: vertical; min-height: 4.5rem; }
.qmodal-field textarea:focus-visible, .qmodal-field select:focus-visible {
    outline: none;
    border-color: color-mix(in srgb, var(--accent) 55%, var(--card-border));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.qmodal .checkbox { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; font-weight: 400; color: var(--text); }
.qmodal .btn-row { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 0.15rem; }

/* Quest detail page */
.quest-detail h1 { margin: 0.4rem 0 0.5rem; }
.detail-reward { display: flex; align-items: baseline; gap: 0.6rem; margin: 0 0 0.9rem; flex-wrap: wrap; }
.detail-reward .qc-reward { font-size: 1.25rem; }
.detail-desc { margin: 0 0 0.2rem; }

/* Uniform stat strip: issuer + completions/posted/closes, divided from the brief above. */
.detail-stats {
    display: flex; flex-wrap: wrap; gap: 1.1rem 2.25rem; align-items: flex-start;
    margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.detail-stats .stat-item { display: flex; flex-direction: column; gap: 0.25rem; }
.detail-stats .lbl { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; }
.detail-stats .val { font-weight: 600; display: flex; align-items: center; gap: 0.4rem; min-height: 1.5rem; }
.detail-stats .issuer-mark .material-symbols-outlined { font-size: 1rem; }

/* Action rows on the detail page. */
.detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1.1rem; padding-top: 0.9rem; border-top: 1px solid var(--border); }
.detail-actions:empty, .detail-actions .icon-row:empty { display: none; }
.detail-actions .icon-row { gap: 0.5rem; }
.detail-actions .note-input, .detail-actions .tier-select { width: auto; min-width: 11rem; margin-top: 0; }

.participant-list { list-style: none; margin: 0.6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.participant-list .p-row {
    display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
    padding: 0.5rem 0.7rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
}
.participant-list .p-row.lb-me { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.participant-list .p-identity { display: inline-flex; align-items: center; gap: 0.5rem; min-width: 0; flex-wrap: wrap; }
.participant-list .p-name { font-weight: 600; }
.participant-list .roster-by { color: var(--text-muted); font-size: 0.78rem; }
.participant-list .p-note { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--text-muted); font-size: 0.85rem; font-style: italic; }
.participant-list .p-note .material-symbols-outlined { font-size: 1rem; }
.participant-list .p-note-review { font-style: normal; }
.participant-list .p-actions { margin-left: auto; display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }
.participant-list .p-note-input { width: auto; min-width: 10rem; margin-top: 0; padding: 0.35rem 0.55rem; }

/* Rendered Discord markdown */
.markdown { line-height: 1.55; }
.markdown :first-child { margin-top: 0; }
.markdown :last-child { margin-bottom: 0; }
.markdown p { margin: 0 0 0.6rem; }
.markdown ul, .markdown ol { margin: 0 0 0.6rem; padding-left: 1.4rem; }
.markdown code {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; padding: 0.05rem 0.3rem; font-size: 0.88em;
}
.markdown pre {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 0.75rem 1rem; overflow-x: auto;
}
.markdown pre code { background: none; border: 0; padding: 0; }
.markdown blockquote {
    margin: 0 0 0.6rem; padding: 0.2rem 0 0.2rem 0.9rem;
    border-left: 3px solid var(--border); color: var(--text-muted);
}
.markdown a { color: var(--accent); }

/* EasyMDE markdown editor — themed to the glass/dark tokens. */
.EasyMDEContainer .CodeMirror {
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-top: 0;
    border-bottom-left-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm);
}
.EasyMDEContainer .CodeMirror-cursor { border-color: var(--text); }
.EasyMDEContainer .editor-toolbar {
    background: var(--surface); border: 1px solid var(--border);
    border-top-left-radius: var(--radius-sm); border-top-right-radius: var(--radius-sm); opacity: 1;
}
.EasyMDEContainer .editor-toolbar button { color: var(--text-muted) !important; }
.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active { background: var(--glass-highlight); border-color: var(--border); }
.EasyMDEContainer .editor-toolbar i.separator { border-color: var(--border); }
.EasyMDEContainer .editor-preview, .EasyMDEContainer .editor-preview-side { background: var(--bg-base); color: var(--text); }
.EasyMDEContainer .CodeMirror-selected { background: var(--glass-highlight) !important; }
.qc-note { color: var(--text-muted); font-size: 0.8rem; margin: 0; }

.reward-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Top-right cluster: tier rank badge + time. */
.qc-top-right { display: flex; align-items: center; gap: 0.5rem; }
/* Tier badge inline in a settings field label (tier letter as a visual reference next to its reward input). */
.mform .field label .tier-badge { vertical-align: -4px; margin-right: 0.4rem; }

.tier-badge {
    display: inline-grid; place-items: center;
    min-width: 1.5rem; height: 1.5rem; padding: 0 0.35rem;
    border-radius: 7px;
    font-size: 0.8rem; font-weight: 800; line-height: 1;
    color: #1a1205;
    /* glossy pop: soft drop shadow + bright top inner highlight + subtle inner rim */
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 0 0 1px rgba(0, 0, 0, 0.06);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* Tier-colored left edge — a gradient "border" masked to the left side so it hugs the rounded corners.
   Used by both the board card and the detail panel. */
.tier-accent { position: relative; }
.tier-accent::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding-left: 6px;
    background: linear-gradient(160deg, var(--tier-from), var(--tier-to));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
}
.tier-edge-S { --tier-from: #fde047; --tier-to: #f59e0b; }
.tier-edge-A { --tier-from: #fb7185; --tier-to: #ef4444; }
.tier-edge-B { --tier-from: #c084fc; --tier-to: #8b5cf6; }
.tier-edge-C { --tier-from: #60a5fa; --tier-to: #3b82f6; }
.tier-edge-D { --tier-from: #4ade80; --tier-to: #22c55e; }
.tier-edge-E { --tier-from: #cbd5e1; --tier-to: #94a3b8; }
.tier-S { background: linear-gradient(135deg, #fde047, #f59e0b); }
.tier-A { background: linear-gradient(135deg, #fb7185, #ef4444); color: #fff; }
.tier-B { background: linear-gradient(135deg, #c084fc, #8b5cf6); color: #fff; }
.tier-C { background: linear-gradient(135deg, #60a5fa, #3b82f6); color: #fff; }
.tier-D { background: linear-gradient(135deg, #4ade80, #22c55e); color: #06270f; }
.tier-E { background: linear-gradient(135deg, #cbd5e1, #94a3b8); color: #1e293b; }

/* Reward as colored inline text, right of the Details link. */
.qc-detail-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.qc-reward { font-weight: 700; font-size: 0.95rem; white-space: nowrap; display: inline-flex; align-items: center; }
.qc-reward.reward-coin { color: #b45309; }
.qc-reward.reward-points { color: #1d4ed8; }
:root[data-theme="dark"] .qc-reward.reward-coin { color: #fdba74; }
:root[data-theme="dark"] .qc-reward.reward-points { color: #93c5fd; }
/* Legacy owner block (kept global; not used by the QuestCard component). */
.qc-owner { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.qc-owner .who { font-size: 0.85rem; min-width: 0; }
.qc-owner .who b { font-weight: 600; }
.qc-owner .who .sub { color: var(--text-muted); }
.avatar-sm {
    width: 1.7rem; height: 1.7rem; border-radius: 50%; flex: 0 0 auto;
    display: inline-grid; place-items: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-soft));
    color: #fff; font-weight: 700; font-size: 0.72rem;
}

.btn-block { width: 100%; }

/* Cohesive action bar: inputs on the left, action buttons on the right (destructive pinned far-right). */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}
.action-left { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; flex: 1; min-width: 0; }
.action-left:empty { display: none; }
.action-left .note-input, .action-left .tier-select { margin-top: 0; width: auto; min-width: 9rem; }
.action-right { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.action-right .far-right { margin-left: 0.35rem; }

.issuer-mark {
    width: 1.7rem; height: 1.7rem; border-radius: 8px; flex: 0 0 auto;
    display: inline-grid; place-items: center;
    background: rgba(37, 99, 235, 0.14); color: #1d4ed8; font-size: 0.85rem;
}
:root[data-theme="dark"] .issuer-mark { color: #93c5fd; }
img.avatar-sm { object-fit: cover; }

/* Icon action buttons. Semantic colour: green approve, red deny/withdraw, amber caution, accent claim. */
.icon-btn {
    display: inline-grid; place-items: center;
    width: 2rem; height: 2rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem; line-height: 1;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.05s ease, background 0.15s ease;
}
.icon-btn:hover { text-decoration: none; filter: brightness(1.05); background: var(--glass-highlight); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.icon-btn.success { background: #16a34a; border-color: transparent; color: #fff; }
.icon-btn.danger  { background: var(--danger); border-color: transparent; color: #fff; }
.icon-btn.warn    { background: #d97706; border-color: transparent; color: #fff; }
.icon-btn.primary:hover, .icon-btn.success:hover, .icon-btn.danger:hover, .icon-btn.warn:hover { filter: brightness(1.1); }
.icon-btn .material-symbols-outlined { font-size: 1.2rem; }
.brand-mark { font-size: 1.4rem; }
.issuer-mark .material-symbols-outlined { font-size: 1.1rem; }
.esc-lock {
    font-size: 0.95em;
    line-height: 1;
    opacity: 0.7;
    margin-left: 0.25rem;
    font-variation-settings: "FILL" 0, "wght" 400, "opsz" 20;
}

/* ---- Chips (category / status) ------------------------------------------- */
.chip {
    display: inline-flex; align-items: center; gap: 0.25rem;
    font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
.chip-quest   { background: rgba(37, 99, 235, 0.14);  color: #1d4ed8; border-color: transparent; }
.chip-player  { background: rgba(139, 92, 246, 0.16); color: #6d28d9; border-color: transparent; }
.chip-op      { background: var(--surface); }
.chip-review  { background: rgba(22, 163, 74, 0.16);  color: #15803d; border-color: transparent; }
.chip-progress{ background: var(--surface); color: var(--text-muted); }
.chip-closed  { background: rgba(220, 38, 38, 0.14);  color: #b91c1c; border-color: transparent; }
.chip-points  { background: rgba(37, 99, 235, 0.14);  color: #1d4ed8; border-color: transparent; }
.chip-coin    { background: rgba(217, 119, 6, 0.16);  color: #b45309; border-color: transparent; }
.chip-reward  { background: rgba(37, 99, 235, 0.12);  color: #1d4ed8; border-color: transparent; }

:root[data-theme="dark"] .chip-quest,   :root[data-theme="dark"] .chip-points, :root[data-theme="dark"] .chip-reward { color: #93c5fd; }
:root[data-theme="dark"] .chip-coin      { color: #fdba74; }
:root[data-theme="dark"] .chip-player    { color: #c4b5fd; }
:root[data-theme="dark"] .chip-review    { color: #86efac; }
:root[data-theme="dark"] .chip-closed    { color: #fca5a5; }

/* ---- Progress bar -------------------------------------------------------- */
.progress { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-soft)); }

/* Respect reduced motion / transparency preferences. */
@media (prefers-reduced-transparency: reduce) {
    .glass { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* Panel header with an action on the right (e.g. "+ New currency"). */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.panel-head h2 { margin: 0; }

/* CSS-only tabs (works under static SSR — no JS). Radios drive which panel shows; all inputs stay in
   the DOM so the single form still posts every field regardless of the visible tab. */
.tabs > input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.tabs > label {
    display: inline-block; padding: .45rem .9rem; cursor: pointer;
    border-bottom: 2px solid transparent; opacity: .7;
}
.tabs > input[type="radio"]:checked + label { border-bottom-color: var(--accent); opacity: 1; font-weight: 600; }
.tabs .tab-panels { padding-top: 1rem; }
.tabs .tab-panel { display: none; }
#ct-base:checked    ~ .tab-panels #tp-base,
#ct-auth:checked    ~ .tab-panels #tp-auth,
#ct-sec:checked     ~ .tab-panels #tp-sec,
#ct-credit:checked  ~ .tab-panels #tp-credit,
#ct-debit:checked   ~ .tab-panels #tp-debit,
#ct-balance:checked ~ .tab-panels #tp-balance { display: block; }

/* Stacked field: label on its own line, full-width control below (for the JSON body editors). */
.field-block { display: flex; flex-direction: column; gap: .35rem; margin-top: .75rem; }
.field-block > label { font-weight: 600; }
.field-block textarea.json-editor {
    width: 100%; min-height: 160px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .85rem;
}
/* CodeMirror JSON editor sizing/skin to match the glass panels. */
.field-block .CodeMirror {
    height: auto; border: 1px solid var(--border, rgba(255,255,255,.15)); border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem;
}

/* Member "Sync balances" row under the wallet panel. */
.balance-sync-row { display: flex; align-items: center; gap: .6rem; margin: .25rem 0 1rem; flex-wrap: wrap; }

/* Datagrid frame for standalone (non-TabFrame) datagrids. Same glass shell as Sessions' folder-tab frame but
   with all four corners rounded. Strips the panel's own padding so dg-toolbar/footer borders span edge-to-edge. */
.dg-frame { padding: 0; overflow: hidden; margin-bottom: 1rem; display: flex; flex-direction: column; min-height: 0; }
.dg-frame .dg-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
/* Flat, subtle frame shared by the economy ledger grids (LedgerFrame) — replaces the heavier .panel.glass look. */
.ledger-frame { background: rgba(255, 255, 255, 0.018); border: 1px solid var(--glass-border); border-radius: var(--radius); }
/* Shared ledger cell bits (treasury / participation / wallet grids). */
.dg-table .led-when { color: var(--text-muted); font-size: 0.82rem; white-space: nowrap; }
.dg-table .led-when .exp { font-size: 1rem; vertical-align: -3px; margin-right: 0.15rem; color: var(--text-muted); }
.dg-table .src-chip { display: inline-flex; align-items: center; gap: 0.25rem; }
.dg-table .src-chip .material-symbols-outlined { font-size: 1.05rem; color: var(--text-muted); opacity: 1; }
.dg-table .user-chip .avatar-sm { width: 22px; height: 22px; font-size: 0.65rem; }
.dg-table .user-chip-name b { font-weight: 500; font-size: 0.85rem; }
/* Direction toggle (All / In-Out / Debit-Credit) shared across the ledger toolbars. */
.dir-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 0.55rem; overflow: hidden; }
.dir-toggle button { appearance: none; background: transparent; border: none; border-left: 1px solid var(--border); color: var(--text-muted); font: inherit; font-size: 0.82rem; padding: 0.38rem 0.7rem; cursor: pointer; transition: background 0.12s, color 0.12s; }
.dir-toggle button:first-child { border-left: none; }
.dir-toggle button:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.dir-toggle button.active { background: var(--accent); color: #fff; }

/* Day-group header rows + per-day subtotal. */
.dg-table tr.dg-group td { background: rgba(255, 255, 255, 0.03); color: var(--text-muted); font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.03em; padding-top: 0.4rem; padding-bottom: 0.4rem; }
.grp-net { float: right; text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.grp-net.pos, .grp-net .pos, .grp-net .credit { color: #4ade80; }
.grp-net.neg, .grp-net .neg, .grp-net .debit { color: var(--danger); }

/* Clickable rows + the transaction detail drawer. */
.led-row { cursor: pointer; }
.led-row.open > td { background: var(--surface); }
.led-detail > td { background: rgba(255, 255, 255, 0.02); }
.ld-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.5rem 1.5rem; padding: 0.6rem 0.4rem; white-space: normal; }
.ld-grid > div { display: flex; flex-direction: column; gap: 0.1rem; }
.ld-grid .ld-reason { grid-column: 1 / -1; }
.ld-grid .k { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.ld-grid .v { font-size: 0.88rem; }
.ld-grid .v.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; word-break: break-all; }
.ld-grid .v.pos, .ld-grid .v.credit { color: #4ade80; }
.ld-grid .v.neg, .ld-grid .v.debit { color: var(--danger); }

/* Footer totals. */
.dg-totals { font-size: 0.82rem; color: var(--text-muted); }
.dg-totals .pos { color: #4ade80; }
.dg-totals .neg { color: var(--danger); }

/* Wallet/member page breadcrumb header (shared across the wallet tabs). */
.wallet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.wallet-controls { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.wallet-crumb { display: flex; align-items: center; gap: 0.5rem; font-size: 1.35rem; font-weight: 600; }
.wallet-crumb a { color: var(--text-muted); font-weight: 600; }
.wallet-crumb a:hover { color: var(--text); }
.wallet-crumb .sep { font-size: 1.5rem; color: var(--text-muted); opacity: 0.55; }
.wallet-crumb .wallet-ico { font-size: 1.7rem; color: var(--accent); margin-right: 0.15rem; }
.wallet-crumb .user-chip .avatar-sm { width: 30px; height: 30px; font-size: 0.85rem; }
.wallet-crumb .user-chip-name b { font-size: 1.35rem; font-weight: 600; }
/* Make a standalone datagrid fill the viewport height (full-frame pages like shop disputes). */
.dg-fill { min-height: 68vh; }

/* Shop settings master switch — a plain on/off row above the toolbar (no card frame). */
.shop-master-switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 0.25rem 0 0.9rem; }
.shop-master-switch .checkbox { font-size: 1.02rem; }
.shop-master-switch .checkbox:has(input:disabled) { opacity: 0.65; }
/* Disabled toolbar link (manage categories / store types while the shop is off). */
.btn.is-disabled { pointer-events: none; opacity: 0.5; }

/* ---- Reusable tab frame (TabFrame.razor) --------------------------------- */
/* Folder tabs sit on top of a bordered frame and overlap its top border, so the active tab reads as the
   front of the folder opening into the body. See docs/ux/sessions-datagrid.md for the design rationale. */
.tabframe { display: flex; flex-direction: column; gap: 0; min-height: 0; }
/* Square only the top-left corner so the active (leftmost) tab's left border continues the frame's left
   border as one straight line. Top-right and both bottom corners keep the glass radius. */
.tabframe-frame { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 0; overflow: hidden; margin-bottom: 0; border-top-left-radius: 0; }

/* Fill mode: the content column hosting the frame drops its width cap and fills the viewport height, so
   the frame is full-width and its body (not the page) scrolls. Scoped via :has to the .tabframe-fill
   marker; disabled on mobile where the layout is a single scrolling column. */
@media (min-width: 861px) {
    .app-main:has(.tabframe-fill), .app-main:has(.dg-fill) {
        max-width: none;
        height: calc(100dvh - 1.8rem);
        padding-bottom: 0.9rem;
        display: flex;
        flex-direction: column;
    }
    .app-main:has(.tabframe-fill) .tabframe { flex: 1 1 auto; min-height: 0; }
    .app-main:has(.dg-fill) .dg-fill { flex: 1 1 auto; min-height: 0; margin-bottom: 0; }
    /* Width-only full-bleed: treasury read pages (overview/distribution/flow) drop the column cap but keep
       natural page-height scrolling. Marked by the .t-wide sentinel on the page header. */
    .app-main:has(.t-wide) { max-width: none; }
}

/* The strip overlaps the frame's top border by 1px; the active tab carries its own top/side borders +
   glass fill (and no bottom border), so it merges seamlessly into the body — a real folder tab. */
.tabframe-strip { display: flex; gap: 0.3rem; padding: 0; margin-bottom: -1px; position: relative; z-index: 1; }
.tabframe-tab {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.5rem 0.95rem 0.6rem;
    border: 1px solid transparent; border-top-width: 2px; border-bottom: 0;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: transparent; color: var(--text-muted);
    font: inherit; font-weight: 600; font-size: 0.9rem; cursor: pointer;
}
.tabframe-tab .material-symbols-outlined { font-size: 1.1rem; }
.tabframe-tab:hover { color: var(--text); }
.tabframe-tab.active {
    color: var(--text);
    background: var(--glass-bg);
    border-left-color: var(--glass-border);
    border-right-color: var(--glass-border);
    border-top-color: var(--accent);
    backdrop-filter: blur(var(--glass-blur)) saturate(160%);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
}

.tabframe-body { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }

/* Standard content padding for form/section panes (TabPane Padded="true"). Datagrid panes stay flush and let
   their .dg-* children pad edge-to-edge. In fill mode this wrapper is the scroll container. */
.tabpane-pad { padding: 1.25rem 1.4rem; flex: 1 1 auto; min-height: 0; overflow: auto; }

/* ---- Sessions datagrid content (inside the tab frame) -------------------- */

.dg-toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
    padding: 0.9rem 1.4rem; border-bottom: 1px solid var(--border);
}
.dg-filters { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.dg-actions { display: flex; align-items: center; gap: 0.5rem; }
.dg-actions .material-symbols-outlined { font-size: 1.1rem; }

.dg-subhead {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.9rem 1.4rem; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 0.9rem;
}
.dg-message { padding: 0.7rem 1.4rem 0; margin: 0; }
/* A muted footnote inside the frame body, padded to the same gutter as the toolbar/cards. */
.dg-note { color: var(--text-muted); font-size: 0.82rem; margin: 0; padding: 0.5rem 1.4rem 0.9rem; }

/* "⚡ N× active" — shown when a reward multiplier is live for the current scope. */
.mult-badge {
    display: inline-flex; align-items: center; gap: 0.2rem;
    padding: 0.18rem 0.55rem; border-radius: 999px;
    font-size: 0.8rem; font-weight: 700; white-space: nowrap;
    background: linear-gradient(90deg, var(--accent), var(--accent-soft)); color: #fff;
}

/* Segmented status control. */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
    padding: 0.35rem 0.7rem; border: 0; border-left: 1px solid var(--border);
    background: transparent; color: var(--text-muted); font: inherit; font-size: 0.85rem; cursor: pointer;
}
.seg button:first-child { border-left: 0; }
.seg button.active { background: var(--accent); color: #fff; }

.dg-search, .dg-select {
    width: auto; margin: 0; padding: 0.38rem 0.6rem;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-size: 0.85rem;
}
.dg-search { min-width: 11rem; }

/* Spinner shown while a query is in flight. */
.dg-loading { width: 1rem; height: 1rem; border-radius: 50%;
    border: 2px solid var(--border); border-top-color: var(--accent);
    animation: reconnect-spin .8s linear infinite; }

/* The only scrolling region: fills the remaining frame height, rows scroll under a sticky header. */
.dg-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.dg-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.dg-table th, .dg-table td { text-align: left; padding: 0.6rem 1.4rem; border-bottom: 1px solid var(--border); }
.dg-table th {
    position: sticky; top: 0; z-index: 1;
    color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em;
    background: var(--surface); backdrop-filter: blur(var(--glass-blur));
}
.dg-table th.num, .dg-table td.num { text-align: right; }
.dg-table th.sortable { cursor: pointer; user-select: none; }
.dg-table th.sortable:hover { color: var(--text); }
.dg-table tbody tr:hover { background: var(--surface); }
.dg-table .dg-empty td { text-align: center; color: var(--text-muted); padding: 2.25rem 1rem; }

.dg-actions-col { width: 1%; white-space: nowrap; text-align: right; }
.dg-row-actions { display: inline-flex; gap: 0.35rem; justify-content: flex-end; }

/* Signed amounts: +/- in the data column. Scoped to .dg-table so the existing .leaderboard rule is untouched. */
.dg-table td.pos { color: #4ade80; font-weight: 600; }
.dg-table td.neg { color: var(--danger); font-weight: 600; }

/* Ledger source chip — icon + label inline, used in the Source column of the activity/movement grids. */
.src-chip { display: inline-flex; align-items: center; gap: 0.35rem; }
.src-chip .material-symbols-outlined { font-size: 1rem; opacity: 0.78; }

/* Audit log specifics. */
.dg-zone-label { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--text-muted); font-size: 0.85rem; }
.dg-zone-label .material-symbols-outlined { font-size: 1rem; }
.audit-action { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
/* One-line summary cell — chips and amounts stay inline, overflow truncates with ellipsis. The popup carries the
   full breakdown so nothing's lost. */
.audit-details {
    color: var(--text); max-width: 32rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.audit-details .user-chip { display: inline-flex; vertical-align: middle; }
.audit-details .user-chip-name { display: inline; }
.audit-details .avatar-sm { display: inline-block; vertical-align: middle; }

/* Category pill that precedes the action key — color-coded per AuditCategory so the eye groups by area. */
.audit-cat {
    display: inline-block; margin-right: 0.4rem;
    padding: 0.08rem 0.4rem; border-radius: 999px;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
    background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); white-space: nowrap;
}
.audit-cat-configuration { background: rgba(96, 165, 250, 0.18); color: #60a5fa; border-color: transparent; }
.audit-cat-currency      { background: rgba(74, 222, 128, 0.18); color: #4ade80; border-color: transparent; }
.audit-cat-tracking      { background: rgba(245, 158, 11, 0.18); color: #f59e0b; border-color: transparent; }
.audit-cat-quests        { background: rgba(167, 139, 250, 0.18); color: #a78bfa; border-color: transparent; }
.audit-cat-seasons       { background: rgba(244, 114, 182, 0.18); color: #f472b6; border-color: transparent; }
.audit-cat-membership    { background: rgba(45, 212, 191, 0.18); color: #2dd4bf; border-color: transparent; }
.audit-cat-apiclients    { background: rgba(248, 113, 113, 0.18); color: #f87171; border-color: transparent; }
.audit-cat-system        { background: rgba(148, 163, 184, 0.20); color: #94a3b8; border-color: transparent; }

/* Origin pill — different palette than the category so they don't compete visually. */
.audit-origin {
    display: inline-block;
    padding: 0.08rem 0.45rem; border-radius: var(--radius-sm);
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
    background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); white-space: nowrap;
}
.audit-origin-ui        { color: #60a5fa; border-color: rgba(96, 165, 250, 0.5); }
.audit-origin-bot       { color: #5865f2; border-color: rgba(88, 101, 242, 0.5); }
.audit-origin-api       { color: #f59e0b; border-color: rgba(245, 158, 11, 0.5); }
.audit-origin-connector { color: #2dd4bf; border-color: rgba(45, 212, 191, 0.5); }
.audit-origin-system    { color: #94a3b8; border-color: rgba(148, 163, 184, 0.5); }
.audit-origin-unknown   { color: var(--text-muted); }

/* Outcome badge — three states. Success is muted/subtle so the eye lands on the failures. */
.audit-outcome {
    display: inline-block;
    padding: 0.08rem 0.45rem; border-radius: var(--radius-sm);
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap;
}
.audit-outcome-success { color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); }
.audit-outcome-denied  { color: #f59e0b; background: rgba(245, 158, 11, 0.18); }
.audit-outcome-failed  { color: var(--danger); background: rgba(248, 113, 113, 0.18); }
.audit-outcome-warning { color: #eab308; background: rgba(234, 179, 8, 0.16); }

/* Correlation link inline with the action — a small chip the admin can click to drill in. */
.audit-corr {
    display: inline-flex; align-items: center; gap: 0.2rem; margin-left: 0.5rem;
    padding: 0.05rem 0.4rem; border-radius: 999px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.7rem;
    color: var(--text-muted); background: var(--surface); border: 1px solid var(--border);
    cursor: pointer;
}
.audit-corr:hover { color: var(--accent); border-color: var(--accent); }
.audit-corr .material-symbols-outlined { font-size: 0.85rem; }

/* Audit KPI strip + compact charts row — both kept short so the datagrid below still dominates the page. */
.audit-kpis .stat .num.audit-kpi-chip { font-size: 0.95rem; }
.audit-kpis .stat .num.audit-warning { color: #f59e0b; }

.audit-charts {
    display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 0.8rem; margin-bottom: 0.9rem;
}
@media (max-width: 860px) {
    .audit-charts { grid-template-columns: 1fr; }
}

.audit-chart { padding: 0.7rem 0.9rem; display: flex; flex-direction: column; gap: 0.45rem; }
.audit-chart-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem;
}
.audit-chart-head .label {
    color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em;
}
.audit-chart-head .subtitle { color: var(--text-muted); font-size: 0.78rem; }
.audit-chart-foot {
    display: flex; justify-content: space-between;
    color: var(--text-muted); font-size: 0.7rem;
}
.audit-chart-empty { color: var(--text-muted); font-size: 0.85rem; text-align: center; padding: 0.4rem 0; }

.audit-chart-bars svg { width: 100%; height: 56px; display: block; }
.audit-bar { fill: var(--accent); opacity: 0.85; }
.audit-bar:hover { opacity: 1; }

/* Origin breakdown: a single horizontal segmented bar + a tight legend below. */
.audit-origin-bar {
    display: flex; height: 12px; border-radius: 999px; overflow: hidden;
    background: var(--surface);
}
.audit-origin-seg { display: block; height: 100%; }
.audit-origin-seg.audit-origin-ui        { background: #60a5fa; }
.audit-origin-seg.audit-origin-bot       { background: #5865f2; }
.audit-origin-seg.audit-origin-api       { background: #f59e0b; }
.audit-origin-seg.audit-origin-connector { background: #2dd4bf; }
.audit-origin-seg.audit-origin-system    { background: #94a3b8; }
.audit-origin-seg.audit-origin-unknown   { background: var(--text-muted); }
.audit-origin-legend {
    display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem;
    font-size: 0.75rem; color: var(--text-muted);
}
.audit-origin-legend-item { display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; }
.audit-origin-dot { width: 8px; height: 8px; border-radius: 50%; }
.audit-origin-dot.audit-origin-ui        { background: #60a5fa; }
.audit-origin-dot.audit-origin-bot       { background: #5865f2; }
.audit-origin-dot.audit-origin-api       { background: #f59e0b; }
.audit-origin-dot.audit-origin-connector { background: #2dd4bf; }
.audit-origin-dot.audit-origin-system    { background: #94a3b8; }
.audit-origin-dot.audit-origin-unknown   { background: var(--text-muted); }
.audit-origin-name { color: var(--text); }
.audit-origin-count { color: var(--text-muted); }

.audit-correlation-banner {
    display: inline-flex; align-items: center; gap: 0.5rem;
    color: var(--text-muted); font-size: 0.85rem;
}

/* Sub-toolbar row hosting the multi-select pill rows. Sits below the main dg-toolbar with a softer border. */
.dg-toolbar-sub {
    border-top: 1px solid var(--border);
    padding: 0.55rem 1.4rem; gap: 1rem;
}
.dg-pill-row { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.dg-pill-label { color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.dg-pill {
    padding: 0.18rem 0.55rem; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600;
    border: 1px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer;
}
.dg-pill:hover { color: var(--text); border-color: var(--accent); }
.dg-pill.active { background: var(--accent); color: #fff; border-color: transparent; }
.dg-pill-clear { color: var(--text-muted); border: 0; padding: 0 0.3rem; font-size: 0.9rem; }
.dg-pill-clear:hover { color: var(--danger); }
.audit-row { cursor: pointer; }
.audit-row:hover { background: var(--surface); }

/* Audit token styles — driven by the AuditStyle flags emitted by formatters. */
.audit-bold { font-weight: 600; }
.audit-italic { font-style: italic; }
.audit-underline { text-decoration: underline; }
.audit-muted { color: var(--text-muted); }
.audit-positive { color: #4ade80; font-weight: 600; }
.audit-negative { color: var(--danger); font-weight: 600; }
.audit-warning { color: #f59e0b; font-weight: 600; }
.audit-tok-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem;
    background: var(--surface); padding: 0 0.3rem; border-radius: var(--radius-sm);
}
.audit-tok-id, .audit-tok-role, .audit-tok-channel, .audit-tok-currency {
    color: var(--text-muted); font-size: 0.85rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.audit-tok-amount { font-weight: 600; }
.audit-tok-amount.pos { color: #4ade80; }
.audit-tok-amount.neg { color: var(--danger); }

/* Detail sheet — centered modal on desktop, right slide-sheet on mobile. Backdrop is a sibling so a click
   outside the sheet dismisses without leaking events to the underlying row. */
.audit-backdrop {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
}
.audit-sheet {
    position: fixed; z-index: 91;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    display: flex; flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    outline: none;
}
.audit-sheet-head {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.9rem 1.2rem; border-bottom: 1px solid var(--border);
}
.audit-sheet-title { display: flex; flex-direction: column; gap: 0.2rem; flex: 1 1 auto; min-width: 0; }
.audit-sheet-when { color: var(--text-muted); font-size: 0.82rem; }
.audit-sheet-actor { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }
.audit-sheet-body {
    padding: 0.6rem 1.2rem 1.2rem;
    overflow: auto;
    display: flex; flex-direction: column; gap: 1rem;
}
.audit-sheet-section h3 {
    margin: 0.6rem 0 0.3rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-muted);
}
.audit-section-body { white-space: pre-wrap; word-break: break-word; }

/* Structured label / value grid for formatter sections. Two columns, baseline-aligned, with a subtle row
   divider so dense payloads still read at a glance. */
.audit-kv {
    display: grid;
    grid-template-columns: minmax(7rem, auto) 1fr;
    column-gap: 1rem; row-gap: 0.4rem;
    margin: 0;
}
.audit-kv dt {
    color: var(--text-muted); font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600;
    padding-top: 0.1rem;
}
.audit-kv dd { margin: 0; color: var(--text); word-break: break-word; }
.audit-kv dd .user-chip { display: inline-flex; }

/* Desktop: centered modal. */
@media (min-width: 861px) {
    .audit-sheet {
        top: 50%; left: 50%; transform: translate(-50%, -50%);
        width: min(720px, 92vw); max-height: 82vh;
    }
}

/* Mobile: right-edge full-height flyout. */
@media (max-width: 860px) {
    .audit-sheet {
        top: 0; right: 0; bottom: 0;
        width: min(92vw, 28rem); border-radius: 0;
        border-right: 0; border-top: 0; border-bottom: 0;
    }
}

.status-dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-right: 0.4rem; vertical-align: middle; flex: 0 0 auto; }
.status-dot.is-active { background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18); }
.status-dot.is-paused { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18); }
.status-dot.is-stats  { background: var(--accent-soft); }
.status-dot.is-ended { background: var(--text-muted); opacity: 0.5; }

.dg-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    padding: 0.9rem 1.4rem; border-top: 1px solid var(--border);
    color: var(--text-muted); font-size: 0.88rem;
}
.dg-footer-left { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.dg-pagesize { display: flex; align-items: center; gap: 0.4rem; }
.dg-pagesize .dg-select { padding: 0.25rem 0.45rem; }
.dg-tz { font-size: 0.85rem; }
.dg-pager { display: flex; align-items: center; gap: 0.75rem; }

.banner-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

/* Warning notice (e.g. "you're being tracked"): amber accent + a left status bar + icon. */
.banner-warn {
    gap: 0.75rem;
    border: 1px solid color-mix(in srgb, #d97706 45%, var(--border));
    border-left: 3px solid #d97706;
    background: color-mix(in srgb, #d97706 10%, var(--surface));
}
.banner-warn .banner-icon { color: #d97706; font-size: 1.5rem; flex: 0 0 auto; }
.banner-warn .banner-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; flex: 1 1 16rem; }
.banner-warn .banner-why { color: var(--text-muted); font-size: 0.82rem; }
.banner-warn .btn { flex: 0 0 auto; }

/* Channel reference: kind icon (voice speaker, text #, stage, forum, …) + name, so the type reads at a glance. */
.channel-ref { display: inline-flex; align-items: center; gap: 0.3rem; }
.channel-ref .material-symbols-outlined { font-size: 1.05rem; color: var(--text-muted); }

/* ---- Voice leaderboard ---------------------------------------------------- */
.lb-rank-col { width: 3.25rem; }
.lb-rank { font-weight: 700; font-size: 1.05rem; }
.lb-table tbody tr.lb-me { background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* Voice time + a slim bar beneath it, scaled to the #1 member (so it's consistent across pages). */
.lb-bar { display: inline-block; min-width: 6rem; padding-bottom: 0.4rem; position: relative; }
.lb-bar span { font-variant-numeric: tabular-nums; }
.lb-bar::after {
    content: ""; position: absolute; left: 0; bottom: 0; height: 4px;
    width: var(--lb-pct, 0%); border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-soft));
}

/* ---- Session detail: live ops dashboard ----------------------------------- */
.sess-head { padding: 0.2rem 0 1rem; margin-bottom: 1.1rem; border-bottom: 1px solid var(--border); }
.sess-head-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.sess-back .material-symbols-outlined { font-size: 1.1rem; }
.sess-head-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.sess-head-actions .btn .material-symbols-outlined { font-size: 1.1rem; }
.updated { color: var(--text-muted); font-size: 0.8rem; }

.sess-title { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.6rem 0 0.55rem; }
.sess-title h1 { margin: 0; }

.live-badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.18rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.04em;
    background: rgba(74, 222, 128, 0.16); color: #16a34a;
}
.live-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: #22c55e; animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,0.5); } 50% { opacity: 0.6; box-shadow: 0 0 0 5px rgba(34,197,94,0); } }
.badge.ended-badge { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }

.sess-meta { display: flex; align-items: center; gap: 0.3rem 0.5rem; flex-wrap: wrap; color: var(--text-muted); font-size: 0.9rem; }
.sess-meta > span { display: inline-flex; align-items: center; gap: 0.3rem; }
.sess-meta > span + span::before { content: "·"; margin-right: 0.5rem; }
.sess-meta .material-symbols-outlined { font-size: 1.05rem; }

.sess-kpis { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 0.75rem; margin-bottom: 1rem; }
.kpi { flex: 1 1 8rem; max-width: 14rem; padding: 0.85rem 1rem; text-align: center; display: flex; flex-direction: column; justify-content: center; }
.kpi-num { font-size: 1.5rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-num.accent { color: #16a34a; }
.kpi-num.warn { color: #d97706; }
.kpi-num.muted { color: var(--text-muted); }
.kpi-sub { font-size: 0.95rem; font-weight: 600; color: var(--text-muted); margin-left: 0.25rem; }
.kpi-unit { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-left: 0.2rem; }
.kpi-label { color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 0.2rem; display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem; }
.mult-chip {
    display: inline-flex; align-items: center; padding: 0.05rem 0.4rem; border-radius: 999px;
    font-size: 0.7rem; font-weight: 800; letter-spacing: 0; text-transform: none;
    background: linear-gradient(90deg, var(--accent), var(--accent-soft)); color: #fff;
}

.sess-rules { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.rules-label { font-weight: 600; }
.rules-hint { color: var(--text-muted); font-size: 0.8rem; }
.rule-chip {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.25rem 0.65rem; border-radius: 999px; border: 1px solid var(--border); font-size: 0.85rem;
}
.rule-chip .material-symbols-outlined { font-size: 1.05rem; }
.rule-chip.on { background: var(--accent); color: #fff; border-color: transparent; }
.rule-chip.off { color: var(--text-muted); opacity: 0.7; }

/* Timeline visuals */
.viz { padding: 1rem 1.2rem 1.2rem; }
.viz .panel-head { margin-bottom: 0.6rem; }
.occ { margin-bottom: 1rem; }
.occ-svg { width: 100%; height: 5rem; display: block; }
.occ-area { fill: var(--accent); opacity: 0.14; }
.occ-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.occ-axis { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 0.78rem; margin-top: 0.2rem; }

.gantt { display: flex; flex-direction: column; gap: 0.3rem; max-height: 20rem; overflow: hidden auto; }
.gantt-row { display: flex; align-items: center; gap: 0.6rem; }
.gantt-name { flex: 0 0 11rem; width: 11rem; display: flex; align-items: center; gap: 0.35rem; min-width: 0; font-size: 0.85rem; }
.gantt-name .user-chip { min-width: 0; }
.gantt-name .user-chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-track { position: relative; flex: 1 1 auto; height: 0.85rem; background: var(--surface); border-radius: 999px; overflow: hidden; }
.gantt-bar { position: absolute; top: 0; height: 100%; border-radius: 999px; background: var(--accent); opacity: 0.7; }
.gantt-bar.live { opacity: 1; background: linear-gradient(90deg, var(--accent), #22c55e); animation: live-pulse 1.8s ease-in-out infinite; }

/* Exact (event-driven) gantt: each presence run is split into earning (green) / paused (amber) segments. */
.gantt-seg { position: absolute; top: 0; height: 100%; }
.gantt-seg.earn { background: #22c55e; }
.gantt-seg.paused { background: #d97706; opacity: 0.55; }
.gantt-row .gantt-seg:first-of-type { border-radius: 999px 0 0 999px; }
.gantt-row .gantt-seg:last-of-type { border-radius: 0 999px 999px 0; }
.seg-key { display: inline-flex; align-items: center; gap: 0.25rem; margin-left: 0.4rem; }
.seg-key::before { content: ""; width: 0.6rem; height: 0.6rem; border-radius: 2px; }
.seg-key.earn::before { background: #22c55e; }
.seg-key.paused::before { background: #d97706; opacity: 0.55; }

/* Status donut, embedded as a KPI tile on active sessions: donut + chip legend, content-sized. */
.kpi-donut { flex: 0 1 auto; max-width: none; flex-direction: row; align-items: center; gap: 0.85rem; padding: 0.7rem 0.9rem; text-align: left; }
.donut { width: 3.6rem; height: 3.6rem; flex: 0 0 auto; }
.donut-track { fill: none; stroke: var(--border); stroke-width: 3; }
.donut-seg { fill: none; stroke-width: 3; }
.donut-seg.earn { stroke: #22c55e; }
.donut-seg.paused { stroke: #d97706; }
.donut-seg.left { stroke: var(--text-muted); opacity: 0.5; }
.donut-center { fill: var(--text); font-size: 0.5rem; font-weight: 800; text-anchor: middle; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.donut-legend li {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.12rem 0.5rem; border-radius: 999px; border: 1px solid var(--border);
    font-size: 0.78rem; white-space: nowrap;
}
.donut-legend b { margin-left: auto; padding-left: 0.4rem; font-variant-numeric: tabular-nums; }

/* Medal + member name in the attendance grid. */
.dg-member { display: inline-flex; align-items: center; gap: 0.4rem; }
.medal { font-size: 1.05rem; line-height: 1; }

/* Per-button loading spinner: pair with the Material Symbol `progress_activity` while a command is in flight. */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.9s linear infinite; display: inline-block; }
.btn .spin, .icon-btn .spin { vertical-align: -2px; }

/* Top progress bar (TopProgress.razor): fixed across the viewport's top edge while any page-level work is in
   flight. Indeterminate — a single gradient bar slides off-left → off-right, repeating with an ease curve.
   Always-rendered so .on/off fades smoothly via opacity transition. */
.top-progress {
    position: fixed; top: 0; left: 0; right: 0;
    height: 2px; overflow: hidden; pointer-events: none;
    z-index: 9999;
    opacity: 0; transition: opacity 0.25s ease;
}
.top-progress.on { opacity: 1; }
.top-progress-bar {
    position: absolute; top: 0; height: 100%; width: 30%;
    left: -30%;
    background: linear-gradient(90deg, transparent, var(--accent) 40%, var(--accent) 60%, transparent);
    box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 70%, transparent);
    animation: top-progress-slide 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes top-progress-slide {
    0%   { left: -30%; }
    100% { left: 100%; }
}

/* ---- Background tab (live presence) --------------------------------------- */
.bg-card { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 0.9rem 1.4rem; }
/* Header sticks to the top of the scroll region while its members scroll past (no overflow:hidden on the
   card, which would clip the sticky). */
.bg-card-head {
    position: sticky; top: 0; z-index: 1; cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
    padding: 0.6rem 0.85rem; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    backdrop-filter: blur(var(--glass-blur));
}
.bg-card-head:hover { color: var(--text); }
.bg-chevron { font-size: 1.2rem; color: var(--text-muted); }
.bg-card-head .channel-ref { font-weight: 600; }
.bg-rate { color: var(--text-muted); font-size: 0.82rem; }
.bg-count { margin-left: auto; color: var(--text-muted); font-size: 0.82rem; }
.badge.bg-reward { background: var(--accent); color: #fff; }
.badge.bg-stats { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }

.bg-members { display: flex; flex-direction: column; }
.bg-member { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.85rem; border-top: 1px solid var(--border); }
.bg-member:first-child { border-top: 0; }
.bg-member.lb-me { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.bg-member-meta { margin-left: auto; color: var(--text-muted); font-size: 0.82rem; text-align: right; }

/* Pinned "you" row, rendered outside the grid when the viewer isn't on the current page. */
.lb-self {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 1.4rem; border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.lb-self .lb-rank { width: 3.25rem; }
.lb-self .lb-you { font-weight: 600; }
.lb-self .lb-self-time { margin-left: auto; font-variant-numeric: tabular-nums; }

/* Small muted footnote stating which zone times are shown in (detail / me pages have no grid footer). */
.tz-note { color: var(--text-muted); font-size: 0.82rem; margin: 0.35rem 0.25rem 0; }

/* Interactive-circuit reconnect overlay. Hidden by default; blazor.web.js adds the components-reconnect-*
   classes to #components-reconnect-modal as the circuit drops/recovers, and these rules reveal the right state. */
.reconnect-modal { display: none; position: fixed; inset: 0; z-index: 1000;
    align-items: center; justify-content: center; padding: 1rem;
    background: rgba(8, 18, 37, 0.45); backdrop-filter: blur(2px); }
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected { display: flex; }

.reconnect-card { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
    padding: 1rem 1.25rem; border-radius: var(--radius, 16px); color: var(--text); max-width: 90vw; }
.reconnect-spinner { width: 1.1rem; height: 1.1rem; flex: none; border-radius: 50%;
    border: 2px solid var(--border, rgba(127,127,127,.3)); border-top-color: var(--accent, #2563eb);
    animation: reconnect-spin .8s linear infinite; }
@keyframes reconnect-spin { to { transform: rotate(360deg); } }

/* One card, three messages — show only the one matching the current circuit state. */
.reconnect-text { margin: 0; display: none; align-items: center; gap: .5rem; }
#components-reconnect-modal.components-reconnect-show    .reconnect-text-show     { display: flex; }
#components-reconnect-modal.components-reconnect-failed   .reconnect-text-failed   { display: flex; }
#components-reconnect-modal.components-reconnect-rejected .reconnect-text-rejected { display: flex; }
/* The spinner only makes sense while actively retrying. */
#components-reconnect-modal.components-reconnect-failed .reconnect-spinner,
#components-reconnect-modal.components-reconnect-rejected .reconnect-spinner { display: none; }

/* --- Members directory + MemberDetail --- */

/* Tracking-state pill on the Members directory + MemberDetail header. Color-coded by choice. */
.track-pill { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; padding: .12rem .5rem;
    border-radius: 999px; border: 1px solid var(--border, rgba(127,127,127,.3)); color: var(--text); white-space: nowrap; }
.track-pill.track-default { background: rgba(127,127,127,.12); }
.track-pill.track-in { background: rgba(34,197,94,.16); border-color: rgba(34,197,94,.35); }
.track-pill.track-backgroundout { background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.35); }
.track-pill.track-allout { background: rgba(239,68,68,.16); border-color: rgba(239,68,68,.35); }
.track-pill.track-dmout { background: rgba(99,102,241,.16); border-color: rgba(99,102,241,.35); margin-left: .25rem; }

/* Role chip in MemberDetail Overview. */
.role-chip { display: inline-block; font-size: .72rem; padding: .1rem .5rem; margin: .15rem .15rem 0 0;
    border-radius: 999px; background: rgba(127,127,127,.12); border: 1px solid var(--border, rgba(127,127,127,.25)); }
.member-roles { display: flex; flex-wrap: wrap; gap: .15rem; margin-top: .25rem; }

/* Section spacing inside MemberDetail tabs (vertical rhythm between Balances/Voice/Roles/etc.). */
.member-detail-section { display: flex; flex-direction: column; gap: .75rem; }
.member-detail-section h2 { margin: .75rem 0 .25rem 0; font-size: 1rem; }
.member-detail-section h3 { margin: .5rem 0 .25rem 0; font-size: .9rem; }

/* Inline checkbox in the Members toolbar (DM opt-outs filter). */
.dg-check { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--text-soft, #b9c0d4); }
.dg-check input { margin: 0; }

/* Clickable UserChip — pages pass Href when the viewer can drill into MemberDetail. Underline on hover,
   inherit color so the chip doesn't repaint as a generic link. */
a.user-chip-link { text-decoration: none; color: inherit; cursor: pointer; }
a.user-chip-link:hover .user-chip-name b { text-decoration: underline; }
a.user-chip-link:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; border-radius: 6px; }

/* --- MemberDetail header (profile card above KPIs + tabs) — no frame; sits on the page background. --- */
.member-header { display: flex; align-items: center; gap: 1rem; padding: 0 .25rem .75rem .25rem; }
.member-header-avatar { flex: 0 0 auto; width: 56px; height: 56px; border-radius: 50%; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(127,127,127,.18); border: 1px solid var(--border, rgba(127,127,127,.3)); }
.member-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-header-avatar .avatar-initial { font-size: 1.5rem; font-weight: 600; color: var(--text); }
.member-header-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .25rem; }
.member-header-name { margin: 0; font-size: 1.4rem; line-height: 1.2; }
.member-header-pills { display: flex; flex-wrap: wrap; gap: .25rem; }
.member-header-meta { font-size: .8rem; color: var(--text-soft, #b9c0d4); display: flex; flex-wrap: wrap; gap: .35rem; }

/* Page-level toolbar under header + KPIs — actions that span the whole member, not one tab. */
.member-toolbar { display: flex; gap: .5rem; align-items: center; margin: .5rem 0 .75rem 0; }

/* Member audit grid: every non-Details column shrinks to its content (width:1% + nowrap is the
   table-layout-auto trick); Details (last column) claims the rest with single-line ellipsis. */
.audit-member-table th, .audit-member-table td { white-space: nowrap; }
.audit-member-table th:not(:last-child),
.audit-member-table td:not(:last-child) { width: 1%; }
.audit-member-table th:last-child,
.audit-member-table td:last-child { width: auto; max-width: 0;
    overflow: hidden; text-overflow: ellipsis;
    color: var(--text-soft, #b9c0d4); font-size: .85rem; }
.audit-member-table .audit-action { font-size: .8rem; }
.audit-cat { display: inline-flex; font-size: .7rem; padding: .1rem .45rem; border-radius: 999px;
    border: 1px solid var(--border, rgba(127,127,127,.3)); background: rgba(127,127,127,.12); }


/* ---- Participation parts (Overview / Season) ----------------------------- */
/* KPI tiles reuse .stat-grid + .card.glass.stat; these add the watermark + sparkline + accents. */
.card.glass.stat { position: relative; overflow: hidden; }
.stat .kpi-ico { position: absolute; top: 0.3rem; right: 0.45rem; font-size: 3.6rem; opacity: 0.1; pointer-events: none; }
.stat .num.accent-green { color: #4ade80; }
.stat .num.accent-amber { color: #EF9F27; }
.pp-spark { width: 100%; height: 24px; margin-top: 0.35rem; display: block; }
.pp-spark polyline { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.pp-spark.green polyline { stroke: #4ade80; }
.pp-spark.amber polyline { stroke: #EF9F27; }
.pp-spark.blue polyline { stroke: #60a5fa; }
.pp-spark.violet polyline { stroke: #7F77DD; }

/* Season sub-heading */
.pp-seasonhead { display: flex; align-items: center; gap: 0.6rem; margin: 0.2rem 0 1rem; }
.pp-seasonname { font-size: 1.05rem; font-weight: 600; }
.pp-tag { font-size: 0.7rem; background: rgba(239, 159, 39, 0.18); color: #EF9F27; padding: 2px 8px; border-radius: 0.5rem;
    text-transform: uppercase; letter-spacing: 0.03em; }

/* Frameless cards + 50/50 split */
.pp-card { background: rgba(255, 255, 255, 0.025); border: 1px solid var(--glass-border); border-radius: var(--radius);
    padding: 1rem 1.2rem; margin-bottom: 1rem; }
.pp-card .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.9rem; }
.pp-card h2 { margin: 0; font-size: 1rem; }
.pp-rankctl { display: inline-flex; align-items: center; gap: 0.5rem; }
.pp-card .legend { display: flex; gap: 1rem; font-size: 0.78rem; color: var(--text-muted); flex-wrap: wrap; }
.pp-card .legend > span { display: inline-flex; align-items: center; gap: 0.3rem; }
.pp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .pp-cols { grid-template-columns: 1fr; } }

.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.sw.bar { background: #1D9E75; }
.sw.new { background: #1D9E75; }
.sw.ret { background: #60a5fa; }
.sw.churn { background: var(--danger); }
.ln.rate { width: 14px; height: 2px; background: #EF9F27; }

/* Engagement-by-season combo (bars + participation line) */
.pp-combo { width: 100%; height: 168px; }
.pp-combo .axis { stroke: rgba(255, 255, 255, 0.1); }
.pp-combo .p-cbar { fill: #1D9E75; }
.pp-combo .p-rate { fill: none; stroke: #EF9F27; stroke-width: 2; vector-effect: non-scaling-stroke; }
.pp-combo .p-dot { fill: #EF9F27; }
.pp-axis-labels { display: flex; gap: 10px; margin-top: 6px; font-size: 0.72rem; color: var(--text-muted); text-align: center; }
.pp-axis-labels > span { flex: 1; }
.pp-axis-labels .cnt { color: var(--text-muted); opacity: 0.8; }

/* Weekly velocity bars */
.pp-bars { display: flex; align-items: flex-end; gap: 10px; height: 112px; }
.pp-bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.pp-bar { width: 100%; max-width: 46px; background: #1D9E75; border-radius: 3px 3px 0 0; min-height: 2px; }

/* Earner-movement stacked bars (new / returning / churned) */
.pp-stack { width: 100%; height: 150px; }
.pp-stack .axis { stroke: rgba(255, 255, 255, 0.12); }
.pp-stack .s-new { fill: #1D9E75; }
.pp-stack .s-ret { fill: #60a5fa; }
.pp-stack .s-churn { fill: var(--danger); }
.pp-stack .zero { stroke: rgba(255, 255, 255, 0.18); }

/* Cumulative-reach / cumulative-points area */
.pp-area { width: 100%; height: 150px; }
.pp-area .axis { stroke: rgba(255, 255, 255, 0.1); }
.pp-area .fill { fill: rgba(29, 158, 117, 0.18); stroke: none; }
.pp-area .line { fill: none; stroke: #1D9E75; stroke-width: 2; vector-effect: non-scaling-stroke; }

/* Earner-mix donut */
.pp-donut { display: flex; align-items: center; gap: 1.4rem; }
.pp-donut-legend { display: flex; flex-direction: column; gap: 0.45rem; font-size: 0.88rem; min-width: 9rem; }
.pp-donut-legend > div { display: flex; align-items: center; gap: 0.45rem; }
.pp-donut-legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.pp-dot { width: 0.7rem; height: 0.7rem; border-radius: 0.2rem; flex: 0 0 auto; }
.pp-dot.new { background: #1D9E75; }
.pp-dot.ret { background: #60a5fa; }
.pp-dot.churn { background: var(--danger); }

/* Source bars */
.pp-src { display: flex; align-items: center; gap: 0.7rem; margin: 0.5rem 0; font-size: 0.88rem; }
.pp-src .name { width: 120px; display: inline-flex; align-items: center; gap: 0.3rem; color: var(--text); flex: none; }
.pp-src .name .material-symbols-outlined { font-size: 1.05rem; color: var(--text-muted); }
.pp-src .bar { flex: 1; height: 8px; background: rgba(255, 255, 255, 0.05); border-radius: 5px; overflow: hidden; }
.pp-src .bar .fill { height: 100%; background: #1D9E75; border-radius: 5px; }
.pp-src .val { width: 60px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-muted); flex: none; }

/* Podium rows + medals */
.pp-pod { display: flex; align-items: center; gap: 0.6rem; padding: 6px 0; border-bottom: 0.5px solid var(--border); font-size: 0.9rem; }
.pp-pod .rank { width: 22px; color: var(--text-muted); flex: none; text-align: center; }
.pp-pod .rank.gold, .pp-pod .rank.silver, .pp-pod .rank.bronze {
    height: 22px; line-height: 22px; border-radius: 50%; font-weight: 700; font-size: 0.78rem; color: #1c1606; }
.pp-pod .rank.gold { background: linear-gradient(145deg, #fde68a, #f59e0b); }
.pp-pod .rank.silver { background: linear-gradient(145deg, #f1f5f9, #94a3b8); }
.pp-pod .rank.bronze { background: linear-gradient(145deg, #f7c08a, #b45309); color: #fff; }
.pp-pod .val { margin-left: auto; font-variant-numeric: tabular-nums; }
