/* ============================================================ */
/* mujun.wiki — Frosted Encyclopedia in a Jewel Box              */
/* ============================================================ */

/*
 * Design notes — implementation reference (per DESIGN.md):
 *   Interlocking Circles:** Overlapping circles forming a classic
 *   retro tessellation on a 36px grid sit behind the central content well.
 *   The watercolor field is parallax-driven via scroll listeners (no
 *   IntersectionObserver` use) — the transition should be glacially slow
 *   and barely noticeable on a per-scroll-tick basis.
 */

:root {
    /* Jewel-tone palette (exact hexes from DESIGN.md) */
    --amethyst: #6A0DAD;
    --sapphire: #1B3A8C;
    --emerald:  #047857;
    --ruby:     #B91C42;
    --topaz:    #D4920B;
    --opal:     rgba(255, 255, 255, 0.12);
    --obsidian: #0D0221;
    --obsidian-deep: #1A0536;
    --pearl:    #F0ECF5;
    --pure:     #FFFFFF;

    /* Glass panel construction (per DESIGN.md spec) */
    --glass-bg:        rgba(255, 255, 255, 0.12);
    --glass-bg-strong: rgba(255, 255, 255, 0.16);
    --glass-bg-soft:   rgba(255, 255, 255, 0.09);
    --glass-border:    rgba(255, 255, 255, 0.18);
    --glass-inner:     rgba(255, 255, 255, 0.25);

    /* Layout */
    --rail-w:  240px;
    --side-w:  280px;
    --gap:     24px;
    --topbar-h: 96px;

    /* Motion — every transition is elastic */
    --elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

    /* Spectral cycle (animated by JS via --spectral-hue) */
    --spectral-hue: 280deg;

    /* Pattern breathing */
    --pattern-opacity: 0.10;
}

/* ============================================================ */
/* Reset / base                                                 */
/* ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

body {
    font-family: "Nunito Sans", "Nunito", system-ui, sans-serif;
    font-size: 17px;
    line-height: 1.72;
    font-weight: 400;
    color: var(--pearl);
    background:
        radial-gradient(140% 90% at 50% 0%, var(--obsidian-deep) 0%, var(--obsidian) 60%, #060110 100%);
    background-attachment: fixed;
    overflow-x: hidden;
}

::selection {
    background: rgba(212, 146, 11, 0.45);
    color: var(--pure);
}

a {
    color: var(--sapphire);
    text-decoration: none;
    transition: color 300ms var(--elastic), text-shadow 300ms var(--elastic);
}

/* Sapphire is darker than the page — links in body need a luminous twin */
.well a, .lead a, .card a, blockquote a {
    color: #7FB0FF;
    text-shadow: 0 0 12px rgba(27, 58, 140, 0.5);
}
.well a:hover, .lead a:hover, .card a:hover, blockquote a:hover {
    color: var(--topaz);
    text-shadow: 0 0 14px rgba(212, 146, 11, 0.55);
}

h1, h2, h3, h4, h5, h6 {
    font-family: "Quicksand", "Nunito", sans-serif;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
    color: var(--pure);
    text-shadow: 0 2px 8px rgba(106, 13, 173, 0.35);
    margin: 0 0 0.65em;
}

h3, h4, h5, h6 {
    font-family: "Nunito", sans-serif;
    font-weight: 600;
    letter-spacing: 0.02em;
}

p { margin: 0 0 1em; }
strong { color: var(--pure); font-weight: 700; }
em { color: #E9DCF5; font-style: italic; }

code, .inline-code, pre, .code-card {
    font-family: "Comfortaa", "Nunito", monospace;
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* ============================================================ */
/* Atmosphere — layers 2 / 3 / 4                                 */
/* ============================================================ */
.atmosphere {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

/* Layer 3 — retro pattern substrate (zone-aware) */
.pattern-substrate {
    position: absolute;
    opacity: var(--pattern-opacity);
    transition: opacity 600ms var(--ease-out);
    filter: hue-rotate(var(--spectral-hue));
    mix-blend-mode: screen;
}

.pattern-substrate--rail {
    left: 0;
    top: var(--topbar-h);
    width: calc(var(--rail-w) + var(--gap) * 2);
    bottom: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48'><g stroke='%236A0DAD' stroke-width='1' fill='none' opacity='0.85' transform='rotate(15 24 24)'><line x1='24' y1='4' x2='24' y2='44'/><line x1='4' y1='24' x2='44' y2='24'/><line x1='10' y1='10' x2='38' y2='38'/><line x1='38' y1='10' x2='10' y2='38'/><line x1='24' y1='6' x2='32' y2='24'/><line x1='24' y1='6' x2='16' y2='24'/><line x1='24' y1='42' x2='32' y2='24'/><line x1='24' y1='42' x2='16' y2='24'/><circle cx='24' cy='24' r='3'/></g></svg>");
}

.pattern-substrate--center {
    left: calc(var(--rail-w) + var(--gap) * 2);
    right: calc(var(--side-w) + var(--gap) * 2);
    top: var(--topbar-h);
    bottom: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='36' height='36'><g stroke='%231B3A8C' stroke-width='1' fill='none' opacity='0.95'><circle cx='0' cy='0' r='18'/><circle cx='36' cy='0' r='18'/><circle cx='0' cy='36' r='18'/><circle cx='36' cy='36' r='18'/><circle cx='18' cy='18' r='18'/></g></svg>");
}

.pattern-substrate--side {
    right: 0;
    top: var(--topbar-h);
    width: calc(var(--side-w) + var(--gap) * 2);
    bottom: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16'><circle cx='8' cy='8' r='2' fill='%23F0ECF5' opacity='0.95'/></svg>");
}

.pattern-substrate--header {
    left: 0;
    right: 0;
    top: 0;
    height: var(--topbar-h);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='56' height='49'><g stroke='%23047857' stroke-width='1' fill='none' opacity='0.95' transform='rotate(-8 28 24)'><polygon points='14,0 42,0 56,24.25 42,48.5 14,48.5 0,24.25'/></g></svg>");
}

/* Layer 2 — watercolor blob field */
.watercolor-field {
    position: absolute;
    inset: -10%;
    opacity: 0;
    transition: opacity 1500ms var(--elastic);
    filter: url(#watercolor-displace);
    will-change: transform;
}

body.is-loaded .watercolor-field {
    opacity: 0.6;
}

.watercolor-blob {
    position: absolute;
    left: var(--bx);
    top: var(--by);
    width: var(--bs);
    height: var(--bs);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    mix-blend-mode: screen;
    filter: blur(28px);
    opacity: 0;
    animation:
        blob-bloom 1500ms var(--elastic) forwards,
        blob-drift 52s ease-in-out infinite alternate;
}

.blob-amethyst   { background: radial-gradient(circle, rgba(106, 13, 173, 0.95) 0%, rgba(106, 13, 173, 0.55) 35%, rgba(106, 13, 173, 0) 70%); animation-delay: 0ms,    0s; }
.blob-sapphire   { background: radial-gradient(circle, rgba(27, 58, 140, 0.95)  0%, rgba(27, 58, 140, 0.55)  35%, rgba(27, 58, 140, 0)  70%); animation-delay: 150ms,  3s; }
.blob-emerald    { background: radial-gradient(circle, rgba(4, 120, 87, 0.92)   0%, rgba(4, 120, 87, 0.5)    35%, rgba(4, 120, 87, 0)    70%); animation-delay: 300ms,  6s; }
.blob-ruby       { background: radial-gradient(circle, rgba(185, 28, 66, 0.92)  0%, rgba(185, 28, 66, 0.5)   35%, rgba(185, 28, 66, 0)   70%); animation-delay: 450ms,  9s; }
.blob-topaz      { background: radial-gradient(circle, rgba(212, 146, 11, 0.85) 0%, rgba(212, 146, 11, 0.45) 35%, rgba(212, 146, 11, 0)  70%); animation-delay: 600ms, 12s; }
.blob-amethyst-2 { background: radial-gradient(circle, rgba(106, 13, 173, 0.85) 0%, rgba(106, 13, 173, 0.4)  40%, rgba(106, 13, 173, 0)  75%); animation-delay: 750ms, 15s; }
.blob-sapphire-2 { background: radial-gradient(circle, rgba(27, 58, 140, 0.85)  0%, rgba(27, 58, 140, 0.4)   40%, rgba(27, 58, 140, 0)   75%); animation-delay: 900ms, 18s; }

@keyframes blob-bloom {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
    60%  { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes blob-drift {
    0%   { translate: 0 0; }
    25%  { translate: 24px 18px; }
    50%  { translate: -16px 22px; }
    75%  { translate: 18px -12px; }
    100% { translate: -22px -14px; }
}

/* Pattern breathing animation — 30s cycle */
@keyframes pattern-breathe {
    0%, 100% { --pattern-opacity: 0.06; }
    50%      { --pattern-opacity: 0.12; }
}

@property --pattern-opacity {
    syntax: "<number>";
    inherits: true;
    initial-value: 0.10;
}

body { animation: pattern-breathe 30s ease-in-out infinite; }

/* ============================================================ */
/* Glass panel base                                              */
/* ============================================================ */
.glass-panel {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow:
        0 8px 32px rgba(106, 13, 173, 0.18),
        0 1px 0 rgba(255, 255, 255, 0.10) inset,
        0 12px 40px rgba(13, 2, 33, 0.4);
    isolation: isolate;
    overflow: hidden;
}

/* Inner frost gradient (top-left highlight) */
.glass-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 55%);
    pointer-events: none;
    z-index: 0;
}

/* Rainbow caustic top edge */
.glass-panel::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        rgba(106, 13, 173, 0.8) 0%,
        rgba(27, 58, 140, 0.85) 35%,
        rgba(4, 120, 87, 0.8) 65%,
        rgba(212, 146, 11, 0.7) 100%);
    z-index: 2;
    pointer-events: none;
}

.glass-panel > * { position: relative; z-index: 1; }

/* Rail-specific — deeper frost + amethyst tint */
.glass-panel--rail {
    background:
        linear-gradient(180deg, rgba(106, 13, 173, 0.12), rgba(106, 13, 173, 0.04)),
        var(--glass-bg);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
}

/* Right side — slightly more transparent */
.glass-panel--side {
    background: var(--glass-bg-soft);
}

/* Corner gem markers — pulsing topaz diamonds */
.gem {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--topaz);
    transform: rotate(45deg) scale(1);
    box-shadow:
        0 0 8px rgba(212, 146, 11, 0.85),
        0 0 16px rgba(212, 146, 11, 0.45);
    z-index: 3;
    animation: gem-pulse 4s ease-in-out infinite;
}
.gem-tl { top: 8px;    left: 8px; }
.gem-tr { top: 8px;    right: 8px;  animation-delay: 1s; }
.gem-bl { bottom: 8px; left: 8px;   animation-delay: 2s; }
.gem-br { bottom: 8px; right: 8px;  animation-delay: 3s; }

@keyframes gem-pulse {
    0%, 100% { transform: rotate(45deg) scale(1);   opacity: 0.85; }
    50%      { transform: rotate(45deg) scale(1.3); opacity: 1; }
}

/* ============================================================ */
/* Topbar                                                        */
/* ============================================================ */
.topbar {
    position: relative;
    margin: var(--gap) var(--gap) 0;
    padding: 18px 28px;
    display: grid;
    grid-template-columns: minmax(280px, auto) 1fr auto;
    align-items: center;
    gap: 28px;
    transform: translateY(-30px);
    opacity: 0;
    animation: panel-slide 700ms var(--elastic) 200ms forwards;
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 0 12px rgba(106, 13, 173, 0.25);
}

.brand-name {
    font-family: "Quicksand", sans-serif;
    font-weight: 700;
    font-size: 26px;
    margin: 0;
    letter-spacing: -0.02em;
    color: var(--pure);
    text-shadow:
        0 2px 8px rgba(106, 13, 173, 0.55),
        0 0 22px rgba(212, 146, 11, 0.18);
}
.brand-dot { color: var(--topaz); }

.brand-tag {
    margin: 2px 0 0;
    font-family: "Nunito", sans-serif;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(240, 236, 245, 0.7);
}

.topbar__nav {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.topnav-link {
    font-family: "Nunito", sans-serif;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pearl);
    padding: 9px 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: all 400ms var(--elastic);
    position: relative;
    background: transparent;
}
.topnav-link:hover {
    color: var(--topaz);
    border-color: rgba(212, 146, 11, 0.35);
    background: rgba(212, 146, 11, 0.08);
    transform: translateY(-2px);
    text-shadow: none;
}
.topnav-link.is-active {
    color: var(--pure);
    background: linear-gradient(135deg, rgba(106, 13, 173, 0.45), rgba(27, 58, 140, 0.35));
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 14px rgba(106, 13, 173, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    text-shadow: none;
}

.topbar__meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.14);
    font-family: "Nunito", sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--pearl);
}

.meta-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    box-shadow: 0 0 10px currentColor;
}
.meta-dot--emerald { background: var(--emerald); color: #2BD9A0; }
.meta-dot--topaz   { background: var(--topaz);   color: #FFC23A; }

/* ============================================================ */
/* Dashboard grid                                                */
/* ============================================================ */
.dashboard {
    display: grid;
    grid-template-columns: var(--rail-w) 1fr var(--side-w);
    gap: var(--gap);
    padding: var(--gap);
    min-height: calc(100vh - var(--topbar-h) - 80px);
    align-items: start;
}

/* ============================================================ */
/* Left rail                                                     */
/* ============================================================ */
.rail {
    padding: 22px 18px;
    position: sticky;
    top: var(--gap);
    max-height: calc(100vh - var(--gap) * 2);
    overflow-y: auto;
    transform: translateX(-30px);
    opacity: 0;
    animation: panel-slide-x 700ms var(--elastic) 350ms forwards;
}

.rail__search { margin-bottom: 22px; }

.search-label {
    display: block;
    font-family: "Nunito", sans-serif;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(240, 236, 245, 0.65);
    margin-bottom: 8px;
}

.search-shell {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(13, 2, 33, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    padding: 6px 10px;
    transition: all 400ms var(--elastic);
}
.search-shell:focus-within {
    border-color: rgba(212, 146, 11, 0.55);
    box-shadow: 0 0 0 3px rgba(212, 146, 11, 0.18), 0 6px 20px rgba(106, 13, 173, 0.45);
    transform: translateY(-1px);
}

.search-icon {
    color: rgba(240, 236, 245, 0.7);
    margin-right: 6px;
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--pearl);
    font-family: "Nunito Sans", sans-serif;
    font-size: 15px;
    padding: 6px 4px;
}
.search-input::placeholder { color: rgba(240, 236, 245, 0.45); }

.search-glow {
    position: absolute;
    inset: -2px;
    border-radius: 14px;
    pointer-events: none;
    background: radial-gradient(circle at center, rgba(212, 146, 11, 0.35), transparent 65%);
    opacity: 0;
    transition: opacity 500ms var(--elastic);
}
.search-shell.is-active .search-glow { opacity: 1; }

.rail__heading {
    font-family: "Nunito", sans-serif;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(240, 236, 245, 0.7);
    margin: 0 0 10px;
    text-shadow: none;
}
.rail__heading--small { margin-top: 18px; }

.cat-group {
    margin-bottom: 6px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: background 400ms var(--elastic), border-color 400ms var(--elastic);
}
.cat-group[open] {
    background: rgba(106, 13, 173, 0.14);
    border-color: rgba(106, 13, 173, 0.32);
}

.cat-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    list-style: none;
    font-family: "Nunito", sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: var(--pearl);
    transition: color 300ms var(--elastic);
}
.cat-summary::-webkit-details-marker { display: none; }
.cat-summary::after {
    content: "+";
    margin-left: auto;
    font-family: "Quicksand", sans-serif;
    font-weight: 700;
    color: var(--topaz);
    font-size: 18px;
    line-height: 1;
    transition: transform 400ms var(--elastic);
}
.cat-group[open] > .cat-summary::after {
    transform: rotate(45deg);
}
.cat-summary:hover { color: var(--topaz); }

.cat-icon {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    transform: rotate(45deg);
    box-shadow: 0 0 8px currentColor;
}
.cat-icon[data-glyph="amethyst"] { background: var(--amethyst); color: var(--amethyst); }
.cat-icon[data-glyph="sapphire"] { background: var(--sapphire); color: #4870D0; }
.cat-icon[data-glyph="emerald"]  { background: var(--emerald);  color: #2BD9A0; }
.cat-icon[data-glyph="ruby"]     { background: var(--ruby);     color: #FF6E8A; }
.cat-icon[data-glyph="topaz"]    { background: var(--topaz);    color: var(--topaz); }

.cat-count {
    font-size: 11px;
    color: rgba(240, 236, 245, 0.55);
    font-weight: 700;
    margin-left: 4px;
}

.cat-list {
    list-style: none;
    margin: 0;
    padding: 0 12px 10px 28px;
    display: grid;
    gap: 4px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 600ms var(--elastic);
}
.cat-group[open] .cat-list { max-height: 320px; }

.cat-link {
    display: block;
    font-family: "Nunito Sans", sans-serif;
    font-size: 13px;
    color: var(--pearl);
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 300ms var(--elastic);
    text-shadow: none;
}
.cat-link:hover {
    background: rgba(212, 146, 11, 0.12);
    color: var(--topaz);
    transform: translateX(3px);
    text-shadow: none;
}
.cat-link.is-current {
    color: var(--pure);
    background: linear-gradient(90deg, rgba(106, 13, 173, 0.4), rgba(27, 58, 140, 0.2));
    box-shadow: inset 2px 0 0 var(--topaz);
}

.rail__progress { margin-top: 22px; }

.depth-track {
    position: relative;
    height: 8px;
    background: rgba(13, 2, 33, 0.55);
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}
.depth-fill {
    position: absolute;
    inset: 0 100% 0 0;
    background: linear-gradient(90deg, var(--amethyst), var(--sapphire), var(--emerald), var(--topaz));
    transition: inset 500ms var(--elastic);
    box-shadow: 0 0 14px rgba(212, 146, 11, 0.5);
}
.depth-marker {
    position: absolute;
    left: var(--mp);
    top: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    z-index: 1;
}
.depth-readout {
    margin: 8px 0 0;
    font-family: "Nunito", sans-serif;
    font-size: 12px;
    letter-spacing: 0.04em;
    color: rgba(240, 236, 245, 0.65);
}

/* ============================================================ */
/* Central well                                                  */
/* ============================================================ */
.well {
    min-width: 0;
}

.article {
    display: grid;
    gap: var(--gap);
}

.card {
    padding: 28px 32px;
    transform: translateY(40px) scale(0.98);
    opacity: 0;
    animation: card-spring 700ms var(--elastic) forwards;
    transition: transform 400ms var(--elastic), box-shadow 400ms var(--elastic), border-color 400ms var(--elastic);
}
.card:hover {
    transform: translateY(-4px);
    box-shadow:
        0 14px 40px rgba(106, 13, 173, 0.35),
        0 1px 0 rgba(255, 255, 255, 0.15) inset,
        0 0 0 1px rgba(212, 146, 11, 0.2);
    border-color: rgba(212, 146, 11, 0.3);
}

.card:nth-child(1) { animation-delay: 500ms; }
.card:nth-child(2) { animation-delay: 600ms; }
.card:nth-child(3) { animation-delay: 700ms; }
.card:nth-child(4) { animation-delay: 800ms; }
.card:nth-child(5) { animation-delay: 900ms; }
.card:nth-child(6) { animation-delay: 1000ms; }
.card:nth-child(7) { animation-delay: 1100ms; }

@keyframes card-spring {
    0%   { opacity: 0; transform: translateY(40px) scale(0.96); }
    60%  { opacity: 1; transform: translateY(-6px) scale(1.01); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.card__title {
    font-size: 22px;
    margin-bottom: 14px;
}

/* Lede card */
.card--lede {
    padding: 38px 36px 32px;
    background:
        linear-gradient(135deg, rgba(106, 13, 173, 0.18), rgba(27, 58, 140, 0.10) 60%, rgba(4, 120, 87, 0.08)),
        var(--glass-bg);
}

.lede__breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-family: "Nunito", sans-serif;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(240, 236, 245, 0.7);
    margin-bottom: 18px;
}
.lede__breadcrumb a {
    color: var(--pearl);
    text-shadow: none;
    transition: color 300ms var(--elastic);
}
.lede__breadcrumb a:hover { color: var(--topaz); }
.crumb-sep { color: var(--topaz); font-size: 8px; }
.crumb-current { color: var(--pure); font-weight: 700; }

.lede__title {
    font-size: clamp(40px, 5vw, 64px);
    margin: 0 0 10px;
    display: flex;
    align-items: baseline;
    gap: 18px;
    flex-wrap: wrap;
    text-shadow: 0 4px 22px rgba(106, 13, 173, 0.55);
}
.lede__cjk {
    font-family: "Quicksand", sans-serif;
    font-size: 0.55em;
    color: var(--topaz);
    background: linear-gradient(135deg, var(--topaz), #FFE38A 50%, var(--amethyst));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    letter-spacing: 0.04em;
}

.lede__subtitle {
    font-family: "Nunito", sans-serif;
    font-size: 18px;
    line-height: 1.5;
    color: rgba(240, 236, 245, 0.85);
    max-width: 60ch;
    margin: 0 0 24px;
}

.lede__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(13, 2, 33, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.14);
    font-family: "Nunito", sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--pearl);
}
.chip-glow {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}
.chip-glow--amethyst { background: var(--amethyst); color: var(--amethyst); }
.chip-glow--emerald  { background: var(--emerald);  color: #2BD9A0; }
.chip-glow--topaz    { background: var(--topaz);    color: var(--topaz); }

/* Lead paragraph */
.lead {
    font-size: 19px;
    line-height: 1.7;
    color: var(--pearl);
}
.lead strong { color: var(--pure); }

.kanji {
    font-family: "Quicksand", sans-serif;
    font-weight: 700;
    color: var(--topaz);
    font-size: 1.15em;
    margin: 0 2px;
}

blockquote.quote {
    margin: 18px 0;
    padding: 18px 22px;
    border-left: 3px solid var(--topaz);
    background: rgba(212, 146, 11, 0.08);
    border-radius: 0 12px 12px 0;
    font-family: "Nunito", sans-serif;
    font-style: italic;
    color: var(--pearl);
}
blockquote.quote p { margin: 0 0 8px; font-size: 17px; }
.quote__attrib {
    font-style: normal;
    font-size: 13px;
    color: rgba(240, 236, 245, 0.7);
    letter-spacing: 0.04em;
}
.quote cite { color: var(--topaz); font-style: italic; }

/* Inline code */
.inline-code {
    font-family: "Comfortaa", monospace;
    font-size: 0.9em;
    background: rgba(4, 120, 87, 0.18);
    border: 1px solid rgba(4, 120, 87, 0.4);
    border-radius: 6px;
    padding: 1px 7px;
    color: #6BFFC4;
}

/* Code card — card within a card */
.code-card {
    background: rgba(13, 2, 33, 0.55);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 1px solid var(--emerald);
    border-radius: 12px;
    padding: 18px 22px;
    margin: 18px 0;
    overflow-x: auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    font-size: 14.5px;
    line-height: 1.65;
    color: var(--pearl);
    font-family: "Comfortaa", monospace;
}
.code-card code { font-family: inherit; }
.ck { color: rgba(240, 236, 245, 0.55); }

/* Bullets with gem markers */
.bullets {
    list-style: none;
    padding: 0;
    margin: 14px 0 0;
    display: grid;
    gap: 10px;
}
.bullets li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    transition: transform 400ms var(--elastic), background 400ms var(--elastic);
}
.bullets li:hover {
    transform: translateX(6px);
    background: rgba(212, 146, 11, 0.08);
}
.bullet-gem {
    width: 10px;
    height: 10px;
    transform: rotate(45deg);
    box-shadow: 0 0 8px currentColor;
    flex-shrink: 0;
}
.bullet-gem--amethyst { background: var(--amethyst); color: var(--amethyst); }
.bullet-gem--sapphire { background: var(--sapphire); color: #4870D0; }
.bullet-gem--emerald  { background: var(--emerald);  color: #2BD9A0; }
.bullet-gem--ruby     { background: var(--ruby);     color: #FF6E8A; }

/* Table */
.table-shell {
    overflow-x: auto;
    border-radius: 12px;
    background: rgba(13, 2, 33, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 12px;
}
.ledger {
    width: 100%;
    border-collapse: collapse;
    font-family: "Nunito Sans", sans-serif;
    font-size: 15px;
}
.ledger th, .ledger td {
    padding: 12px 18px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.ledger thead th {
    font-family: "Nunito", sans-serif;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--topaz);
    background: rgba(212, 146, 11, 0.06);
    text-shadow: none;
}
.ledger tbody tr {
    transition: background 300ms var(--elastic);
}
.ledger tbody tr:hover {
    background: rgba(106, 13, 173, 0.12);
}
.ledger tbody tr:last-child td { border-bottom: 0; }
.kanji-cell {
    font-family: "Quicksand", sans-serif;
    font-weight: 700;
    color: var(--topaz);
    font-size: 18px;
}

/* Notice card */
.card--notice {
    background:
        linear-gradient(135deg, rgba(185, 28, 66, 0.16), rgba(212, 146, 11, 0.08)),
        var(--glass-bg);
}
.notice {
    display: flex;
    gap: 16px;
    align-items: stretch;
}
.notice__bar {
    width: 4px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--ruby), var(--topaz));
    box-shadow: 0 0 14px rgba(185, 28, 66, 0.6);
}
.notice__title {
    margin: 0 0 8px;
    color: var(--pure);
    font-size: 16px;
    text-shadow: 0 1px 6px rgba(185, 28, 66, 0.5);
}
.notice__body p { margin: 0; font-size: 15px; }

/* References */
.refs {
    list-style: none;
    counter-reset: ref;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}
.refs li {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 12px;
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    font-size: 14px;
}
.refs li:last-child { border-bottom: 0; }
.ref-num {
    font-family: "Quicksand", sans-serif;
    font-weight: 700;
    color: var(--topaz);
    background: rgba(212, 146, 11, 0.12);
    border: 1px solid rgba(212, 146, 11, 0.35);
    border-radius: 8px;
    padding: 2px 0;
    text-align: center;
    font-size: 13px;
}
.ref-text { color: rgba(240, 236, 245, 0.85); }
.ref-text em { color: var(--pearl); }

/* ============================================================ */
/* Right side widgets                                            */
/* ============================================================ */
.side {
    padding: 22px 18px;
    display: grid;
    gap: 18px;
    align-content: start;
    position: sticky;
    top: var(--gap);
    max-height: calc(100vh - var(--gap) * 2);
    overflow-y: auto;
    transform: translateX(30px);
    opacity: 0;
    animation: panel-slide-x-rev 700ms var(--elastic) 450ms forwards;
}

.widget {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 16px;
}
.widget:first-child {
    border-top: 0;
    padding-top: 0;
}

.widget__title {
    font-family: "Nunito", sans-serif;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--topaz);
    margin: 0 0 10px;
    text-shadow: none;
}

.facets {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
    font-size: 13px;
}
.facets li {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.08);
    color: rgba(240, 236, 245, 0.7);
}
.facets li:last-child { border-bottom: 0; }
.facets b { color: var(--pure); font-weight: 700; }

.revs {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
    position: relative;
}
.revs::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.18), transparent);
}
.revs li {
    display: grid;
    grid-template-columns: 16px 1fr;
    gap: 10px;
    align-items: start;
    position: relative;
}
.rev-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    margin-top: 4px;
    box-shadow: 0 0 10px currentColor;
    border: 2px solid var(--obsidian-deep);
}
.rev-dot--amethyst { background: var(--amethyst); color: var(--amethyst); }
.rev-dot--sapphire { background: var(--sapphire); color: #4870D0; }
.rev-dot--emerald  { background: var(--emerald);  color: #2BD9A0; }
.rev-dot--ruby     { background: var(--ruby);     color: #FF6E8A; }
.rev-dot--topaz    { background: var(--topaz);    color: var(--topaz); }

.rev-title {
    margin: 0;
    font-family: "Nunito", sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: var(--pure);
    text-shadow: none;
    line-height: 1.35;
}
.rev-meta {
    margin: 2px 0 0;
    font-size: 11px;
    color: rgba(240, 236, 245, 0.55);
    letter-spacing: 0.04em;
}

.seealso {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 4px;
}
.seealso a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 8px;
    font-family: "Nunito", sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--pearl);
    text-shadow: none;
    transition: all 400ms var(--elastic);
}
.seealso a:hover {
    background: rgba(212, 146, 11, 0.12);
    color: var(--topaz);
    transform: translateX(4px);
}
.sa-glyph {
    width: 8px;
    height: 8px;
    transform: rotate(45deg);
    box-shadow: 0 0 6px currentColor;
}
.sa-glyph--amethyst { background: var(--amethyst); color: var(--amethyst); }
.sa-glyph--sapphire { background: var(--sapphire); color: #4870D0; }
.sa-glyph--emerald  { background: var(--emerald);  color: #2BD9A0; }
.sa-glyph--ruby     { background: var(--ruby);     color: #FF6E8A; }
.sa-glyph--topaz    { background: var(--topaz);    color: var(--topaz); }

.widget--palette { padding-bottom: 6px; }
.palette-note {
    font-size: 12px;
    color: rgba(240, 236, 245, 0.6);
    margin: 0 0 10px;
}
.palette-note code {
    color: var(--topaz);
    background: rgba(212, 146, 11, 0.1);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: "Comfortaa", monospace;
    font-size: 11px;
}

.swatch-row {
    display: flex;
    gap: 6px;
}
.swatch {
    flex: 1;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transition: transform 400ms var(--elastic), box-shadow 400ms var(--elastic);
}
.swatch[data-hex="#6A0DAD"] { background: var(--amethyst); }
.swatch[data-hex="#1B3A8C"] { background: var(--sapphire); }
.swatch[data-hex="#047857"] { background: var(--emerald); }
.swatch[data-hex="#B91C42"] { background: var(--ruby); }
.swatch[data-hex="#D4920B"] { background: var(--topaz); }
.swatch:hover {
    transform: translateY(-3px) scale(1.06);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        0 6px 18px currentColor;
}
.swatch.is-active {
    transform: translateY(-4px) scale(1.1);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 0 0 2px rgba(212, 146, 11, 0.6),
        0 8px 22px currentColor;
}

/* ============================================================ */
/* Footbar                                                       */
/* ============================================================ */
.footbar {
    margin: var(--gap);
    padding: 18px 28px;
    text-align: center;
    transform: translateY(30px);
    opacity: 0;
    animation: panel-slide 700ms var(--elastic) 700ms forwards;
}
.footbar__line {
    margin: 0;
    font-family: "Nunito", sans-serif;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--pearl);
}
.footbar__line--soft {
    color: rgba(240, 236, 245, 0.55);
    font-size: 11px;
    margin-top: 4px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.footbar__line--soft span {
    color: var(--topaz);
    font-family: "Comfortaa", monospace;
}

/* ============================================================ */
/* Panel intro animations                                        */
/* ============================================================ */
@keyframes panel-slide {
    0%   { opacity: 0; transform: translateY(-30px); }
    60%  { opacity: 1; transform: translateY(6px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes panel-slide-x {
    0%   { opacity: 0; transform: translateX(-30px); }
    60%  { opacity: 1; transform: translateX(6px); }
    100% { opacity: 1; transform: translateX(0); }
}
@keyframes panel-slide-x-rev {
    0%   { opacity: 0; transform: translateX(30px); }
    60%  { opacity: 1; transform: translateX(-6px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* ============================================================ */
/* Scrollbars                                                    */
/* ============================================================ */
.rail::-webkit-scrollbar,
.side::-webkit-scrollbar,
.code-card::-webkit-scrollbar,
.table-shell::-webkit-scrollbar { width: 6px; height: 6px; }
.rail::-webkit-scrollbar-thumb,
.side::-webkit-scrollbar-thumb,
.code-card::-webkit-scrollbar-thumb,
.table-shell::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--amethyst), var(--sapphire));
    border-radius: 999px;
}

/* ============================================================ */
/* Responsive                                                    */
/* ============================================================ */
@media (max-width: 1180px) {
    :root { --rail-w: 220px; --side-w: 250px; }
    .topbar { grid-template-columns: 1fr auto; }
    .topbar__nav { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
    .topbar__meta { display: none; }
}

@media (max-width: 960px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    .rail, .side {
        position: static;
        max-height: none;
    }
    .pattern-substrate--rail,
    .pattern-substrate--side {
        display: none;
    }
    .pattern-substrate--center {
        left: 0; right: 0;
    }
}

@media (max-width: 600px) {
    :root { --gap: 14px; --topbar-h: 140px; }
    .topbar { padding: 14px 18px; gap: 10px; }
    .brand-name { font-size: 22px; }
    .card { padding: 22px 18px; }
    .card--lede { padding: 28px 20px 22px; }
    .lede__title { font-size: 36px; gap: 10px; }
    .topbar__nav { gap: 4px; }
    .topnav-link { padding: 6px 12px; font-size: 12px; }
    .footbar { padding: 14px 18px; margin: var(--gap); }
}
