/*
 * GLOBAL JOKERLIST — Bureau / a registry on an archivist's desk.
 * The documents are working UI surfaces; the room photograph is not used.
 * Scoped overrides preserve the existing renderers, image crops and drag behavior.
 */
@property --light-reveal {
  syntax: '<length>';
  inherits: false;
  initial-value: 0px;
}

:root {
  color-scheme: dark;
  --bg: #070806;
  --surface: #13140e;
  --card: #1d1e14;
  --card-hover: #2b2a1c;
  --border: #3a3828;
  --border-light: #615b3c;
  --accent: #d7b56e;
  --accent-hover: #ecd398;
  --accent-dim: rgba(215, 181, 110, .12);
  --accent-alt: #bca062;
  --accent-alt-dim: rgba(188, 160, 98, .12);
  --crimson: #b77a67;
  --text: #efe3c4;
  --text-muted: #cfc2a0;
  --text-faint: #b2a783;
  --success: #b7c593;
  --success-dim: rgba(183, 197, 147, .1);
  --warning: #dec37c;
  --warning-dim: rgba(222, 195, 124, .12);
  --error: #e2a08e;
  --error-dim: rgba(226, 160, 142, .12);
  --info: #abc1c6;
  --info-dim: rgba(171, 193, 198, .1);
  --paper: #c4b08a;
  --paper-light: #ecd8ab;
  --ink: #19190f;
  --ink-muted: #363525;
  --ink-faint: #403e2b;
  --paper-line: #aa9870;
  --shadow-sm: 0 3px 8px rgba(0, 0, 0, .15);
  --shadow-md: 0 16px 36px rgba(0, 0, 0, .3);
  --shadow-lg: 0 28px 72px rgba(0, 0, 0, .5);
  --shadow-accent: 0 0 0 1px rgba(198, 177, 108, .22);
  --shadow-alt: var(--shadow-md);
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 5px;
  --radius-xl: 7px;
  --font: 'Old Soviet', serif;
  --font-display: 'Capture It', sans-serif;
  --font-mono: var(--font);
  --transition: 180ms ease;
  --page-width: 1120px;
  --page-gutter: clamp(16px, 4vw, 56px);
  --lamp-size: 230px;
  --lamp-top: -65px;
  --lamp-light-x: 50vw;
  --lamp-light-y: calc(var(--lamp-top) + var(--lamp-size) * .87);
  --lamp-power: 1;
  --lamp-response: 240ms;
  --grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.88' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' opacity='.13' filter='url(%23g)'/%3E%3C/svg%3E");
}

html { scroll-padding-top: 84px; }
body {
  font-size: 1rem;
  font-weight: 700;
  font-synthesis: none;
  letter-spacing: -.015em;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 54% 46%, rgba(27, 25, 16, .3), rgba(0, 0, 0, .2) 66%, rgba(0, 0, 0, .55) 100%);
  isolation: isolate;
  -webkit-font-smoothing: antialiased;
}
#app { position: relative; }
.main-content { position: relative; z-index: 1; }
#app, .main-content, #page-root { min-width: 0; width: 100%; }
body::before { content: none; }
::selection { background: #7d7247; color: #f3ecd4; }
h1, h2, h3, h4, h5, h6 { text-transform: none; letter-spacing: -.035em; }
h3 { font-size: 1.125rem; line-height: 1.4; font-weight: 600; }
p { line-height: 1.75; }
input, textarea, select { accent-color: var(--accent); }
input:disabled, textarea:disabled, select:disabled { opacity: .6; cursor: not-allowed; }
.text-sm, .form-label, .perm-label { font-size: .875rem; }
.text-xs, .form-hint, .form-error { font-size: .8125rem; }
.section-label { font-family: var(--font-mono); font-size: .75rem; letter-spacing: .08em; }
.mb-sm { margin-bottom: var(--space-sm); }
.gap-2xl { gap: var(--space-2xl); }
.bg-blob, .auth-mesh-bg, .cosmic-void-bg, .auth-mockup { display: none; }

:where(button, a, input, textarea, select, [tabindex]):focus-visible,
.btn:focus-visible, .tab:focus-visible, .btn-icon:focus-visible, .nav-logo:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* Light and material, without a photographic room background. */
.room-light {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse clamp(135px, 12vw, 190px) clamp(95px, 9vw, 140px) at var(--lamp-light-x) var(--lamp-light-y), rgba(255, 197, 83, .68), rgba(226, 160, 51, .35) 42%, transparent 100%),
    radial-gradient(ellipse clamp(330px, 34vw, 560px) clamp(300px, 32vw, 510px) at var(--lamp-light-x) var(--lamp-light-y), rgba(195, 144, 53, .34), rgba(120, 88, 35, .2) 46%, transparent 100%),
    radial-gradient(ellipse clamp(440px, 42vw, 740px) 650px at var(--lamp-light-x) calc(var(--lamp-light-y) + 170px), rgba(116, 84, 29, .12), transparent 84%);
  opacity: var(--lamp-power);
  transition: opacity var(--lamp-response) ease-out;
}
.room-grain {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background-image: var(--grain);
  opacity: .075;
}
.room-darkness {
  position: absolute;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  background: radial-gradient(ellipse at 78% 0%, rgba(3, 5, 3, .89), rgba(1, 3, 2, .97) 72%);
  --light-reveal: 160vmax;
  -webkit-mask-image: radial-gradient(circle at var(--light-x, 50vw) var(--light-y, 110px), transparent max(0px, calc(var(--light-reveal) - 24vmax)), #000 var(--light-reveal));
  mask-image: radial-gradient(circle at var(--light-x, 50vw) var(--light-y, 110px), transparent max(0px, calc(var(--light-reveal) - 24vmax)), #000 var(--light-reveal));
  transition: --light-reveal 700ms cubic-bezier(.22, .7, .28, 1);
}
/* A faint shared shadow makes the papers respond to the same lamp voltage. */
.room-voltage {
  position: absolute;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: #050603;
  opacity: calc((1 - var(--lamp-power)) * .42);
  transition: opacity var(--lamp-response) ease-out;
}
.desk-lamp {
  display: block;
  position: absolute;
  top: var(--lamp-top);
  left: 50%;
  transform: translateX(-50%);
  width: var(--lamp-size);
  aspect-ratio: 1;
  pointer-events: none;
  z-index: 0;
}
.lamp-object {
  display: block;
  position: relative;
  width: 100%;
  height: auto;
  filter: brightness(calc(.3 + var(--lamp-power) * .7));
  transition: filter var(--lamp-response) ease-out, transform 250ms ease;
  pointer-events: none;
  outline: none;
}
.desk-lamp::after {
  content: '';
  position: absolute;
  z-index: 6;
  top: 76%;
  left: 21%;
  width: 58%;
  height: 15%;
  pointer-events: none;
  background: radial-gradient(ellipse, rgba(255, 187, 69, .4), transparent 72%);
  filter: blur(9px);
  mix-blend-mode: screen;
  opacity: var(--lamp-power);
  transition: opacity var(--lamp-response) ease-out;
}

body:has(:where(.home-page, #login-page, .registry-header)) .desk-lamp {
  z-index: 5;
}
body:has(:where(.home-page, #login-page, .registry-header)) .lamp-object {
  pointer-events: auto;
  cursor: pointer;
}
body:has(:where(.home-page, #login-page, .registry-header)) .lamp-object:hover,
body:has(:where(.home-page, #login-page, .registry-header)) .lamp-object:focus-visible {
  filter: brightness(calc(.45 + var(--lamp-power) * .7));
  transform: scale(1.02);
}
body:has(:where(.home-page, #login-page, .registry-header)) .lamp-object:active {
  transform: scale(0.98);
}

/* Background state for other pages */
body:not(:has(:where(.home-page, #login-page, .registry-header))) .lamp-object {
  filter: brightness(calc(.15 + var(--lamp-power) * .35)) blur(6px);
  opacity: 0.85;
}
body:not(:has(:where(.home-page, #login-page, .registry-header))) .desk-lamp::after {
  opacity: calc(var(--lamp-power) * 0.6);
}

body[data-lamp='off'] .room-darkness { --light-reveal: 0px; transition-duration: 420ms; }
body[data-lamp='off'] .room-light { opacity: 0; transition-duration: 420ms; }
body[data-lamp='off'] .room-voltage { opacity: 0; }
body[data-lamp='off'] .desk-lamp::after { opacity: 0; }

/* Navigation stays at 60px, matching the existing router. */
.top-nav {
  background: rgba(13, 14, 10, .97);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.nav-container { max-width: calc(var(--page-width) + var(--page-gutter) * 2); margin-inline: auto; padding-inline: var(--page-gutter) !important; }
.nav-logo { gap: 13px !important; }
.nav-logo-text {
  display: grid; place-items: center; width: 43px; height: 31px;
  border: 1px solid var(--border-light); border-radius: 2px;
  color: var(--text) !important; font-family: var(--font-display);
  font-size: 1.0625rem !important; font-weight: 400 !important;
  letter-spacing: -.035em; background: var(--surface);
}
.nav-logo::after { content: 'GLOBAL JOKERLIST'; color: var(--text-muted); font-family: var(--font-mono); font-size: .75rem; letter-spacing: .08em; }
.nav-right { gap: 10px !important; }
.dropdown-toggle { border-color: transparent !important; color: var(--text-muted); }
.dropdown-menu { min-width: 220px !important; margin-top: 9px; padding: 6px !important; border-radius: 4px !important; box-shadow: var(--shadow-lg); }
.dropdown-item { min-height: 44px; padding: 10px 12px !important; font-size: .875rem; }
.dropdown-item > span:empty { display: none; }
.dropdown-item.active { background: var(--accent-dim); }
.user-chip { padding: 4px 10px 4px 5px !important; background: transparent !important; border-color: transparent !important; }
.user-chip:hover { border-color: var(--border-light) !important; }
.user-avatar { background: var(--accent-dim) !important; color: var(--accent) !important; border: 1px solid var(--border-light); border-radius: 3px !important; font-weight: 500 !important; }
.beta-session-badge { flex-shrink: 0; font-size: .75rem; border-radius: 2px; }

.page-header, .page-body { width: calc(100% - var(--page-gutter) * 2); max-width: var(--page-width); margin-inline: auto; }
.page-header { padding: 32px 0 24px; position: relative; top: auto; border-bottom: 0; background: transparent; }
.page-title { font-family: var(--font-display); font-size: clamp(1.8rem, 3.1vw, 2.75rem) !important; font-weight: 400 !important; line-height: 1.2; text-transform: none !important; letter-spacing: -.045em !important; overflow-wrap: anywhere; text-shadow: 0 2px 3px rgba(0, 0, 0, .85), 0 6px 20px rgba(0, 0, 0, .6); }
.page-body { padding: 24px 0 64px; }
.page-actions { gap: 10px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Shared controls. */
.btn {
  min-height: 42px; padding: 10px 18px; gap: 8px; border-radius: 3px;
  font-size: .875rem; font-weight: 600; line-height: 1.4; letter-spacing: -.01em;
  transition: color var(--transition), background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn::after { display: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { color: #24271b; background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { color: #24271b; border-color: var(--accent-hover); }
.btn-ghost { color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover, .btn-surface:hover { color: var(--text); border-color: var(--border-light); background: var(--card-hover); }
.btn-danger { color: var(--error); background: var(--error-dim); border-color: rgba(226, 160, 142, .3); }
.btn-danger:hover { color: #281810; background: var(--error); border-color: var(--error); }
.btn-success { color: #588157; background: rgba(88, 129, 87, 0.1); border-color: rgba(88, 129, 87, 0.3); }
.btn-success:hover { color: #ece3c2; background: #3a5a40; border-color: #3a5a40; }
.btn-sm { min-height: 35px; padding: 7px 12px; font-size: .875rem; }
.btn-lg { min-height: 50px; font-size: 1rem; }
.btn-icon { min-width: 36px; min-height: 36px; }
.btn .spinner { border-top-color: currentColor; }
.form-group { gap: 8px; }
.form-label { color: var(--text-muted); font-size: .875rem; font-weight: 500; letter-spacing: 0; }
.form-input, .form-textarea, .form-select, #joker-search-input {
  min-width: 0; min-height: 46px; width: 100%; padding: 12px 14px;
  border: 1px solid var(--border-light); border-radius: 3px;
  color: var(--text); background-color: #10120c; font-size: 1rem; line-height: 1.5;
}
.form-input:focus, .form-textarea:focus, .form-select:focus, #joker-search-input:focus { outline: none; border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-dim); }
.form-select { padding-right: 38px; }
.form-textarea { min-height: 130px; }
input::placeholder, textarea::placeholder { color: var(--text-faint); opacity: 1; }
.form-row .form-group { min-width: 0; }
.card, .stat-card { background: linear-gradient(115deg, #232318, #191b12); box-shadow: var(--shadow-sm); }
.card-hover:hover { border-color: var(--accent-alt); }
.card-glass { background: rgba(26, 27, 18, .96); border-color: var(--border); }

/* A paper surface has its own accessible ink palette. */
.paper-sheet, .demonlist-card, .table-wrap {
  --text: var(--ink); --text-muted: var(--ink-muted); --text-faint: var(--ink-faint);
  --border: var(--paper-line); --border-light: #8c8568;
  --accent: #5c4c22; --accent-hover: #3a3d2d; --accent-alt: #494329;
  --accent-dim: rgba(83, 77, 43, .1);
  --surface: #b9a67e; --card: var(--paper); --card-hover: #cdbc94;
  --error: #8c3527; --error-dim: rgba(140, 53, 39, .08);
  --success: #354724; --success-dim: rgba(53, 71, 36, .09);
  --warning: #604518; --warning-dim: rgba(96, 69, 24, .1);
  --info: #2e474b; --info-dim: rgba(46, 71, 75, .1);
  --crimson: #82432f;
  color-scheme: light;
  color: var(--ink);
}
.paper-sheet {
  position: relative;
  color-scheme: light;
  color: var(--ink);
  background-color: var(--paper);
  background-image: var(--grain), radial-gradient(ellipse at 82% 0%, #f0deaf, var(--paper-light) 30%, var(--paper) 100%);
  border: 1px solid #cbb688;
  border-top-color: #f1ddb0;
  border-radius: 2px;
  box-shadow: 2px 3px 0 #665d40, -12px 24px 48px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 242, 204, .32);
}
.document-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid currentColor; }
.document-kicker, .document-folio { font-family: var(--font-mono); font-size: .75rem; font-weight: 400; letter-spacing: .09em; line-height: 1.6; }
.document-folio { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.document-title { margin: 28px 0; font-family: var(--font-display); font-size: clamp(2rem, 3vw, 2.75rem); line-height: 1.1; font-weight: 400; letter-spacing: -.05em; }
.document-title em { font-weight: 400; }
.document-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-family: var(--font-mono); font-size: .75rem; line-height: 1.5; }
.ink-stamp { padding: 5px 8px; color: #4e492d; border: 1px solid currentColor; transform: rotate(-7deg); font-family: var(--font-mono); font-size: .75rem; letter-spacing: .08em; white-space: nowrap; }
:is(.paper-sheet, .table-wrap, .demonlist-card) .btn-primary { background: var(--ink); border-color: var(--ink); color: #ece3c2; }
:is(.paper-sheet, .table-wrap, .demonlist-card) .btn-primary:hover { background: #3a3e2b; border-color: #3a3e2b; color: #fff4d4; }
:is(.paper-sheet, .table-wrap, .demonlist-card) .btn-danger:hover { color: #fff1d8; }
.paper-sheet .form-input, .paper-sheet .form-select, .paper-sheet .form-textarea {
  background-color: rgba(249, 241, 210, .14);
  border-color: var(--paper-line);
  border-bottom-color: #747354;
  border-radius: 1px;
  color: var(--ink);
  box-shadow: none;
}
.paper-sheet .form-input:focus { background-color: rgba(249, 241, 210, .35); box-shadow: 0 0 0 2px var(--accent-dim); }

/* Home: a working registry cover beside an actual summary sheet. */
.home-page { width: calc(100% - var(--page-gutter) * 2); max-width: var(--page-width); margin-inline: auto; min-height: calc(100svh - 60px); padding: 142px 0 72px; }
.desk-context { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 36px; font-family: var(--font-mono); font-size: .75rem; letter-spacing: .04em; color: var(--text-faint); }
.home-desk { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .86fr); gap: 0; align-items: center; padding: 0 10px 0 0; }
.registry-cover { position: relative; min-height: 484px; padding: 36px 48px 30px 52px; background-color: #262519; background-image: var(--grain), radial-gradient(ellipse at 100% 0%, rgba(181, 141, 62, .12), transparent 75%), linear-gradient(115deg, #232418, #2c2c1e); color: #eadbb4; border: 1px solid #615b38; border-top-color: #9b824c; border-radius: 3px; box-shadow: 1px 3px 0 #14160e, -8px 30px 55px rgba(0, 0, 0, .66), inset 0 1px 0 rgba(224, 190, 116, .12); }
.registry-cover::before { content: ''; position: absolute; top: 0; bottom: 0; left: 17px; width: 1px; background: #15170e; box-shadow: 2px 0 0 rgba(218, 196, 140, .1); pointer-events: none; }
.folder-tab { position: absolute; top: -29px; left: -1px; padding: 9px 28px 9px 30px; color: #e1cea0; background: #28281a; border: 1px solid #655c3b; border-bottom: 0; border-radius: 8px 20px 0 0; font-family: var(--font-mono); font-size: .75rem; line-height: 1; letter-spacing: .065em; }
.cover-topline { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-bottom: 24px; border-bottom: 1px solid rgba(222, 215, 172, .2); font-size: .8125rem; color: #e8dfb7; }
.cover-monogram { border: 1px solid #b2ac80; padding: 4px 7px; font-family: var(--font-display); font-size: 1.25rem; line-height: 1; letter-spacing: -.07em; }
.registry-cover h1 { margin: 36px 0 22px; color: #f3e6bf; font-family: var(--font-display); font-size: clamp(3rem, 5.8vw, 5.4rem); font-weight: 400; line-height: .98; letter-spacing: -.065em; overflow-wrap: anywhere; text-shadow: 0 1px 1px rgba(0, 0, 0, .12); }
.cover-description { font-size: 1rem; color: #e1d0a5; line-height: 1.65; }
.cover-open { margin-top: 28px; padding: 14px 20px; min-width: 224px; justify-content: space-between; border-color: #e5c681; background: linear-gradient(120deg, #dfc383, #bd974c); color: #191a10; border-radius: 2px; box-shadow: inset 0 1px 0 rgba(255, 239, 192, .45), 0 4px 14px rgba(0, 0, 0, .25); }
.cover-open span { font-size: 1.375rem; font-weight: 400; transition: transform 180ms ease; }
.cover-open:hover span { transform: translate(2px, -2px); }
.cover-colophon { display: flex; justify-content: space-between; gap: 16px; margin-top: 40px; padding-top: 18px; border-top: 1px solid rgba(222, 215, 172, .2); font-family: var(--font-mono); font-size: .75rem; color: #e2ddbb; }
.summary-sheet { min-height: 405px; margin-left: -10px; padding: 30px 32px; transform: rotate(1.6deg); z-index: 1; }
.summary-rule { height: 3px; margin-bottom: 8px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.stats-container { margin-bottom: 26px; }
.stat-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; padding: 20px 0 16px; border-bottom: 1px solid var(--paper-line); }
.stat-number { order: 2; font-family: var(--font); font-weight: 700; font-size: 3.25rem; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-caption { order: 1; padding-bottom: 3px; font-size: .9375rem; color: var(--ink-muted); }

/* Entry is an admission document, with the original sign-in and beta controls. */
.auth-page { min-height: 100svh; padding: 212px var(--page-gutter) 80px; }
.auth-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 408px); align-items: center; gap: clamp(48px, 8vw, 120px); max-width: 1050px; width: 100%; padding: 0; background: none; border: 0; }
.auth-intro { align-self: center; }
.auth-intro > .document-kicker { color: var(--accent); margin-bottom: 32px; letter-spacing: .16em; }
.auth-intro h1 { color: var(--text); font-family: var(--font-display); font-size: clamp(3.25rem, 6.5vw, 5.25rem); font-weight: 400; letter-spacing: -.06em; line-height: .98; }
.auth-intro h1 em { color: #c7b87c; font-weight: 400; }
.auth-intro-footer { display: flex; align-items: center; gap: 20px; margin-top: 46px; }
.bureau-mark { flex-shrink: 0; padding: 11px 10px; border: 1px solid #96976f; color: #b5b58a; font-family: var(--font-display); font-size: 1.5rem; letter-spacing: -.06em; transform: rotate(-7deg); }
.auth-intro-footer p { color: var(--text-faint); font-family: var(--font-mono); font-size: .8125rem; line-height: 1.8; }
#login-form { width: 100%; padding: 30px 32px 32px; transform: rotate(.65deg); }
#login-form .document-title { margin-block: 28px; font-size: 2.3rem; }
#login-form > .flex { gap: 22px; }
#login-form .form-label { font-family: var(--font-mono); font-size: .8125rem; letter-spacing: .035em; }
#login-form .form-input { min-height: 48px; }
#login-btn { margin-top: 3px; }
.beta-entry { margin-top: 24px; padding-top: 22px; border-top: 1px dashed #898768; }
.beta-entry .btn { border-color: #737353; background: transparent; color: var(--ink); white-space: normal; }
.beta-entry .btn:hover { background: rgba(76, 78, 45, .09); border-color: var(--ink); }
.beta-note { margin-top: 10px; color: var(--ink-faint); text-align: center; font-family: var(--font-mono); font-size: .75rem; line-height: 1.6; }

/* Registry tabs are the actual folder tabs; their original events are unchanged. */
.registry-header { position: relative; top: auto; background: transparent; }
.registry-heading { min-height: 112px; padding: 0 168px 6px 0; }
.registry-heading .document-kicker { color: var(--text-faint); margin-bottom: 9px; }
.registry-heading .page-title { font-size: clamp(1.9rem, 3.5vw, 2.75rem) !important; }
.tabs { display: flex; flex-wrap: wrap; align-items: stretch; gap: 4px; width: fit-content; max-width: 100%; margin-bottom: 24px; padding: 0; border-bottom: 1px solid #76623c; border-radius: 0; background: none; }
.tab {
  min-height: 44px; padding: 11px 23px; border: 1px solid #4b503b; border-bottom: 0;
  border-radius: 5px 17px 0 0; background: #25261a; color: #d1c39c;
  font-size: .9375rem; font-weight: 500; line-height: 1.35; letter-spacing: -.01em;
  text-transform: none; text-shadow: none; box-shadow: none;
}
.tab:hover { color: var(--text); background: #373421; border-color: #8c7649; text-shadow: none; transform: none; }
.tab.active { background: #625232; color: #f4e4b6; border-color: #a18750; font-weight: 500; text-shadow: none; box-shadow: none; }
.page-header .tabs { margin-bottom: 0; }
.registry-header > div:last-child { margin-top: 2px !important; flex-wrap: wrap; gap: 12px !important; }
.registry-header > div:last-child > div { max-width: 460px !important; }
#joker-search-input { padding-left: 16px !important; font-size: .9375rem; background-color: #12140d !important; }
#btn-new-jokers { min-width: 46px; min-height: 46px; }

/* Numbered index slips. Image crops and the movable drag clone keep their logic. */
.demonlist-container { gap: 12px; }
.demonlist-card {
  min-width: 0; min-height: 128px;
  background-color: var(--paper) !important;
  background-image: var(--grain), linear-gradient(110deg, #e0cca0, var(--paper)) !important;
  border-radius: 3px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18) !important;
}
.demonlist-card:hover { transform: translateY(-2px); border-color: #c9c99a !important; box-shadow: 0 10px 24px rgba(0, 0, 0, .28) !important; }
.demonlist-card:has(.drag-indicator:active) { transform: none; }
.card-rank {
  width: 76px !important; background: #343423 !important; border-right-color: #70623d !important;
  color: #e9dfb9 !important; font-family: var(--font); font-size: 2.15rem !important;
  font-weight: 700 !important; font-variant-numeric: tabular-nums; letter-spacing: -.06em; text-shadow: none !important;
}
.rank-gold { color: #f5d76e !important; border-right-color: #f5d76e !important; text-shadow: 0 0 10px rgba(245, 215, 110, 0.3) !important; }
.rank-silver { color: #d1d5d8 !important; border-right-color: #d1d5d8 !important; text-shadow: 0 0 10px rgba(209, 213, 216, 0.3) !important; }
.rank-bronze { color: #cd7f32 !important; border-right-color: #cd7f32 !important; text-shadow: 0 0 10px rgba(205, 127, 50, 0.3) !important; }
.card-photo { width: 115px !important; height: 115px !important; margin: 12px 0 12px 14px; align-self: center; border: 5px solid #e2d8b7; border-radius: 1px; background: #b4ad88 !important; transform: rotate(-1.7deg); box-shadow: 0 2px 3px rgba(35, 37, 23, .2); }
.photo-empty { display: flex; flex-direction: column; align-items: center; gap: 7px; font-family: var(--font-mono); color: #374028; font-size: .75rem; line-height: 1.2; }
.photo-empty strong { font-family: var(--font-display); font-size: 1.65rem; letter-spacing: -.07em; font-weight: 400; }
.card-photo > div { font-size: .75rem !important; border-radius: 1px !important; padding: 2px 5px !important; }
.card-info { min-width: 0; padding: 18px 24px !important; overflow-wrap: anywhere; }
.card-register-id { margin-bottom: 6px; color: var(--ink-faint); font-family: var(--font-mono); font-size: .75rem; letter-spacing: .07em; line-height: 1.4; text-transform: uppercase; }
.card-name { font-family: var(--font) !important; font-size: 1.5rem !important; font-weight: 700 !important; line-height: 1.25; letter-spacing: -.025em; }
.card-description { margin-top: 7px !important; font-size: .875rem !important; line-height: 1.6; }
.drag-indicator { width: 44px !important; min-width: 44px; align-self: stretch; flex-shrink: 0; color: #64694b !important; border-left: 1px dashed #a19e7b !important; background: rgba(0, 0, 0, 0.06) !important; touch-action: none; }
.drag-indicator:hover { color: #2f3d23 !important; background: rgba(64, 76, 38, .08) !important; }
.demonlist-card > div:has(> .btn-add-to-top) { width: 112px !important; flex-shrink: 0; border-left: 1px dashed #a19e7b !important; background: rgba(0, 0, 0, 0.06) !important; }
.btn-add-to-top { color: var(--ink) !important; background: transparent !important; min-width: 72px; width: 100%; height: 100%; }
.btn-add-to-top:hover { background: rgba(64, 76, 38, .09) !important; }
.demonlist-card.drag-over { border-top: 3px solid #747a41 !important; }

/* Dossiers contain a photograph and a separate, readable record sheet. */
.joker-detail-header { gap: 32px; align-items: flex-start; }
#detail-body > .flex { width: 100%; min-width: 0; }
#detail-body .skeleton { max-width: 100%; }
.joker-detail-header > div:first-child { min-width: 0; max-width: 100%; }
.joker-detail-cover { border: 8px solid #d3c8a1; border-radius: 1px; box-shadow: 0 10px 24px rgba(0, 0, 0, .28); }
.joker-detail-info { min-width: 0; padding: 28px 32px 36px; overflow-wrap: anywhere; }
.joker-detail-info h2 { margin-top: 24px; font-family: var(--font); font-size: 2.25rem !important; font-weight: 700; line-height: 1.2; }
.joker-detail-info p { font-size: 1rem !important; line-height: 1.9 !important; }
#detail-body a.card, #section-links a { overflow-wrap: anywhere; }
.joker-card { box-shadow: var(--shadow-sm); }
.joker-card:hover { box-shadow: var(--shadow-md); }
.joker-card-name { font-family: var(--font); font-size: 1.3rem; font-weight: 700; }
.joker-card-desc { font-size: .875rem; line-height: 1.65; }
.photo-grid { gap: 12px; }
.photo-item { border-radius: 2px; border: 4px solid #c1b68e; background: var(--surface); }
.photo-item:focus-within .photo-item-actions { opacity: 1; }
.edit-photo-item { padding: 12px !important; }
.edit-photo-item .btn { min-height: 36px; font-size: .875rem !important; white-space: normal; }
.edit-photo-item > div { font-size: .8125rem !important; }
.upload-zone { border-width: 1px; border-color: var(--border-light); background: rgba(198, 177, 108, .025); }
.upload-zone:hover { background: var(--accent-dim); }
.perm-item { min-height: 44px; padding: 12px; }
.perm-item input[type='checkbox'] { width: 16px; height: 16px; flex-shrink: 0; }

/* Administrative tables read as ledger sheets, without changing table semantics. */
.table-wrap { background-color: var(--paper); background-image: var(--grain); border-color: #aca582; border-radius: 2px; box-shadow: 1px 2px 0 #7f8162, var(--shadow-md); }
table { font-size: .875rem; }
thead tr { background: #b5a47e; border-bottom-color: #8e805a; }
thead th { padding: 15px 18px; color: #343d26; font-family: var(--font-mono); font-size: .75rem; font-weight: 400; letter-spacing: .045em; }
tbody tr { border-bottom-color: #aba581; }
tbody tr:hover { background: #dfcca1; }
tbody td { padding: 17px 18px; color: var(--ink); }
tbody td[colspan] { padding-block: 36px; }
table .btn-icon { font-size: .875rem; white-space: nowrap; }
table .user-avatar { color: #3f4726 !important; border-color: #8a8d64; background: rgba(58, 70, 29, .09) !important; font-size: .875rem !important; }
.badge { border-radius: 2px; padding: 4px 9px; font-family: var(--font-mono); font-size: .8125rem; font-weight: 400; line-height: 1.45; white-space: nowrap; }
.badge-new { border-radius: 2px; background: var(--crimson); color: #fff1d8; font-family: var(--font-mono); font-size: .75rem; font-weight: 500; box-shadow: none; }
.role-badge-owner { background: var(--accent-dim); border: 1px solid var(--accent-alt); color: var(--accent); }
.role-badge-admin { border: 1px solid currentColor; }
.badge-success, .badge-error { border: 1px solid currentColor; }
.page-btn { width: 40px; height: 40px; }
.page-btn.active { color: var(--bg); }
.empty-state { padding: 42px 24px; border: 1px dashed var(--border-light); border-radius: 3px; background: rgba(45, 50, 31, .35); }
.empty-state-icon:empty { display: none; }
.empty-state p { font-size: 1rem !important; }

/* Feedback remains quiet and above the scene. */
.modal-overlay { z-index: 1500; background: rgba(8, 11, 7, .78); backdrop-filter: blur(6px); }
.modal { border-color: var(--border-light); border-top: 2px solid var(--accent); box-shadow: var(--shadow-lg); max-height: calc(100svh - 48px); }
.modal-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 400; line-height: 1.3; }
.modal-header { padding: 22px 28px; }
.modal-body { padding: 26px 28px; }
.modal-footer { padding: 0 28px 26px; flex-wrap: wrap; }
.toast { border-radius: 4px; background: #2e3225; font-weight: 400; line-height: 1.5; }
.alert { line-height: 1.65; }
.alert-success { border-color: rgba(183, 197, 147, .25); }
.alert-error { border-color: rgba(226, 160, 142, .3); }
.loader-logo, .stat-value { background: none; -webkit-text-fill-color: currentColor; color: var(--accent); font-family: var(--font-display); font-weight: 400; font-variant-numeric: tabular-nums; }
.loader-logo { font-size: 3rem; letter-spacing: -.07em; }
.stat-label { font-size: .875rem; }
.stat-value { font-family: var(--font); font-weight: 700; }
h1, h2, h3, h4, h5, h6, .page-title, .document-title, .auth-intro h1,
.registry-cover h1, .card-name, .joker-card-name, .joker-detail-info h2,
.modal-title, .nav-logo-text, .cover-monogram, .bureau-mark, .loader-logo,
.photo-empty strong {
  font-family: var(--font-display);
  font-weight: 400 !important;
  font-style: normal;
  letter-spacing: .015em !important;
}
.document-title em, .auth-intro h1 em { font-style: normal; }
.registry-cover h1, .auth-intro h1 { line-height: 1.08; }
.glow-accent, .glow-alt { box-shadow: var(--shadow-sm); }
@keyframes bureau-enter { from { opacity: 0; } to { opacity: 1; } }
.page-enter, .joker-card { animation: bureau-enter 240ms ease; }
.skeleton { animation-duration: 2s; }

@media (max-width: 900px) {
  .joker-detail-cover { width: 240px !important; height: 240px !important; }
  .card-rank { width: 62px !important; font-size: 1.8rem !important; }
  .card-info { padding: 16px 18px !important; }
  .home-page { padding-top: 142px; }
  .home-desk { grid-template-columns: minmax(0, 1fr); max-width: 620px; margin-inline: auto; padding: 0 8px; gap: 22px; }
  .registry-cover { min-height: 0; }
  .summary-sheet { margin-left: 26px; margin-right: 6px; min-height: 0; transform: rotate(1deg); }
  .summary-sheet .document-title { font-size: 2rem; }
  .summary-sheet .document-title br { display: none; }
  .stats-container { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
  .stat-item { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .stat-number { order: 1; }
  .stat-caption { order: 2; }
  .auth-card { grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: 36px; }
  .auth-intro h1 { font-size: clamp(2.5rem, 5.8vw, 3.6rem); }
  .auth-intro-footer { gap: 14px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  :root { --lamp-size: 155px; --lamp-top: -56px; }
  .page-header { position: relative; top: auto; }
  .page-header.registry-header { padding-top: 96px; }
  .registry-heading { min-height: 0; padding-right: 0; }
  .page-header > div:has(> .page-title) { flex-wrap: wrap; }
  .registry-header > div:last-child > div { max-width: none !important; }
  .tab { padding-inline: 16px; }
  .joker-detail-header > div:first-child { width: 100%; align-items: flex-start !important; }
  .joker-detail-cover { width: min(300px, 100%) !important; height: auto !important; aspect-ratio: 1; }
  .joker-detail-info { flex-basis: 100%; padding: 24px; }
  .jokers-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
  #add-link-form, .form-group > .flex:has(#create-link-url) { flex-wrap: wrap; }
  #add-link-form .form-input, .form-group .flex > #create-link-url, #create-link-label { flex-basis: 100% !important; }
  .card-photo { width: 84px !important; height: 84px !important; margin-left: 12px; }
  .card-name { font-size: 1.25rem !important; }
  .demonlist-card > div:has(> .btn-add-to-top) { width: 84px !important; }
  .auth-page { padding-top: 144px; padding-bottom: 44px; }
  .auth-card { grid-template-columns: minmax(0, 1fr); max-width: 430px; gap: 36px; }
  .auth-intro h1 { font-size: clamp(2.65rem, 8vw, 3.8rem); line-height: 1.05; }
  .auth-intro h1 br { display: none; }
  .auth-intro h1 em { display: block; }
  .auth-intro > .document-kicker { margin-bottom: 18px; }
  .auth-intro-footer { display: none; }
  #login-form { transform: none; }
  .home-page { padding-top: 92px; }
  .desk-context { margin-bottom: 34px; }
  .desk-context > span:last-child { display: none; }
  .registry-cover { padding: 28px 28px 24px 38px; }
  .registry-cover h1 { font-size: clamp(2.3rem, 10vw, 4.5rem); }
  .cover-topline { font-size: .75rem; }
  .cover-colophon { margin-top: 30px; }
  .summary-sheet { margin-left: 10px; padding: 26px; }
  .page-body { padding-top: 20px; }
  .nav-logo::after { display: none; }
}
@media (max-width: 520px) {
  .nav-container { padding-inline: 16px !important; }
  .nav-left { gap: 8px !important; }
  .nav-right { gap: 4px !important; }
  .dropdown-toggle { padding-inline: 8px; }
  .user-name { max-width: 72px !important; }
  .page-header { padding: 24px 0 18px; }
  .page-body { padding-bottom: 40px; }
  .card { padding: 20px; }
  .registry-header .tabs { width: 100%; }
  .top-tab { flex: 1; padding-inline: 10px; font-size: .875rem; }
  .demonlist-card { flex-wrap: wrap; min-height: 124px; }
  .card-rank { width: 42px !important; font-size: 1.35rem !important; }
  .card-photo { width: 60px !important; height: 76px !important; margin-left: 9px; border-width: 3px; }
  .photo-empty { gap: 5px; font-size: .75rem; text-align: center; }
  .photo-empty strong { font-size: 1.15rem; }
  .card-info { padding: 13px 11px !important; }
  .card-register-id { font-size: .75rem; letter-spacing: 0; }
  .card-name { font-size: 1.1875rem !important; }
  .card-description { font-size: .875rem !important; }
  .drag-indicator { width: 32px !important; min-width: 32px; }
  .demonlist-card > div:has(> .btn-add-to-top) { width: 100% !important; flex-basis: 100%; border-left: 0 !important; border-top: 1px dashed #a19e7b; }
  .btn-add-to-top { min-height: 42px; }
  .home-desk { padding-right: 4px; padding-left: 0; }
  .cover-open { min-width: 0; width: 100%; }
  .cover-colophon { font-size: .75rem; }
  .summary-sheet { padding: 24px; margin-right: 0; transform: none; }
  .stat-number { font-size: 2.8rem; }
  .document-footer { gap: 10px; flex-wrap: wrap; }
  #login-form { padding: 26px; }
  .modal-overlay { padding: 12px; }
  .modal { max-height: calc(100svh - 24px); }
  .modal-header { padding: 18px 20px; }
  .modal-body { padding: 20px; }
  .modal-footer { padding: 0 20px 20px; }
  .toast-container { bottom: 16px; }
  .toast { min-width: 0; max-width: 100%; }
}
@media (max-width: 380px) {
  .user-chip .user-info { display: none !important; }
  .user-chip { padding: 4px !important; }
  .registry-cover { padding-left: 30px; padding-right: 22px; }
  .registry-cover h1 { font-size: 2.2rem; }
  #login-form { padding: 22px; }
  .card-rank { width: 36px !important; }
  .card-photo { width: 52px !important; }
  .card-info { padding-inline: 9px !important; }
}
@media (hover: none) {
  .photo-item-actions { opacity: 1; inset: auto 0 0; min-height: 40px; padding: 4px; }
  .demonlist-card:hover, .joker-card:hover { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .room-voltage { display: none; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .btn, .tab, .card, .paper-sheet, .registry-cover, .demonlist-card, .badge { border: 1px solid ButtonText !important; }
  .tab.active, .page-btn.active { outline: 2px solid Highlight; outline-offset: -3px; }
  .room-light, .room-grain, .room-darkness, .room-voltage, .desk-lamp { display: none !important; }
}
