:root {
  --bg: #000000;
  --surface: #0a0a0a;
  --border: #2a2f38;
  --text: #e9eef7;
  --muted: #8fa3c4;
  --accent: #3d7dd6;
  --accent-hover: #5590e0;
  --gold: #c9a227;
  --ok: #3d9e6d;
  --bad: #d14b4b;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

/* Ensure [hidden] always wins over component display rules (e.g. .rating-row flex). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand__mark {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.brand__tag {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-row label {
  font-size: 0.85rem;
  color: var(--muted);
}

select#exam-profile {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
}

.panel {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem;
}

.lede {
  font-size: 1rem;
  color: var(--muted);
}

.lede code {
  font-size: 0.85em;
  background: var(--surface);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--gold);
}

.hint {
  color: var(--gold);
  font-size: 0.95rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 1.5rem;
}

.contact-admin-panel {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.contact-admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 32rem;
}

.contact-admin-form textarea {
  width: 100%;
  min-height: 6rem;
  resize: vertical;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.cat-card {
  text-align: left;
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.cat-card:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.cat-card:disabled,
.cat-card--empty {
  opacity: 0.45;
  cursor: not-allowed;
}

.cat-card__title {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
}

.cat-card__meta {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.q-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.q-list li {
  margin: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.linklike {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
  padding: 0.4rem 0;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-top: 0.5rem;
}

.stem {
  font-size: 1.05rem;
  margin: 0 0 1rem;
}

/* ----- FAA Written Exam: question prominence (faa-written.html) ----- */

body.faa-written .quiz-card .stem {
  font-size: clamp(1.09rem, 2.8vw, 1.22rem);
  line-height: 1.52;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #f4f8ff;
}

/* When figures are visible, make the stem clearly larger than choices and the diagram area */
body.faa-written .quiz-card:has(.figure-stack:not([hidden])) .stem {
  font-size: clamp(1.28rem, 4.5vw, 1.62rem);
  line-height: 1.42;
  font-weight: 700;
  letter-spacing: 0.015em;
  margin: 0 0 0.95rem;
  padding: 0.55rem 0 1rem;
  border-bottom: 1px solid var(--border);
  color: #fff;
}

body.faa-written .quiz-card:has(.figure-stack:not([hidden])) .figure-stack {
  margin-top: 0.15rem;
  margin-bottom: 1.05rem;
}

body.faa-written .quiz-card:has(.figure-stack:not([hidden])) .choices {
  margin-top: 0.35rem;
}

body.faa-written .quiz-card:has(.figure-stack:not([hidden])) .choice {
  font-size: clamp(0.93rem, 2.55vw, 1.03rem);
  font-weight: 500;
  line-height: 1.38;
  padding: 0.62rem 0.92rem;
}

.figure {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.figure-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.figure-stack .figure {
  margin-bottom: 0;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.choice {
  text-align: left;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #12161c;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.choice:hover:not(:disabled) {
  border-color: var(--accent);
}

.choice:disabled {
  cursor: default;
  opacity: 0.95;
}

.choice--correct {
  border-color: var(--ok);
  background: rgba(61, 158, 109, 0.18);
}

.choice--wrong {
  border-color: var(--bad);
  background: rgba(209, 75, 75, 0.15);
}

.choice--selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.feedback {
  margin: 1rem 0 0;
  font-weight: 500;
}

.explanation {
  margin-top: 0.75rem;
  padding: 0.85rem;
  background: rgba(61, 125, 214, 0.12);
  border-radius: 8px;
  font-size: 0.95rem;
  color: #c8d8f0;
}

.rating-row {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.rating-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.study-actions {
  margin-top: 1.25rem;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--muted);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.exam-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.exam-title {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gold);
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.exam-submit {
  margin-top: 1rem;
  width: 100%;
}

.result-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
}

.result-flag {
  font-size: 1.25rem;
  font-weight: 700;
}

.result-flag.pass {
  color: var(--ok);
}

.result-flag.fail {
  color: var(--bad);
}

.fineprint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-panel {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
}

.login-title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.25rem;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.login-form input[type="text"],
.login-form input[type="password"],
.admin-form input,
.admin-form textarea,
.admin-form select {
  background: #12161c;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: inherit;
}

.login-form input:focus,
.admin-form input:focus,
.admin-form textarea:focus,
.admin-form select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-error {
  color: var(--bad);
  font-size: 0.9rem;
  margin: 0;
}

.btn.wide {
  width: 100%;
}

.text-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 0.9rem;
}

.user-greet {
  font-size: 0.85rem;
  color: var(--muted);
}

.admin-layout {
  max-width: 1100px;
}

.admin-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.admin-tabs button {
  cursor: pointer;
}

.admin-tabs button.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.admin-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-toolbar input,
.admin-toolbar select {
  min-width: 12rem;
  background: #12161c;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  font: inherit;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
}

.data-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.data-table button.linklike {
  padding: 0;
}

.pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
}

.pill.bad {
  border-color: var(--bad);
  color: var(--bad);
}

.pill.ok {
  border-color: var(--ok);
  color: var(--ok);
}

.admin-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 900px) {
  .admin-split {
    grid-template-columns: 1fr;
  }
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.admin-form .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.admin-form textarea {
  min-height: 4.5rem;
  resize: vertical;
}

.figure-preview {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ----- Global header layout ----- */

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem 1rem;
}

.header-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
}

.nav-pill {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: 0.82rem;
  color: var(--muted);
}

.nav-pill:hover {
  color: var(--accent);
  border-color: rgba(61, 125, 214, 0.45);
}

.topbar--stacked {
  flex-direction: column;
  align-items: stretch;
}

.topbar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.topbar__row--secondary {
  padding-top: 0.65rem;
  margin-top: 0.35rem;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.exam-profile-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: 0.5rem;
}

#head-user-slot {
  flex-shrink: 0;
}

/* Account dropdown */
.acct-menu {
  position: relative;
}

.acct-menu__summary {
  list-style: none;
  cursor: pointer;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
}

.acct-menu__summary::-webkit-details-marker {
  display: none;
}

.acct-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #080c14;
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.55);
  z-index: 50;
}

.acct-menu__muted {
  font-size: 0.76rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  word-break: break-all;
}

.acct-menu__link {
  display: block;
  padding: 0.45rem 0.35rem;
  color: var(--accent);
}

.acct-menu__btn {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.acct-menu__btn:hover {
  border-color: var(--bad);
  color: var(--bad);
}

/* Profile page */
.profile-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1rem 0;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.profile-field input {
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #12161c;
  color: var(--text);
  font: inherit;
}

.profile-readonly-card {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px dashed rgba(143, 163, 196, 0.35);
}

.profile-lede {
  margin-top: 0.25rem;
}

/* ----- Admin editor (organized) ----- */

.admin-q-shell {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.admin-q-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 960px) {
  .admin-q-grid {
    grid-template-columns: 1fr;
  }
}

.admin-fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem 1rem;
  margin: 0;
  background: rgba(10, 10, 10, 0.45);
}

.admin-fieldset legend {
  padding: 0 0.35rem;
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.admin-field-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 700px) {
  .admin-field-two {
    grid-template-columns: 1fr;
  }
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-form label.row-inline {
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-hint-inline {
  font-size: 0.78rem;
  color: var(--muted);
  margin: -0.2rem 0 0.4rem;
}

.figure-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.65rem;
  min-height: 3rem;
}


.figure-tile {
  width: calc(33.333% - 8px);
  min-width: 140px;
  max-width: 220px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #0c1018;
  display: flex;
  flex-direction: column;
}

.figure-tile img {
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: #05070a;
  border-bottom: 1px solid var(--border);
}

.figure-tile__path {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.4rem 0.5rem;
  word-break: break-all;
  font-family: ui-monospace, monospace;
}

.figure-tile__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem;
  border-top: 1px solid var(--border);
}

.figure-upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.login-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 4rem;
  background: #12161c;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem;
  font: inherit;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.module-tile {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1.1rem 1.2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, background 0.12s;
  min-height: 110px;
  position: relative;
}

.module-tile:hover:not(.module-tile--soon) {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.module-tile__title {
  font-weight: 700;
  font-size: 1.05rem;
}

.module-tile__meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.module-tile__stat {
  margin-top: auto;
  font-size: 0.82rem;
  color: var(--gold);
}

.module-tile--soon {
  opacity: 0.55;
  cursor: not-allowed;
}

.module-tile__badge {
  align-self: flex-start;
  margin-top: auto;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px solid var(--border);
  background: rgba(143, 163, 196, 0.08);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.module-tile__badge--admin {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(201, 162, 39, 0.08);
}

.module-tile--admin {
  border-color: var(--gold);
}

/* ---------- Stat tiles (statistics page) ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin: 0.5rem 0 1rem;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  text-align: center;
}

.stat-tile__value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
}

.stat-tile__label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* ---------- FAA module home extras ---------- */

.card-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 1rem 0 1.25rem;
}

.goal-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin: 0.5rem 0 0.25rem;
}

.goal-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.goal-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 2.5rem;
  text-align: right;
}

#daily-goal-input {
  flex: 1 1 240px;
  accent-color: var(--accent);
}

/* ---------- Recall rating buttons ---------- */

.rating-btn--forgot {
  border-color: var(--bad);
  color: #f4b3b3;
}

.rating-btn--forgot:hover {
  background: rgba(209, 75, 75, 0.15);
}

.rating-btn--recalled {
  border-color: var(--gold);
  color: #ebd28a;
}

.rating-btn--recalled:hover {
  background: rgba(201, 162, 39, 0.15);
}

.rating-btn--remembered {
  border-color: var(--ok);
  color: #abe2c4;
}

.rating-btn--remembered:hover {
  background: rgba(61, 158, 109, 0.15);
}

/* ---------- Misc ---------- */

.btn-danger {
  border-color: var(--bad);
  color: #f4b3b3;
}

.btn-danger:hover {
  background: rgba(209, 75, 75, 0.15);
}
