/* ---------------------------------------------------------------------------
   Theme: black & gold, white text, blue as the secondary accent.
   --------------------------------------------------------------------------- */
:root {
  color-scheme: dark;

  --bg: #0a0a0c;
  --bg-2: #101014;
  --surface: #15151a;
  --surface-2: #1d1d24;
  --surface-3: #26262e;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f6f3ec;
  --muted: #9a9aa8;

  --gold: #d4af37;
  --gold-2: #f3d67a;
  --gold-3: #a8842a;
  --gold-soft: rgba(212, 175, 55, 0.14);
  --gold-glow: rgba(212, 175, 55, 0.35);
  --gold-gradient: linear-gradient(135deg, #f3d67a 0%, #d4af37 45%, #b8922c 100%);

  --blue: #3b82f6;
  --blue-2: #60a5fa;
  --blue-soft: rgba(59, 130, 246, 0.16);
  --blue-glow: rgba(59, 130, 246, 0.35);

  --primary: var(--gold);
  --primary-hover: var(--gold-2);
  --danger: #f26d6d;
  --success-bg: rgba(52, 199, 122, 0.14);
  --success-text: #6fe3a3;
  --error-bg: rgba(242, 109, 109, 0.14);
  --error-text: #ff9b9b;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-gold: 0 8px 28px rgba(212, 175, 55, 0.22);
  --ring: 0 0 0 3px var(--blue-soft);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Segoe UI', Inter, system-ui, -apple-system, Roboto, sans-serif;
  background:
    radial-gradient(900px 500px at 8% -10%, rgba(212, 175, 55, 0.14), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(59, 130, 246, 0.14), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a {
  color: var(--blue-2);
}

h1 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
  line-height: 1.15;
}

h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.8rem;
}

/* Layout */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  height: 64px;
  background: rgba(10, 10, 12, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.6;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand > span:last-child {
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* The bulb from the logo: crop the top-centre of /logo.png and lift the dark
   navy strokes to light (invert + hue-rotate keeps the purple accent purple). */
.brand-logo {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  background-image: url('/logo.png');
  background-repeat: no-repeat;
  background-size: 180% auto;
  background-position: 50% 1px;
  filter: invert(1) hue-rotate(180deg) drop-shadow(0 0 8px var(--gold-glow));
}

.nav {
  display: flex;
  gap: 0.25rem;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav a.active {
  background: var(--gold-soft);
  color: var(--gold-2);
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.35);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.topbar-right a.btn {
  text-decoration: none;
}

.user-chip {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.content {
  flex: 1;
  padding: 2rem 1.25rem 3rem;
  width: 100%;
}

.page-narrow {
  max-width: 560px;
  margin: 0 auto;
}

.page-wide {
  max-width: 1100px;
  margin: 0 auto;
}

.center-screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* Cards */
.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card-accent {
  border-color: rgba(212, 175, 55, 0.45);
  box-shadow: var(--shadow), 0 0 0 1px rgba(212, 175, 55, 0.15);
}

.login-card {
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--gold-gradient);
}

.login-card h1 {
  margin-top: 0.25rem;
}

.login-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.form textarea {
  font: inherit;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text);
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--ring);
}

.form input[type='file'] {
  padding: 0.5rem 0.6rem;
}

.form input[type='file']::file-selector-button {
  font: inherit;
  font-weight: 600;
  margin-right: 0.75rem;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.form input,
.form select {
  font: inherit;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form input::placeholder,
.form textarea::placeholder {
  color: #6c6c78;
}

.form input:focus,
.form select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--ring);
}

.form select option {
  background: var(--surface);
}

.form-inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-inline label {
  flex: 1 1 180px;
}

/* Buttons */
.btn {
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.65rem 1.15rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: rgba(255, 255, 255, 0.28);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gold-gradient);
  border-color: transparent;
  color: #141008;
  box-shadow: var(--shadow-gold);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #fbe28f 0%, #e2bc45 45%, #c59d31 100%);
  border-color: transparent;
  box-shadow: 0 10px 32px rgba(212, 175, 55, 0.35);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: transparent;
  color: var(--text);
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(242, 109, 109, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: var(--error-bg);
  border-color: rgba(242, 109, 109, 0.5);
}

.btn-small {
  padding: 0.38rem 0.75rem;
  font-size: 0.78rem;
}

/* Alerts & badges */
.alert {
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: rgba(242, 109, 109, 0.3);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: rgba(52, 199, 122, 0.3);
}

.badge {
  display: inline-block;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border-strong);
}

.badge-ok {
  background: var(--blue-soft);
  color: var(--blue-2);
  border-color: rgba(59, 130, 246, 0.35);
}

/* Language switch */
.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-2);
  padding: 2px;
  gap: 2px;
}

.lang-switch button {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.3rem 0.6rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-switch button.active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 0 12px var(--blue-glow);
}

/* Info grid */
.info-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.45rem 1.25rem;
  margin: 0;
  font-size: 0.9rem;
}

.info-grid dt {
  color: var(--muted);
}

.info-grid dd {
  margin: 0;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

.table th {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg-2);
}

.table .actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.device-info {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Materials page (notice + document cards) */
.materials {
  max-width: 1100px;
  margin: 0 auto;
}

.materials-board {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.notice {
  position: relative;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.12), rgba(59, 130, 246, 0.08));
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.5rem 1.75rem;
  text-align: center;
  font-size: 1.1rem;
  line-height: 1.6;
  white-space: pre-wrap;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.notice::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--gold-gradient);
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.1rem;
}

.doc-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 190px;
  padding: 1.25rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 50%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.doc-card::after {
  content: '';
  position: absolute;
  inset: auto -40% -60% auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.18), transparent 65%);
  pointer-events: none;
  transition: opacity 0.2s ease;
  opacity: 0.6;
}

.doc-card:hover {
  transform: translateY(-3px);
  border-color: rgba(212, 175, 55, 0.55);
  box-shadow: var(--shadow), 0 0 0 1px rgba(212, 175, 55, 0.2), var(--shadow-gold);
}

.doc-card:hover::after {
  opacity: 1;
}

.doc-icon {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: var(--gold-soft);
  color: var(--gold-2);
  border: 1px solid rgba(212, 175, 55, 0.35);
}

.doc-title {
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  margin-top: 0.25rem;
}

/* Description preview on a card: at most 3 lines, the full text is in the
   details dialog (public page) or under the reader title (members). */
.doc-desc {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
  white-space: pre-line;
}

.doc-card-clickable {
  cursor: pointer;
}

.doc-card-clickable:focus-visible {
  outline: none;
  box-shadow: var(--shadow), var(--ring);
}

.doc-info-text {
  margin: 0.25rem 0 1rem;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.reader-desc {
  margin: 0.2rem 0 0;
  max-width: 70ch;
  white-space: pre-line;
}

.form-row-full {
  flex: 1 1 100%;
}

.card-nested {
  margin: 1rem 0 0;
}

.card-nested h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.card-nested h3 strong {
  color: var(--gold-2);
}

.doc-open {
  margin-top: auto;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--blue-2);
}

.doc-empty {
  margin: 1rem 0 0;
}

/* PDF reader */
.reader-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.reader-heading h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.35rem;
}

.reader-back {
  text-decoration: none;
  padding-left: 0.6rem;
  padding-right: 0.9rem;
}

.reader {
  max-width: 1100px;
  margin: 0 auto;
}

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.reader-toolbar h1 {
  margin: 0;
}

.reader-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.9rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.reader-viewport {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-height: 60vh;
  overflow-x: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Discourage selecting/copying the rendered PDF text out of the reader. */
.reader-viewport .react-pdf__Page__textContent {
  user-select: none;
  -webkit-user-select: none;
}

.pdf-page {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.reader-video {
  display: block;
  width: 100%;
  max-height: 78vh;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  background: #000;
  outline: none;
}

.pdf-page .react-pdf__Page {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  background: #fff;
  border-radius: 4px;
}

.pdf-page .react-pdf__Page__textContent {
  user-select: none;
  -webkit-user-select: none;
}

/* Public "claim a document" page */
.claim-subtitle {
  margin: -0.35rem 0 1.5rem;
  font-size: 1.02rem;
  max-width: 640px;
}

.materials > h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  background: linear-gradient(90deg, #ffffff 0%, #f3d67a 55%, #d4af37 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

.doc-card-active {
  border-color: var(--gold);
  box-shadow: var(--shadow), 0 0 0 1px rgba(212, 175, 55, 0.35), var(--shadow-gold);
}

.doc-claim {
  margin-top: auto;
  align-self: stretch;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
  animation: fade-in 0.15s ease;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  margin: 0;
  overflow: hidden;
  animation: pop-in 0.18s ease;
}

.modal-card-wide {
  max-width: 560px;
}

.modal-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--gold-gradient);
}

.modal-card h2 {
  margin-top: 0.25rem;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}

.modal-card h2 strong {
  color: var(--gold-2);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

/* Payment details shown after a claim */
.payment {
  margin: 0.25rem 0 1rem;
}

.payment h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.payment-logos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.payment-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
}

.payment-logo svg {
  display: block;
  height: 20px;
  width: auto;
}

.payment-logo-visa {
  background: #fff;
}

.payment-logo-mc {
  background: #fff;
}

.payment-logo-wu {
  background: #ffdd00;
}

.payment-rows {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1rem;
  align-items: center;
  margin: 0;
}

.payment-rows dt {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.payment-rows dd {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.payment-rows code {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--gold-2);
}

.payment-after {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  border: 1px solid rgba(212, 175, 55, 0.3);
  font-size: 0.92rem;
  line-height: 1.5;
}

.payment-after a {
  color: var(--gold-2);
  font-weight: 700;
}

@media (max-width: 640px) {
  .payment-rows {
    grid-template-columns: 1fr;
    gap: 0.15rem 0;
  }

  .payment-rows dd {
    margin-bottom: 0.6rem;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.section-head h2 {
  margin: 0;
}

/* Document picker (dropdown with a check-mark list) */
.doc-picker {
  position: relative;
  min-width: 200px;
}

.doc-picker-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: 100%;
  font: inherit;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.doc-picker-toggle:focus-visible,
.doc-picker.open .doc-picker-toggle {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--ring);
}

.doc-picker-toggle:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.doc-picker-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-picker-caret {
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s ease;
}

.doc-picker.open .doc-picker-caret {
  transform: rotate(-135deg) translateY(-2px);
}

.doc-picker-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.35rem);
  left: 0;
  min-width: 100%;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.doc-picker-divider {
  height: 1px;
  margin: 0.3rem 0.4rem;
  background: var(--border);
}

.doc-picker-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.doc-picker-item:hover,
.doc-picker-item:focus-visible {
  outline: none;
  background: var(--surface-3);
}

.doc-picker-item.checked {
  color: var(--gold-2);
}

.doc-picker-check {
  flex: 0 0 auto;
  width: 1.1rem;
  height: 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--bg-2);
  position: relative;
}

.doc-picker-item.checked .doc-picker-check {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.doc-picker-item.checked .doc-picker-check::after {
  content: '';
  position: absolute;
  left: 0.33rem;
  top: 0.12rem;
  width: 0.3rem;
  height: 0.55rem;
  border-right: 2px solid var(--gold-2);
  border-bottom: 2px solid var(--gold-2);
  transform: rotate(45deg);
}

.doc-picker-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Admin: vertical side navigation */
.admin-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.admin-nav {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.admin-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.admin-nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.admin-nav-item:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.admin-nav-item.active {
  background: var(--gold-soft);
  color: var(--gold-2);
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.35);
}

.admin-nav-count {
  min-width: 1.5rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.admin-nav-item.active .admin-nav-count {
  background: rgba(212, 175, 55, 0.25);
  color: var(--gold-2);
}

.admin-content {
  min-width: 0;
}

@media (max-width: 800px) {
  .admin-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .admin-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .admin-nav::-webkit-scrollbar {
    display: none;
  }

  .admin-nav-item {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 0.6rem 0.85rem;
    gap: 0.5rem;
  }

  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .topbar-right {
    gap: 0.4rem;
  }

  .user-chip {
    display: none;
  }

  .content {
    padding: 1.25rem 0.85rem 2rem;
  }

  .reader-viewport,
  .materials-board {
    padding: 0.75rem;
    border-radius: 12px;
  }

  .doc-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.6rem;
  }

  .doc-card {
    min-height: 150px;
    padding: 0.9rem;
  }

  .card {
    padding: 1.1rem;
  }
}
