/* The bottom sheet (bottom-sheet.js) and the phone server switcher (server-switcher.js).
   Phone rules use the same media list as the phone layout in styles.css. */

/* ---------- bottom sheet ----------
   Above the call bubble (38) and the channel list drawer (36), level with dialogs (40). */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 40; background: rgba(4, 7, 18, calc(0.65 * var(--sheet-fade, 1))); animation: fade .15s;
}
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 82%; display: flex; flex-direction: column; outline: none;
  background: var(--panel); border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding: 0 calc(14px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
  transition: transform .2s ease-out; animation: sheet-up .22s ease-out;
}
.sheet.side {
  left: auto; top: 0; width: min(380px, 100%); max-height: none; border-bottom: 1px solid var(--line-strong); border-radius: 22px 0 0 22px;
  padding: env(safe-area-inset-top) calc(14px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) 14px;
  animation: sheet-in .22s ease-out;
}
.sheet-head {
  position: relative; flex: none; display: flex; align-items: baseline; justify-content: space-between; gap: 0 12px; padding: 22px 4px 4px;
  touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
}
.sheet-grip { position: absolute; top: 9px; left: 50%; translate: -50% 0; width: 38px; height: 4px; border-radius: 4px; background: var(--line-strong); }
.sheet.side .sheet-grip { display: none; }
.sheet.side .sheet-head { padding-top: 14px; }
.sheet-title { margin: 0 0 6px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sheet-hint { margin: 0 0 6px; font-size: 12px; color: var(--faint); }
.sheet-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.sheet-body::-webkit-scrollbar { display: none; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes sheet-in { from { transform: translateX(40px); opacity: 0; } }

/* ---------- server switcher: tab rows in the sheet ---------- */
.sw-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
/* the red strip a row slides off to reveal while it is swiped */
.sw-item { position: relative; border-radius: var(--r-md); overflow: hidden; background: var(--danger); }
.sw-item::after { content: 'Close'; position: absolute; right: 16px; top: 50%; translate: 0 -50%; font-weight: 800; font-size: 13px; color: #fff; }
.sw-row {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 4px; padding-right: 6px; border-radius: var(--r-md);
  background: var(--panel-2); border: 1px solid var(--line); touch-action: pan-y; transition: transform .16s ease-out;
}
.sw-row.dragging { transition: none; }
.sw-row.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sw-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 8px 6px 8px 10px; border-radius: var(--r-md); text-align: left; min-height: 56px; }
.sw-main .tile { width: 38px; height: 38px; border-radius: 12px; font-size: 13px; }
.sw-main .sw-name { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-main .sw-name small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.sw-open { flex: none; font-size: 11.5px; font-weight: 700; color: var(--accent-2); }
.sw-x { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.sw-x:active { background: var(--raised-2); }
.sw-main:focus-visible, .sw-x:focus-visible, .sw-add:focus-visible, .server-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sw-add {
  width: 100%; margin-top: 8px; display: flex; align-items: center; gap: 12px; padding: 10px; min-height: 58px; border-radius: var(--r-md);
  border: 1px dashed var(--line-strong); color: var(--soft); font-weight: 700; text-align: left;
}
.sw-plus { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--accent-2); background: var(--accent-soft); flex: none; }

/* ---------- server switcher: the top bar button (phones only) ---------- */
.switcher { display: none; }
@media (max-width: 760px), (hover: none) and (max-height: 500px) and (max-width: 1000px) {
  .tabs { display: none; }
  .switcher { display: flex; flex: 1; min-width: 0; }
  .server-switch {
    position: relative; flex: 1; min-width: 0; height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 10px 0 5px;
    border-radius: var(--r-md); background: color-mix(in srgb, var(--panel-2) 80%, transparent); border: 1px solid var(--line); text-align: left;
  }
  .server-switch .sw-name { min-width: 0; font-weight: 800; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .server-switch .sw-chev { margin-left: auto; flex: none; display: flex; color: var(--muted); }
  .server-switch .sw-ico { display: grid; place-items: center; background-color: var(--raised-2); color: var(--soft); }
  /* sits on the pill's top right corner, outside its border */
  .sw-total { position: absolute; right: -5px; top: -7px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10.5px; border: 2px solid var(--bg); box-sizing: content-box; line-height: 16px; }
  .sw-total.sw-dot { min-width: 0; width: 8px; height: 8px; padding: 0; border-radius: 50%; background: var(--text); }
}
/* the narrowest phones: tighter spacing around the logo and the actions so the server name keeps its room */
@media (max-width: 380px) {
  .topbar { gap: 4px; }
  .brand { width: 46px; }
  .top-actions { margin-right: 2px; padding: 0; }
  .dust-btn { padding-inline: 8px; min-width: 40px; justify-content: center; }
  .status-btn { padding-inline: 4px; min-width: 40px; justify-content: center; }
}
/* a phone held sideways: a shorter top bar */
@media (hover: none) and (max-height: 500px) and (max-width: 1000px) {
  .app, .app.side-closed { grid-template-rows: 50px minmax(0, 1fr); }
  .server-switch { height: 38px; }
}

/* ---------- install helper (install-sheet.js) ---------- */
.inst-lede { margin: 4px 0 12px; font-size: 14px; line-height: 1.5; color: var(--soft); }
.inst-alt { margin: 12px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.inst-alt a { color: var(--accent-2); }
.inst-go { width: 100%; justify-content: center; min-height: 44px; }
.inst-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.inst-step { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--raised); font-size: 14px; line-height: 1.4; color: var(--soft); }
.inst-ico { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent-2); font-size: 13px; }
