/* ---------------- Shared shell (main.js) ---------------- */

#root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-bare {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.is-busy {
  opacity: 0.7;
  cursor: progress !important;
}

.topbar-app {
  flex-wrap: wrap;
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
  order: 3;
  flex: 1 1 100%;
}

.topbar-app .topbar-right {
  margin-left: auto;
}

.topnav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
}

.topnav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.topnav a.active {
  color: var(--text);
  background: rgba(43, 142, 224, 0.2);
}

.bell {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-decoration: none;
  flex: none;
}

.bell:hover {
  background: rgba(255, 255, 255, 0.16);
}

.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
}

/* The player has its own top bar (see play.js). */
body.is-player .topbar-app {
  display: none;
}

@media (max-width: 760px) {
  .topbar-app {
    padding: 12px 16px;
    row-gap: 10px;
  }

  .topnav {
    order: 3;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
}

/* ---------------- Public (sign-in, forgot, reset, register) ---------------- */

.auth-shell {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.auth-shell .login-card {
  max-width: 440px;
}

.login-card .lead {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.login-card h1 + .muted {
  margin-bottom: 22px;
}

.login-card .brand {
  text-decoration: none;
  color: inherit;
}

.login-card form {
  margin-top: 4px;
}

.field-hint {
  margin: -8px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--danger);
}

input[type="checkbox"],
input[type="radio"] {
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
  accent-color: var(--primary-bright);
}

textarea,
select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(4, 12, 24, 0.55);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.5;
}

select option {
  background: var(--bg-1);
  color: var(--text);
}

textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-bright);
  box-shadow: 0 0 0 4px rgba(43, 142, 224, 0.2);
  background: rgba(4, 12, 24, 0.8);
}

textarea::placeholder {
  color: rgba(147, 169, 194, 0.6);
}

label.check-row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 18px;
  font-size: 0.9rem;
}

.auth-links a {
  color: var(--primary-bright);
  text-decoration: none;
  font-weight: 600;
}

.auth-links a:hover {
  text-decoration: underline;
}

.btn-link {
  padding: 4px 0;
  background: none;
  border: none;
  color: var(--primary-bright);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
}

.btn-link:hover:not(:disabled) {
  text-decoration: underline;
}

.btn-link:disabled {
  color: var(--muted);
  text-decoration: none;
}

.turnstile-slot {
  display: flex;
  justify-content: center;
  min-height: 65px;
}

.hp-field {
  position: absolute !important;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.otp-input {
  letter-spacing: 0.45em;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  text-indent: 0.45em;
}

.success-mark {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(95, 211, 154, 0.14);
  border: 1px solid rgba(95, 211, 154, 0.45);
  color: #7fe3b3;
  margin-bottom: 18px;
}

.success-mark svg {
  width: 24px;
  height: 24px;
}

.notice-box {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(43, 142, 224, 0.12);
  border: 1px solid rgba(43, 142, 224, 0.4);
  font-size: 0.92rem;
  line-height: 1.5;
}

.legal-links a:focus-visible,
.auth-links a:focus-visible,
.topnav a:focus-visible,
.back-link:focus-visible,
.brand:focus-visible,
.bell:focus-visible,
a.btn-ghost:focus-visible,
.btn-link:focus-visible,
.game-card a:focus-visible {
  outline: 2px solid var(--primary-bright);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------------- Pages (library, profile, notifications, report) ---------------- */

.dashboard.narrow {
  max-width: 760px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 14px 20px;
}

.dashboard .lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
  max-width: 640px;
}

.dashboard > .muted {
  margin-bottom: 0;
}

.panel {
  margin-top: 28px;
  padding: 26px 24px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.panel > .muted {
  margin-bottom: 18px;
}

.panel form {
  gap: 14px;
}

.panel-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
  margin-top: 28px;
}

.panel-split + .panel-split {
  margin-top: 22px;
}

.panel-split > .panel {
  margin-top: 0;
}

.panel .error {
  margin-top: 0;
}

.panel .btn-primary {
  margin-top: 4px;
}

.btn-primary.btn-inline {
  align-self: flex-start;
  padding: 12px 22px;
}

.btn-danger {
  padding: 9px 16px;
  color: #fff;
  background: #a31a2a;
  font-size: 0.9rem;
  font-weight: 600;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.85rem;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.stat {
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
}

.stat-value {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  display: block;
  margin-top: 4px;
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
}

.chip-progress {
  color: #9fd2ff;
  border-color: rgba(43, 142, 224, 0.55);
  background: rgba(43, 142, 224, 0.16);
}

.chip-done {
  color: #7fe3b3;
  border-color: rgba(95, 211, 154, 0.5);
  background: rgba(95, 211, 154, 0.14);
}

.chip-alert {
  color: #ffc9c9;
  border-color: rgba(255, 107, 107, 0.5);
  background: rgba(255, 107, 107, 0.12);
}

/* ---------------- Library cards ---------------- */

.game-cover img.glyph-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
}

.game-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.game-body .game-subtitle {
  margin: -4px 0 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
}

.game-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 6px 0 2px;
  padding: 12px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.game-stats dt {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.game-stats dd {
  margin: 3px 0 0;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.game-actions .btn-play {
  margin-top: 0;
  flex: 1 1 140px;
}

.game-actions .btn-ghost {
  flex: 1 1 150px;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}

.game-actions .btn-ghost.is-done {
  color: #7fe3b3;
  border-color: rgba(95, 211, 154, 0.45);
}

/* ---------------- Player top bar (play.js) ---------------- */

.player-topbar {
  display: flex;
  align-items: center;
  gap: 12px 16px;
  flex-wrap: wrap;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(5, 13, 24, 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.player-topbar .player-title {
  flex: 1 1 200px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

a.btn-primary,
a.btn-ghost,
.player-topbar .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

.player-page {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.player-page .player-wrap {
  min-height: 0;
  padding: 16px;
}

@media (max-width: 640px) {
  .player-topbar {
    padding: 12px 14px;
  }

  .player-page .player-wrap {
    padding: 10px;
  }
}

.player-notice {
  margin: auto;
  max-width: 460px;
  padding: 32px 28px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.player-notice h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.player-notice p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------------- Notifications ---------------- */

.notice-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.notice-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 12px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
}

.notice-item.is-unread {
  border-color: rgba(43, 142, 224, 0.5);
  background: rgba(43, 142, 224, 0.09);
}

.notice-dot {
  width: 9px;
  height: 9px;
  margin-top: 7px;
  border-radius: 50%;
  background: transparent;
}

.notice-item.is-unread .notice-dot {
  background: var(--primary-bright);
  box-shadow: 0 0 0 4px rgba(43, 142, 224, 0.2);
}

.notice-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.notice-item.is-read .notice-title {
  font-weight: 500;
  color: var(--text);
}

.notice-body {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.notice-date {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.notice-list-modal {
  max-height: 60vh;
  overflow: auto;
  padding-right: 4px;
}

/* ---------------- Profile ---------------- */

.kv {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin: 0;
}

.kv div {
  min-width: 0;
}

.kv dt {
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.kv dd {
  margin: 4px 0 0;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.issue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.issue-item {
  padding: 14px 16px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: rgba(4, 12, 24, 0.35);
}

.issue-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.issue-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  overflow-wrap: anywhere;
  min-width: 0;
}

.issue-meta {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.issue-note {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--primary-bright);
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

fieldset {
  margin: 0;
  padding: 0;
  border: none;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

legend {
  padding: 0;
  margin-bottom: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-transform: uppercase;
}

label.radio-row {
  flex: 1 1 110px;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(4, 12, 24, 0.55);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

label.radio-row:has(input:checked) {
  border-color: var(--primary-bright);
  background: rgba(43, 142, 224, 0.16);
}

label.radio-row:has(input:focus-visible) {
  box-shadow: 0 0 0 4px rgba(43, 142, 224, 0.25);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.form-actions .btn-primary {
  margin-top: 0;
}

.muted-small {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------------- Toasts and modal (ui.js) ---------------- */

#toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: #0c2540;
  border: 1px solid rgba(43, 142, 224, 0.5);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  font-size: 0.92rem;
  line-height: 1.4;
  animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.toast-success {
  border-color: rgba(95, 211, 154, 0.6);
}

.toast-error {
  border-color: rgba(255, 107, 107, 0.7);
  color: #ffd6d6;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 8, 16, 0.68);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal {
  width: min(480px, 100%);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: #0a1f38;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.modal-wide {
  width: min(680px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.modal-body {
  padding: 18px 20px 20px;
  overflow: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions .btn-ghost,
.modal-actions .btn-primary {
  margin-top: 0;
}

/* ---------------- Small screens ---------------- */

@media (max-width: 640px) {
  .auth-shell {
    padding: 24px 14px;
  }

  .auth-shell .login-card {
    padding: 26px 20px 20px;
  }

  .turnstile-slot {
    zoom: 0.9;
  }

  .form-row,
  .panel-split {
    grid-template-columns: 1fr;
    margin-top: 22px;
  }

  .panel {
    padding: 20px 18px;
  }

  .game-actions .btn-play,
  .game-actions .btn-ghost {
    flex-basis: 100%;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .kv {
    grid-template-columns: 1fr;
  }

  .otp-input {
    font-size: 1.35rem;
  }

  .modal-overlay {
    padding: 12px;
  }
}

@media (min-width: 641px) {
  .kv {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------------- Screen-reader only ---------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- Library: search and topics ---------------- */

.library-toolbar {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.search-field {
  position: relative;
}

.search-field input[type="search"] {
  padding-left: 44px;
  padding-right: 84px;
}

.search-field input[type="search"]::-webkit-search-cancel-button,
.search-field input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  display: none;
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  color: var(--muted);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.85rem;
}

.search-clear:hover {
  background: rgba(255, 255, 255, 0.16);
}

.search-hint {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 7px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  pointer-events: none;
}

.search-field:focus-within .search-hint,
.search-field:has(.search-clear:not([hidden])) .search-hint {
  display: none;
}

@media (pointer: coarse) {
  .search-hint {
    display: none;
  }
}

.topic-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.topic-chip:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.topic-chip[aria-pressed="true"] {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary-bright), var(--primary));
  box-shadow: 0 8px 18px var(--primary-glow);
}

.topic-chip:focus-visible,
.topic-toggle:focus-visible,
.topic-section a:focus-visible {
  outline: 2px solid var(--primary-bright);
  outline-offset: 3px;
}

.topic-chip-count {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.library-status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.topic-sections {
  display: grid;
}

.topic-section {
  margin-top: 26px;
}

.topic-heading {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.topic-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0;
  background: none;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: left;
}

.topic-toggle:hover .topic-name {
  color: var(--primary-bright);
}

.topic-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.topic-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.topic-caret {
  display: inline-grid;
  color: var(--muted);
  transition: transform 0.2s;
}

.topic-section.is-collapsed .topic-caret {
  transform: rotate(-90deg);
}

.topic-grid {
  margin-top: 18px;
}

.topic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.topic-tag {
  display: inline-flex;
  max-width: 100%;
  padding: 3px 9px;
  border: 1px solid rgba(43, 142, 224, 0.35);
  border-radius: 999px;
  background: rgba(43, 142, 224, 0.12);
  color: #bfe3ff;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.library-empty-text {
  margin: 0 0 14px;
  color: var(--text);
}

/* ---------------- Terms & Conditions: gate and page ---------------- */

.topbar-gate {
  flex-wrap: wrap;
}

.terms-gate {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  padding: 24px 20px 32px;
}

.terms-dialog {
  width: min(760px, 100%);
  max-height: calc(100vh - 150px);
  max-height: calc(100dvh - 150px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0a1f38;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.terms-head {
  flex: none;
  padding: 20px 24px 0;
}

.terms-head h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}

.terms-head h1:focus {
  outline: none;
}

.terms-summary {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 46vh;
  overflow: auto;
  padding: 14px 24px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.terms-summary p,
.terms-body p {
  margin: 0 0 12px;
  color: #cfdcea;
  font-size: 0.93rem;
  line-height: 1.6;
}

.terms-headline {
  margin: 0 0 8px;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.terms-list,
.terms-policies {
  margin: 0 0 12px;
  padding-left: 20px;
  color: #cfdcea;
  font-size: 0.93rem;
  line-height: 1.6;
}

.terms-list li,
.terms-policies li {
  margin-bottom: 4px;
}

.terms-policies a,
.terms-summary a,
.terms-body a,
.terms-line a {
  color: var(--primary-bright);
  font-weight: 600;
}

.terms-scroll {
  flex: 1 1 auto;
  min-height: 120px;
  overflow: auto;
  padding: 16px 24px 12px;
  -webkit-overflow-scrolling: touch;
}

.terms-scroll:focus-visible {
  outline: 2px solid var(--primary-bright);
  outline-offset: -2px;
}

.terms-title {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.terms-section h3 {
  margin: 18px 0 6px;
  font-size: 1rem;
}

.terms-foot {
  flex: none;
  display: grid;
  gap: 14px;
  padding: 16px 24px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(4, 12, 24, 0.35);
}

.terms-check {
  align-items: flex-start;
  font-size: 0.92rem;
  line-height: 1.45;
}

.terms-check input[type="checkbox"] {
  margin-top: 2px;
}

.terms-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.terms-actions .btn-primary,
.terms-actions .btn-ghost {
  margin-top: 0;
}

.terms-page {
  max-width: 760px;
}

.terms-page .terms-body {
  margin-top: 22px;
}

.terms-page .terms-body-full {
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

@media (max-width: 640px) {
  .terms-gate {
    padding: 12px 10px 16px;
  }

  .terms-dialog {
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
  }

  .terms-head,
  .terms-summary,
  .terms-scroll,
  .terms-foot {
    padding-left: 18px;
    padding-right: 18px;
  }

  .terms-actions .btn-primary,
  .terms-actions .btn-ghost {
    flex: 1 1 100%;
  }

  .topic-toggle {
    font-size: 1rem;
  }
}
