/* The dashboard's own layout and controls, on top of base.css. */

main { padding-top: clamp(1.75rem, 5vw, 3rem); padding-bottom: 2rem; }
body.has-bar main { padding-bottom: 7rem; }

.topbar .who { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--muted); font-size: 0.95rem; }
.topbar .who .avatar, .topbar .who .initials { width: 2rem; height: 2rem; border-radius: 50%; }
@media (max-width: 520px) {
  .topbar .who-name { display: none; }
  .brand .area { display: none; }
}

/* ---------------- signing in ---------------- */
.signin { padding-top: clamp(1rem, 6vw, 4rem); padding-bottom: 2rem; }
.signin .title { max-width: 16ch; font-size: clamp(2.4rem, 8vw, 4.4rem); }
.signin .cta { margin: 0 0 1.75rem; }
.signin .fine { max-width: 62ch; color: var(--muted); font-size: 0.9rem; margin: 0; }

/* ---------------- the servers ---------------- */
.servers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 0.85rem;
}
.server {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-height: 4.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}
a.server:hover { border-color: var(--sky); background: var(--lift); color: var(--text); }
.server .avatar, .server .initials { width: 3rem; height: 3rem; }
.server-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.server-name { font-weight: 700; line-height: 1.3; }
.server-meta { color: var(--muted); font-size: 0.85rem; }
.server .go { color: var(--sky-lit); font-size: 1.2rem; }
.server.invite { background: transparent; border-style: dashed; }
.invites { margin-top: 2.75rem; }
.invites h2 { font-family: var(--display); font-weight: 800; font-size: 1.5rem; letter-spacing: -0.015em; margin: 0 0 0.3rem; }
.invites > p { margin: 0 0 1.1rem; }

/* ---------------- a server: the sidebar beside the settings ---------------- */
.guild {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.25rem);
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 5.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: calc(100vh - 6rem);
  overflow: auto;
  padding-bottom: 1rem;
}
.server-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  padding: 0.25rem 0;
}
.server-head:hover .server-name { color: var(--sky-lit); }
.server-head .avatar, .server-head .initials { width: 2.75rem; height: 2.75rem; }
.switch-server { font-size: 0.9rem; align-self: flex-start; }
.nav-toggle { display: none; }
.nav-groups { display: flex; flex-direction: column; gap: 1.1rem; margin-top: 0.6rem; }
.nav-title {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--pink);
  margin: 0 0 0.35rem;
}
.nav-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.nav-group a {
  display: block;
  padding: 0.42rem 0.7rem;
  border-radius: 8px;
  border-left: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.35;
}
.nav-group a:hover { background: var(--panel); color: var(--text); }
.nav-group a[aria-current="page"] {
  background: var(--panel);
  color: var(--text);
  border-left-color: var(--pink);
  font-weight: 700;
}

@media (max-width: 860px) {
  .guild { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .sidebar { position: static; max-height: none; overflow: visible; padding-bottom: 0; border-bottom: 1px solid var(--edge); padding-bottom: 1rem; }
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    min-height: 2.9rem;
    padding: 0.55rem 0.9rem;
    border: 1px solid var(--edge);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
  }
  .nav-toggle:hover { border-color: var(--sky); }
  .nav-toggle .chev { color: var(--sky-lit); }
  .sidebar.open .nav-toggle .chev { transform: rotate(180deg); }
  .nav-groups { display: none; }
  .sidebar.open .nav-groups { display: flex; }
}

/* ---------------- a server's overview ---------------- */
.overview-group { margin-top: 2rem; }
.group-title {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--pink);
  margin: 0 0 0.75rem;
}
.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 0.75rem;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  height: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid var(--edge);
  border-left: 2px solid var(--sky);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}
.card:hover { border-color: var(--sky); background: var(--lift); color: var(--text); }
.card-title { font-weight: 700; }
.card-text { color: var(--muted); font-size: 0.9rem; line-height: 1.45; }

/* ---------------- a section's settings ---------------- */
.section .title { font-size: clamp(1.9rem, 4.5vw, 2.7rem); }
.fields {
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--panel);
}
.field {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 0.6rem 2rem;
  margin: 0;
  padding: 1.1rem 1.25rem;
  border: 0;
  border-top: 1px solid var(--hair);
  min-width: 0;
}
.field:first-child { border-top: 0; }
.field-head { min-width: 0; }
.field-label {
  display: block;
  padding: 0;
  margin: 0;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}
.field .help { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.field-body { min-width: 0; display: flex; flex-direction: column; gap: 0.45rem; justify-content: center; }
.field-error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 700;
  font-size: 0.92rem;
}
.field.has-error { background: rgba(229, 72, 77, 0.05); }
.field-toggle .field-body { align-items: flex-end; }
.field-info .info-value { margin: 0; color: var(--muted); }
@media (max-width: 720px) {
  .field { grid-template-columns: minmax(0, 1fr); padding: 1rem; }
  .field-toggle { grid-template-columns: minmax(0, 1fr) auto; }
  .field-toggle .field-error { grid-column: 1 / -1; }
}

.input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
}
.input:hover { border-color: rgba(156, 195, 255, 0.55); }
.input:focus-visible { border-color: var(--sky-lit); outline-offset: 2px; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[disabled] { opacity: 0.55; cursor: not-allowed; }
.input.narrow { width: 9.5rem; max-width: 100%; }
textarea.input { resize: vertical; min-height: 6.5rem; }
select.input { cursor: pointer; }
select.input option, select.input optgroup { background: var(--panel); color: var(--text); }
.input.mono { font-family: var(--mono); font-size: 0.9rem; }

.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.stack { display: flex; flex-direction: column; gap: 0.4rem; }
.split { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 0.5rem 1rem; }
.unit { color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 0.85rem; }
.hint.warn { color: var(--warn); }
.count { margin-left: auto; font-family: var(--mono); font-size: 0.75rem; }
.count.over { color: var(--danger); }

/* A switch: the checkbox drawn as one, with its thumb painted on, so it needs
   no extra element and keeps the checkbox's keyboard and screen-reader sense. */
input.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 3.1rem;
  height: 1.75rem;
  margin: 0;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--bg) radial-gradient(circle at 0.86rem 50%, var(--muted) 0.52rem, transparent 0.55rem) no-repeat;
  cursor: pointer;
}
input.switch:checked {
  border-color: var(--pink);
  background: var(--pink) radial-gradient(circle at calc(100% - 0.86rem) 50%, var(--on-pink) 0.52rem, transparent 0.55rem) no-repeat;
}
input.switch:hover { border-color: var(--sky-lit); }
input.switch[aria-invalid="true"] { border-color: var(--danger); }

/* Ticked choices, as pills. */
.pills { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.3rem 0.8rem 0.3rem 0.55rem;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
  font-size: 0.92rem;
}
.pill:hover { border-color: rgba(156, 195, 255, 0.55); }
.pill input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--pink); cursor: pointer; }
.pill:has(input:checked) { border-color: var(--pink); background: rgba(255, 111, 174, 0.1); }
.pill:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
.pill:has(input:focus-visible) { outline: 2px solid var(--sky-lit); outline-offset: 2px; }
.pill input:focus-visible { outline: none; }

/* Picked channels, roles and emoji, as chips. */
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.25rem;
  max-width: 100%;
  padding: 0.2rem 0.25rem 0.2rem 0.7rem;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--lift);
  font-size: 0.92rem;
}
.chip-warn { border-color: rgba(255, 210, 122, 0.6); }
.chip-name { overflow-wrap: anywhere; }
.chip-note { color: var(--warn); font-size: 0.78rem; }
.chip-remove {
  display: inline-grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.chip-remove:hover { background: var(--edge); color: var(--text); }
.chip-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip-tools > select { flex: 1 1 14rem; }
.swatch { width: 0.7rem; height: 0.7rem; flex: none; }
.emoji-img { width: 1.25rem; height: 1.25rem; object-fit: contain; }

/* The words Vandal fills in, under a message. */
.variables { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.variable {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.variable code { color: var(--sky-lit); }
.variable:hover { border-color: var(--sky); color: var(--text); }

input.color {
  width: 3rem;
  height: 2.75rem;
  padding: 0.2rem;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}

/* A list's rows: level rewards, command rules. */
.list-field { display: flex; flex-direction: column; gap: 0.75rem; }
.rows { display: flex; flex-direction: column; gap: 0.6rem; }
.row { border: 1px solid var(--edge); border-radius: var(--radius); background: var(--bg); }
.row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem 0.5rem 0.9rem;
  border-bottom: 1px solid var(--hair);
}
.row-name { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sky-lit); }
.row-tools { display: flex; gap: 0.35rem; }
.row-tools .btn.small { min-height: 2.25rem; min-width: 2.25rem; padding: 0.3rem 0.6rem; }
.row-fields .field { grid-template-columns: minmax(0, 1fr); gap: 0.4rem; padding: 0.75rem 0.9rem; }
.row-fields .field-toggle { grid-template-columns: minmax(0, 1fr) auto; }

/* ---------------- the bar that saves ---------------- */
.savebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 0 0 max(0.85rem, env(safe-area-inset-bottom));
  pointer-events: none;
}
.savebar .shell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  pointer-events: auto;
  max-width: calc(var(--shell) - 2rem);
  padding: 0.75rem 0.85rem 0.75rem 1.15rem;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.8);
}
.savebar p { margin: 0; font-weight: 700; flex: 1 1 14rem; }
.savebar[data-tone="bad"] .shell { border-color: rgba(255, 139, 139, 0.6); }
.savebar[data-tone="bad"] p { color: var(--danger); }
.savebar[data-tone="good"] .shell { border-color: rgba(126, 226, 168, 0.55); }
.savebar[data-tone="good"] p { color: var(--ok); }
.savebar-actions { display: flex; gap: 0.5rem; margin-left: auto; }
@media (max-width: 520px) {
  .savebar .shell { margin: 0 0.6rem; width: auto; }
  .savebar-actions { width: 100%; }
  .savebar-actions .btn { flex: 1; }
}

/* ---------------- leaving with unsaved changes ---------------- */
dialog {
  width: min(28rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
}
dialog::backdrop { background: rgba(8, 11, 22, 0.78); }
dialog h2 { font-family: var(--display); font-weight: 800; margin: 0 0 0.4rem; font-size: 1.45rem; letter-spacing: -0.015em; }
dialog p { margin: 0 0 1.25rem; color: var(--muted); }
dialog .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }

@media (prefers-reduced-motion: no-preference) {
  .server, .card, .nav-group a, .pill, .chip-remove, .variable, input.switch { transition: background 140ms ease, border-color 140ms ease, color 140ms ease, background-position 140ms ease; }
}
