/* Cascade order: base rules, then the theme tokens, then the feature layers. */
@layer base, theme, feature;

@layer base {
/* A real 700 instance. The 400–700 file is a static Regular, so bold used to be
   synthesised; here the face is genuine and matches the reference's stroke. */
@font-face {
  font-family: 'Instrument Sans';
  src: url('/fonts/instrument-sans-700.woff2') format('woff2');
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* 400 is the family's floor; the 380 instance below it clamps to 400 and
   renders identically, so the plain variable file is enough. */
@font-face {
  font-family: 'Instrument Sans';
  src: url('/fonts/instrument-sans-latin.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Instrument Sans';
  src: url('/fonts/instrument-sans-latin-ext.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: dark;
  /* Every token is written as light-dark(); the site is dark today, so a
     light scheme only needs color-scheme flipped. */
  --background: light-dark(#000, #000);
  --panel: light-dark(#0f0f0f, #0f0f0f);
  --line: light-dark(#2a2a2a, #2a2a2a);
  --text: light-dark(#f4f4f4, #f4f4f4);
  --muted: light-dark(#a9a9a9, #a9a9a9);
  /* Steps between the muted label and the body text, so dim copy is not a
     fresh hex each time. */
  --muted-strong: light-dark(#c4c4c4, #c4c4c4);
  --muted-soft: light-dark(#b4b4b4, #b4b4b4);
  --font: 'Instrument Sans', 'Segoe UI', 'Malgun Gothic', sans-serif;
  --motion-ease: cubic-bezier(.32, .72, 0, 1);
  background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--background); font: 1rem/1.55 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; font-kerning: normal; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.045em; text-wrap: balance; }
html { text-size-adjust: 100%; scrollbar-color: var(--line) var(--background); }
h1, h2, h3, p, dd, li { word-break: keep-all; overflow-wrap: break-word; }
p, dd, li { text-wrap: pretty; }
::selection { color: var(--background); background: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
svg { width: 1.15em; height: 1.15em; flex: none; }
.icon-symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.noscript-note { margin: 0; padding: .7rem 1rem; background: #f1f1f1; color: #111; font-size: .85rem; text-align: center; }
/* A chip that drops clear of the topbar rather than a full-bleed banner. */
.skip-link:is(:focus, :focus-visible) { transform: translate(-50%, 0); outline-offset: 3px; }
.skip-link {
  position: fixed;
  top: .6rem;
  left: 50%;
  z-index: 5;
  padding: .5rem .95rem;
  border-radius: .6rem;
  background: #f1f1f1;
  color: #111;
  font-size: .83rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 .5rem 1.6rem #000c;
  transform: translate(-50%, calc(-100% - .6rem));
  transition: transform .2s var(--motion-ease);
}
/* The skip target takes focus so the next Tab continues inside it. A soft left
   rule marks where the reader has landed without boxing the whole page. */
main[tabindex='-1'] { outline: none; }
main[tabindex='-1']:focus-visible { outline: none; box-shadow: inset 3px 0 0 #8f8f8f; }
/* The home-style layout is a centred card, so an edge rule would float away
   from the text; a soft ring around the card reads better there. */
.home main[tabindex='-1']:focus-visible { box-shadow: 0 0 0 2px #6f6f6f; border-radius: 1.25rem; }
:focus-visible { outline: 2px solid #d8d8d8; outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.skeleton { display: block; border-radius: .45rem; background: var(--skeleton-color, #2b2b2b); }
.skeleton-label { width: min(100%, 6rem); height: .85rem; margin-block: .27rem; }
.skeleton-help { width: min(100%, 8rem); height: .65rem; margin-block: .28rem; }
.skeleton-title { width: min(80%, 12rem); height: 1.1rem; margin-block: .28rem; }
.skeleton-line { width: min(90%, 15rem); height: .72rem; margin-block: .2rem; }
.skeleton-control, .skeleton-button { height: 2.65rem; border-radius: .7rem; }
.skeleton-button { width: 7.5rem; }
.skeleton-square { flex: none; width: 2.5rem; height: 2.5rem; border-radius: .75rem; }
.skeleton-circle { flex: none; width: 2.05rem; height: 2.05rem; border-radius: 50%; }
.skeleton-textarea { height: 7.45rem; border-radius: .7rem; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 2.65rem;
  padding: .55rem .95rem;
  border: 1px solid transparent;
  border-radius: .85rem;
  background: transparent;
  font-size: .88rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .2s var(--motion-ease);
}

.button:active:not(:disabled) { transform: scale(.97); }
.button svg { transition: transform .22s var(--motion-ease); }
.button:is(:hover, :focus-visible):not(:disabled) svg { transform: translateY(-1px); }

.glass {
  position: relative;
  isolation: isolate;
  border: 1px solid #ffffff1f;
  background:
    radial-gradient(120% 98% at 18% -40%, #ffffff24, transparent 90%),
    linear-gradient(176deg, #ffffff0a, transparent 48%, #00000024),
    var(--glass-fill, #ffffff0d);
  backdrop-filter: blur(18px);
  box-shadow: inset 0 1px 2px #ffffff14, inset 0 -3px 7px #ffffff08;
}

@supports (mask-composite: exclude) {
  .glass::before {
    content: '';
    position: absolute;
    inset: -1px;
    padding: 1px;
    border-radius: inherit;
    background: conic-gradient(from 26deg, #ffffff0b, #ffffff39 32%, #ffffff5c 48%, #ffffff08 68%, #ffffff66 87%, #ffffff0b);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    pointer-events: none;
  }
}

.glass.button:is(:hover, :focus-visible) {
  border-color: #ffffff40;
  box-shadow: inset 0 1px 2px #ffffff28, inset 0 -3px 7px #ffffff12;
}

.login-button { --glass-fill: #ffffff20; }
.outline-button { background: #ffffff06; border-color: #4f4f4f; }
.outline-button:is(:hover, :focus-visible), .account-link:is(:hover, :focus-visible) { border-color: #606060; background: #ffffff12; }
.text-button { color: var(--muted); }
.text-button:is(:hover, :focus-visible) { color: var(--text); background: #ffffff0d; }
.primary-button { background: #f1f1f1; color: #111; border-color: #f1f1f1; box-shadow: 0 2px 10px #0009; }
.primary-button:focus-visible { outline-color: #8a8a8a; }
.primary-button:is(:hover, :focus-visible) { background: #d9d9d9; }

.home {
  position: relative;
  /* A faint sky gradient under the canvas, so the page still has depth if the
     script never runs and the canvas stays blank. */
  background: radial-gradient(58% 48% at 50% 44%, #101016 0%, #000 78%);
  grid-template-rows: 1fr auto;
  display: grid;
  min-height: 100svh;
  place-items: stretch;
}

.home-sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mask-image: radial-gradient(ellipse 53% 44% at 50% 49%, #00000030, #000 83%);
}

.home-content {
  align-self: center;
  justify-self: center;
  position: relative;
  z-index: 1;
  width: min(94%, 45rem);
  margin-top: -6vh;
  padding: 2rem 0 1.5rem;
  text-align: center;
}

.logo-slot { display: block; width: clamp(3rem, 7.5vh, 4.25rem); height: auto; margin: 0 auto 1.15rem; border-radius: 1.05rem; box-shadow: 0 1.2rem 2.6rem #0009; }
.home h1 {
  word-break: normal;
  font-size: clamp(2.55rem, 7.4vw, 5.5rem);
  letter-spacing: -.04em;
  font-weight: 570;
  line-height: 1.04;
}
.home-lede { max-width: 27ch; margin: 1.05rem auto 0; color: var(--muted); font-size: clamp(.95rem, 2.2vw, 1.06rem); text-wrap: pretty; }

.home-actions { display: flex; justify-content: center; gap: .7rem; margin: 1.7rem auto 0; }
.home-actions .button { min-width: 8.75rem; min-height: 3.3rem; border-radius: 4rem; font-size: .95rem; }
.home-actions .depth-icon { width: 1.22rem; height: 1.22rem; }
.home-discord-link { display: inline-flex; align-items: center; gap: .46rem; min-height: 2.75rem; margin-top: .72rem; padding: 0 .45rem; border-radius: .5rem; color: var(--muted); font-size: .87rem; transition: color .18s ease; }
.home-discord-link:is(:hover, :focus-visible) { color: var(--text); }
.skeleton-login { width: 8.75rem; height: 3.3rem; border-radius: 4rem; }
/* The login link starts as a skeleton until JS decides; without JS it stays a
   real link, so it must look like one from the first paint. */
.home-actions [data-skeleton] { visibility: hidden; }
.no-js .home-actions [data-skeleton] { visibility: visible; }
.no-js .home-actions .skeleton-login { display: none; }
.home-status { max-width: 34ch; margin: 1.15rem auto 0; color: var(--muted); font-size: 1.02rem; }
.home-status:empty { display: none; }
.status-code { display: block; margin: 0 0 .35rem; color: #7d7d7d; font: 600 .95rem/1 var(--font); font-variant-numeric: tabular-nums; letter-spacing: .16em; }
.status-code + h1 { font-size: clamp(2.15rem, 6vw, 3.9rem); letter-spacing: -.05em; }

@media (max-height: 760px) {
  .home-content { margin-top: 0; padding-block: 2.5rem 1rem; }
}

@media (max-width: 340px) {
  .home h1 { font-size: clamp(1.85rem, 12.4vw, 2.55rem); letter-spacing: -.03em; }
}

@media (max-height: 520px) {
  .home-content { padding-block: 1.25rem .5rem; }
  .logo-slot { width: 2.5rem; margin-bottom: .7rem; border-radius: .75rem; }
  .home h1 { font-size: clamp(2rem, 6vw, 3rem); }
  .home-lede { margin-top: .6rem; font-size: .95rem; }
  .home-actions { margin-top: 1rem; }
  .home-actions .button { min-height: 2.8rem; }
  .home-discord-link { margin-top: .1rem; min-height: 2.2rem; }
  .home-footer { padding-block: .7rem; }
}

.home-footer {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .35rem 1.1rem;
  padding: 1.4rem 1rem 1.35rem;
  color: #8f8f8f;
  font-size: .8rem;
}
@media (max-width: 420px) {
  .home-footer { gap: .3rem .8rem; font-size: .74rem; }
  .home-footer span { flex-basis: 100%; text-align: center; }
}
.home-footer a { padding: .2rem .1rem; border-radius: .3rem; transition: color .18s ease; }
.home-footer a:is(:hover, :focus-visible) { color: var(--text); }

.dashboard { min-height: 100svh; }
.welcome-confetti { position: fixed; z-index: 3; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.topbar { border-bottom: 1px solid #1e1e1e; }
.topbar-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  min-height: 5.1rem;
  width: min(100% - 3rem, 78rem);
  gap: 1rem;
  margin: auto;
}

.wordmark { width: fit-content; font-size: 1.22rem; font-weight: 650; letter-spacing: -.045em; }
.topnav {
  position: relative;
  display: grid;
  /* One track per tab, so the track width and the step line up. */
  grid-template-columns: repeat(var(--nav-count, 4), 1fr);
  align-items: center;
  gap: .25rem;
  padding: .3rem;
  border-radius: 2rem;
}
.topnav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .52rem .9rem;
  border: 1px solid transparent;
  border-radius: 2rem;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color .18s ease;
}

/* Track width and step both follow --nav-count, so a page only says how many
   tabs it has and which index is lit; neither is enumerated per tab. */
.topnav {
  /* Everything is sized from the count: track width and one step. */
  --nav-count: 4;
  --nav-step: calc(100% / var(--nav-count, 4));
  --nav-offset: calc(.3rem + var(--nav-index, 0) * var(--nav-step));
}
/* The community page has two tabs; its body class is what says so. */
.dashboard.community .topnav { --nav-count: 2; }
.topnav:has(#nav-custom[aria-current='page']) { --nav-index: 0; }
.topnav:is(:has(#nav-profile[aria-current='page']), :has(#nav-community[aria-current='page'])) {
  --nav-index: 1;
}
.topnav:has(#nav-rankings[aria-current='page']) { --nav-index: 2; }
/* The console page's third tab is the Discord invite. */
.topnav:has(#nav-discord[aria-current='page']) { --nav-index: 2; }

.topnav a[aria-current='page'] { border-color: #ffffff24; background: #ffffff14; color: var(--text); }
.topnav a:is(:hover, :focus-visible) { color: var(--text); }
/* A tab that needs a session is dimmed and marked, so it does not read as
   available and then open onto a login panel. */
.topnav a[data-locked] { color: #909090; }
.topnav a[data-locked] .depth-icon { opacity: .55; filter: none; }
/* The dot reads as "needs a session" without widening the tab. */
.topnav a[data-locked]::after {
  content: '';
  flex: none;
  width: .3rem;
  height: .3rem;
  margin-left: .1rem;
  border-radius: 50%;
  border: 1px solid #a8a8a8;
}
.nav-indicator { display: none; }

}

@layer feature {
@supports selector(:has(*)) {
  .nav-indicator {
    position: absolute;
    display: block;
    inset: .3rem auto .3rem 0;
    width: calc((100% - .6rem) / var(--nav-count, 4));
    max-width: 12rem;
    border: 1px solid #ffffff28;
    border-radius: 2rem;
    background: linear-gradient(180deg, #ffffff13, #ffffff08);
    box-shadow: inset 0 1px 1px #ffffff13;
    pointer-events: none;
    opacity: 0;
    left: var(--nav-offset);
    transform: none;
    transition: transform .2s ease, opacity .15s ease;
  }

  .topnav:has(a[aria-current='page']) .nav-indicator { opacity: 1; }
  .topnav a[aria-current='page'] { border-color: transparent; background: transparent; box-shadow: none; }

  /* Pointer and keyboard preview the tab before it is entered. */
  .topnav:has(a:hover) .nav-indicator { opacity: .55; }
  .topnav:has(#nav-custom:is(:hover, :focus-visible)) { --nav-index: 0; }
  .topnav:is(:has(#nav-profile:is(:hover, :focus-visible)), :has(#nav-community:is(:hover, :focus-visible))) {
    --nav-index: 1;
  }
  .topnav:is(:has(#nav-rankings:is(:hover, :focus-visible)), :has(#nav-discord:is(:hover, :focus-visible))) {
    --nav-index: 2;
  }
  .topnav:has(#nav-discord:is(:hover, :focus-visible)) { --nav-index: 2; }
}

.account-link { max-width: 100%; color: var(--text); justify-self: end; min-width: 0; border-radius: 2rem; padding-right: .55rem; }
.account-link span { max-width: 10rem; }
.account-link span { overflow: hidden; text-overflow: ellipsis; }
.skeleton-account { width: min(100%, 5.5rem); height: .85rem; margin-right: .95rem; justify-self: end; }

.workspace { width: min(100% - 3rem, 78rem); margin: 0 auto; padding: 3.7rem 0 4rem; }
.page-intro { margin-bottom: 2rem; }
.page-intro h1 { font-size: clamp(2.25rem, 5.5vw, 4.45rem); font-weight: 590; letter-spacing: -.05em; }
.page-intro p { margin-top: .7rem; color: var(--muted); }
.intro-title { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.premium-label {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid #3a3a3a;
  border-radius: 2rem;
  padding: .23rem .68rem;
  color: #d7d7d7;
  background: #161616;
  font-size: .8rem;
  font-weight: 550;
}

.editor-layout { display: grid; grid-template-columns: minmax(17rem, .85fr) minmax(0, 1.55fr); gap: 1.3rem; align-items: start; }
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: var(--panel);
}

.preview-panel { display: flex; flex-direction: column; min-height: 0; }
.preview-panel .simulation { min-height: 0; }
.panel-heading { padding: 1.33rem 1.4rem 1.07rem; }
.panel-heading h2, .admin-card h2 { font-size: 1.06rem; font-weight: 650; }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding-top: .94rem; padding-bottom: .85rem; }
.replay-button { min-height: 2.35rem; padding: .4rem .7rem; }

.access-panel, .profile-empty {
  display: grid;
  min-height: 20.5rem;
  justify-items: center;
  align-content: center;
  gap: .85rem;
  padding: 1.4rem;
  text-align: center;
}

.access-panel { margin: 0 1.15rem 1.15rem; border: 1px solid #232323; border-radius: .95rem; background: #121212; }
.access-panel h3 { font-size: 1.06rem; }
.access-panel p, .profile-empty p { max-width: 26ch; color: var(--muted); font-size: 1.02rem; }
.access-panel .button, .profile-empty .button { margin-top: .35rem; }
.access-icon {
  display: inline-grid;
  flex: none;
  place-items: center;
  border: 1px solid #514c5b;
  background: linear-gradient(145deg, #333039, #201e24 55%, #17161a);
  box-shadow: inset 0 1px 0 #eae3ff22, inset 0 -1px 0 #0009, 0 2px 0 #121014, 0 4px 9px #0006;
  width: 3.3rem;
  height: 3.3rem;
  border-radius: .95rem;
}
.access-icon .depth-icon { width: 1.65rem; height: 1.65rem; }

.depth-icon {
  width: 1.2em;
  height: 1.2em;
  overflow: visible;
  color: #f3f0f8;
  filter: drop-shadow(.35px .85px 0 #938a9e) drop-shadow(.4px 1px 0 #514858) drop-shadow(0 2px 2px #0008);
#save-settings[aria-busy='true'] { background: #cfcfcf; color: #3a3a3a; cursor: progress; }
}

.topnav a:not([aria-current='page']):not(:hover):not(:focus-visible) .depth-icon { color: #c9c2d2; }

.fields { display: grid; min-inline-size: 0; margin: 0; border: 0; padding: .12rem 1.4rem 1.15rem; gap: 1rem; }
.field { display: grid; gap: .42rem; min-width: 0; }
.field label, .field > span { color: #e5e5e5; font-size: 1.02rem; font-weight: 600; }
.field input, .field textarea {
  width: 100%;
  min-height: 2.65rem;
  border: 1px solid #565656;
  border-radius: .7rem;
  background: #141414;
  color: var(--text);
  padding: .55rem .75rem;
}
.field input::placeholder, .field textarea::placeholder { color: #8b8b8b; }
.field input[aria-invalid='true'], .field textarea[aria-invalid='true'] { border-color: #c88a80; }
.field textarea { resize: vertical; min-height: 6rem; }
/* Formatting tools sit on the field's top edge, quiet until hovered or focused. */
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .12rem; }
.toolbar-button {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: .5rem;
  background: transparent;
  color: #a9a9a9;
}
.toolbar-button svg { width: 1rem; height: 1rem; }
.toolbar-button .depth-icon { filter: none; }
.toolbar-button:is(:hover, :focus-visible) { color: var(--text); border-color: #3a3a3a; background: #1c1c1c; }
.field:has(.editor-toolbar) { gap: .3rem; }
.field small, .form-status { color: var(--muted); font-size: .8rem; }
.form-status[data-error] { color: #e7a49b; }
.field small { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; }
.field small::first-line { flex: 1; }
.char-count { color: #8f8f8f; font-variant-numeric: tabular-nums; white-space: nowrap; }
.char-count.is-near { color: #d8c59a; }
.char-count.is-full { color: #f0b0a8; }
.input-with-icon { position: relative; }
.input-with-icon svg { position: absolute; left: .75rem; top: .78rem; color: #9d9d9d; pointer-events: none; }
.input-with-icon input { padding-left: 2.3rem; }
.upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
/* The panel is a column so the action bar can stay put beneath the fields
   instead of being pushed under the fold by the page header. */
.editor-panel { display: flex; flex-direction: column; }
#settings-form { display: flex; flex-direction: column; }
/* On a desktop viewport the editor fills the space under the header, so the
   fields scroll inside their panel and the action bar never leaves the fold. */
@media (min-width: 861px) and (min-height: 400px) {
  /* Pin the editor to the viewport so the fold always contains the action bar.
     The view fills from its own top to the bottom of the window. */
  #custom-view { display: flex; flex-direction: column; }
  #custom-view .page-intro { flex: none; }
  .editor-layout { flex: 1; min-height: 0; align-items: stretch; grid-template-rows: minmax(0, 1fr); max-height: min(calc(100svh - var(--editor-top, 14rem) + 2.5rem), 56rem); }
  .editor-panel { min-height: 0; }
  .editor-panel #settings-form { flex: 1; min-height: 0; }
  .editor-panel .fields { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; align-content: start; }
  .editor-panel #editor-skeleton { flex: 1; min-height: 0; overflow-y: auto; }
}

/* On a short desktop window every vertical pixel competes, so the header block
   tightens and the preview shares the space instead of holding a rigid height. */
@media (min-width: 861px) and (max-height: 700px) {
  #custom-view .page-intro { margin-bottom: .85rem; }
  #custom-view .page-intro h1 { font-size: 2rem; }
  #custom-view .page-intro p { margin-top: .3rem; font-size: .88rem; }
  /* The preview needs the height more than the intro does. */
  #custom-view .page-intro { margin-bottom: .5rem; }
  .editor-layout { gap: .85rem; }
  .preview-panel { display: flex; flex-direction: column; min-height: 0; }
  .preview-panel .simulation { flex: 1; min-height: 12rem; height: auto; }
  .preview-panel .preview-feedback { margin-top: .5rem; }
}

/* Under ~520px of window height the preview drops to a compact sliver so the
   whole editor still sits in one screen. */
@media (min-width: 861px) and (max-height: 520px) {
  #custom-view .page-intro h1 { font-size: 1.6rem; }
  #custom-view .page-intro p { display: none; }
  #custom-view .page-intro { margin-bottom: .6rem; }
  .preview-panel .simulation { min-height: 9rem; }
  .preview-panel .preview-feedback { display: none; }
  .preview-panel .panel-heading { padding-block: .7rem; }
}
#settings-form[hidden] { display: none; }
.form-footer { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; margin-top: auto; padding: 1rem 1.4rem; border-top: 1px solid var(--line); }
.form-footer .form-status { margin-right: auto; }
#save-settings { position: relative; }
/* The save action keeps its weight but only raises its voice when there is
   something to save. */
#save-settings[data-idle]:not([aria-busy='true']) { background: #dcdcdc; border-color: #dcdcdc; color: #333; box-shadow: none; }
#discard-settings { margin-right: -.25rem; }
#save-settings[aria-busy='true']::after {
  content: '';
  position: absolute;
  inset: auto .65rem .28rem;
  height: 2px;
  border-radius: 1rem;
  background: #565656;
  pointer-events: none;
}

.simulation {
  display: grid;
  /* The chat owns the room, as Discord gives it; the channel list only needs
     enough for a truncated name. */
  grid-template-columns: 3.2rem minmax(4.5rem, .52fr) minmax(0, 3fr);
  /* Bound the row so the chat column can scroll instead of growing past the frame. */
  grid-template-rows: minmax(0, 1fr);
  /* Fill the panel so the whole invite card fits, with a floor for short windows. */
  flex: 1 1 auto;
  min-height: 27rem;
  margin: 0 1.05rem;
  border: 1px solid #363636;
  border-radius: .85rem;
  overflow: hidden;
  background: #1a1a1a;
}

.bot-avatar img {
  width: 100%;
  height: 100%;
  /* Discord avatars are square; cover fills the circle with no dark ring. */
  object-fit: cover;
  object-position: center;
}

.sim-rail { background: #131313; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: .65rem; padding-top: .7rem; }
.server-icon, .rail-decoration, .bot-avatar, .welcome-hash {
  display: grid;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  color: #dedede;
  border: 1px solid #434343;
  border-radius: .75rem;
  background: #303030;
  overflow: hidden;
}
.server-icon img { width: 100%; height: 100%; object-fit: cover; }
.small-server-icon { width: 2.65rem; height: 2.65rem; }
.rail-separator { width: 1.65rem; border-top: 1px solid #363636; }
.rail-decoration { background: #202020; color: #aaa; border-color: #303030; }
.sim-channels { background: #191919; min-width: 0; }
.sim-server, .sim-channel-title {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 3rem;
  gap: .5rem;
  padding: .65rem .75rem;
  border-bottom: 1px solid #363636;
  color: var(--text);
  font-weight: 650;
  font-size: .87rem;
}
.sim-server span, .sim-channel span, .sim-channel-title span, .sim-composer span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.channel-list { padding: .85rem .45rem; }
.channel-list p { margin: 0 0 .38rem .36rem; color: var(--muted); font-size: .72rem; font-weight: 600; }
.sim-channel { display: flex; align-items: center; gap: .3rem; min-width: 0; min-height: 1.95rem; padding: .23rem .32rem; color: var(--muted-soft); border: 1px solid transparent; border-radius: .38rem; font-size: .83rem; }
.sim-active { color: var(--text); background: #333; border-color: #ffffff12; }
.sim-chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; background: #2a241b; border-left: 1px solid var(--line); }
.sim-channel-title { background: #252525; }
.sim-channel-title svg { color: #b5b5b5; }
.sim-chat-content { overflow-y: auto; overscroll-behavior: contain; padding: 1rem .85rem .85rem; display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.sim-welcome { display: grid; gap: .35rem; margin-top: auto; padding-bottom: .9rem; border-bottom: 1px solid #3a3a3a; overflow-wrap: anywhere; }
.welcome-hash { margin-bottom: .2rem; border-radius: 50%; background: #303030; color: #dedede; border-color: #444; }
.sim-welcome strong { font-size: clamp(.91rem, 1.4vw, 1.17rem); line-height: 1.25; }
.sim-welcome small { font-size: .76rem; color: var(--muted-soft); }
.message-preview { display: flex; gap: .55rem; min-width: 0; }
.bot-avatar { width: 2.05rem; height: 2.05rem; border-radius: 50%; }
/* Grow into the bubble so the card can use the column; without this the
   card's 100% makes the block shrink-wrap to the message text. */
.message-content { flex: 1 1 auto; min-width: 0; }
.message-author { display: flex; align-items: center; gap: .35rem; font-size: .84rem; font-weight: 650; }
.message-author span { padding: .04rem .27rem; border-radius: .24rem; background: #424242; color: #f1f1f1; font-size: .6rem; }
/* The rendered message; also the block a p would have been. */
/* The chat body is a flex column, so a bubble shrinks to its content; stretch
   it to the column or the card cannot use the room. */
.message-preview { align-items: flex-start; align-self: stretch; }
/* Grow into the bubble so the card can use the column; without this the
   card's 100% makes the block shrink-wrap to the message text. */
.message-content { flex: 1 1 auto; min-width: 0; }
.message-content p, #preview-message { margin-top: .18rem; color: #dedede; font-size: .81rem; overflow-wrap: anywhere; }
.message-content p + p, .message-content blockquote + p, .message-content ul + p { margin-top: .5rem; }
.message-content strong { font-weight: 700; color: #f6f6f6; }
.message-content em { font-style: italic; }
.message-content u { text-decoration: underline; text-underline-offset: 2px; }
.message-content s { text-decoration: line-through; color: #a8a8a8; }
.message-content code { padding: .08rem .3rem; border-radius: .24rem; background: #111; font: .92em/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; }
.message-content blockquote { margin: .12rem 0; padding: .05rem 0 .05rem .65rem; border-left: .22rem solid #5c5c5c; border-radius: .1rem; color: #cfcfcf; }
.message-content ul { margin: .1rem 0; padding-left: 1.1rem; }
.message-content li { margin-top: .1rem; }
.message-content .md-mention, .message-content .md-channel { padding: .02rem .2rem; border-radius: .24rem; background: #3b3b5c; color: #cdd3ff; }
.message-content .md-channel { background: #2f3a44; color: #c7d6e2; }
/* The reference's file chip is a bare grey pill, no glyph or label. */
/* The reference's row: a rounded grey pill with a paperclip and the name. */
.message-file {
  display: block;
  /* The guild's own banner, cropped to a band; the tile hangs over its edge. */
  grid-row: 1;
  grid-column: 1 / -1;
  height: 88px;
  border-radius: .3rem .3rem 0 0;
  background: #141414 url(/images/invite-banner.png) center / 100% 100% no-repeat;
}
.message-file > * { display: none; }
/* The sliver Discord leaves between the file and the embed under it. */
/* Same cap as the card under it, so the two edges line up. */
.file-bar { display: none; }

.invite-embed {
  display: grid; container-type: inline-size;
  align-content: start;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: visible;
  /* Discord caps an embed's width; the bubble keeps the leftover room. */
  position: relative; z-index: 2;
  /* The banner now occupies the card top, so the card needs its own room
     instead of tucking under the message. */
  margin-top: .5rem; width: 100%; max-width: 23.4rem;
  border: 1px solid #313137;
  border-radius: .3rem;
  background: #242429;
  color: inherit; text-decoration: none;
}
/* A dimmed crop of the server art sits over the banner, as Discord shows it. */
/* The reference card has no banner band: the tile simply sits at the top. */
.invite-banner { display: none; }
.invite-art, .invite-body { grid-row: 2; }
/* Absolute: the tile overhangs the card edge without making the row taller. */
.invite-art {
  position: absolute; top: -33px; left: 12px; z-index: 3;
  width: 79px; height: 79px;
  border-radius: .55rem;
  background: #0d0d0f; overflow: hidden;
}
.invite-art img { width: 100%; height: 100%; object-fit: cover; }
/* Row rhythm copied from the reference: title, meta and est sit tight; the
   note and button each get their own gap. */
.invite-body { grid-area: 2 / 1; display: grid; gap: 0; padding: 0 .7rem 0 96px; min-width: 0; }
/* Narrow cards: the tile is fixed at 79px, so the text only clears that. */
@container (max-width: 300px) {
  /* 12px inset + 79px tile + 3px clearance. */
  .invite-body { padding-left: 94px; padding-right: .35rem; }
  .invite-name { font-size: 1rem; }
  .invite-meta, .invite-est, .invite-note { font-size: .92rem; }
  /* A 120px banner is half the card here; keep it low so the text leads. */
  .message-file { height: 76px; }
  /* The count pair cannot stay on one line this narrow. */
  .invite-meta { white-space: normal; flex-wrap: wrap; }
}
.invite-name { display: flex; align-items: center; gap: .3rem; min-width: 0; margin-top: 0; color: #f2f2f2; font-weight: 600; font-size: 1.18rem; line-height: 1.25; letter-spacing: -0.01em; white-space: nowrap; }
.invite-name .hash { color: #f2f2f2; }
.invite-name > .hash { flex: none; }
/* The name is the only flexible part; ellipsis beats breaking the row. */
.invite-name { overflow: hidden; }
.invite-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.invite-name { flex-wrap: nowrap; }
/* Badges are the reference's own pixels, so the shapes match exactly. */
/* Native pixel sizes so the cut assets are not resampled. */
.invite-medal { width: 24px; height: 24px; flex: none; font-style: normal; background: url(/images/invite-medal.png) center / 24px 24px no-repeat; }
.invite-team { width: 54px; height: 24px; flex: none; font-style: normal; background: url(/images/invite-team.png) center / 54px 24px no-repeat; }
.invite-meta { display: flex; align-items: center; gap: .34rem; min-width: 0; margin-top: 0; font-family: 'Card Test'; font-weight: 300; color: #888b8f; font-size: 1.1rem; line-height: 1.3; letter-spacing: -0.012em; white-space: nowrap; }
.invite-dot { width: 10px; height: 10px; border-radius: 50%; background: #3ba55d; }
.invite-sep { flex: none; width: 6px; height: 6px; border-radius: 50%; background: #8a8a90; }
@font-face { font-family: 'Card Test'; src: url('/fonts/inter300.woff2') format('woff2'); font-weight: 300; font-display: swap; }
.invite-est { font-family: 'Card Test'; font-weight: 300; letter-spacing: -0.012em; color: #888b8f; font-size: 1.02rem; line-height: 1.3; white-space: nowrap; margin-top: 3px; }
.invite-note { margin-top: 10px; font-family: 'Card Test'; font-weight: 300; letter-spacing: -0.012em; color: #888b8f; font-size: 1.02rem; line-height: 1.32; overflow-wrap: anywhere; }
.invite-action { margin: 16px 7px 18px 1px; padding: 12px .6rem; border-radius: .3rem; background: #008545; color: #fff; font-size: .8rem; font-weight: 400; text-align: center; line-height: 1.2; }
.message-content .md-time { padding: .02rem .2rem; border-radius: .24rem; background: #2a2a2a; color: #d8d8d8; }
/* Spoilers: hidden until clicked, with the toggle itself always legible. */
.md-spoiler { display: inline; }
.md-spoiler-toggle { padding: 0 .14rem; margin: 0; border: 0; border-radius: .2rem; background: #3a3a3a; color: #d4d4d4; font: inherit; font-size: .72em; line-height: 1.1; }
.md-spoiler-toggle[aria-expanded='true'] { color: #9a9a9a; background: #2b2b2b; }
.md-spoiler-body { margin-left: .1rem; padding: 0 .3rem; border-radius: .2rem; background: #3b3b3b; color: transparent; box-shadow: inset 0 0 0 1px #262626; }
.md-spoiler[data-open] .md-spoiler-body { background: #2b2b2b; color: inherit; box-shadow: none; }
.sim-composer { display: flex; align-items: center; gap: .45rem; min-width: 0; margin: 0 .83rem .85rem; padding: .48rem .5rem; border-radius: .48rem; background: #2c2c2c; color: #b8b8b8; font-size: .76rem; }
.preview-feedback { margin: .5rem 1.15rem 0; min-height: 1.4rem; color: var(--muted); font-size: .8rem; }

#preview-skeleton { --skeleton-color: #383838; }
.skeleton-channels { display: grid; gap: .55rem; padding-top: 1rem; }
.skeleton-channels .skeleton-label:nth-child(2) { width: min(75%, 4.1rem); }
#preview-skeleton .sim-welcome .skeleton-square { margin-bottom: .2rem; border-radius: 50%; }
.skeleton-message { flex: 1; min-width: 0; }
.skeleton-message .skeleton-label { width: min(40%, 3rem); }
#preview-skeleton .sim-composer { height: 2.15rem; background: var(--skeleton-color); }

.community-view { max-width: 44rem; margin-inline: auto; }
.community-card { overflow: hidden; }
.community-body { display: flex; align-items: center; gap: 1.1rem; padding: 1.5rem 1.55rem 1.15rem; }
.community-summary { min-width: 0; }
.community-summary h2 { font-size: 1.28rem; font-weight: 640; }
.community-summary p { margin-top: .32rem; color: var(--muted); font-size: .93rem; text-wrap: pretty; }
.community-tier { width: fit-content; margin: .2rem 1.55rem 0; padding: .24rem .72rem; border: 1px solid #414141; border-radius: 2rem; color: var(--muted); font-size: .8rem; font-weight: 550; }
.community-tier-premium { border-color: #6d6d6d; background: #1d1d1d; color: var(--text); }
.community-perks { display: grid; gap: .1rem; margin: 1.15rem 1.55rem 0; padding: 0; list-style: none; }
.community-perks li { display: flex; align-items: start; gap: .7rem; padding: .62rem .1rem; border-top: 1px solid #1f1f1f; color: #dcdcdc; font-size: 1.02rem; line-height: 1.45; }
.community-perks li:first-child { border-top: 0; }
.community-perks svg { margin-top: .16rem; width: 1.05rem; height: 1.05rem; color: #c9c2d2; }
.community-perks strong { font-weight: 620; }
.perk-state { margin-left: .4rem; padding: .04rem .4rem; border: 1px solid #333; border-radius: 999px; color: var(--muted); font-size: .68rem; font-weight: 550; white-space: nowrap; vertical-align: .05em; }
.community-perk-locked .perk-state { border-color: #3a3a3a; }
.community-perk-locked { color: var(--muted); }
.community-perk-locked svg { opacity: .55; }
.community-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; padding: 1.25rem 1.55rem 1.5rem; }
.community-actions .outline-button { margin-left: auto; }
.community-note { margin: -.55rem 1.55rem 1.5rem; color: var(--muted); font-size: .8rem; }
.skeleton-summary { flex: 1; display: grid; gap: .35rem; }
.skeleton-perk { display: block; height: 2rem; border-radius: .5rem; }
.skeleton-icon { flex: none; width: 3.3rem; height: 3.3rem; border-radius: .95rem; }
#community-skeleton .community-perks { margin-bottom: 1.5rem; }
.community-actions .button[hidden], .community-perks[hidden] { display: none; }

@media (max-width: 520px) {
  .community-body { align-items: start; gap: .85rem; padding: 1.2rem 1.2rem 1rem; }
  .community-summary h2 { font-size: 1.14rem; }
  .community-tier, .community-perks, .community-actions { margin-inline: 1.2rem; }
  .community-actions { padding-inline: 0; }
  .community-note { margin-inline: 1.2rem; }
}

.profile-view { max-width: 49rem; margin-inline: auto; }
.profile-empty p { max-width: 35ch; }
.identity-card { overflow: hidden; }
.identity-banner {
  height: 7.75rem;
  background: #252525;
}
.identity-body { position: relative; padding: 0 1.55rem 1.45rem; }
.profile-avatar { position: relative; display: grid; place-items: center; width: 5.55rem; height: 5.55rem; margin-top: -3.1rem; border: .36rem solid var(--panel); border-radius: 50%; background: #262626; overflow: hidden; }
.profile-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-initial { font-size: 2rem; font-weight: 600; color: #d6d6d6; text-transform: uppercase; }
.identity-name { margin: .8rem 0 .95rem; padding-right: 8rem; overflow-wrap: anywhere; }
.identity-name h2 { font-size: 1.8rem; }
.identity-name p { margin-top: .24rem; color: var(--muted); }
.user-id { padding: .72rem .85rem; border: 1px solid var(--line); border-radius: .75rem; background: #141414; overflow-wrap: anywhere; }
.user-id dt { margin-bottom: .15rem; color: var(--muted); font-size: .82rem; }
.user-id dd { font-variant-numeric: tabular-nums; }
.logout-button { position: absolute; top: 3.55rem; right: 1.55rem; }
#profile-feedback:empty { display: none; }
#profile-feedback { margin-top: .65rem; }
.admin-card { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; padding: 1.25rem 1.55rem; }
.admin-card p { min-height: 1.25em; margin-top: .17rem; font: 600 1.8rem/1.25 var(--font); font-variant-numeric: tabular-nums; }
p.admin-rank { flex-basis: 100%; margin-top: .3rem; color: var(--muted); font: 500 .82rem/1.3 var(--font); }
.admin-card .premium-card-copy { min-height: 0; margin-top: .2rem; color: var(--muted); font: 400 .9rem/1.5 var(--font); }
.admin-card button { margin-top: .5rem; }
.keys-list { display: grid; gap: .7rem; margin: .8rem 0 0; padding: 0; list-style: none; }
.keys-list li { display: grid; gap: .15rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: .6rem; }
.keys-detail { color: var(--muted); font-size: .82rem; }
.keys-key { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-size: .95rem; letter-spacing: .08em; user-select: all; }
.join-feedback { margin-bottom: 1rem; padding: .8rem 1rem; color: var(--text); font-size: 1.02rem; }
.identity-banner.skeleton { border-radius: 0; }
.profile-avatar.skeleton { background: var(--skeleton-color, #2b2b2b); }
.skeleton-name { display: grid; gap: .3rem; padding-top: .25rem; }
.skeleton-name .skeleton-title { height: 1.5rem; }
.skeleton-id { display: grid; gap: .15rem; }

.rankings-view { max-width: 62rem; margin-inline: auto; }
.rankings-results { overflow: clip; }
.rankings-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.rankings-table :is(th, td) { padding: .95rem 1rem; text-align: left; overflow-wrap: anywhere; }
.rankings-table thead { background: #151515; color: var(--muted); font-size: .82rem; }
.rankings-table thead th { border-bottom: 1px solid #313131; font-weight: 600; letter-spacing: .01em; }
.rankings-table thead th:first-child { width: 4.8rem; }
.rankings-table thead th:last-child { width: 35%; }
.rankings-table :is(th, td):last-child { text-align: right; white-space: nowrap; }
.rankings-table tbody tr { border-top: 1px solid var(--line); }
.rankings-table tbody th { font-weight: 550; }
.rankings-table tbody td { font-variant-numeric: tabular-nums; }
.rankings-table tbody td:first-child { color: var(--muted); }
.rankings-table tbody td:last-child { font-weight: 650; }
.ranking-current { background: #1b1b1b; }
.ranking-you { color: var(--muted); font-size: .8rem; font-weight: 400; white-space: nowrap; }
.ranking-account { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .65rem; }
.ranking-avatar { flex: none; width: 2.15rem; height: 2.15rem; border-radius: 50%; background: #363636; object-fit: cover; }
.ranking-avatar-unavailable { visibility: hidden; }
.ranking-who { min-width: 0; }
.ranking-name { min-width: 0; }
.ranking-discord-id { color: var(--muted); font-size: .8rem; font-weight: 400; font-variant-numeric: tabular-nums; }
.ranking-tier { padding: .07rem .48rem; border: 1px solid #414141; border-radius: 999px; color: var(--muted); font-size: .73rem; font-weight: 550; white-space: nowrap; }
.ranking-tier-premium { border-color: #777; background: #282828; color: var(--text); }
.rankings-empty { display: grid; justify-items: center; text-align: center; gap: .85rem; padding: 3rem 1rem; }
.rankings-empty p { color: var(--muted); }
#rankings-loading { display: grid; place-items: center; min-height: 8rem; padding: 1rem; color: var(--muted); }

@media (max-width: 940px) {
  .editor-layout { gap: .85rem; }
  /* The narrow two-column layout can overflow a laptop window; scroll inside it
     rather than moving the page under the fixed action bar. */
  /* The intro is pure orientation on a phone; shrink it so the fields — not the
     heading — own the screen. */
  #custom-view .page-intro { margin-bottom: .6rem; }
  #custom-view .page-intro h1 { font-size: 1.7rem; }
  #custom-view .page-intro p { margin-top: .25rem; font-size: .85rem; }
  #custom-view { max-height: calc(100svh - var(--editor-top, 12rem) - 1rem); }
  #custom-view > .editor-layout { overflow-y: auto; overscroll-behavior: contain; }
  .simulation { grid-template-columns: 2.8rem minmax(5.5rem, .85fr) minmax(0, 1.7fr); margin-inline: .72rem; }
  .sim-rail :is(.server-icon, .rail-decoration, .skeleton-square) { width: 2rem; height: 2rem; border-radius: .65rem; }
  .panel-heading, .fields, .form-footer { padding-inline: 1.05rem; }
}

/* Below this width the two side-by-side panes squeeze the chat column, so the
   preview takes the full width above the form instead. */
@media (max-width: 860px) {
  .editor-layout { grid-template-columns: 1fr; }
  .workspace { padding-top: 2.5rem; }
  .preview-panel { order: 1; }
  .simulation { grid-template-columns: 2.8rem minmax(5.5rem, .85fr) minmax(0, 2.1fr); height: 22.5rem; }
}

/* The three-column header runs out of room before the phone layout, so the nav
   moves to its own row as soon as the wordmark and account start to squeeze. */
@media (max-width: 900px) {
  .topbar-inner { grid-template-columns: minmax(0, 1fr) auto; row-gap: .45rem; }
  .topnav { grid-row: 2; grid-column: 1 / -1; width: fit-content; justify-self: center; }
  .account-link, .skeleton-account { grid-column: 2; grid-row: 1; }
}

/* Phones this narrow cannot fit three columns of prose; the header shortens and
   the id gets its own line instead of breaking mid-number. */
@media (max-width: 860px) {
  /* Fixed rather than sticky so it survives a shrunken keyboard viewport; the
     panel reserves matching space at the bottom so the last field clears it. */
  /* The reveal animation leaves a transform on the view, so it — not the
     window — is the containing block. Bound the view to the window and let its
     own content scroll, then anchor the bar to the view's bottom edge. */
  #custom-view {
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: calc(100svh - var(--editor-top, 12rem));
  }
  #custom-view > .editor-layout { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  #custom-view .preview-panel { align-self: start; }
  .form-footer {
    position: absolute;
    inset: auto 0 0;
    z-index: 3;
    justify-content: flex-end;
    padding: .7rem 1rem max(.7rem, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
  .editor-panel { padding-bottom: 4.25rem; }
}

@media (max-width: 480px) {
  .topbar-inner {
    min-height: auto; width: calc(100% - 1.6rem); gap: .35rem; padding: .55rem 0 .7rem;
    /* The nav owns the whole second row, so no auto column may widen the sheet. */
    grid-template-columns: minmax(0, 1fr) auto;
  }
  /* Four labelled tabs do not fit; the icons keep their aria-labels, so the
     tabs shrink to icon-sized squares and the nav fits the viewport. */
  .topnav { width: 100%; max-width: 100%; justify-self: stretch; gap: .2rem; }
  .topnav a { padding: .52rem .35rem; gap: 0; font-size: 0; min-width: 0; }
  .topnav a svg { width: 1.25rem; height: 1.25rem; }
  /* Icons alone carry the tab; a ring would only widen it. */
  .topnav a[data-locked]::after { display: none; }
  /* The embed is narrow here; the art column shrinks and the note gives way. */
  /* The card is already one column now; keep the rows from wrapping. */
  .invite-embed { max-width: 100%; }
  .invite-name { font-size: .74rem; gap: .2rem; }
  .invite-note { display: none; }
  .invite-meta, .invite-est { font-size: .68rem; }
  /* The tile shrinks here, so the text only clears the smaller tile. */
  .invite-art { width: 2.2rem; height: 2.2rem; top: -13px; left: .4rem; }
  .invite-body { padding: 0 .45rem 0 2.9rem; }
  .invite-medal { width: .9rem; height: .9rem; }
  .invite-est { display: block; font-size: .66rem; margin-top: .15rem; }
  .invite-action { padding-inline: .3rem; font-size: .74rem; margin-top: .4rem; }
  .workspace { width: calc(100% - 1.6rem); padding-top: 2rem; }
  .intro-title { gap: .55rem; }
  .page-intro p { font-size: .91rem; }
  .access-panel { min-height: 16rem; }
  .home-actions { gap: .5rem; }
  .home-actions .button { min-width: 0; padding-inline: 1.05rem; }
  .skeleton-login { width: 6.25rem; }
  /* A phone that narrow cannot hold four columns plus a readable union list;
     the channel list folds away and the chat takes the rest. */
  .simulation { grid-template-columns: 2.2rem minmax(0, 1fr); height: 27rem; }
  .sim-channels { display: none; }
  .sim-rail :is(.server-icon, .rail-decoration, .skeleton-square) { width: 1.85rem; height: 1.85rem; }
  .sim-server, .sim-channel-title, .sim-chat-content { padding-inline: .45rem; }
  .channel-list { padding-inline: .26rem; }
  .sim-channel { padding-inline: .2rem; }
  .sim-channel svg { width: .95em; height: .95em; }
  .sim-composer { margin-inline: .42rem; }
  .identity-body { padding-inline: 1.05rem; }
  .identity-name { padding-right: 0; }
  .logout-button { position: static; margin-top: .8rem; }
  /* Two columns: the rank rides beside the account details rather than sitting
     alone and vertically centred, and the header shortens to fit. */
  .rankings-table :is(th, td) { padding: .8rem .7rem; }
  .rankings-table :is(thead, tbody) :is(th, td):first-child { width: 3rem; padding-left: .55rem; }
  .rankings-table thead th:first-child { white-space: nowrap; }
  .rankings-table thead th:last-child { width: 34%; font-size: .74rem; }
  .rankings-table tbody td:first-child { align-content: center; padding-bottom: 1.25rem; font-weight: 550; }
  .rankings-table tbody td:nth-child(2) { width: auto; }
  /* A 16-digit score cannot fit one line here; let it break. */
  .rankings-table tbody td:last-child { white-space: normal; word-spacing: -.06em; line-height: 1.2; font-size: .92rem; }
  .ranking-account { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; }
  .ranking-account:has(.ranking-avatar:not(.ranking-avatar-unavailable)) { grid-template-columns: auto minmax(0, 1fr); column-gap: .55rem; }
  .ranking-avatar { width: 1.75rem; height: 1.75rem; }
  .ranking-discord-id, .ranking-tier { grid-column: 1 / -1; justify-self: start; }
  .ranking-discord-id { font-size: .74rem; }
}

@media (max-width: 360px) {
  .rankings-table { table-layout: fixed; }
  .rankings-table :is(thead, tbody) :is(th, td):first-child { width: 1.9rem; padding-inline: .3rem; }
  .rankings-table thead th:last-child { width: 40%; font-size: .68rem; letter-spacing: -.01em; white-space: nowrap; }
  .rankings-table thead th:nth-child(2) { white-space: nowrap; }
  .rankings-table thead th:first-child { font-size: .7rem; }
  .rankings-table tbody td:first-child { padding-bottom: 1.6rem; }
  /* The value column must win space; the id gives way rather than overlapping. */
  .rankings-table tbody td:nth-child(2) { width: auto; }
  /* A 16-digit score cannot fit one line here; let it break. */
  .rankings-table tbody td:last-child { white-space: normal; word-spacing: -.06em; line-height: 1.2; font-size: .92rem; }
  .rankings-table tbody th { min-width: 0; }
  .ranking-account, .ranking-who { min-width: 0; }
  .ranking-discord-id { display: block; min-width: 0; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .66rem; }
  .ranking-account { grid-template-columns: minmax(0, 1fr); }
  .ranking-avatar { display: none; }
}

/* On phones the action bar rides the bottom edge so saving never needs a scroll
   back to the end of a long form. */

@keyframes page-enter {
  from { opacity: 0; transform: translateY(7px); }
}

@keyframes page-exit {
  to { opacity: 0; transform: translateY(-4px); }
}

@keyframes reveal-content {
  from { opacity: .55; transform: translateY(4px); }
}

@keyframes skeleton-sweep {
  from { background-position-x: 115%; }
  to { background-position-x: -15%; }
}

@keyframes replay-turn {
  to { transform: rotate(-360deg); }
}

@keyframes save-progress {
  from { background-position-x: 100%; }
  to { background-position-x: 0%; }
}

@keyframes save-confirmation {
  from { box-shadow: 0 0 0 0 #ffffff55; }
  to { box-shadow: 0 0 0 .4rem #ffffff00; }
}

@keyframes icon-bounce {
  35% { transform: translateY(var(--icon-bounce-offset)); }
  68% { transform: translateY(-2px); }
}

@keyframes trophy-rock {
  25% { transform: translateY(-.8px) rotate(-5deg); }
  50% { transform: rotate(5deg); }
  75% { transform: translateY(-.3px) rotate(-2deg); }
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }

  .skeleton {
    background-image: linear-gradient(105deg, transparent 34%, #ffffff0b 46%, transparent 58%);
    background-size: 220% 100%;
    animation: skeleton-sweep 1.65s .2s linear infinite;
  }

  .nav-indicator {
    view-transition-name: console-tab;
    transition: transform .32s var(--motion-ease), opacity .16s ease-out;
  }
  ::view-transition-group(console-tab) { animation-duration: .32s; }

  :is(#editor-access, #settings-form, #simulation, #profile-empty, #profile-details, #rankings-empty, #rankings-results):not([hidden]) {
    animation: reveal-content .25s var(--motion-ease);
  }

  #save-settings[aria-busy='true']::after {
    background: linear-gradient(90deg, #424242 28%, #9c9c9c 50%, #424242 72%) 100% / 230% 100%;
    animation: save-progress .95s linear infinite;
  }
  #save-settings[data-saved] { animation: save-confirmation .46s ease-out; }

  .icon-action .depth-icon { transition: transform .25s var(--motion-ease), color .18s ease; }
  .icon-action:is(:hover, :focus-visible):not(:disabled) .depth-icon {
    transform: perspective(64px) translateY(-1px) rotateX(10deg) rotateY(-14deg);
  }

  .depth-icon .dashboard-tile { transition: height .3s ease-in-out, y .3s ease-in-out; }
  .icon-action:is(:hover, :focus-visible) .tile-top-left { height: 5px; }
  .icon-action:is(:hover, :focus-visible) .tile-top-right { height: 9px; }
  .icon-action:is(:hover, :focus-visible) .tile-bottom-right { height: 5px; y: 16px; }
  .icon-action:is(:hover, :focus-visible) .tile-bottom-left { height: 9px; y: 12px; }

  .slider-track { transition: d .4s ease-in-out; }
  .icon-action:is(:hover, :focus-visible) .slider-track-top { d: path('M3 5H4 M8 3V7 M8 5H21'); }
  .icon-action:is(:hover, :focus-visible) .slider-track-middle { d: path('M3 12H16 M16 10V14 M20 12H21'); }
  .icon-action:is(:hover, :focus-visible) .slider-track-bottom { d: path('M3 19H7 M11 17V21 M11 19H21'); }

  .icon-action:is(:hover, :focus-visible) :is(.user-shoulders, .user-head) {
    animation: icon-bounce .6s ease-in-out;
  }
  .user-shoulders { --icon-bounce-offset: 4px; }
  .user-head { --icon-bounce-offset: 1px; }
  .trophy-cup, .replay-arrow { transform-box: view-box; transform-origin: center; }
  .icon-action:is(:hover, :focus-visible) .trophy-cup { animation: trophy-rock .8s ease-in-out; }
  .upload-arrow, .replay-arrow { transition: transform .3s var(--motion-ease); }
  .icon-action:is(:hover, :focus-visible):not(:disabled) .upload-arrow { transform: translateY(-2px); }
  .icon-action:is(:hover, :focus-visible):not(:disabled) .replay-arrow { transform: rotate(-45deg); }
  .replay-button.is-playing .replay-arrow { animation: replay-turn .66s var(--motion-ease); }

  .home-content { view-transition-name: console-home; }
  #custom-view { view-transition-name: console-editor; }
  #profile-view { view-transition-name: console-profile; }
  #rankings-view { view-transition-name: console-rankings; }

  :root:not(.has-native-transition) :is(.home-content, .workspace > section) {
    animation: page-enter .28s var(--motion-ease) both;
  }

  ::view-transition { pointer-events: none; }
  ::view-transition-old(root) { display: none; }
  ::view-transition-new(root) { animation: none; }
  ::view-transition-group(*) { animation-duration: .32s; animation-timing-function: var(--motion-ease); }

  ::view-transition-new(console-home),
  ::view-transition-new(console-editor),
  ::view-transition-new(console-profile),
  ::view-transition-new(console-rankings) {
    animation: page-enter .32s var(--motion-ease) both;
  }

  ::view-transition-old(console-home),
  ::view-transition-old(console-editor),
  ::view-transition-old(console-profile),
  ::view-transition-old(console-rankings) {
    animation: page-exit .16s ease-out both;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .button.icon-action:is(:hover, :focus-visible):not(:disabled) .depth-icon { transform: none; }
}


/* Windows high-contrast strips our greys and paints white; restore the surfaces
   the design relies on so panels and the chat frame stay distinguishable. */
@media (forced-colors: active) {
  :root { --line: CanvasText; --muted: CanvasText; }
  body { background: Canvas; color: CanvasText; }
  .panel, .simulation, .sim-chat, .sim-channels, .sim-rail, .access-panel, .identity-banner, .field input, .field textarea { background: Canvas; }
  .panel, .simulation, .access-panel, .identity-card, .admin-card, .field input, .field textarea { border-color: CanvasText; }
  .form-status[data-error], .form-status[data-error] { color: Highlight; font-weight: 600; }
  .access-icon, .server-icon, .bot-avatar, .welcome-hash, .rail-decoration, .sim-composer { border: 1px solid CanvasText; background: Canvas; }
  .glass { background: Canvas; backdrop-filter: none; box-shadow: none; }
  .primary-button, .login-button { background: Canvas !important; color: CanvasText !important; border: 2px solid CanvasText; font-weight: 700; }
  .sim-active, .ranking-current { background: Canvas; outline: 1px solid Highlight; }
  /* The nav track is a gradient; give it a real edge instead. */
  .topnav a[aria-current='page'] { outline: 2px solid Highlight; border-radius: 2rem; }
  .nav-indicator { border-color: CanvasText; }
}

/* Readers who ask for more contrast get heavier text and firmer rules instead
   of the softer greys used by default. */
@media (prefers-contrast: more) {
  :root {
    --muted: #d2d2d2;
    --line: #4a4a4a;
  }
  .field input, .field textarea { border-color: #7a7a7a; }
  .outline-button { border-color: #8a8a8a; }
  .char-count { color: var(--muted-strong); }
  .form-status, .preview-feedback { color: var(--muted-strong); }
  .home-footer { color: var(--muted-soft); }
  .status-code { color: var(--muted-soft); }
  .ranking-discord-id, .ranking-tier, .ranking-you { color: var(--muted-strong); }
}
}
