/* Relay dashboard. Builds on styles.css tokens. */
body.dash { min-height: 100vh; display: flex; flex-direction: column; }
.dash__main { flex: 1; padding: 48px 0 120px; }
.dash__badge {
  margin-left: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font: 700 11px/1 var(--font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b5c0ff;
  background: rgba(59, 82, 252, 0.16);
  border: 1px solid rgba(59, 82, 252, 0.35);
}
.dash__user { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; margin-left: auto; }
.dash .nav__links { margin-left: 28px; }
.dash__user img { width: 30px; height: 30px; border-radius: 50%; }
.dash__user button { margin-left: 6px; }
.dash__loading { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 80px 0; justify-content: center; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--sky); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

button { font: inherit; cursor: pointer; }
/* .btn sets display:inline-flex, which would otherwise beat the browser's
   rule for [hidden] and leave hidden buttons on screen. */
[hidden] { display: none !important; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none !important; }
.btn--danger { color: #ffb4b4; background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.35); }
.btn--danger:hover { background: rgba(239, 68, 68, 0.2); }
.btn--xs { padding: 7px 12px; font-size: 13px; }
.link-btn { background: none; border: 0; color: #8fb4ff; padding: 0; font-weight: 600; }

/* Login */
.login { max-width: 460px; margin: 40px auto; text-align: center; padding: 44px 36px; border-radius: 28px; border: 1px solid var(--line-2); background: linear-gradient(180deg, rgba(21, 32, 56, 0.9), rgba(14, 21, 38, 0.9)); box-shadow: 0 50px 90px -50px rgba(59, 82, 252, 0.55); }
.login img { width: 96px; height: 96px; margin: 0 auto 18px; filter: drop-shadow(0 14px 30px rgba(59, 82, 252, 0.45)); }
.login h1 { font-size: 30px; max-width: none; }
.login p { color: var(--muted); margin: 12px 0 26px; }
.login .fine { font-size: 13px; color: var(--faint); margin: 20px 0 0; }

/* Server list */
.dash h1.page-title { font-size: clamp(28px, 3.4vw, 40px); max-width: none; margin: 0; text-align: left; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-sub { color: var(--muted); margin: 10px 0 30px; max-width: 70ch; }
.servers { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.server { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 18px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02); transition: border-color 0.2s, transform 0.3s var(--ease); }
.server:hover { border-color: var(--line-2); transform: translateY(-2px); }
.server--off { opacity: 0.72; }
.server__icon { flex: none; width: 48px; height: 48px; border-radius: 14px; background: var(--panel-2); display: grid; place-items: center; font: 700 16px/1 var(--font-display); color: var(--muted); overflow: hidden; }
.server__icon img { width: 100%; height: 100%; object-fit: cover; }
.server__body { min-width: 0; flex: 1; }
.server__name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.server__state { font-size: 12.5px; color: var(--faint); margin-top: 2px; }
.server__state--on { color: #7ee2c8; }

/* Guild view */
.guild-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.guild-head .server__icon { width: 56px; height: 56px; }
.guild-head h1 { font-size: 28px; max-width: none; margin: 0; }
.guild-head .link-btn { display: block; margin-bottom: 6px; font-size: 14px; }
.guild-layout { display: grid; grid-template-columns: 210px 1fr; gap: 28px; align-items: start; }
.tabs { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 4px; }
.tab { text-align: left; padding: 11px 14px; border-radius: 12px; border: 1px solid transparent; background: none; color: var(--muted); font-weight: 600; font-size: 14.5px; display: flex; gap: 10px; align-items: center; }
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.03); }
.tab[aria-selected="true"] { color: var(--text); background: rgba(59, 82, 252, 0.12); border-color: rgba(59, 82, 252, 0.3); }

.panel-card { padding: 26px; border-radius: 22px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02); }
.panel-card + .panel-card { margin-top: 16px; }
.panel-card h2 { font-size: 21px; max-width: none; margin: 0 0 4px; }
.panel-card > p.hint { color: var(--muted); margin: 0 0 20px; font-size: 14.5px; }
.panel-card h2 + .fields, .panel-card h2 + .row-head, .panel-card h2 + .checklist { margin-top: 18px; }
.fields { display: grid; gap: 18px; }
.fields--2 { grid-template-columns: 1fr 1fr; }
.field { display: block; }
.field label, .field .label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.field small { display: block; color: var(--faint); font-size: 12.5px; margin-top: 6px; }
.input, select.input, textarea.input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: rgba(6, 10, 20, 0.6);
  color: var(--text);
  font: 500 14.5px/1.4 var(--font);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(30, 160, 240, 0.18); }
textarea.input { min-height: 140px; resize: vertical; font-family: var(--font); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.input--sm { max-width: 140px; }

/* ── Dropdown (custom listbox; native option lists can't be styled) ───────── */
.pick { position: relative; }
.pick__btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}
.pick__btn:hover { border-color: rgba(150, 170, 255, 0.34); }
.pick.is-open .pick__btn { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(30, 160, 240, 0.18); }
.pick__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick__label--empty { color: var(--faint); }
.pick__chevron {
  flex: none;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-3px) rotate(45deg);
  transition: transform 0.25s var(--ease);
}
.pick.is-open .pick__chevron { transform: translateY(1px) rotate(225deg); }

.pick__panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  padding: 6px;
  border-radius: 14px;
  background: #111a2e;
  border: 1px solid var(--line-2);
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.95);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}
.pick.is-open .pick__panel { opacity: 1; transform: none; pointer-events: auto; }
.pick__search {
  width: 100%;
  margin-bottom: 6px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(6, 10, 20, 0.6);
  color: var(--text);
  font: 500 14px/1.4 var(--font);
}
.pick__search:focus { outline: none; border-color: var(--sky); }
.pick__list { max-height: 260px; overflow-y: auto; display: grid; gap: 2px; scrollbar-width: thin; }
.pick__opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: #d4daf0;
  font: 500 14.5px/1.3 var(--font);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pick__opt:hover, .pick__opt--active { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.pick__opt--on { background: rgba(59, 82, 252, 0.18); color: #fff; font-weight: 700; }
.pick__opt--on::after { content: "✓"; float: right; opacity: 0.8; }
.pick__empty { padding: 12px; color: var(--faint); font-size: 14px; text-align: center; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.toggle input { appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-2); position: relative; cursor: pointer; transition: background 0.2s; flex: none; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #c7cfea; transition: transform 0.25s var(--ease); }
.toggle input:checked { background: var(--grad); border-color: transparent; }
.toggle input:checked::after { transform: translateX(18px); background: #fff; }

.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; max-height: 320px; overflow: auto; padding: 4px; }
.check { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); font-size: 14px; cursor: pointer; }
.check:hover { border-color: var(--line-2); }
.check input { accent-color: var(--blue); }
.check--on { background: rgba(59, 82, 252, 0.1); border-color: rgba(59, 82, 252, 0.35); }
.group-label { grid-column: 1 / -1; font-size: 11.5px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-top: 10px; }

.status { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border-radius: 16px; margin-bottom: 18px; }
.status--ok { background: rgba(11, 179, 171, 0.08); border: 1px solid rgba(11, 179, 171, 0.3); }
.status--warn { background: rgba(245, 158, 11, 0.08); border: 1px solid rgba(245, 158, 11, 0.32); }
.status b { display: block; }
.status span { color: var(--muted); font-size: 14px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 14.5px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; }

.rows { display: grid; gap: 10px; }
:root { --row-cols: 74px minmax(0, 1.2fr) minmax(0, 1.7fr) 96px minmax(0, 1.1fr) 158px; }
/* Header and rows are separate grids, so every track has to size from the
   template alone — minmax(0, …fr) and a fixed action column keep the two
   in step whatever the content is. */
.row-edit { display: grid; grid-template-columns: var(--row-cols); gap: 8px; align-items: center; padding: 10px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.015); }
.row-edit .input { padding: 9px 10px; font-size: 13.5px; }
.row-edit .pick__panel { min-width: 220px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-head { display: grid; grid-template-columns: var(--row-cols); gap: 8px; padding: 0 11px 2px; font-size: 11.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }

.snip-list { display: grid; gap: 8px; }
.snip { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); cursor: pointer; }
.snip:hover, .snip--on { border-color: rgba(59, 82, 252, 0.4); background: rgba(59, 82, 252, 0.07); }
.snip code { font-size: 13px; }
.snip span { color: var(--faint); font-size: 12.5px; white-space: nowrap; }

.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; transform: translateY(110%); transition: transform 0.35s var(--ease); }
.savebar.is-on { transform: none; }
.savebar__inner { margin: 0 auto 18px; width: min(760px, 100% - 32px); display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 20px; border-radius: 18px; background: rgba(17, 26, 46, 0.96); border: 1px solid var(--line-2); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.9); backdrop-filter: blur(12px); }
.savebar__inner span { flex: 1; font-weight: 600; font-size: 14.5px; }

.toast-stack { position: fixed; top: 84px; right: 18px; z-index: 80; display: grid; gap: 8px; }
.toast-item { padding: 12px 16px; border-radius: 14px; background: rgba(17, 26, 46, 0.96); border: 1px solid var(--line-2); font-size: 14px; font-weight: 600; box-shadow: 0 20px 44px -20px rgba(0, 0, 0, 0.9); animation: rise 0.35s var(--ease); max-width: 360px; }
.toast-item--ok { border-color: rgba(11, 179, 171, 0.45); }
.toast-item--err { border-color: rgba(239, 68, 68, 0.5); color: #ffc9c9; }

.empty { color: var(--faint); font-size: 14.5px; padding: 8px 0; }

@media (max-width: 1000px) {
  /* The links live in the hamburger panel; the avatar and Log out stay put. */
  .dash .nav__links { margin-left: 0; }
}

@media (max-width: 560px) {
  /* Keep the header to the essentials on small phones. */
  .dash__badge, .dash__user span { display: none; }
}

@media (max-width: 900px) {
  .guild-layout { grid-template-columns: 1fr; }
  /* Sticky under the header so the sections are always reachable. */
  .tabs {
    position: sticky;
    top: 68px;
    z-index: 30;
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    margin: 0 -20px 16px;
    padding: 10px 20px;
    background: rgba(11, 17, 30, 0.94);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; border-color: var(--line); }
  .fields--2 { grid-template-columns: 1fr; }
  .row-head { display: none; }
  .row-edit { grid-template-columns: 74px minmax(0, 1fr); }
  .row-edit > :nth-child(3), .row-edit > :nth-child(4), .row-edit > :nth-child(5), .row-edit > :nth-child(6) { grid-column: 1 / -1; }
}

/* Emoji picker — same shell as .pick, but a grid of glyphs instead of a list. */
.emoji-pick__btn { justify-content: center; padding: 9px 6px; }
.emoji-pick__value { font-size: 17px; line-height: 1; text-align: center; }
.emoji-pick__value.pick__label--empty { font-size: 12px; }
.emoji-pick__panel { min-width: 300px; padding-bottom: 8px; }
.emoji-pick__grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; max-height: 220px; overflow-y: auto; scrollbar-gutter: stable; padding: 6px; }
.emoji-pick__opt { display: flex; align-items: center; justify-content: center; height: 34px; font-size: 18px; line-height: 1; border: 0; border-radius: 9px; background: transparent; color: inherit; cursor: pointer; }
.emoji-pick__opt:hover, .emoji-pick__opt:focus-visible { background: rgba(255, 255, 255, 0.07); outline: none; }
.emoji-pick__opt--on { background: rgba(90, 162, 255, 0.18); box-shadow: inset 0 0 0 1px rgba(120, 180, 255, 0.5); }
.emoji-pick__clear { width: calc(100% - 12px); margin: 0 6px; padding: 8px; border: 0; border-top: 1px solid var(--line); border-radius: 0 0 9px 9px; background: transparent; color: var(--faint); font: inherit; font-size: 12.5px; cursor: pointer; }
.emoji-pick__clear:hover { color: var(--ink); background: rgba(255, 255, 255, 0.05); }
/* Beats .row-edit .pick__panel, which is narrower than the emoji grid needs. */
.row-edit .emoji-pick__panel { min-width: 300px; }
