/* Modal layout (the default; "blocks" internally): a top bar, a scrolling grid of module blocks, and each module's page in a modal.
   Loaded last, so it reshapes the sidebar layout without touching the other stylesheets. */

/* ---- Top bar (the old sidebar, laid out in a row) ---- */
.shell { display: block; min-height: 100%; }
.rail {
  position: sticky; top: 0; z-index: 55; height: auto; overflow: visible;  /* above the modal: wallet and menus stay usable */
  flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 12px clamp(16px, 4vw, 48px); border-right: 0; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
}
.rail > nav { display: none !important; }  /* still there: it lists the modules and who may see them */
.rail .serverpick { display: flex; align-items: center; gap: 12px; }
.rail .serverpick label { display: flex; align-items: center; gap: 8px; padding: 0; }
.rail .serverpick select { min-height: 36px; padding: 6px 10px; width: auto; max-width: 220px; }
.rail-foot { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 0; background: none; border: 0; }
.rail-foot .soundbox { display: flex; align-items: center; gap: 8px; }
.rail-foot .soundbox input[type="range"] { width: 90px; margin: 0; }
.rail-foot #viewAsBox { display: flex; align-items: center; gap: 8px; padding: 0; }
.rail-foot #viewAsBox select { min-height: 36px; padding: 6px 10px; width: auto; }
.rail-foot .who-chip { width: auto; }
.rail-foot > .wallet { margin: 0; }
.rail-foot .who-menu { bottom: auto; top: calc(100% + 6px); left: auto; right: 0; min-width: 190px; }
.rail-foot .linkish { padding: 0; }

/* ---- Home: the module blocks ---- */
.home { padding: 28px clamp(16px, 4vw, 48px) 80px; max-width: 1480px; margin: 0 auto; }
.home-group { margin-bottom: 28px; }
.home-group > h2 {
  font: 700 .8125rem/1 var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--gold);
  margin: 0 0 12px; display: flex; align-items: center; gap: 10px;
}
.home-group > h2::after { content: ""; flex: 0 0 48px; height: 1px; background: linear-gradient(90deg, var(--acc, var(--gold-fill)), transparent); }
.blocks { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.block {
  position: relative; text-align: left; cursor: pointer; color: inherit; font: inherit;
  display: grid; grid-template-rows: auto 1fr; gap: 14px; min-height: 190px; padding: 22px 22px 20px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  transition: transform .18s cubic-bezier(.3, .7, .2, 1), border-color .18s, box-shadow .18s;
}
.block::before { content: ""; position: absolute; left: 16px; right: 16px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--acc, var(--gold-fill)), transparent); opacity: .9; }
.block.wide { grid-column: span 2; }
.block:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--gold-fill) 45%, var(--line));
  box-shadow: 0 10px 24px -16px rgba(0, 0, 0, .45); }
.block:active { transform: scale(.985); }
.block .top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.block .icon { width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 14px;
  background: color-mix(in srgb, var(--acc, var(--gold-fill)) 16%, var(--sunken)); font-size: 1.625rem; }
.block .name { font: 700 1.3125rem/1.2 var(--display); letter-spacing: .03em; min-width: 0; }
.block .sum { color: var(--muted); font-size: 1rem; line-height: 1.5; align-self: end; }
.block .sum .now-t { display: block; color: var(--ink); font-weight: 700; font-size: 1.1875rem; line-height: 1.3; }
.block .sum .now-by { display: block; font-size: .9375rem; }
.block .mini-bar { height: 6px; border-radius: 99px; background: var(--sunken); overflow: hidden; margin: 10px 0 2px; }
.block .mini-bar i { display: block; height: 100%; background: var(--gold-fill); border-radius: 99px; transition: width .6s linear; }
.block .sts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.block .st { display: inline-flex; gap: 5px; align-items: baseline; padding: 4px 10px; border-radius: 999px;
  background: var(--sunken); border: 1px solid var(--line); font-size: .8125rem; color: var(--muted); white-space: nowrap; }
.block .st b { color: var(--ink); font-weight: 700; }
.block .sum b { color: var(--ink); font-weight: 600; }
.block .sum .big { display: block; font: 700 1.75rem/1.2 var(--display); color: var(--gold); margin-bottom: 4px; }
.block .sw { margin-left: auto; flex: none; }
.block.off { opacity: .6; }
.block.off .sum::before { content: "Switched off · "; color: var(--danger); font-weight: 600; }
.block:focus-visible { outline: 2px solid var(--gold-fill); outline-offset: 2px; }

/* ---- The modal: <main> holds every module's page, opened one at a time ---- */
main {
  display: none; position: fixed; inset: var(--bar, 0px) 0 0 0; z-index: 50;  /* starts below the top bar */ overflow-y: auto; overscroll-behavior: contain;
  padding: 28px clamp(12px, 4vw, 48px) 64px;
  background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(6px);
}
/* Chromium browsers (Opera GX, Chrome, Edge...): the blur made opening and scrolling choppy in Opera GX.
   Since 2026-11-16 they keep the frosted blur too (it ran fine; Legacy is the fallback); only GPU scrolling is kept.
   If it gets choppy again, restore the lighter style by putting back these three rules:
     html[data-engine="chromium"] .rail { background: var(--surface); backdrop-filter: none; }
     html[data-engine="chromium"] main { background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: none; }
     html[data-engine="chromium"] main > section { box-shadow: 0 20px 50px -24px rgba(0, 0, 0, .55); } */
html[data-engine="chromium"] main { will-change: scroll-position; }
body.modal-open { overflow: hidden; }
body.modal-open main { display: block; animation: modal-bg .2s ease-out; }
main > section {
  margin: 0 auto; background: var(--bg); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px clamp(16px, 3vw, 36px) 32px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .55);
}
body.modal-open main > section:not([hidden]) { animation: modal-in .32s cubic-bezier(.2, .8, .2, 1); }
.modal-close {
  position: sticky; top: 0; float: right; z-index: 2; margin: -8px -8px 0 0; width: 42px; height: 42px;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 1.125rem; cursor: pointer; box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .4);
}
.modal-close:hover { border-color: var(--gold-fill); }
@keyframes modal-bg { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }

/* Home blocks rise in one after another, like panels do. */
.home.entering .block { animation: rise .45s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 30ms); }

@media (max-width: 760px) {
  .rail { position: static; }
  .rail-foot { margin-left: 0; width: 100%; }
  .blocks { grid-template-columns: minmax(0, 1fr); }
  .block.wide { grid-column: auto; }
  .block { min-height: 0; }
  main { padding: 0; inset: 0; z-index: 56; }  /* the top bar is too tall here: the page covers it... */
  body.modal-open #walletFloat:not([hidden]) { display: flex; }  /* ...and a copy of the wallet floats in the corner */
  main > section { border-radius: 0; border: 0; min-height: 100%; padding: 20px 16px 80px; }  /* room for the floating wallet */
  .modal-close { margin: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .block, body.modal-open main, body.modal-open main > section:not([hidden]), .home.entering .block { animation: none; transition: none; }
}

/* Leave room in each page's title row for the close button. */
main > section > h1, main > section > .pagehead, main > section > .me-head { padding-right: 52px; }

/* Kel Studio: a picture as a home block's icon ({avatar}, {server_icon}, {bot_avatar}, {mask} or a link). */
.block .icon .lookicon { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; image-rendering: auto; }
.block .icon .lookicon[src^="/img/masks/"] { object-fit: contain; image-rendering: pixelated; }
