/* The shared structure of every panel. The look of each character is in theme-<key>.css, loaded after this
   file. */

:root {
  /* The pages are dark by design: a browser that forces a dark mode must not recolour them. */
  color-scheme: dark;
  color-scheme: only dark;
  --bg: #14161b;
  --bg-soft: #1b1e25;
  --card: #1f232b;
  --card-edge: #2d323d;
  --text: #e8eaee;
  --muted: #9aa1ae;
  --accent: #f0a63a;
  --accent-ink: #20150a;
  --good: #5cc98a;
  --warn: #f0a63a;
  --bad: #ef6b6b;
  --radius: 10px;
  --gutter: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }
code { background: var(--bg-soft); border-radius: 4px; padding: 0 4px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 10px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
  position: absolute; left: var(--gutter); top: -48px;
  background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 6px;
}
.skip-link:focus { top: 8px; }

.muted { color: var(--muted); }
.lead { color: var(--muted); max-width: 62ch; }
.hint, .fine-print { color: var(--muted); font-size: .85rem; }

.hud-tag, .hud-index {
  color: var(--accent); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 6px;
}

/* layout */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px var(--gutter); background: var(--bg-soft); border-bottom: 1px solid var(--card-edge);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-text { display: flex; flex-direction: column; }
.brand-text small { color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar-actions form { margin: 0; }

.shell { display: flex; flex: 1; gap: 20px; padding: 20px var(--gutter); width: 100%; max-width: 1200px; margin: 0 auto; }
.page { flex: 1; min-width: 0; }
.footer { padding: 16px var(--gutter); color: var(--muted); font-size: .8rem; text-align: center; }

.rail { width: 230px; flex: none; }
.rail-back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; }
.rail-guild { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.rail-guild img, .server-initials { border-radius: 12px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-group { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; margin: 8px 0 4px; }
.rail-nav a {
  display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none;
}
.rail-nav a:hover { background: var(--bg-soft); }
.rail-nav a[aria-current="page"] { background: var(--card); box-shadow: inset 3px 0 0 var(--accent); }
.rail-index { color: var(--muted); font-size: .75rem; }

/* cards and forms */
.panel, .form-card {
  background: var(--card); border: 1px solid var(--card-edge); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.jump { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.callout { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; border: 1px solid var(--card-edge); background: var(--bg-soft); }
.callout-error { border-color: var(--bad); }
.callout p:last-child { margin-bottom: 0; }

.flashes { margin-bottom: 16px; display: grid; gap: 8px; }
.flash { display: flex; gap: 10px; border-radius: 8px; padding: 10px 12px; background: var(--card); border-left: 4px solid var(--muted); }
.flash p { margin: 0; }
.flash-ok { border-left-color: var(--good); }
.flash-warning { border-left-color: var(--warn); }
.flash-error { border-left-color: var(--bad); }

.hero { padding: 24px 0; }
.display { font-size: 2.1rem; max-width: 20ch; }
.hero-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 18px 0 10px; }
.feature-grid, .card-grid, .stat-grid, .server-grid {
  display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-bottom: 16px;
}
.nav-card { color: var(--text); text-decoration: none; display: block; }
.nav-card:hover { border-color: var(--accent); }
.stat-label { color: var(--muted); font-size: .8rem; margin: 0; }
.stat-value { font-size: 1.4rem; margin: 4px 0 0; display: flex; align-items: center; gap: 8px; }
.stat-note { color: var(--muted); margin: 4px 0 0; font-size: .85rem; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.stat-online .pulse { background: var(--good); }
.stat-offline .pulse { background: var(--bad); }

.server-card {
  display: flex; align-items: center; gap: 12px; padding: 12px; color: var(--text); text-decoration: none;
  background: var(--card); border: 1px solid var(--card-edge); border-radius: var(--radius);
}
.server-card:hover { border-color: var(--accent); }
.server-index { color: var(--muted); font-size: .75rem; }
.server-icon { width: 48px; height: 48px; border-radius: 12px; }
.server-initials { display: inline-flex; width: 48px; height: 48px; align-items: center; justify-content: center; background: var(--bg-soft); }
.server-meta { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.server-meta strong { overflow-wrap: anywhere; }
.badge { font-size: .72rem; border-radius: 999px; padding: 1px 8px; width: fit-content; border: 1px solid var(--card-edge); }
.badge-owner { border-color: var(--accent); color: var(--accent); }

.checklist { padding-left: 20px; }
.tag-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tag { border: 1px solid var(--card-edge); border-radius: 999px; padding: 2px 10px; background: var(--bg-soft); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 8px;
  padding: 8px 14px; font: inherit; cursor: pointer; text-decoration: none; background: var(--card); color: var(--text);
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { border-color: var(--card-edge); background: transparent; }
.btn-danger { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn-small { padding: 4px 10px; font-size: .9rem; }
.btn-large { padding: 12px 20px; font-size: 1.05rem; }
.discord-glyph { width: 20px; height: 20px; }
form.is-busy .btn { opacity: .6; pointer-events: none; }

.lang-switch { display: inline-flex; border: 1px solid var(--card-edge); border-radius: 8px; overflow: hidden; }
.lang-switch button { background: transparent; color: var(--muted); border: 0; padding: 4px 10px; cursor: pointer; font: inherit; }
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.user-chip { display: inline-flex; align-items: center; gap: 8px; }
.user-chip img, .avatar-fallback { width: 28px; height: 28px; border-radius: 50%; }
.avatar-fallback { display: inline-flex; align-items: center; justify-content: center; background: var(--card); }

.field select, .field input[type="text"], .field input[type="search"], select, input[type="search"], input[type="text"] {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--card-edge); border-radius: 8px;
  padding: 7px 10px; font: inherit; max-width: 100%;
}
.inline-form, .multi-actions, .toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.multi-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row-remove, .chip-remove { background: transparent; color: var(--muted); border: 0; cursor: pointer; font-size: 1.1rem; }
.toggle { display: inline-flex; gap: 10px; align-items: flex-start; }
.toggle-text { display: flex; flex-direction: column; }
.toggle-text small { color: var(--muted); }

.chip-list, .grant-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.grant { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.role-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-soft); border: 1px solid var(--card-edge); border-radius: 999px; padding: 2px 10px; }
.role-chip small { color: var(--muted); }
.role-missing { border-style: dashed; color: var(--muted); }
.role-dot { width: 10px; height: 10px; }
.command-head p { color: var(--muted); }
.command-row[hidden] { display: none; }

.status { border: 1px solid var(--card-edge); border-radius: 999px; padding: 1px 10px; font-size: .85rem; }
.status-ok { border-color: var(--good); color: var(--good); }
.status-warning, .state-warn { border-color: var(--warn); color: var(--warn); }
.state { border: 1px solid var(--card-edge); border-radius: 999px; padding: 1px 10px; font-size: .85rem; }
.state-on { border-color: var(--good); color: var(--good); }

.fatal { display: grid; place-items: center; }
.fatal-card { max-width: 480px; margin: 20vh var(--gutter) 0; background: var(--card); border: 1px solid var(--card-edge); border-radius: var(--radius); padding: 20px; }

/* narrow screens: the rail becomes a strip above the page */
@media (max-width: 760px) {
  .shell { flex-direction: column; gap: 12px; }
  .rail { width: 100%; }
  .rail-nav { flex-direction: row; overflow-x: auto; }
  .rail-group { display: none; }
  .display { font-size: 1.6rem; }
}

/* settings pages of the second wave: number and time fields, text areas, tables, form grids */
input[type="number"], input[type="datetime-local"], textarea, .field input[type="number"], .field input[type="datetime-local"], .field textarea {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--card-edge); border-radius: 8px;
  padding: 7px 10px; font: inherit; max-width: 100%;
}
textarea { width: 100%; min-height: 4.5em; resize: vertical; }
input[type="number"] { width: 8em; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 16px; margin: 12px 0; }
.form-grid .field { display: flex; flex-direction: column; gap: 4px; }
.form-grid small, .field small { color: var(--muted); }
.data-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.data-table th, .data-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--card-edge); vertical-align: top; overflow-wrap: anywhere; }
.data-table th { color: var(--muted); font-weight: 600; }
.table-scroll { overflow-x: auto; }
.preview { background: var(--bg-soft); border: 1px dashed var(--card-edge); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.sub-card { border-top: 1px solid var(--card-edge); padding-top: 12px; margin-top: 12px; }

/* the economy and community pages: forms of several fields, previews, sub-cards */
.stack { display: grid; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-wide { width: 100%; }
.field small, .hint { color: var(--muted); }
.field-group { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); border: 1px solid var(--card-edge); border-radius: var(--radius); padding: 10px 12px; margin: 0; }
fieldset.field-group legend { color: var(--muted); font-size: .85rem; padding: 0 6px; }
textarea { background: var(--bg-soft); color: var(--text); border: 1px solid var(--card-edge); border-radius: 8px; padding: 7px 10px; font: inherit; width: 100%; max-width: 100%; box-sizing: border-box; resize: vertical; }
select[multiple] { background: var(--bg-soft); color: var(--text); border: 1px solid var(--card-edge); border-radius: 8px; padding: 4px; font: inherit; max-width: 100%; }
.sub-card { border: 1px solid var(--card-edge); border-radius: var(--radius); padding: 12px; margin-top: 12px; }
.sub-card > summary { cursor: pointer; }
.preview { background: var(--bg-soft); border-left: 4px solid var(--accent); border-radius: 6px; padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--card-edge); vertical-align: top; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.multi-form .multi-row .field { flex: 1; }
.rank-label { min-width: 5.5rem; white-space: nowrap; }
.multi-row .field-name { flex: 2; }

/* the button panel builder: the panel as Discord draws it, and the buttons in order */
.embed-preview { background: #2b2d31; color: #dbdee1; border-radius: var(--radius); padding: 12px; margin: 10px 0; max-width: 520px; }
.embed-box { display: flex; background: #232428; border-radius: 4px; overflow: hidden; }
.embed-bar { width: 4px; flex: none; align-self: stretch; height: auto; }
.embed-body { padding: 8px 12px; min-width: 0; }
.embed-title { margin: 0 0 4px; font-weight: 700; overflow-wrap: anywhere; }
.embed-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.discord-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.discord-button { border-radius: 4px; padding: 4px 14px; font-size: .9rem; color: #fff; background: #4e5058; overflow-wrap: anywhere; }
.discord-button-primary { background: #5865f2; }
.discord-button-success { background: #248046; }
.discord-button-danger { background: #da373c; }
.button-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid var(--card-edge); }
.button-order { color: var(--muted); min-width: 1.5em; }
.button-name { flex: 1; min-width: 12em; overflow-wrap: anywhere; }
.button-tools { display: inline-flex; gap: 6px; align-items: center; }
.button-edit { margin: 0 0 8px 1.5em; }

/* a colour as the browser's picker, and the list that puts a channel link into a text */
input[type="color"] { width: 64px; height: 40px; padding: 3px; border: 1px solid var(--card-edge); border-radius: 8px; background: var(--bg-soft); cursor: pointer; }
.channel-insert { max-width: 320px; }
.channel-insert[hidden] { display: none; }
