/* Sis's own parts (sis.js): the server list, the server switch at the top of
   the menu and the Whitelist page. Only while <html data-bot="sis">, which is
   always the new design, so it builds on dash.css's tokens. */

:where(html[data-bot="sis"]) {
  & .sis-logo { display: block; width: 38px; height: 38px; flex: none; border-radius: 11px; }
  & img.is-logo { padding: 6px; object-fit: contain; background: color-mix(in srgb, #e0559c 15%, var(--card)); }
  & img.is-logo.sm { padding: 4px; }
  & .pk-card > img.is-logo { padding: 9px; }
  & .sis-gi { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 11px; object-fit: cover;
              color: #fff; font-size: 14px; font-weight: 700; background: var(--raised); }
  & .sis-gi.sm { width: 26px; height: 26px; border-radius: 8px; font-size: 11px; }
  & .sis-gi.none { background: var(--hover); color: var(--faint); }
  & .lvl { font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 7px; white-space: nowrap; }
  & .lvl.admin { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
  & .lvl.mod { background: var(--soft); color: var(--hi); }
  & .lvl.owner { background: color-mix(in srgb, var(--yellow) 15%, transparent); color: var(--yellow); }

  /* ── the server list ── */
  & .pk-top { display: flex; align-items: center; gap: 10px; padding: 10px 28px; position: sticky; top: 0; z-index: 30;
              padding-top: max(10px, env(safe-area-inset-top));
              background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
  & .pk-top > .sis-logo { width: 30px; height: 30px; border-radius: 9px; }
  & .pk-top > b { color: var(--head); font-size: 15px; }
  & .pk-top .grow { flex: 1; }
  & .pk-top .who { display: flex; align-items: center; gap: 10px; font-size: 14px; }
  & main.pk { max-width: 880px; margin: 0 auto; padding: 32px 28px 80px; }
  & .pk h1 { margin: 0 0 4px; }
  & .pk .lead { margin: 0 0 18px; }
  & .pk h2 { margin: 28px 0 10px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
  & .pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 10px; }
  /* one server: icon, name and access on one line, the whole row is the link */
  & .pk-card { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px 14px; color: inherit; text-decoration: none;
               background: var(--card); border: 1px solid var(--line); border-radius: 14px;
               transition: border-color var(--fast), background var(--fast); }
  & .pk-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--raised); }
  & .pk-card:focus-visible { outline: 2px solid var(--hi); outline-offset: 2px; }
  & .pk-card > .sis-gi, & .pk-card > .sis-logo { width: 44px; height: 44px; border-radius: 13px; font-size: 16px; }
  & .pk-body { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
  & .pk-body b { color: var(--head); font-size: 15px; font-weight: 650; line-height: 1.25;
                 white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  & .pk-meta { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 13px; }
  & .pk-list { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  & .pk-chev { width: 16px; height: 16px; flex: none; color: var(--faint); transition: transform var(--fast), color var(--fast); }
  & .pk-card:hover .pk-chev { color: var(--hi); transform: translateX(2px); }
  @media (prefers-reduced-motion: reduce) { & .pk-card:hover .pk-chev { transform: none; } }

  /* ── the switch at the top of the menu ── */
  & .bar-seg:not(:has(> button:nth-child(2))) { display: none; }   /* one section only (the bot-wide pages) */
  & .panel { position: relative; }
  & button.sis-switch { width: 100%; background: none; border: 0; border-radius: 0; text-align: left; color: inherit; box-shadow: none;
                        padding: 18px 18px 14px; display: flex; }
  & button.sis-switch:hover { background: none; border: 0; }
  & button.sis-switch:active { transform: none; }
  & .sw-box { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 6px; margin: -6px; border-radius: 12px;
              transition: background var(--fast); }
  & button.sis-switch:hover .sw-box, & button.sis-switch[aria-expanded="true"] .sw-box { background: var(--card); }
  & .sw-txt { min-width: 0; flex: 1; }
  & .sw-txt b { display: block; color: var(--head); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  & .sw-txt span { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; }
  & .sw-chev { width: 16px; height: 16px; flex: none; color: var(--faint); transform: rotate(90deg); transition: transform var(--mid) var(--ease); }
  & button.sis-switch[aria-expanded="true"] .sw-chev { transform: rotate(-90deg); }
  & .sw-pop { position: absolute; left: 10px; width: max(calc(100% - 20px), 280px); top: 74px; z-index: 50; padding: 6px; max-height: min(70vh, 520px); overflow-y: auto;
              background: var(--raised); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow);
              animation: pop-in .14s var(--ease) both; }
  & .sw-pop h5 { margin: 6px 10px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
  & .sw-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; color: var(--text); text-decoration: none;
               font-size: 14px; font-weight: 500; }
  & .sw-item:hover { background: var(--hover); color: var(--head); }
  & .sw-item.cur { background: var(--soft); color: var(--hi); }
  & .sw-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  & .sw-ic { width: 26px; height: 26px; padding: 5px; flex: none; border-radius: 8px; background: var(--hover); color: var(--muted); }
  & .sw-pop hr { border: 0; border-top: 1px solid var(--line-2); margin: 6px 4px; }

  /* ── Whitelist ── */
  & .wl-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
  & .wl-add label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
  & .wl-add input { width: 230px; max-width: 100%; padding: 8px 11px; font: inherit; font-size: 14px; }
  & .wl-add input.mono { font-family: ui-monospace, Consolas, monospace; width: 220px; }
  & .wl-add .hint { flex-basis: 100%; font-size: 13px; color: var(--faint); }
  & .wl-add .hint.bad { color: var(--red); }
  & .card.wl-list { padding: 0; overflow: hidden; border-radius: 16px; }
  & .wl-head { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 18px; border-bottom: 1px solid var(--line);
               font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
  & .wl-head span { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 13px; }
  & .wl-row { display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 12px 18px; border-top: 1px solid var(--line);
              flex-wrap: wrap; transition: background var(--fast); }
  & .wl-head + .wl-row, & .card > h3 + .note + .wl-row { border-top: 0; }
  & .wl-row:hover { background: var(--raised); }
  & .wl-row .sis-gi { width: 42px; height: 42px; border-radius: 12px; }
  & .wl-who { flex: 1; min-width: 200px; }
  & .wl-who b { display: block; color: var(--head); font-weight: 600; line-height: 1.3; }
  & .wl-who code { background: none; padding: 0; color: var(--faint); font-size: 12px; }
  & input.wl-note { display: block; width: min(300px, 100%); margin: 2px 0 0 -6px; padding: 2px 6px; font: inherit; font-size: 13px;
                    background: transparent; border: 1px solid transparent; border-radius: 7px; color: var(--muted); box-shadow: none; }
  & input.wl-note:hover { border-color: var(--line-2); }
  & input.wl-note:focus { outline: none; border-color: var(--hi); background: var(--deep); color: var(--head); box-shadow: 0 0 0 3px var(--soft); }
  & .wl-state { font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 8px; white-space: nowrap; }
  & .wl-state.in { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
  & .wl-state.out { background: var(--hover); color: var(--muted); }
  & .wl-acts { display: flex; gap: 8px; }
  & .wl-acts button { padding: 6px 12px; font-size: 13px; }
  & .wl-empty { margin: 0; padding: 18px; color: var(--muted); }
  & .card + .card.wl-list, & .card.wl-list + .card { margin-top: 14px; }
}

@media (max-width: 720px) {
  :where(html[data-bot="sis"]) {
    & .pk-top, & main.pk { padding-left: 16px; padding-right: 16px; }
    & .pk-top .who-name { display: none; }
  }
}

/* the narrow menu (tablets, or "Icons only"): just the server's icon */
@media (max-width: 1100px) and (min-width: 901px) {
  :where(html[data-bot="sis"]) {
    & .sw-txt, & .sw-chev { display: none; }
    & button.sis-switch { justify-content: center; padding: 16px 0 12px; }
    & .sw-box { flex: none; }
    & .sw-pop { right: auto; width: 270px; }
  }
}
@media (min-width: 901px) {
  :where(html[data-bot="sis"][data-sidebar="icons"]) {
    & .sw-txt, & .sw-chev { display: none; }
    & button.sis-switch { justify-content: center; padding: 16px 0 12px; }
    & .sw-box { flex: none; }
    & .sw-pop { right: auto; width: 270px; }
  }
}

/* Data requests: a case also says which server it's from */
:where(html[data-bot="sis"]) .dr-case { grid-template-columns: 18px 48px auto auto minmax(0, 1fr) auto; }
:where(html[data-bot="sis"]) .dr-case .badge.chg { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 900px) {
  :where(html[data-bot="sis"]) .dr-case { grid-template-columns: 18px 44px auto minmax(0, 1fr); }
  :where(html[data-bot="sis"]) .dr-case .r, :where(html[data-bot="sis"]) .dr-case > :last-child { grid-column: 3 / span 2; }
}
