/* CAD Vault – glass dashboard */
:root, [data-theme="light"], [data-theme="liquid"], [data-theme="sakura"], [data-theme="ocean"] {
  --font: "Urbanist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --r-sm: 10px; --r-md: 14px; --r-lg: 22px; --r-xl: 28px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --gap: 18px;
  --rail: 76px;
  --blur: 26px;

  --bg: #e9e6e2;
  --glass: rgba(255, 255, 255, .62);
  --glass-2: rgba(255, 255, 255, .5);
  --glass-solid: rgba(250, 248, 246, .96);
  --rim: rgba(255, 255, 255, .85);
  --sheen: linear-gradient(140deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 42%);
  --ink: #1d1a1e;
  --ink-2: #3b363c;
  --muted: #5b5459;
  --line: rgba(30, 24, 28, .09);
  --line-2: rgba(30, 24, 28, .16);
  --field: rgba(255, 255, 255, .6);
  --shadow: 0 1px 1px rgba(40, 20, 30, .04), 0 18px 40px -24px rgba(60, 30, 40, .35);
  --shadow-lg: 0 2px 6px rgba(40, 20, 30, .08), 0 36px 80px -30px rgba(60, 30, 40, .5);
  --accent: #f07a2e;
  --accent-hi: #f58d47;
  --accent-ink: #2a1203;
  --accent-soft: rgba(240, 122, 46, .15);
  --accent-text: #a8470d;
  --accent-lo: #d8601a;
  --accent-glow: rgba(240, 122, 46, .6);
  --alt: #2a7fd0; --alt-hi: #62a8ea;
  --glass-sat: 1.3;
  --btn-r: 12px;
  --pill-bg: linear-gradient(180deg, var(--accent-hi), var(--accent));
  --pill-ink: var(--accent-ink);
  --pill-shadow: 0 8px 18px -10px var(--accent);
  --blobs: none;
  --good: #126b45; --good-soft: rgba(18, 140, 90, .14);
  --bad: #b3261e; --bad-soft: rgba(200, 50, 40, .12);
  --info: #1c5a9e; --info-soft: rgba(30, 110, 200, .12);
  --tile-1: rgba(255, 224, 204, .68); --tile-2: rgba(214, 245, 234, .64); --tile-3: rgba(255, 238, 206, .66); --tile-4: rgba(220, 236, 252, .66);
  --tile-ink: #1d1a1e;
  --backdrop-filter: grayscale(.2) brightness(1.15) blur(3px);
  --backdrop-wash: linear-gradient(180deg, rgba(246, 242, 238, .72), rgba(233, 230, 226, .9));
  color-scheme: light;
}
[data-theme="dark"], [data-theme="liquid-dark"], [data-theme="midnight"], [data-theme="aurora"] {
  --accent: #f07a2e; --accent-hi: #f58d47; --accent-lo: #d8601a; --accent-ink: #2a1203; --accent-glow: rgba(240, 122, 46, .6);
  --alt: #2a7fd0; --alt-hi: #62a8ea;
  --r-lg: 22px; --r-xl: 28px; --btn-r: 12px; --blur: 26px; --glass-sat: 1.3; --blobs: none;
  --pill-bg: linear-gradient(180deg, var(--accent-hi), var(--accent)); --pill-ink: var(--accent-ink); --pill-shadow: 0 8px 18px -10px var(--accent);
  --bg: #0d1117;
  --glass: rgba(28, 31, 38, .62);
  --glass-2: rgba(255, 255, 255, .05);
  --glass-solid: rgba(24, 27, 33, .97);
  --rim: rgba(255, 255, 255, .09);
  --sheen: linear-gradient(140deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, 0) 42%);
  --ink: #f3efe9;
  --ink-2: #d9d3cc;
  --muted: #a39d98;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .15);
  --field: rgba(255, 255, 255, .06);
  --shadow: 0 1px 1px rgba(0, 0, 0, .2), 0 18px 40px -24px rgba(0, 0, 0, .7);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 36px 80px -30px rgba(0, 0, 0, .8);
  --accent-soft: rgba(240, 122, 46, .18);
  --accent-text: #f7a26b;
  --good: #5fd3a0; --good-soft: rgba(95, 211, 160, .14);
  --bad: #ff8a80; --bad-soft: rgba(255, 138, 128, .14);
  --info: #8fc1f5; --info-soft: rgba(143, 193, 245, .14);
  --tile-1: rgba(240, 122, 46, .2); --tile-2: rgba(15, 156, 122, .18); --tile-3: rgba(201, 138, 16, .18); --tile-4: rgba(42, 127, 208, .2);
  --tile-ink: #f3efe9;
  --backdrop-filter: grayscale(.4) brightness(.45) blur(3px);
  --backdrop-wash: linear-gradient(180deg, rgba(13, 17, 23, .55), rgba(13, 17, 23, .88));
  color-scheme: dark;
}

/* ---------- Extra themes ---------- */
/* Liquid Glass: clear, bright glass over a colourful wallpaper, with a lit top edge, like iOS 26 */
[data-theme="liquid"] {
  --bg: #dfe6f2;
  --r-lg: 26px; --r-xl: 34px; --btn-r: 999px;
  --blur: 20px; --glass-sat: 1.9;
  --glass: rgba(255, 255, 255, .2);
  --glass-2: rgba(255, 255, 255, .3);
  --glass-solid: rgba(246, 248, 253, .8);
  --rim: rgba(255, 255, 255, .7);
  --sheen: linear-gradient(165deg, rgba(255, 255, 255, .6) 0%, rgba(255, 255, 255, .1) 30%, rgba(255, 255, 255, 0) 62%, rgba(255, 255, 255, .22) 100%);
  --ink: #0b1220; --ink-2: #1e2939; --muted: #3f4b5e;
  --line: rgba(20, 30, 60, .1); --line-2: rgba(20, 30, 60, .16);
  --field: rgba(255, 255, 255, .4);
  --shadow: inset 0 1px 0 rgba(255, 255, 255, .95), inset 0 -1px 1px rgba(255, 255, 255, .4), inset 0 0 0 .5px rgba(255, 255, 255, .5), 0 12px 32px -14px rgba(30, 40, 90, .4);
  --shadow-lg: inset 0 1px 0 rgba(255, 255, 255, .95), inset 0 -1px 1px rgba(255, 255, 255, .4), 0 34px 80px -26px rgba(30, 40, 90, .55);
  --accent: #0a84ff; --accent-hi: #4ba3ff; --accent-lo: #0062cc; --accent-ink: #fff;
  --accent-soft: rgba(10, 132, 255, .14); --accent-text: #005fd6; --accent-glow: rgba(10, 132, 255, .55);
  --alt: #a64ee0; --alt-hi: #cf8dff;
  --tile-1: rgba(255, 149, 0, .16); --tile-2: rgba(52, 199, 89, .16); --tile-3: rgba(255, 204, 0, .2); --tile-4: rgba(10, 132, 255, .15);
  --tile-ink: #0b1220;
  --pill-bg: linear-gradient(180deg, rgba(255, 255, 255, .85), rgba(255, 255, 255, .5));
  --pill-ink: var(--accent-text);
  --pill-shadow: inset 0 1px 0 #fff, inset 0 -1px 1px rgba(255, 255, 255, .6), 0 6px 16px -6px rgba(30, 40, 90, .35);
  --backdrop-filter: saturate(1.2);
  --backdrop-wash: linear-gradient(180deg, rgba(240, 244, 252, .35), rgba(225, 232, 246, .55));
  --blobs:
    radial-gradient(38% 48% at 12% 18%, rgba(255, 128, 90, .85), transparent 70%),
    radial-gradient(42% 52% at 88% 12%, rgba(80, 140, 255, .85), transparent 70%),
    radial-gradient(48% 50% at 72% 88%, rgba(190, 90, 255, .75), transparent 70%),
    radial-gradient(40% 45% at 18% 88%, rgba(30, 205, 180, .7), transparent 70%),
    radial-gradient(30% 35% at 50% 50%, rgba(255, 210, 90, .55), transparent 70%);
}
[data-theme="liquid-dark"] {
  --bg: #05070d;
  --r-lg: 26px; --r-xl: 34px; --btn-r: 999px;
  --blur: 22px; --glass-sat: 1.8;
  --glass: rgba(28, 30, 40, .28);
  --glass-2: rgba(255, 255, 255, .08);
  --glass-solid: rgba(22, 24, 32, .82);
  --rim: rgba(255, 255, 255, .2);
  --sheen: linear-gradient(165deg, rgba(255, 255, 255, .18) 0%, rgba(255, 255, 255, .03) 30%, rgba(255, 255, 255, 0) 62%, rgba(255, 255, 255, .07) 100%);
  --ink: #f5f7fb; --ink-2: #dce2ec; --muted: #a8b1c2;
  --line: rgba(255, 255, 255, .1); --line-2: rgba(255, 255, 255, .18);
  --field: rgba(255, 255, 255, .07);
  --shadow: inset 0 1px 0 rgba(255, 255, 255, .28), inset 0 -1px 1px rgba(255, 255, 255, .08), inset 0 0 0 .5px rgba(255, 255, 255, .12), 0 14px 36px -14px rgba(0, 0, 0, .8);
  --shadow-lg: inset 0 1px 0 rgba(255, 255, 255, .28), 0 36px 80px -26px rgba(0, 0, 0, .9);
  --accent: #0a84ff; --accent-hi: #49a2ff; --accent-lo: #0060d0; --accent-ink: #fff;
  --accent-soft: rgba(10, 132, 255, .2); --accent-text: #6cb6ff; --accent-glow: rgba(10, 132, 255, .6);
  --alt: #bf5af2; --alt-hi: #da8fff;
  --tile-1: rgba(255, 149, 0, .16); --tile-2: rgba(48, 209, 88, .14); --tile-3: rgba(255, 214, 10, .14); --tile-4: rgba(10, 132, 255, .18);
  --pill-bg: linear-gradient(180deg, rgba(255, 255, 255, .26), rgba(255, 255, 255, .1));
  --pill-ink: #fff;
  --pill-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 6px 16px -6px rgba(0, 0, 0, .6);
  --backdrop-filter: saturate(1.1) brightness(.9);
  --backdrop-wash: linear-gradient(180deg, rgba(5, 7, 13, .55), rgba(5, 7, 13, .78));
  --blobs:
    radial-gradient(38% 48% at 12% 18%, rgba(255, 90, 60, .6), transparent 70%),
    radial-gradient(42% 52% at 88% 12%, rgba(40, 100, 255, .7), transparent 70%),
    radial-gradient(48% 50% at 72% 88%, rgba(160, 60, 255, .6), transparent 70%),
    radial-gradient(40% 45% at 18% 88%, rgba(0, 190, 170, .5), transparent 70%);
}
[data-theme="midnight"] {
  --bg: #060a18;
  --glass: rgba(14, 22, 46, .62);
  --glass-2: rgba(120, 160, 255, .06);
  --glass-solid: rgba(12, 18, 38, .97);
  --rim: rgba(120, 170, 255, .14);
  --ink: #eef3ff; --ink-2: #ccd6f0; --muted: #8f9cc0;
  --line: rgba(140, 170, 255, .1); --line-2: rgba(140, 170, 255, .2);
  --accent: #22d3ee; --accent-hi: #67e8f9; --accent-lo: #0891b2; --accent-ink: #032029;
  --accent-soft: rgba(34, 211, 238, .16); --accent-text: #67e8f9; --accent-glow: rgba(34, 211, 238, .55);
  --alt: #8b7cf6; --alt-hi: #b4a9ff;
  --tile-1: rgba(34, 211, 238, .14); --tile-2: rgba(139, 124, 246, .18); --tile-3: rgba(56, 120, 255, .18); --tile-4: rgba(236, 72, 153, .14);
  --tile-ink: #eef3ff;
  --backdrop-filter: grayscale(.7) brightness(.35) blur(3px);
  --backdrop-wash: radial-gradient(70% 60% at 80% 0%, rgba(40, 70, 180, .45), transparent 70%), linear-gradient(180deg, rgba(6, 10, 24, .6), rgba(6, 10, 24, .92));
}
[data-theme="aurora"] {
  --bg: #04110f;
  --blur: 24px; --glass-sat: 1.5;
  --glass: rgba(10, 24, 26, .5);
  --glass-2: rgba(255, 255, 255, .06);
  --glass-solid: rgba(8, 22, 24, .95);
  --rim: rgba(140, 255, 220, .13);
  --ink: #ecfbf6; --ink-2: #c9eadf; --muted: #8fb5aa;
  --line: rgba(160, 255, 220, .09); --line-2: rgba(160, 255, 220, .18);
  --accent: #34d399; --accent-hi: #6ee7b7; --accent-lo: #059669; --accent-ink: #022018;
  --accent-soft: rgba(52, 211, 153, .16); --accent-text: #6ee7b7; --accent-glow: rgba(52, 211, 153, .55);
  --alt: #a78bfa; --alt-hi: #c4b5fd;
  --tile-1: rgba(52, 211, 153, .16); --tile-2: rgba(167, 139, 250, .18); --tile-3: rgba(45, 212, 191, .14); --tile-4: rgba(96, 165, 250, .16);
  --tile-ink: #ecfbf6;
  --backdrop-filter: saturate(1.1);
  --backdrop-wash: linear-gradient(180deg, rgba(3, 12, 14, .7), rgba(3, 12, 14, .9));
  --blobs:
    radial-gradient(60% 30% at 30% 12%, rgba(52, 211, 153, .45), transparent 70%),
    radial-gradient(50% 35% at 75% 22%, rgba(139, 92, 246, .4), transparent 70%),
    radial-gradient(45% 30% at 55% 40%, rgba(45, 212, 191, .3), transparent 70%);
}
[data-theme="sakura"] {
  --bg: #fbeef2;
  --glass: rgba(255, 250, 252, .6);
  --glass-2: rgba(255, 255, 255, .5);
  --glass-solid: rgba(255, 249, 251, .97);
  --ink: #2b1620; --ink-2: #4a2c39; --muted: #7a5766;
  --line: rgba(120, 40, 70, .1); --line-2: rgba(120, 40, 70, .18);
  --accent: #e0457b; --accent-hi: #ec6d99; --accent-lo: #bf2d60; --accent-ink: #fff;
  --accent-soft: rgba(224, 69, 123, .13); --accent-text: #b02a5a; --accent-glow: rgba(224, 69, 123, .5);
  --alt: #8b5cf6; --alt-hi: #b49aff;
  --tile-1: rgba(255, 214, 228, .72); --tile-2: rgba(234, 222, 255, .7); --tile-3: rgba(255, 228, 210, .7); --tile-4: rgba(214, 240, 232, .7);
  --tile-ink: #2b1620;
  --backdrop-filter: grayscale(.5) brightness(1.15) blur(3px);
  --backdrop-wash: radial-gradient(60% 50% at 85% 10%, rgba(255, 170, 200, .55), transparent 70%), linear-gradient(180deg, rgba(253, 240, 245, .72), rgba(250, 232, 239, .9));
}
[data-theme="ocean"] {
  --bg: #e5f1f6;
  --glass: rgba(250, 254, 255, .6);
  --glass-2: rgba(255, 255, 255, .5);
  --glass-solid: rgba(246, 252, 254, .97);
  --ink: #0b2530; --ink-2: #1f3d49; --muted: #4f6b77;
  --line: rgba(10, 60, 80, .1); --line-2: rgba(10, 60, 80, .17);
  --accent: #0891b2; --accent-hi: #22b0d0; --accent-lo: #0e7490; --accent-ink: #fff;
  --accent-soft: rgba(8, 145, 178, .13); --accent-text: #0a6c86; --accent-glow: rgba(8, 145, 178, .5);
  --alt: #f2734a; --alt-hi: #ff9b78;
  --tile-1: rgba(204, 240, 250, .72); --tile-2: rgba(210, 246, 232, .7); --tile-3: rgba(255, 230, 214, .7); --tile-4: rgba(220, 230, 255, .7);
  --tile-ink: #0b2530;
  --backdrop-filter: grayscale(.4) brightness(1.12) blur(3px);
  --backdrop-wash: radial-gradient(60% 50% at 10% 0%, rgba(120, 210, 235, .5), transparent 70%), linear-gradient(180deg, rgba(236, 247, 251, .72), rgba(226, 240, 246, .9));
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.45;
  color: var(--ink); background: var(--bg);
  min-height: 100vh; -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.backdrop {
  position: fixed; inset: -20px; z-index: -1;
  background: var(--backdrop-wash), url("assets/bg.webp") center / cover no-repeat;
  filter: var(--backdrop-filter);
}
/* Colour fields behind the glass in Liquid Glass and Aurora, drifting slowly */
.backdrop::after { content: ""; position: absolute; inset: -12%; background: var(--blobs); animation: drift 38s ease-in-out infinite alternate; }
@keyframes drift { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(3%, -2%) scale(1.06) rotate(2deg); } 100% { transform: translate(-3%, 2%) scale(1.03) rotate(-2deg); } }

.glass {
  position: relative;
  background: var(--sheen), var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--blur)) saturate(var(--glass-sat));
  border: 1px solid var(--rim);
  box-shadow: var(--shadow);
}

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--btn-r);
  border: 1px solid var(--line-2); background: var(--glass-2);
  font-weight: 600; font-size: 13.5px; text-decoration: none; cursor: pointer;
  transition: background .2s var(--ease), transform .2s var(--ease), border-color .2s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); border-color: transparent; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 20px -10px var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: min(var(--btn-r), 10px); }
[data-theme^="liquid"] .btn.sm, [data-theme^="liquid"] .icon-btn, [data-theme^="liquid"] .seg, [data-theme^="liquid"] .seg button, [data-theme^="liquid"] .seg-thumb, [data-theme^="liquid"] .search input, [data-theme^="liquid"] .select { border-radius: 999px; }
[data-theme^="liquid"] .icon-btn, [data-theme^="liquid"] .btn:not(.primary) { box-shadow: inset 0 1px 0 var(--rim); }
.btn.block { width: 100%; }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn[disabled] { opacity: .55; cursor: wait; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--glass-2); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn.sm svg { width: 16px; height: 16px; }

.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea, .search input, .select {
  width: 100%; height: 42px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--field); font-weight: 500;
}
.field textarea { height: auto; min-height: 88px; padding: 10px 14px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.form-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: 13px; }
.fine { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
kbd { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--muted); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(400px, 100%); padding: 32px 28px; border-radius: var(--r-xl); display: grid; gap: 16px; box-shadow: var(--shadow-lg); }
.login-card h1 { margin: 4px 0 0; font-size: 28px; letter-spacing: -.01em; }
.login-card p.muted { margin: -8px 0 4px; }
.demo-note { padding: 10px 12px; border-radius: 10px; background: var(--info-soft); color: var(--info); font-size: 12.5px; }

.logo {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(160deg, var(--accent-hi), var(--accent-lo)); color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 8px 18px -8px var(--accent); text-decoration: none;
}
.logo svg { width: 24px; height: 24px; fill: currentColor; stroke: none; }
.logo-lg { width: 56px; height: 56px; border-radius: 18px; }
.logo-lg svg { width: 30px; height: 30px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); gap: var(--gap); padding: 14px; max-width: 1480px; margin: 0 auto; }
.rail {
  position: sticky; top: 14px; height: calc(100vh - 28px); z-index: 30; /* above cards and the top bar so tooltips show over them */
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  padding: 14px 0; border-radius: var(--r-xl);
}
.rail-nav, .rail-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rail-foot { margin-top: auto; }
.rail-btn {
  position: relative; display: grid; place-items: center; width: 50px; height: 42px; border-radius: 13px;
  color: var(--ink-2); text-decoration: none; transition: background .2s var(--ease), color .2s;
}
.rail-btn:hover { background: var(--glass-2); color: var(--ink); }
.rail-btn.active, .rail-btn.active:hover { background: none; color: var(--pill-ink); }
button.rail-btn { border: 0; background: none; cursor: pointer; padding: 0; }
.rail-btn.signout:hover { color: var(--bad); background: var(--bad-soft); }
.rail-btn { z-index: 1; }
.rail-pill {
  position: absolute; left: 0; top: 0; width: 50px; height: 42px; border-radius: 13px; pointer-events: none; opacity: 0;
  background: var(--pill-bg); box-shadow: var(--pill-shadow);
  transition: transform .54s var(--ease), width .54s var(--ease), height .54s var(--ease), opacity .2s;
}
.rail-btn .tip {
  position: absolute; left: calc(100% + 12px); top: 50%; transform: translate(-4px, -50%); opacity: 0; pointer-events: none;
  padding: 5px 10px; border-radius: 8px; background: var(--glass-solid); border: 1px solid var(--line); color: var(--ink);
  font-size: 12.5px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow); transition: .18s var(--ease); z-index: 20;
}
.rail-btn:hover .tip, .rail-btn:focus-visible .tip { opacity: 1; transform: translate(0, -50%); }
.avatar {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  background: #f6e2bf; color: #3a2a10; font-weight: 700; font-size: 13px; text-decoration: none;
  border: 2px solid var(--rim); position: relative;
}
.avatar::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: #2fbf71; border: 2px solid var(--bg); animation: breathe-green 2s ease-in-out infinite; }

.col { min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }
.topbar {
  position: sticky; top: 14px; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 60px; padding: 10px 12px 10px 18px; border-radius: var(--r-lg);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { opacity: .5; }
.crumbs b { color: var(--ink); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 8px; }
body:not(.is-admin) .admin-only { display: none !important; }

main { outline: none; padding-bottom: 32px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 4px 18px; }
.page-head h1 { margin: 0; font-size: 34px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.page-head p b { color: var(--ink); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { border-radius: var(--r-lg); padding: 20px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.link-btn { font-size: 13px; font-weight: 600; color: var(--accent-text); text-decoration: none; white-space: nowrap; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Overview ---------- */
.grid-home { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.span-12 { grid-column: span 12; } .span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }

.hero { border-radius: var(--r-xl); padding: 24px; overflow: hidden; min-height: 300px; display: flex; flex-direction: column; gap: 18px; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(0deg, var(--line) 1px, transparent 1px) 0 0 / 28px 28px;
  mask-image: linear-gradient(105deg, transparent 35%, #000 85%);
  -webkit-mask-image: linear-gradient(105deg, transparent 35%, #000 85%);
}
.hero > * { position: relative; z-index: 1; }
.hero-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px;
  background: var(--glass-2); border: 1px solid var(--line); font-size: 12.5px; font-weight: 500; white-space: nowrap;
}
.pill svg { width: 13px; height: 13px; }
.hero h2 { margin: auto 0 0; font-size: clamp(26px, 3.4vw, 40px); font-weight: 600; letter-spacing: -.02em; line-height: 1.1; max-width: 18ch; }
.hero-desc { margin: -8px 0 0; color: var(--ink-2); max-width: 60ch; }
.hero-meta { display: flex; gap: 28px; flex-wrap: wrap; }
.hero-meta div { display: grid; }
.hero-meta b { font-size: 20px; font-weight: 600; }
.hero-meta span { font-size: 12px; color: var(--muted); }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hero-art {
  position: absolute; right: 24px; top: 70px; width: min(36%, 300px); aspect-ratio: 1; z-index: 0;
  color: var(--accent); opacity: .55;
}
.hero-art svg { width: 100%; height: 100%; stroke-width: 1.1; }

.tile { border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--tile-ink); min-height: 132px; text-decoration: none; transition: transform .25s var(--ease); }
.tile { border: 1px solid var(--rim); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--glass-sat)); backdrop-filter: blur(var(--blur)) saturate(var(--glass-sat)); }
a.tile:hover { transform: translateY(-2px); }
.tile.t1 { background: var(--sheen), var(--tile-1); } .tile.t2 { background: var(--sheen), var(--tile-2); }
.tile.t3 { background: var(--sheen), var(--tile-3); } .tile.t4 { background: var(--sheen), var(--tile-4); }
.tile-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; opacity: .8; }
.tile-value { font-size: 34px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; margin-top: auto; }
.tile-sub { font-size: 12.5px; opacity: .7; }

.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rank li { display: grid; grid-template-columns: 22px 54px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px; border-radius: 14px; }
.rank li:hover { background: var(--glass-2); }
.rank .n { color: var(--muted); font-size: 13px; text-align: center; }
.rank .t { min-width: 0; }
.rank .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .t span { font-size: 12.5px; color: var(--muted); }

.thumb {
  display: grid; place-items: center; width: 54px; height: 42px; border-radius: 10px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--line);
}
.thumb.detail { background: var(--info-soft); color: var(--info); }

.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 13px; }
.bar-row b { font-weight: 600; }
.bar-track { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--glass-2); border: 1px solid var(--line); overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-hi)); }
.bar-fill.alt { background: linear-gradient(90deg, var(--alt), var(--alt-hi)); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; font-size: 13.5px; counter-increment: s; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: 12px; }
.steps code, .code-inline { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: 6px; background: var(--glass-2); border: 1px solid var(--line); }

/* ---------- Library tables ---------- */
.tabs { position: relative; display: flex; gap: 6px; margin: 0 4px 14px; border-bottom: 1px solid var(--line); }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 10px 12px; border: 0; background: none; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); }
.tab-line { position: absolute; left: 0; top: 0; pointer-events: none; opacity: 0; transition: transform .5s var(--ease), width .5s var(--ease), opacity .2s; }
.tab-line::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.count { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--glass-2); border: 1px solid var(--line); }

.panel { border-radius: var(--r-xl); padding: 14px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 4px 4px 14px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1 1 260px; max-width: 380px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 38px; height: 40px; }
.seg { position: relative; display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--glass-2); border: 1px solid var(--line); }
.seg button { position: relative; z-index: 1; height: 32px; padding: 0 12px; border: 0; border-radius: 9px; background: none; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.seg button:hover { color: var(--ink); }
.seg button.active { color: var(--ink); }
.seg-thumb { position: absolute; left: 0; top: 0; border-radius: 9px; background: var(--glass-solid); box-shadow: var(--shadow); pointer-events: none; opacity: 0; transition: transform .45s var(--ease), width .45s var(--ease), opacity .2s; }
.select { width: auto; height: 40px; padding-right: 32px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 14px 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--glass-2); }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-main .t { min-width: 0; }
.row-main b { display: block; font-weight: 600; }
.row-main .t span { display: block; font-size: 12.5px; color: var(--muted); max-width: 52ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd { font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-text); white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--glass-2); border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.cad { color: var(--accent-text); } .badge.pdf { color: var(--bad); } .badge.lsp { color: var(--good); }
.badge.plain::before { display: none; }
.badge.super { background: var(--accent-soft); border-color: var(--accent); }
.lock-note { font-size: 11.5px; white-space: nowrap; padding: 0 4px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* Details grid */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; padding-top: 14px; }
.dcard { border-radius: var(--r-lg); background: var(--glass-2); border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; transition: transform .25s var(--ease), border-color .2s; }
.dcard:hover { transform: translateY(-2px); border-color: var(--line-2); }
.dcard-art {
  position: relative; aspect-ratio: 16 / 10; display: grid; place-items: center; cursor: pointer; border: 0; padding: 0; width: 100%;
  color: var(--ink-2);
  background:
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(0deg, var(--line) 1px, transparent 1px) 0 0 / 20px 20px,
    var(--glass-2);
}
.dcard-art svg { width: 46%; height: auto; stroke-width: 1.2; opacity: .75; }
.dcard-art .code { position: absolute; left: 10px; top: 10px; }
.dcard-art .badges { position: absolute; right: 10px; top: 10px; display: flex; gap: 4px; }
.dcard-art .badges .badge { background: var(--glass-solid); }
.dcard-body { padding: 14px; display: grid; gap: 4px; flex: 1; }
.dcard-body b { font-weight: 600; font-size: 15px; }
.dcard-body span { font-size: 12.5px; color: var(--muted); }
.dcard-foot { display: flex; gap: 6px; padding: 0 14px 14px; flex-wrap: wrap; }
.dcard-foot .btn { flex: 1; }

/* ---------- Upload / account ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.drop {
  display: grid; place-items: center; gap: 6px; text-align: center; padding: 22px 16px; border-radius: 16px; cursor: pointer;
  border: 1.5px dashed var(--line-2); background: var(--glass-2); color: var(--muted); font-size: 13px; transition: .2s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.drop svg { width: 26px; height: 26px; color: var(--accent-text); }
.drop b { color: var(--ink); font-weight: 600; }
.drop .file { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.drop input { display: none; }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; align-items: center; }
.progress { flex: 1; font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-all; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: start center; padding: 10vh 16px 16px; background: rgba(10, 12, 16, .45); animation: fade .2s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.no-anim { transition: none !important; }
.word { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .08em; margin-bottom: -.08em; }
.ch { display: inline-block; transform-origin: 0 100%; will-change: transform; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: live-breathe 2s ease-in-out infinite; }
.steps li:first-child::before { animation: breathe-ring 2.2s ease-in-out infinite; }
@keyframes live-breathe { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); } 50% { box-shadow: 0 0 0 7px rgba(240, 122, 46, 0); } }
@keyframes breathe-green { 0%, 100% { box-shadow: 0 0 0 0 rgba(47, 191, 113, .55); } 50% { box-shadow: 0 0 0 6px rgba(47, 191, 113, 0); } }
@keyframes breathe-ring { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); } 50% { box-shadow: 0 0 0 6px var(--accent-soft); } }
.bar-fill { transform-origin: 0 50%; }
.palette { width: min(640px, 100%); border-radius: var(--r-lg); background: var(--glass-solid); overflow: hidden; box-shadow: var(--shadow-lg); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.palette-input input { flex: 1; border: 0; background: none; outline: none; font-size: 16px; }
.palette-list { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow: auto; }
.palette-list li button { width: 100%; display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: center; padding: 8px; border: 0; background: none; border-radius: 12px; cursor: pointer; text-align: left; }
.palette-list li button:hover, .palette-list li button.sel { background: var(--accent-soft); }
.palette-list li button b { display: block; font-weight: 600; }
.palette-list li button span { font-size: 12px; color: var(--muted); }
.palette-list .empty { padding: 24px; }

.overlay#previewOverlay { place-items: center; padding: 16px; }
.preview { width: min(1100px, 100%); height: min(88vh, 900px); border-radius: var(--r-xl); background: var(--glass-solid); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); }
.preview-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); }
.preview-head > div:first-child { flex: 1; min-width: 0; }
.preview-head h2 { margin: 0; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-actions { display: flex; gap: 8px; }
.preview-body { flex: 1; min-height: 0; overflow: auto; }
.preview-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.preview-body pre { margin: 0; padding: 18px 20px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; white-space: pre; tab-size: 2; }
.preview-body .lsp-c { color: var(--muted); font-style: italic; }
.preview-body .lsp-s { color: var(--good); }
.preview-body .lsp-k { color: var(--accent-text); font-weight: 600; }
.preview-body .msg { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  padding: 10px 16px; border-radius: 12px; background: var(--glass-solid); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg); font-weight: 600; font-size: 13.5px; max-width: calc(100vw - 32px);
}
.toast.err { color: var(--bad); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
  .span-3 { grid-column: span 6; }
  .hide-md { display: none; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding: 10px 10px 92px; gap: 12px; }
  .rail {
    position: fixed; top: auto; left: 10px; right: 10px; bottom: 10px; height: auto; z-index: 20;
    flex-direction: row; justify-content: space-around; padding: 8px; border-radius: 22px;
  }
  .rail > .logo, .rail-foot .avatar, .rail-btn .tip { display: none; }
  .rail { gap: 2px; justify-content: space-between; }
  .rail-nav, .rail-foot { display: contents; }
  .rail-btn { width: auto; flex: 1 1 0; min-width: 34px; max-width: 48px; }
  /* More icons than fit: the bar scrolls sideways instead of running off the screen */
  .rail { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
  .rail::-webkit-scrollbar { display: none; }
  .rail-btn { flex: 1 0 40px; }
  .topbar { top: 10px; padding-left: 14px; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { padding: 0 11px; }
  .page-head h1 { font-size: 28px; }
  .span-3 { grid-column: span 6; }
  .tile-value { font-size: 28px; }
  .hero-art { display: none; }
  .hide-sm { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .table td, .table th { padding-left: 6px; padding-right: 6px; }
  .table .thumb { display: none; }
  .row-main .t span { max-width: 20ch; }
  .panel { padding: 10px; }
  .search { max-width: none; }
  .preview-head { flex-wrap: wrap; }
  .preview-actions { order: 3; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, ::before, ::after { transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; } }

/* ---------- Usage GIFs ---------- */
.thumb.gif { position: relative; width: 88px; height: 56px; padding: 0; overflow: hidden; background: #fff; }
.thumb.gif img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.gif i {
  position: absolute; right: 4px; bottom: 4px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(13, 17, 23, .72); color: #fff; transition: transform .3s var(--ease), background .2s;
}
.thumb.gif i svg { width: 10px; height: 10px; fill: currentColor; stroke: none; margin-left: 1px; }
.thumb-btn { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 10px; flex: none; }
.thumb-btn:hover .thumb.gif i { transform: scale(1.15); background: var(--accent); color: var(--accent-ink); }
.rank .thumb.gif { width: 54px; height: 42px; }
.palette-list .thumb.gif { width: 54px; height: 42px; }

.hero-gif {
  position: absolute; right: 24px; top: 64px; bottom: 24px; z-index: 1; width: min(38%, 420px); padding: 0; cursor: pointer;
  border-radius: 18px; overflow: hidden; border: 1px solid var(--rim); background: #fff; box-shadow: var(--shadow-lg);
  transition: transform .4s var(--ease);
}
.hero-gif:hover { transform: translateY(-3px) scale(1.01); }
.hero-gif img { width: 100%; height: 100%; object-fit: contain; display: block; }
.hero-gif .pill { position: absolute; left: 10px; bottom: 10px; background: rgba(13, 17, 23, .72); color: #fff; border-color: transparent; }
.hero-gif .pill svg { fill: currentColor; stroke: none; }
.hero:has(.hero-gif) h2, .hero:has(.hero-gif) .hero-desc { max-width: min(18ch, 55%); }
.hero:has(.hero-gif) .hero-desc { max-width: 55%; }

.usage { margin: 0; height: 100%; display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.usage img {
  flex: 1; min-height: 0; width: 100%; object-fit: contain; border-radius: 14px; background: #fff;
  border: 1px solid var(--line);
}
.usage figcaption { font-size: 13.5px; color: var(--muted); text-align: center; }
.preview-actions .seg button { display: inline-flex; align-items: center; gap: 6px; }
.preview-actions .seg svg { width: 12px; height: 12px; fill: currentColor; stroke: none; }

@media (max-width: 1100px) {
  .hero-gif { position: relative; right: auto; top: auto; bottom: auto; width: 100%; aspect-ratio: 16 / 10; order: -1; }
  .hero:has(.hero-gif) h2, .hero:has(.hero-gif) .hero-desc { max-width: none; }
}
@media (max-width: 760px) {
  .table .thumb-btn { display: none; }
  .usage { padding: 10px; }
}

/* ---------- Members ---------- */
.avatar.sm { width: 34px; height: 34px; font-size: 12px; flex: none; }
.avatar.sm::after { display: none; }
.pw-row { display: flex; gap: 8px; }
.pw-row input { flex: 1; min-width: 0; }
.pw-row .btn { height: 42px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- Profile pictures ---------- */
.avatar { overflow: visible; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar.xl { width: 88px; height: 88px; font-size: 28px; border-width: 3px; }
.avatar.xl::after { display: none; }
.avatar-edit { position: relative; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; flex: none; color: inherit; }
.avatar-cam {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%;
  background: rgba(10, 12, 16, .5); color: #fff; opacity: 0; transition: opacity .2s var(--ease);
}
.avatar-edit .avatar.sm + .avatar-cam svg { width: 14px; height: 14px; }
.avatar-edit:hover .avatar-cam, .avatar-edit:focus-visible .avatar-cam { opacity: 1; }
.profile-pic { display: flex; gap: 18px; align-items: center; margin-bottom: 20px; }
.profile-pic > div { display: grid; gap: 4px; min-width: 0; }
.profile-pic b { font-size: 17px; font-weight: 600; }
.profile-pic .muted { font-size: 12.5px; }
.profile-pic .head-actions { margin-top: 6px; }

/* ---------- Members online ---------- */
.online-card { display: flex; flex-direction: column; }
.online-card .card-head h2 { display: flex; align-items: center; gap: 8px; }
.online-card .fine { margin-top: auto; padding-top: 12px; text-align: left; }
.live-dot.green { background: #2fbf71; animation-name: breathe-green; }
.online-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 300px; overflow: auto; }
.online-list li { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 7px 8px; border-radius: 14px; }
.online-list li:hover { background: var(--glass-2); }
.online-list .t { min-width: 0; }
.online-list .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-list .t > span { font-size: 12px; color: var(--muted); }
.online-list li.on .t > span { color: var(--good); font-weight: 600; }
.online-list li:not(.on) .avatar { filter: grayscale(.6); opacity: .75; }
.you { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); vertical-align: 1px; }
.presence-av { position: relative; display: inline-grid; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); opacity: .6; flex: none; }
.presence-av .status-dot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border: 2px solid var(--glass-solid); opacity: 1; background: #8b8f98; }
.on .status-dot, .online-list li.on .status-dot { background: #2fbf71; opacity: 1; animation: breathe-green 2s ease-in-out infinite; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.status.on { color: var(--good); font-weight: 600; }

/* ---------- Themes ---------- */
.top-actions { position: relative; }
.theme-menu {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 40; width: 300px; max-height: min(72vh, 560px); overflow: auto;
  padding: 10px; border-radius: var(--r-lg); background: var(--sheen), var(--glass-solid); box-shadow: var(--shadow-lg); display: grid; gap: 2px;
}
.theme-menu .eyebrow { padding: 4px 8px 6px; }
.theme-row, .theme-card {
  display: grid; align-items: center; gap: 12px; border: 1px solid transparent; background: none; cursor: pointer; text-align: left; color: var(--ink);
}
.theme-row { grid-template-columns: 54px minmax(0, 1fr) 18px; padding: 6px; border-radius: 14px; }
.theme-row:hover, .theme-row:focus-visible { background: var(--glass-2); }
.theme-row .swatch { height: 38px; border-radius: 10px; }
.theme-row > svg, .theme-card > svg { opacity: 0; color: var(--accent-text); transition: opacity .2s; }
.theme-row.active > svg, .theme-card.active > svg { opacity: 1; }
.theme-row.active { background: var(--accent-soft); }
.sw-name { display: grid; min-width: 0; }
.sw-name b { font-weight: 600; font-size: 13.5px; }
.sw-name span { font-size: 12px; color: var(--muted); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.theme-card { grid-template-columns: minmax(0, 1fr) 18px; padding: 8px 12px 12px 8px; border-radius: 20px; background: var(--glass-2); border-color: var(--line); transition: border-color .2s, transform .25s var(--ease); }
.theme-card .swatch { grid-column: 1 / -1; height: 104px; }
.theme-card .sw-name { padding-left: 4px; }
.theme-card:hover { transform: translateY(-2px); border-color: var(--line-2); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* A small picture of the theme, painted with that theme's own colours */
.swatch {
  position: relative; display: block; overflow: hidden; border-radius: 14px; border: 1px solid var(--line-2);
  background: var(--blobs), var(--backdrop-wash), var(--bg);
}
.swatch i { position: absolute; display: block; background: var(--sheen), var(--glass); border: 1px solid var(--rim); box-shadow: var(--shadow); }
.swatch .sw-rail { left: 7%; top: 12%; bottom: 12%; width: 11%; border-radius: 8px; }
.swatch .sw-card { left: 24%; top: 12%; right: 7%; height: 42%; border-radius: 9px; padding: 7% 8%; display: grid; align-content: start; gap: 5px; }
.swatch .sw-card b { display: block; height: 4px; width: 70%; border-radius: 4px; background: var(--ink); opacity: .75; }
.swatch .sw-card b + b { width: 45%; opacity: .35; }
.swatch .sw-tile { left: 24%; bottom: 12%; width: 32%; height: 26%; border-radius: 8px; background: var(--sheen), var(--tile-1); }
.swatch .sw-dot { right: 7%; bottom: 12%; width: 26%; height: 26%; border-radius: 99px; background: linear-gradient(180deg, var(--accent-hi), var(--accent)); border: 0; }
.theme-row .swatch .sw-card b { height: 3px; gap: 3px; }
@media (max-width: 760px) {
  /* Menu hangs under the whole top bar on phones */
  .top-actions { position: static; }
  .theme-menu { left: 0; right: 0; width: auto; top: calc(100% + 8px); }
}

/* ---------- Library view modes ---------- */
.view-seg { margin-left: auto; }
.view-seg button { width: 36px; padding: 0; display: grid; place-items: center; }
.view-seg svg { width: 16px; height: 16px; }
.media-img { width: 100%; height: 100%; object-fit: cover; display: block; background: #fff; }
.media-img.pdf { object-fit: contain; }
.media-art { display: grid; place-items: center; width: 100%; height: 100%; }
.dcard-art .media-img, .dcard-art .media-art { position: absolute; inset: 0; }
.dcard-art .code, .dcard-art .badges { z-index: 1; }
.dcard-art .badges .badge, .vthumb-media .cmd { background: var(--glass-solid); }
.lcard .media-art svg { width: 60%; color: var(--accent); opacity: .5; }
.play-chip {
  position: absolute; right: 8px; bottom: 8px; z-index: 1; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(13, 17, 23, .72); color: #fff; transition: transform .3s var(--ease), background .2s;
}
.play-chip svg { width: 12px; height: 12px; fill: currentColor; stroke: none; margin-left: 2px; }
.dcard-art:hover .play-chip, .vthumb:hover .play-chip, .vtile-media:hover .play-chip { transform: scale(1.15); background: var(--accent); color: var(--accent-ink); }
.badges-row { display: inline-flex; gap: 4px; flex-wrap: wrap; }

.vtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; padding-top: 14px; }
.vtile {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px;
  border-radius: 18px; background: var(--glass-2); border: 1px solid var(--line); transition: transform .25s var(--ease), border-color .2s;
}
.vtile:hover { transform: translateY(-2px); border-color: var(--line-2); }
.vtile-media {
  position: relative; width: 96px; height: 72px; padding: 0; border-radius: 12px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line); background: var(--accent-soft); color: var(--accent-text);
}
.vtile-media.detail { background: var(--info-soft); color: var(--info); }
.vtile-media .media-art svg { width: 78%; height: auto; stroke-width: 1.4; }
.vtile-media .play-chip { right: 5px; bottom: 5px; width: 22px; height: 22px; }
.vtile .t { min-width: 0; display: grid; gap: 4px; }
.vtile .t b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vtile .t > span { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.vtile .t em { font-style: normal; }
.vtile .badge { height: 20px; font-size: 11px; padding: 0 7px; }
.vtile .actions { flex-direction: column; gap: 4px; }

.vthumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px 14px; padding-top: 14px; }
.vthumb { display: grid; gap: 4px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; color: inherit; min-width: 0; }
.vthumb-media {
  position: relative; display: block; aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden; margin-bottom: 4px;
  border: 1px solid var(--line); color: var(--ink-2); transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .2s;
  background:
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(0deg, var(--line) 1px, transparent 1px) 0 0 / 16px 16px,
    var(--glass-2);
}
.vthumb-media:not(.detail) { color: var(--accent); }
.vthumb-media .media-art svg { width: 56%; height: auto; stroke-width: 1.2; opacity: .7; }
.vthumb-media .cmd { position: absolute; left: 8px; top: 8px; z-index: 1; }
.vthumb:hover .vthumb-media, .vthumb:focus-visible .vthumb-media { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.vthumb b { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.vthumb-sub { font-size: 12px; color: var(--muted); padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Chat ---------- */
.nav-badge {
  position: absolute; top: 2px; right: 4px; z-index: 2; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  display: grid; place-items: center; background: #ff3b30; color: #fff; font-size: 10.5px; font-weight: 700; line-height: 1;
  border: 2px solid var(--glass-solid); animation: badge-pop .5s var(--ease);
}
@keyframes badge-pop { from { transform: scale(.4); opacity: 0; } }
.chat { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: max(480px, calc(100vh - 210px)); border-radius: var(--r-xl); overflow: hidden; }
.chat-side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.chat-side .search { flex: none; max-width: none; margin: 14px 14px 8px; }
.chat-list { list-style: none; margin: 0; padding: 0 8px 10px; overflow: auto; flex: 1; }
.chat-loading { padding: 16px; }
.chat-item {
  width: 100%; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 11px; align-items: center; padding: 9px 10px;
  border: 0; background: none; border-radius: 14px; cursor: pointer; text-align: left; color: inherit; transition: background .15s;
}
.chat-item:hover { background: var(--glass-2); }
.chat-item.active { background: var(--accent-soft); }
.chat-item .t { min-width: 0; }
.chat-item .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .t span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.has-unread .t span { color: var(--ink); font-weight: 600; }
.chat-item .meta { display: grid; justify-items: end; gap: 5px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.unread { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; }
.avatar.group { background: var(--accent-soft); color: var(--accent-text); }
.avatar.group svg { width: 18px; height: 18px; }
.presence-av .status-dot.off { background: #8b8f98; animation: none; }
.presence-av.on .status-dot { background: #2fbf71; animation: breathe-green 2s ease-in-out infinite; }
.on-text { color: var(--good); font-weight: 600; }

.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.chat-head .t { min-width: 0; display: grid; }
.chat-head .t b { font-size: 15.5px; font-weight: 600; }
.chat-head .t > span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-back { display: none; }
.chat-msgs { flex: 1; overflow: auto; padding: 8px 18px 18px; display: flex; flex-direction: column; }
.chat-empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 24px; }
.chat-empty > div { display: grid; justify-items: center; gap: 6px; }
.chat-empty svg { width: 34px; height: 34px; color: var(--accent-text); opacity: .7; margin-bottom: 4px; }
.chat-empty b { color: var(--ink); font-size: 15px; }
.chat-day { text-align: center; margin: 16px 0 6px; }
.chat-day span { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 3px 10px; border-radius: 99px; background: var(--glass-2); border: 1px solid var(--line); }
.msg-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 10px; }
.msg-row.grouped { margin-top: 3px; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-av { width: 34px; flex: none; }
.bubble-wrap { display: grid; gap: 3px; max-width: min(72%, 600px); min-width: 0; }
.msg-row.mine .bubble-wrap { justify-items: end; }
.msg-name { font-size: 12px; font-weight: 600; color: var(--muted); padding-left: 12px; }
.bubble {
  padding: 8px 12px 6px; border-radius: 18px; background: var(--glass-solid); border: 1px solid var(--line); box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.42;
}
.msg-row:not(.mine) .bubble { border-bottom-left-radius: 6px; }
.msg-row.mine .bubble { background: linear-gradient(180deg, var(--accent-hi), var(--accent)); color: var(--accent-ink); border-color: transparent; border-bottom-right-radius: 6px; }
.msg-row.grouped:not(.mine) .bubble { border-top-left-radius: 6px; }
.msg-row.grouped.mine .bubble { border-top-right-radius: 6px; }
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bubble time { display: block; margin-top: 2px; font-size: 10.5px; opacity: .6; text-align: right; }
.msg-del { align-self: center; display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .15s; }
.msg-del svg { width: 15px; height: 15px; }
.msg-row:hover .msg-del, .msg-del:focus-visible { opacity: 1; }
.msg-del:hover { color: var(--bad); background: var(--bad-soft); }
.chat-form { display: flex; gap: 10px; align-items: flex-end; padding: 12px 14px; border-top: 1px solid var(--line); }
.chat-form textarea {
  flex: 1; resize: none; height: 42px; max-height: 140px; padding: 10px 16px; border-radius: 21px;
  border: 1px solid var(--line-2); background: var(--field); line-height: 1.4;
}
.chat-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-form .btn { width: 42px; height: 42px; padding: 0; border-radius: 50%; flex: none; }

@media (max-width: 760px) {
  .view-seg { margin-left: 0; }
  .vtiles { grid-template-columns: 1fr; }
  .vthumbs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - 250px); min-height: 420px; }
  .chat.open .chat-side { display: none; }
  .chat:not(.open) .chat-main { display: none; }
  .chat-back { display: inline-grid; }
  .chat-head { padding: 10px 12px; }
  .chat-msgs { padding: 6px 10px 12px; }
  .bubble-wrap { max-width: 84%; }
  .msg-del { opacity: .5; }
}

/* ---------- Features and access ---------- */
/* Switched-off features disappear for that member (the server refuses them too) */
body.no-download [data-dl], body.no-download .pdf-dl { display: none !important; }
.feature-list { display: grid; gap: 4px; }
.feature-group { margin: 10px 10px 0; }
.feature-group:first-child { margin-top: 0; }
.perm-features .feature-group { margin: 12px 0 0; }
.feature { display: flex; align-items: center; gap: 16px; padding: 12px 10px; border-radius: 14px; cursor: pointer; }
.feature:hover { background: var(--glass-2); }
.feature .t { flex: 1; min-width: 0; display: grid; gap: 2px; }
.feature .t b { font-weight: 600; }
.feature .t span { font-size: 12.5px; color: var(--muted); }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 46px; height: 28px; margin: 0; border-radius: 99px; cursor: pointer;
  background: var(--line-2); border: 1px solid var(--line); transition: background .25s var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: transform .3s var(--ease);
}
.switch:checked { background: var(--good); border-color: transparent; }
.switch:checked::after { transform: translateX(18px); }
.switch:disabled { opacity: .5; cursor: wait; }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.access-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 99px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--glass-2); font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.access-btn svg { width: 14px; height: 14px; color: var(--good); }
.access-btn.custom svg { color: var(--accent-text); }
.access-btn:hover { border-color: var(--accent); }
.access-all { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.chip { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; }
.chip.on { color: var(--good); background: var(--good-soft); }
.chip.off { color: var(--bad); background: var(--bad-soft); }

.overlay#permOverlay { place-items: center; padding: 16px; }
.perm { width: min(760px, 100%); max-height: min(90vh, 860px); border-radius: var(--r-xl); background: var(--sheen), var(--glass-solid); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); }
.perm .preview-head .avatar { flex: none; }
.perm .preview-head > div { flex: 1; min-width: 0; }
.perm-body { flex: 1; min-height: 0; overflow: auto; padding: 6px 20px 20px; }
.perm-sec { padding-top: 14px; }
.perm-sec h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.perm-sec > p { margin: 0 0 10px; font-size: 12.5px; }
.perm-features { display: grid; gap: 4px; }
.perm-feature { display: flex; align-items: center; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.perm-feature:last-child { border-bottom: 0; }
.perm-feature .t { flex: 1; min-width: 0; display: grid; }
.perm-feature .t b { font-weight: 600; font-size: 13.5px; }
.perm-feature .t span { font-size: 12px; color: var(--muted); }
.perm-feature .seg button { padding: 0 10px; }
.perm-lib-head { margin: 8px 0 10px; }
.perm-hint { display: flex; gap: 8px; align-items: center; margin: 4px 0 10px; font-size: 12.5px; color: var(--muted); }
.perm-hint svg { width: 16px; height: 16px; color: var(--good); }
.perm-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.perm-tools .search { flex: 1 1 220px; max-width: none; }
.perm-tree { display: grid; gap: 8px; max-height: 340px; overflow: auto; padding-right: 4px; }
.perm-kind { margin: 6px 0 0; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.perm-cat { border: 1px solid var(--line); border-radius: 14px; background: var(--glass-2); padding: 4px; }
.perm-cat.whole { border-color: var(--accent); background: var(--accent-soft); }
.perm-cat .check { padding: 7px 8px; border-radius: 10px; gap: 10px; }
.perm-cat .check:hover { background: var(--glass-2); }
.perm-cat .check.cat b { font-weight: 600; }
.perm-cat .check.cat .muted { margin-left: auto; font-size: 12px; }
.perm-items { display: grid; padding-left: 26px; }
.perm-items .check { font-size: 13px; }
.perm-items .check:has(input:disabled) { opacity: .7; cursor: default; }
.perm-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.perm-foot { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); }
.perm-foot .muted { flex: 1; font-size: 13px; }
@media (max-width: 760px) {
  .perm-feature { flex-wrap: wrap; }
  .perm-feature .seg { width: 100%; }
  .perm-feature .seg button { flex: 1; }
  .perm-items { padding-left: 8px; }
}

/* ---------- Desktop notifications ---------- */
.notify-banner {
  display: flex; align-items: center; gap: 8px; margin: 14px 14px 0; padding: 8px 8px 8px 12px; border-radius: 14px;
  background: var(--accent-soft); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.notify-banner > svg { width: 16px; height: 16px; color: var(--accent-text); }
.notify-banner span { flex: 1; min-width: 0; }
.notify-banner .icon-btn { width: 28px; height: 28px; border: 0; background: none; }

/* =====================================================================
   Expandable sidebar (sidebar.js) – icon rail that opens into a panel
   ===================================================================== */
@property --rail { syntax: '<length>'; inherits: true; initial-value: 76px; }
.rail-hover {
  position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; opacity: 0; border-radius: 13px;
  background: var(--glass-2); border: 1px solid var(--rim); box-shadow: 0 6px 16px -10px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .12);
  transition: transform .42s var(--ease), width .42s var(--ease), height .42s var(--ease), opacity .2s;
}
.rail-hover.no-anim, .rail-pill.no-anim { transition: opacity .2s; }
.rail-head { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; flex: none; }
.rail-brand { display: none; }
.rail-toggle {
  position: absolute; right: -13px; top: 50%; width: 26px; height: 26px; margin-top: -13px; z-index: 3;
  display: grid; place-items: center; padding: 0; border-radius: 50%; cursor: pointer; color: var(--ink);
  background: var(--glass-solid); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  transition: transform .45s var(--ease), background .2s, right .45s var(--ease);
}
.rail-toggle svg { width: 14px; height: 14px; stroke-width: 2.4; transition: transform .5s var(--ease); }
.rail-toggle:hover { transform: scale(1.12); background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.rail-toggle .tip, .rail-search-btn .tip { position: absolute; left: calc(100% + 12px); top: 50%; transform: translate(-4px, -50%); opacity: 0; pointer-events: none;
  padding: 5px 10px; border-radius: 8px; background: var(--glass-solid); border: 1px solid var(--line); color: var(--ink);
  font-size: 12.5px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow); transition: .18s var(--ease); z-index: 20; }
.rail-toggle:hover .tip, .rail-toggle:focus-visible .tip { opacity: 1; transform: translate(0, -50%); }
.rail kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line-2); color: var(--muted); background: none; }
.rail-search { display: flex; justify-content: center; width: 100%; flex: none; }
.rail-search-box { display: none; }
.rail-sec { width: 22px; height: 2px; border-radius: 2px; margin: 4px auto; background: var(--line-2); flex: none; }
.rail-sec span { display: none; }
.rail-group, .rail-sub, .rail-sub-in { display: contents; }
.rail-grp-btn { display: none; }
.rail-chev { display: none; }
.rail-night-ic { position: relative; width: 20px; height: 20px; display: grid; place-items: center; }
.rail-night-ic svg { position: absolute; inset: 0; width: 20px; height: 20px; transition: transform .5s var(--ease), opacity .3s; }
.rail-night[aria-checked="true"] .sun, .rail-night[aria-checked="false"] .moon { opacity: 0; transform: rotate(-90deg) scale(.5); }
.rail-switch { display: none; }
.rail-me { display: flex; justify-content: center; }
.rail-me-info { display: none; }
.rail-hide { display: none !important; }
html.theme-fade, html.theme-fade * { transition: background-color .45s ease, color .45s ease, border-color .45s ease !important; }

@media (min-width: 761px) {
  :root { transition: --rail .55s var(--ease); }
  .shell { transition: none; }
  html.rail-open { --rail: 268px; }
  html.rail-open .rail { align-items: stretch; gap: 10px; padding: 14px 12px; overflow-x: hidden; overflow-y: auto; scrollbar-width: none; }
  html.rail-open .rail::-webkit-scrollbar { display: none; }
  html.rail-open .rail-toggle svg { transform: rotate(180deg); }

  /* header: logo, name, collapse button */
  html.rail-open .rail-head { justify-content: flex-start; gap: 12px; padding: 0 4px; }
  html.rail-open .rail-brand { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; animation: rail-in .5s var(--ease) .1s both; }
  .rail-brand b { font-size: 16px; font-weight: 700; white-space: nowrap; }
  .rail-brand small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html.rail-open .rail-toggle { position: relative; right: auto; top: auto; margin: 0 0 0 auto; flex: none; }
  html.rail-open .rail-toggle .tip { left: auto; right: 0; top: calc(100% + 8px); transform: translateY(-4px); }
  html.rail-open .rail-toggle:hover .tip { transform: none; }

  /* search */
  html.rail-open .rail-search-btn { display: none; }
  html.rail-open .rail-search-box {
    display: flex; align-items: center; gap: 8px; width: 100%; height: 40px; padding: 0 10px 0 12px; border-radius: 12px; cursor: text;
    background: var(--field); border: 1px solid var(--line); transition: border-color .2s, box-shadow .25s var(--ease); animation: rail-in .5s var(--ease) .14s both;
  }
  .rail-search-box svg { width: 17px; height: 17px; flex: none; color: var(--muted); }
  .rail-search-box input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font: 500 14px var(--font); color: var(--ink); padding: 0; height: 100%; }
  .rail-search-box input::-webkit-search-cancel-button { display: none; }
  .rail-search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .rail-noresult .rail-search-box { border-color: var(--bad); }
  [data-theme^="liquid"] .rail-search-box { border-radius: 999px; }

  /* items: icon + label */
  html.rail-open .rail-nav, html.rail-open .rail-foot { align-items: stretch; gap: 2px; }
  html.rail-open .rail-btn { width: 100%; height: 40px; display: flex; align-items: center; justify-content: flex-start; gap: 12px; padding: 0 12px; border-radius: 12px; }
  html.rail-open .rail-btn > svg { flex: none; }
  html.rail-open .rail-btn:hover { background: none; }
  html.rail-open .rail-btn .tip {
    position: static; transform: none; opacity: 1; padding: 0; border: 0; background: none; box-shadow: none; color: inherit;
    font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: auto;
  }
  html.rail-open .rail-btn .tip kbd { display: none; }
  html.rail-open.rail-anim .rail-btn .tip, html.rail-open.rail-anim .rail-sec span { animation: rail-in .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 16ms + 90ms); }
  @keyframes rail-in { from { opacity: 0; transform: translateX(-10px); } }
  html.rail-open .nav-badge { position: static; margin-left: auto; border: 0; }
  html.rail-open .rail-btn.active { font-weight: 600; }

  /* section labels */
  html.rail-open .rail-sec { width: auto; height: auto; margin: 10px 12px 4px; background: none; border-radius: 0; }
  html.rail-open .rail-sec:first-child { margin-top: 2px; }
  html.rail-open .rail-sec span { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }

  /* the Tools group: header with chevron, children on a tree line */
  html.rail-open .rail-group { display: block; }
  html.rail-open .rail-grp-btn { display: flex; border: 0; background: none; cursor: pointer; color: var(--ink-2); font: inherit; }
  html.rail-open .rail-chev { display: block; width: 16px; height: 16px; margin-left: auto; color: var(--muted); transition: transform .4s var(--ease); }
  html.rail-open .rail-group.closed:not(.searching) .rail-chev { transform: rotate(-90deg); }
  html.rail-open .rail-sub { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .45s var(--ease); }
  html.rail-open .rail-group.closed:not(.searching) .rail-sub { grid-template-rows: 0fr; }
  html.rail-open .rail-sub-in { display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden; position: relative; margin-left: 21px; padding-left: 12px; }
  html.rail-open .rail-sub-in::before { content: ""; position: absolute; left: 0; top: 0; bottom: 20px; width: 1.5px; border-radius: 2px; background: var(--line-2); }
  html.rail-open .rail-sub-in .rail-btn { height: 36px; padding: 0 10px; gap: 10px; }
  html.rail-open .rail-sub-in .rail-btn::before { content: ""; position: absolute; left: -12px; top: 50%; width: 10px; height: 12px; margin-top: -12px; border: solid var(--line-2); border-width: 0 0 1.5px 1.5px; border-bottom-left-radius: 8px; }
  html.rail-open .rail-sub-in .rail-btn > svg { width: 17px; height: 17px; }
  html.rail-open .rail-sub-in .rail-btn .tip { font-size: 13.5px; }
  html.rail-open .rail-group.closed:not(.searching) .rail-sub-in { visibility: hidden; transition: visibility 0s .45s; }

  /* footer: night mode switch and the member card */
  html.rail-open .rail-foot { padding-top: 8px; border-top: 1px solid var(--line); }
  html.rail-open .rail-switch {
    display: block; position: relative; flex: none; margin-left: auto; width: 38px; height: 22px; border-radius: 99px;
    background: var(--line-2); transition: background .3s var(--ease);
  }
  .rail-switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); transition: transform .4s var(--ease); }
  html.rail-open .rail-night[aria-checked="true"] .rail-switch { background: var(--accent); }
  .rail-night[aria-checked="true"] .rail-switch::after { transform: translateX(16px); }
  html.rail-open .rail-me { justify-content: flex-start; align-items: center; gap: 10px; padding: 8px 6px 0; margin-top: 4px; position: relative; z-index: 1; border-radius: 14px; }
  html.rail-open .rail-me-info { display: flex; flex-direction: column; min-width: 0; text-decoration: none; color: var(--ink); line-height: 1.25; animation: rail-in .5s var(--ease) .2s both; }
  .rail-me-info b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; }
  .rail-me-info small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html.rail-open .rail-me .avatar { flex: none; }
}
/* shorter screens: the open panel tightens up */
@media (min-width: 761px) and (max-height: 820px) {
  html.rail-open .rail-btn { height: 36px; }
  html.rail-open .rail-sub-in .rail-btn { height: 32px; }
  html.rail-open .rail-sec { margin-top: 6px; }
}
/* phones keep the bottom bar */
@media (max-width: 760px) {
  .rail-head, .rail-search, .rail-sec, .rail-hover, .rail-me { display: none !important; }
  .rail-night .tip { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  :root { transition: none !important; }
  .rail-hover, .rail-toggle, .rail-sub { transition: none !important; }
}
@media (min-width: 761px) {
  html.rail-open .rail-search .rail-search-btn { display: none; }
  html.rail-open .rail-btn { height: 38px; }
  html.rail-open .rail-sub-in .rail-btn { height: 34px; }
  html.rail-open .rail-search-box { height: 38px; }
  html.rail-open .rail-sec { margin: 8px 12px 3px; }
  /* footer when open: night mode, then Account / Help / Sign out as one row of icons, then the member card */
  html.rail-open .rail-foot { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  html.rail-open .rail-foot > .rail-night, html.rail-open .rail-foot > .rail-me { flex: 1 1 100%; }
  html.rail-open .rail-foot > .rail-btn:not(.rail-night) { flex: 1 1 0; width: auto; justify-content: center; padding: 0; }
  html.rail-open .rail-foot > .rail-btn:not(.rail-night) .tip {
    position: absolute; left: 50%; top: auto; bottom: calc(100% + 6px); transform: translate(-50%, 4px); opacity: 0; pointer-events: none;
    padding: 4px 9px; border-radius: 8px; background: var(--glass-solid); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 12px; font-weight: 600; z-index: 20; animation: none;
  }
  html.rail-open .rail-foot > .rail-btn:not(.rail-night):hover .tip { opacity: 1; transform: translate(-50%, 0); }
}
/* desktop rail scrolls when the screen is short; labels for icons show as one floating tooltip (sidebar.js) */
@media (min-width: 761px) {
  .rail { overflow-x: hidden; overflow-y: auto; scrollbar-width: none; gap: 12px; }
  .rail::-webkit-scrollbar { display: none; }
  .rail-nav, .rail-foot { gap: 4px; }
  .rail-btn .tip, .rail-toggle .tip, .rail-search-btn .tip { display: none; }
  .rail-toggle { right: 2px; top: -4px; margin-top: 0; width: 24px; height: 24px; }
  html.rail-open .rail-btn .tip { display: block; }
  html.rail-open .rail-foot > .rail-btn:not(.rail-night) .tip, html.rail-open .rail-toggle .tip { display: none; }
  html.rail-open .rail-toggle { width: 26px; height: 26px; }
}
.rail-floattip {
  position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; opacity: 0; transform: translate(var(--x), var(--y)) translateX(-4px);
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px; background: var(--glass-solid); border: 1px solid var(--line); color: var(--ink);
  font: 600 12.5px var(--font); white-space: nowrap; box-shadow: var(--shadow); transition: opacity .16s, transform .22s var(--ease);
}
.rail-floattip.on { opacity: 1; transform: translate(var(--x), var(--y)); }
.rail-floattip.above { transform: translate(var(--x), var(--y)) translateY(4px); }
.rail-floattip.above.on { transform: translate(var(--x), var(--y)); }
.rail-floattip kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line-2); color: var(--muted); }
@media (max-width: 760px) { .rail-floattip { display: none; } }
