:root {
  color-scheme: dark;
  --bg: #050506;
  --bg-deep: #020203;
  --surface-1: rgba(16, 16, 19, .86);
  --surface-2: rgba(22, 21, 25, .88);
  --line: rgba(255, 255, 255, .085);
  --line-red: rgba(255, 49, 72, .28);
  --text: #f7f7f8;
  --muted: #969199;
  --red: #ff304f;
  --red-bright: #ff5a70;
  --red-dark: #96152a;
  --red-soft: rgba(255, 48, 79, .1);
  --shadow-xs: 0 1px 0 rgba(255, 255, 255, .035) inset;
  --radius-md: 14px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(ellipse at 76% -15%, rgba(225, 18, 49, .15), transparent 35%),
    radial-gradient(ellipse at 10% 110%, rgba(120, 12, 31, .09), transparent 32%),
    linear-gradient(145deg, #08080a 0%, #040405 58%, #0a0507 100%);
  font-family: "Segoe UI Variable", Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
.hidden { display: none !important; }

.ambient { position: fixed; border-radius: 50%; filter: blur(90px); opacity: .16; pointer-events: none; z-index: -1; }
.ambient-one { width: 340px; height: 340px; background: #ff1838; top: -170px; right: 10%; }
.ambient-two { width: 260px; height: 260px; background: #761226; bottom: -100px; left: 22%; }

.state-screen {
  position: fixed; inset: 0; z-index: 900;
  display: grid; place-items: center; justify-items: center; gap: 12px;
  text-align: center; padding: 24px;
}
.state-screen h2 { margin: 0; font-size: 18px; }
.state-screen p { margin: 0; color: var(--muted); max-width: 320px; line-height: 1.6; font-size: 13px; }
.state-icon { font-size: 40px; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--red-bright);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.brand-mark {
  width: 56px; height: 56px; display: grid; place-items: center; border-radius: 14px;
  font-weight: 900; font-size: 22px; color: #fff;
  background: linear-gradient(145deg, var(--red-bright), var(--red-dark));
  box-shadow: 0 12px 32px rgba(255, 38, 70, .32), inset 0 1px rgba(255,255,255,.25);
}

.project-hub {
  position: fixed; inset: 0; z-index: 900;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(255, 48, 79, .1), transparent),
    var(--bg-deep);
}
.project-hub-screen { width: 100%; max-width: 520px; }
.project-hub-screen.hidden { display: none; }
.project-hub-brand { text-align: center; margin-bottom: 34px; }
.project-hub-brand .brand-mark { margin: 0 auto 18px; }
.project-hub-brand h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: -.01em; }
.project-hub-brand p { margin: 0; color: var(--muted); font-size: 13px; }
.project-cards { display: grid; gap: 12px; }
.project-card {
  display: flex; align-items: center; gap: 16px; width: 100%;
  padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface-1); box-shadow: var(--shadow-xs);
  color: var(--text); text-align: left; cursor: pointer;
  transition: border-color .16s ease, transform .16s ease, background-color .16s ease;
}
.project-card:hover { border-color: var(--line-red); background: var(--surface-2); transform: translateY(-1px); }
.project-card-icon {
  flex: none; width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 12px; background: var(--red-soft); font-size: 22px;
}
.project-card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.project-card-body b { font-size: 15px; }
.project-card-body span { color: var(--muted); font-size: 12px; }
.project-stub { text-align: center; display: grid; justify-items: center; gap: 10px; }
.project-stub .state-icon { font-size: 40px; }
.project-stub h2 { margin: 0; font-size: 18px; }
.project-stub p { margin: 0 0 8px; color: var(--muted); max-width: 360px; line-height: 1.6; }
.secondary-button {
  border: 1px solid var(--line); background: var(--surface-1); color: var(--text);
  border-radius: 10px; padding: 10px 16px; cursor: pointer; font-size: 13px;
}
.secondary-button:hover { border-color: var(--line-red); }

* { scrollbar-color: #40383c transparent; scrollbar-width: thin; }
::selection { color: #fff; background: rgba(255, 48, 79, .48); }

/* -------------------------------------------------------------------- */
/* Settings entry point                                                  */
/* -------------------------------------------------------------------- */

.settings-gear-btn {
  position: fixed; top: max(16px, env(safe-area-inset-top)); right: 16px; z-index: 950;
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-1); color: var(--muted); cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: border-color .16s ease, color .16s ease, transform .16s ease;
}
.settings-gear-btn:hover { border-color: var(--line-red); color: var(--text); transform: rotate(20deg); }

/* -------------------------------------------------------------------- */
/* Settings view                                                         */
/* -------------------------------------------------------------------- */

.settings-view {
  position: fixed; inset: 0; z-index: 940; overflow-y: auto;
  background: var(--bg-deep);
  padding: max(16px, env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
}
.settings-header {
  display: flex; align-items: center; gap: 12px; margin: 4px 0 18px;
}
.settings-header h1 { flex: 1; font-size: 18px; margin: 0; text-align: center; }
.back-btn {
  display: flex; align-items: center; gap: 4px; border: none; background: none;
  color: var(--muted); cursor: pointer; font-size: 13px; padding: 6px 4px;
}
.back-btn:hover { color: var(--text); }

.role-badge {
  --role-color: #71717a;
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .01em; white-space: nowrap;
  color: var(--role-color);
  background: color-mix(in srgb, var(--role-color) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--role-color) 40%, transparent);
}

.settings-tabs {
  display: flex; gap: 6px; padding: 4px; margin-bottom: 18px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-1);
}
.settings-tab {
  flex: 1; border: none; background: none; color: var(--muted); cursor: pointer;
  padding: 9px 10px; border-radius: 9px; font-size: 13px; font-weight: 600;
  transition: background-color .16s ease, color .16s ease;
}
.settings-tab.active { background: var(--red-soft); color: var(--red-bright); }

.settings-tab-panel { max-width: 640px; margin: 0 auto; }
.settings-toolbar {
  display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px;
}
.settings-hint { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; }

.primary-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-red); border-radius: 10px; padding: 10px 16px;
  background: linear-gradient(145deg, var(--red-bright), var(--red-dark)); color: #fff;
  font-size: 13px; font-weight: 700; cursor: pointer;
  box-shadow: 0 10px 24px rgba(255, 38, 70, .28);
  transition: transform .14s ease, box-shadow .14s ease;
}
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(255, 38, 70, .36); }
.primary-button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.danger-button {
  border: 1px solid rgba(255, 48, 79, .4); border-radius: 10px; padding: 10px 16px;
  background: rgba(255, 48, 79, .12); color: var(--red-bright);
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.danger-button:hover { background: rgba(255, 48, 79, .2); }

/* -------------------------------------------------------------------- */
/* Admins list                                                           */
/* -------------------------------------------------------------------- */

.admins-list { display: grid; gap: 10px; }
.admin-card {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface-1); box-shadow: var(--shadow-xs);
}
.admin-card-inactive { opacity: .58; }
.admin-card-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.admin-card-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.admin-card-name b { font-size: 14.5px; }
.admin-card-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 12px; }
.status-badge {
  display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
}
.status-inactive { background: rgba(255, 255, 255, .08); color: var(--muted); }

.project-chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.project-chip {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.project-chip-all { color: var(--red-bright); border-color: var(--line-red); background: var(--red-soft); }
.project-chip-empty { color: var(--muted); font-style: italic; }

.admin-card-actions { display: flex; gap: 6px; flex: none; }
.icon-button {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2);
  color: var(--muted); cursor: pointer; transition: border-color .14s ease, color .14s ease;
}
.icon-button:hover { border-color: var(--line-red); color: var(--text); }
.icon-button-danger:hover { color: var(--red-bright); border-color: var(--line-red); }
.icon-button:disabled { opacity: .35; cursor: not-allowed; }
.icon-button:disabled:hover { border-color: var(--line); color: var(--muted); }

/* -------------------------------------------------------------------- */
/* Modals                                                                 */
/* -------------------------------------------------------------------- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 980; display: grid; place-items: center;
  padding: 20px; background: rgba(3, 2, 3, .68); backdrop-filter: blur(6px);
}
.modal-card {
  width: 100%; max-width: 440px; max-height: calc(100svh - 40px); overflow-y: auto;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface-2);
  padding: 22px; box-shadow: 0 30px 70px rgba(0, 0, 0, .5);
  animation: modal-in .18s ease;
}
.modal-card-sm { max-width: 380px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-close {
  border: none; background: none; color: var(--muted); font-size: 15px; cursor: pointer;
  width: 28px; height: 28px; border-radius: 8px;
}
.modal-close:hover { background: var(--surface-1); color: var(--text); }
.modal-text { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 18px; }

.modal-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.field > span i { font-style: normal; opacity: .7; }
.field input, .field select {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: var(--surface-1); color: var(--text); font-size: 14px; font-family: inherit;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--line-red); }
.field input:disabled { opacity: .55; }

.project-checkbox-list { display: grid; gap: 8px; max-height: 180px; overflow-y: auto; padding-right: 2px; }
.checkbox-item {
  display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; cursor: pointer;
  background: var(--surface-1);
}
.checkbox-item input { accent-color: var(--red-bright); width: 16px; height: 16px; }

.form-error {
  margin: 0; padding: 9px 12px; border-radius: 9px; font-size: 12.5px;
  background: rgba(255, 48, 79, .12); border: 1px solid rgba(255, 48, 79, .35); color: var(--red-bright);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* -------------------------------------------------------------------- */
/* Toasts                                                                 */
/* -------------------------------------------------------------------- */

.toast-host {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 999;
  transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(92vw, 380px);
}
.toast {
  padding: 11px 18px; border-radius: 999px; font-size: 13px; font-weight: 600; text-align: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
  opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease;
}
.toast-visible { opacity: 1; transform: none; }
.toast-error { border-color: rgba(255, 48, 79, .4); color: var(--red-bright); }

/* -------------------------------------------------------------------- */
/* Role documentation                                                     */
/* -------------------------------------------------------------------- */

.roles-docs { display: grid; gap: 12px; max-width: 640px; margin: 0 auto; }
.role-doc-card {
  --role-color: #71717a;
  border: 1px solid var(--line); border-left: 3px solid var(--role-color);
  border-radius: var(--radius-md); background: var(--surface-1); padding: 16px 18px;
}
.role-doc-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.role-doc-head p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.role-doc-toggle {
  display: inline-flex; align-items: center; gap: 6px; border: none; background: none;
  color: var(--role-color); font-size: 12.5px; font-weight: 700; cursor: pointer; padding: 2px 0;
}
.role-doc-toggle svg { transition: transform .16s ease; }
.role-doc-toggle-open svg { transform: rotate(180deg); }
.role-doc-details { margin-top: 12px; display: grid; gap: 12px; }
.role-doc-section h4 { margin: 0 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.role-doc-section ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; line-height: 1.5; }
.role-doc-none { margin: 0; color: var(--muted); font-size: 12.5px; }
