/* PlasmaForms - shared styles
   The accent colour comes from the staff settings and is injected as --accent / --accent-rgb by partials/head.ejs */

:root {
  --bg: #121318;
  --surface: #18191f;
  --surface-2: #1f2027;
  --inset: #0e0f13;
  --line: #26272f;
  --line-strong: #34353e;
  --text: #f1f3f7;
  --text-2: #b6b9c3;
  --text-3: #7c7f8a;
  --pending: #d9a33b;
  --accepted: #3fb36b;
  --denied: #e5534b;
  --radius: 6px;
  --radius-lg: 8px;
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text-2);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3, h4, strong { color: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[x-cloak] { display: none !important; }

::selection { background: rgba(var(--accent-rgb), 0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 2px solid var(--bg); }

.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--text-3); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.accent { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Top bar ---------- */

.topbar { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand img { height: 24px; width: auto; }
.nav { display: flex; align-items: stretch; gap: 22px; height: 100%; flex: 1; }
.nav a { display: flex; align-items: center; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .12s; }
.nav a:hover { color: var(--text); }
.nav a.is-current { color: var(--text); border-bottom-color: var(--accent); }

.usermenu { position: relative; }
.usermenu-btn { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 6px 8px; margin-right: -8px; border-radius: var(--radius); cursor: pointer; color: var(--text-2); }
.usermenu-btn:hover { background: var(--surface-2); }
.usermenu-btn .fa-chevron-down { font-size: 10px; color: var(--text-3); }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); flex-shrink: 0; object-fit: cover; }
.avatar-fallback { display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--text-2); border: 1px solid var(--line-strong); }
.usermenu-list { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); padding: 4px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); display: none; }
.usermenu.is-open .usermenu-list { display: block; }
.usermenu-list a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 4px; color: var(--text-2); }
.usermenu-list a:hover { background: var(--surface-2); color: var(--text); }
.usermenu-list i { width: 14px; text-align: center; color: var(--text-3); font-size: 12px; }
.usermenu-sep { height: 1px; background: var(--line); margin: 4px 0; }

.nav-toggle { display: none; background: none; border: 0; color: var(--text-2); padding: 6px; margin-left: auto; cursor: pointer; font-size: 16px; }

@media (max-width: 760px) {
  .topbar-inner { gap: 12px; padding: 0 16px; }
  .nav-toggle { display: block; margin-left: 0; }
  .usermenu { margin-left: auto; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 56px; flex-direction: column; gap: 0; height: auto; background: var(--bg); border-bottom: 1px solid var(--line); padding: 6px 16px 10px; }
  .topbar.is-open .nav { display: flex; }
  .nav a { padding: 10px 0; border-bottom: 0; margin: 0; }
  .nav a.is-current { color: var(--accent); }
  .usermenu-name { display: none; }
}

/* ---------- Page scaffolding ---------- */

.main { flex: 1; }
.page { max-width: 1120px; margin: 0 auto; padding: 36px 24px 72px; }
.page-narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-title { font-size: 22px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
.page-sub { color: var(--text-3); margin-top: 4px; }
.crumbs { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-3); margin-bottom: 14px; }
.crumbs a:hover { color: var(--text); }
.section { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title { font-size: 15px; font-weight: 600; }
.section-note { color: var(--text-3); font-size: 13px; }
@media (max-width: 760px) { .page { padding: 24px 16px 56px; } }

.footer { border-top: 1px solid var(--line); }
.footer-inner { max-width: 1120px; margin: 0 auto; padding: 18px 24px; font-size: 12.5px; color: var(--text-3); }

/* ---------- Panels ---------- */

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 50px; }
.panel-title { font-size: 14px; font-weight: 600; color: var(--text); }
.panel-desc { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.panel-body { padding: 16px; }
.panel-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-2 > .panel + .panel { margin-top: 0; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font-size: 13.5px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: background-color .12s, border-color .12s, color .12s; }
.btn:hover { background: #272830; border-color: #3f404a; }
.btn:focus-visible { outline: 2px solid rgba(var(--accent-rgb), .6); outline-offset: 2px; }
.btn i { font-size: 12px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.1); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-danger { color: var(--denied); }
.btn-danger:hover { background: rgba(229, 83, 75, .12); border-color: rgba(229, 83, 75, .4); color: var(--denied); }
.btn-success { color: var(--accepted); }
.btn-success:hover { background: rgba(63, 179, 107, .12); border-color: rgba(63, 179, 107, .4); color: var(--accepted); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn-block { width: 100%; }
.btn:disabled, .btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.btn-discord:hover { background: #4752c4; border-color: #4752c4; }

/* ---------- Form controls ---------- */

.field + .field { margin-top: 18px; }
.label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.label .req { color: var(--text-3); font-weight: 400; margin-left: 4px; }
.hint { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
.hint strong, .hint b { color: var(--text-2); font-weight: 500; }
.input, .textarea, .select {
  width: 100%;
  background: var(--inset);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.45;
  transition: border-color .12s, box-shadow .12s;
}
.input, .select { height: 36px; }
.textarea { min-height: 110px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: #5d606b; }
.input:hover, .textarea:hover, .select:hover { border-color: #43444f; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18); }
.input.is-error, .textarea.is-error { border-color: var(--denied); }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237c7f8a' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
input[type="color"].input { padding: 3px; width: 56px; cursor: pointer; }
input[type="file"].input { height: auto; padding: 6px; font-size: 13px; color: var(--text-3); }
input[type="file"].input::file-selector-button { background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); border-radius: 4px; padding: 4px 10px; margin-right: 10px; cursor: pointer; font: inherit; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text-2); user-select: none; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

/* ---------- Status ---------- */

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; color: var(--text-2); white-space: nowrap; text-transform: capitalize; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.status.pending::before { background: var(--pending); }
.status.accepted::before { background: var(--accepted); }
.status.denied::before { background: var(--denied); }
.status.pending { color: var(--pending); }
.status.accepted { color: var(--accepted); }
.status.denied { color: var(--denied); }

.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--text-2); white-space: nowrap; }

/* ---------- Tables & lists ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12.5px; font-weight: 500; color: var(--text-3); padding: 9px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-link { cursor: pointer; }
.table tbody tr.is-link:hover td { background: var(--surface-2); }
.table .cell-title { color: var(--text); font-weight: 500; }

.rows > li, .rows > .row { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-top: 1px solid var(--line); }
.rows > li:first-child, .rows > .row:first-child { border-top: 0; }

.empty { padding: 36px 16px; text-align: center; color: var(--text-3); }
.empty strong { display: block; color: var(--text-2); font-weight: 500; margin-bottom: 2px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; }
.kv dt { color: var(--text-3); }
.kv dd { color: var(--text); min-width: 0; overflow-wrap: anywhere; }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a, .tabs button { display: inline-flex; align-items: center; gap: 8px; padding: 10px 0; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--text-3); cursor: pointer; white-space: nowrap; font-weight: 500; }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs .is-active { color: var(--text); border-bottom-color: var(--accent); }
.count { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); background: var(--surface-2); border-radius: 4px; padding: 1px 6px; }

/* ---------- Notices ---------- */

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--text-2); font-size: 13.5px; }
.notice > i { margin-top: 3px; font-size: 13px; color: var(--text-3); }
.notice.is-error { border-color: rgba(229, 83, 75, .35); background: rgba(229, 83, 75, .07); }
.notice.is-error > i { color: var(--denied); }
.notice.is-warning > i { color: var(--pending); }
.notice ul { margin-top: 4px; padding-left: 16px; list-style: disc; }

/* ---------- Pagination ---------- */

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-3); }
.pager-links { display: flex; gap: 6px; }

/* ---------- Modal ---------- */

.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal.is-active { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 5, 8, .7); }
.modal-card { position: relative; width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); box-shadow: 0 16px 48px rgba(0, 0, 0, .5); }

/* ---------- Prose (form descriptions) ---------- */

.prose { color: var(--text-2); line-height: 1.65; white-space: pre-line; }
.prose strong { color: var(--text); font-weight: 600; }
.prose em { color: var(--text); }

/* ---------- Signed-out pages (login, errors) ---------- */

.solo { min-height: 100vh; display: flex; flex-direction: column; }
.solo-top { padding: 20px 24px; }
.solo-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px 96px; }
.solo-box { width: 100%; max-width: 380px; }
.solo-box.is-wide { max-width: 460px; }
.solo-title { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.solo-text { color: var(--text-3); margin-top: 6px; }
.solo-actions { margin-top: 24px; }
.solo-fine { font-size: 12.5px; color: var(--text-3); margin-top: 14px; }
.btn-ghost.btn-danger { color: var(--text-3); }
.btn-ghost.btn-danger:hover { color: var(--denied); background: rgba(229, 83, 75, .1); }

/* ---------- Staff form editor (create/edit) ---------- */

.fb-section { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; padding: 28px 0; border-top: 1px solid var(--line); }
.fb-section:first-of-type { border-top: 0; padding-top: 0; }
.fb-aside .section-note { display: block; margin-top: 4px; line-height: 1.5; }
@media (max-width: 860px) { .fb-section { grid-template-columns: 1fr; gap: 12px; } }

.q-edit { padding: 14px 16px; }
.q-edit + .q-edit { margin-top: 10px; }
.q-edit-row { display: flex; align-items: center; gap: 10px; }
.q-edit-num { color: var(--text-3); min-width: 22px; }
.q-edit-type { width: 180px; flex-shrink: 0; }
.q-edit-body { margin-left: 32px; }
.q-edit-body:empty { display: none; }
.q-edit-lengths { display: flex; gap: 12px; margin-top: 12px; }
.q-edit-lengths label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); white-space: nowrap; }
.q-edit-lengths .input { width: 96px; }
.q-option { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.q-option-dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #5d606b; flex-shrink: 0; }
.q-option .check { font-size: 13px; }
.q-option + .btn, .q-edit-body > div > .btn { margin-top: 8px; }
.q-edit-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 0 32px; padding-top: 10px; border-top: 1px solid var(--line); }
.q-edit-foot .check { font-size: 13px; }
.q-edit-tools { display: flex; gap: 2px; }
.q-bad { color: var(--denied); }
@media (max-width: 640px) {
  .q-edit-row { flex-wrap: wrap; }
  .q-edit-row .input { flex: 1 1 200px; }
  .q-edit-type { width: 100%; }
  .q-edit-body, .q-edit-foot { margin-left: 0; }
  .q-option { flex-wrap: wrap; }
  .q-option .input { flex: 1 1 160px; }
}

.fb-actions { position: sticky; bottom: 0; z-index: 20; display: flex; justify-content: flex-end; gap: 8px; padding: 14px 0; margin-top: 8px; border-top: 1px solid var(--line); background: var(--bg); }

/* select2, restyled to match .input */
.select2-container--default .select2-selection--multiple { background: var(--inset); border: 1px solid var(--line-strong); border-radius: var(--radius); min-height: 36px; padding: 2px 6px; cursor: text; }
.select2-container--default.select2-container--focus .select2-selection--multiple { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18); }
.select2-container--default .select2-selection--multiple .select2-selection__choice { background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 4px; color: var(--text); font-size: 12.5px; padding: 1px 8px 1px 22px; margin: 4px 4px 0 0; }
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove { color: var(--text-3); border-right: 1px solid var(--line-strong); padding: 0 5px; height: 100%; }
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover { background: transparent; color: var(--text); }
.select2-container--default .select2-selection--multiple .select2-selection__clear { color: var(--text-3); margin-top: 6px; margin-right: 4px; }
.select2-container .select2-search--inline .select2-search__field { color: var(--text); font-family: var(--font); font-size: 14px; margin-top: 6px; height: 20px; }
.select2-container .select2-search--inline .select2-search__field::placeholder { color: #5d606b; }
.select2-dropdown { background: var(--surface); border: 1px solid var(--line-strong) !important; border-radius: var(--radius) !important; overflow: hidden; color: var(--text-2); }
.select2-container--open .select2-dropdown--below { margin-top: 4px; }
.select2-results__option { padding: 7px 10px; font-size: 13.5px; }
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable { background: var(--surface-2); color: var(--text); }
.select2-container--default .select2-results__option--selected { background: transparent; color: var(--accent); }
.select2-container--default .select2-results__option--selected::after { content: ' ✓'; }
