/* ============================================================
   Multimodal Intelligence Lab — styles.css
   Minimal, text-focused, black / white / grey only
   ============================================================ */

/* ---------- CSS Variables (greyscale only) ---------- */
:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111;
  --bg-card: #161616;
  --bg-input: #1a1a1a;
  --border: #2a2a2a;
  --border-focus: #555;

  --text-primary: #e5e5e5;
  --text-secondary: #999;
  --text-muted: #666;

  --accent: #888;
  --accent-hover: #aaa;
  --accent-light: rgba(255,255,255,0.06);

  --success: #777;
  --warning: #777;
  --danger: #888;
  --danger-hover: #999;
  --form-error: #ff8d8d;
  --ticket-fresh: #3cba6a;
  --ticket-day: #6aa7ff;
  --ticket-late: #ff8d8d;

  --nav-width: 200px;
  --sidebar-user-width: 7.75rem;
  --sidebar-account-btn: 6.25rem;
  --controls-width: 200px;
  --radius: 0;
  --radius-lg: 0;
  --shadow: none;
  --shadow-sm: none;

  --font-sans: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: ui-monospace, monospace;

  --transition: 0.15s ease;
}

/* Light mode */
[data-theme="light"] {
  --bg-primary: #fff;
  --bg-secondary: #f5f5f5;
  --bg-card: #fafafa;
  --bg-input: #eee;
  --border: #ddd;
  --border-focus: #888;

  --text-primary: #111;
  --text-secondary: #444;
  --text-muted: #777;

  --accent: #555;
  --accent-hover: #222;
  --accent-light: rgba(0,0,0,0.06);
  --form-error: #c0392b;
  --ticket-fresh: #1a7f37;
  --ticket-day: #1d4f91;
  --ticket-late: #c0392b;
}

/* Font size scale (base set by JS on html) */
html { font-size: 14px; }
html[data-fontsize="s"] { font-size: 12px; }
html[data-fontsize="m"] { font-size: 14px; }
html[data-fontsize="l"] { font-size: 16px; }

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

img {
  max-width: 100%;
  display: block;
}

ul {
  list-style: none;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
}

h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }

p { color: var(--text-secondary); }

/* ---------- App layout: left nav, main, right controls ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.nav-sidebar {
  width: var(--nav-width);
  flex-shrink: 0;
  background: var(--bg-primary);
  border-right: none;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-sidebar .nav-brand {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-primary);
  padding: 0 1rem 1rem;
  border-bottom: none;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.nav-sidebar .nav-brand span { color: var(--text-primary); }

.nav-sidebar .nav-links {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
}

.nav-sidebar .nav-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 400;
  padding: 0.5rem 1rem;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
}

.nav-sidebar .nav-links a:hover {
  color: var(--text-secondary);
}

.nav-sidebar .nav-links a.active {
  /* color set by theme rules below */
}

/* ---------- App layout: left nav, main; top-right bar for user + controls ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.nav-sidebar {
  width: var(--nav-width);
  flex-shrink: 0;
  background: var(--bg-primary);
  border-right: none;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-sidebar .nav-brand {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-primary);
  padding: 0 1rem 1rem;
  border-bottom: none;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.nav-sidebar .nav-brand span { color: var(--text-primary); }

.nav-sidebar .nav-links {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
}

.nav-sidebar .nav-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 400;
  padding: 0.5rem 1rem;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
}

.nav-sidebar .nav-links a:hover {
  color: var(--text-secondary);
}

.nav-sidebar .nav-links a.active {
  /* color set by theme rules below */
}

[data-theme="light"] .nav-sidebar .nav-links a.active {
  color: #000;
}

[data-theme="dark"] .nav-sidebar .nav-links a.active {
  color: #fff;
}

.nav-brand-logo {
  display: block;
  width: 4.625rem;
  max-width: 100%;
  height: auto;
}

[data-theme="dark"] .nav-brand-logo.is-placeholder {
  filter: invert(1);
}

.logo-admin {
  padding: 0 1rem 0.75rem;
}

.logo-panel {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.55rem;
}

.logo-size-note,
.logo-empty {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.logo-history-label {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.logo-history {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.logo-past {
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.25rem;
  cursor: pointer;
}

.logo-past.is-current {
  border-color: var(--text-primary);
  outline: 1px solid var(--text-primary);
}

.logo-past img {
  width: 100%;
  height: 2.4rem;
  object-fit: contain;
}

.logo-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

#logo-admin[hidden],
#logo-panel[hidden] { display: none !important; }

/* ---- Nav visibility eye toggles (admin only) ---- */

/* Hide toggleable links until initNavVisibility has run, preventing a flash
   of hidden items. Uses visibility:hidden so layout space is preserved. */
html:not([data-nav-ready]) .nav-sidebar .nav-links a[href="portfolio-software.html"],
html:not([data-nav-ready]) .nav-sidebar .nav-links a[href="portfolio-design.html"],
html:not([data-nav-ready]) .nav-sidebar .nav-dropdown[data-nav-key="forum"],
html:not([data-nav-ready]) .nav-sidebar .nav-dropdown[data-nav-key="teaching"],
html:not([data-nav-ready]) .nav-sidebar .nav-links a[href="writing.html"],
html:not([data-nav-ready]) .nav-sidebar .nav-links a[href="news.html"],
html:not([data-nav-ready]) .nav-sidebar .nav-links a[href="consultation.html"],
html:not([data-nav-ready]) .nav-sidebar .nav-dropdown[data-nav-key="portal"],
html:not([data-nav-ready]) .nav-sidebar .nav-dropdown[data-nav-key="join"] {
  visibility: hidden;
}

/* Row wrapper injected by JS for admin (holds drag handle + link + eye button) */
.nav-link-row {
  display: flex;
  align-items: center;
}
.nav-link-row > a {
  flex: 1;
}
.nav-link-row.dragging,
.nav-dropdown.dragging {
  opacity: 0.4;
}
.nav-link-row.drag-over,
.nav-dropdown.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 2px;
}

/* Drag handle */
.nav-drag-handle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.35rem 0.5rem 0;
  cursor: grab;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--transition);
  line-height: 1;
}
.nav-sidebar:hover .nav-drag-handle {
  opacity: 0.3;
}
.nav-drag-handle:hover {
  opacity: 0.8 !important;
}

/* Eye toggle button */
.nav-eye-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0.5rem 0.75rem 0.5rem 0;
  cursor: pointer;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
  line-height: 1;
}
.nav-sidebar:hover .nav-eye-btn {
  opacity: 0.4;
}
.nav-eye-btn:hover {
  opacity: 1 !important;
  color: var(--text-primary);
}
/* Always show at partial opacity when the item is currently hidden,
   so admin can find and re-enable it */
.nav-eye-btn.is-hidden {
  opacity: 0.6;
}

/* Teaching dropdown in nav */
.nav-dropdown {
  display: flex;
  flex-direction: column;
}

.nav-dropdown-head {
  display: flex;
  align-items: center;
}

.nav-dropdown-head .nav-dropdown-btn {
  flex: 1;
  min-width: 0;
}

.nav-sidebar .nav-links a.nav-dropdown-btn,
.nav-dropdown-btn {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 400;
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  transition: color var(--transition);
}

[data-theme="light"] .nav-sidebar .nav-links a.nav-dropdown-btn.active {
  color: #000;
}

[data-theme="dark"] .nav-sidebar .nav-links a.nav-dropdown-btn.active {
  color: #fff;
}

.nav-dropdown-btn:hover {
  color: var(--text-secondary);
}

.nav-dropdown-chevron {
  font-size: 0.65rem;
  opacity: 0.5;
  transition: transform 0.2s;
}

.nav-dropdown.open .nav-dropdown-chevron {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  display: none;
  flex-direction: column;
}

.nav-dropdown.open .nav-dropdown-menu {
  display: flex;
}

.nav-dropdown-menu a[hidden] { display: none !important; }

/* Higher specificity to override .nav-sidebar .nav-links a */
.nav-sidebar .nav-links .nav-dropdown-menu a {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 400;
  padding: 0.35rem 1rem 0.35rem 1.5rem;
  transition: color var(--transition);
}

.nav-sidebar .nav-links .nav-dropdown-menu a::before {
  content: "– ";
  opacity: 0.4;
}

.nav-sidebar .nav-links .nav-dropdown-menu a:hover {
  color: var(--text-secondary);
}

[data-theme="light"] .nav-sidebar .nav-links .nav-dropdown-menu a.active {
  color: #000;
}

[data-theme="dark"] .nav-sidebar .nav-links .nav-dropdown-menu a.active {
  color: #fff;
}

/* Teaching password gate */
.teaching-lock-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2100;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.teaching-lock-modal.is-open {
  display: flex;
}

.teaching-lock-dialog {
  background: var(--bg-card, var(--bg-primary));
  border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
  padding: 1.25rem 1.35rem;
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.teaching-lock-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.teaching-lock-hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.teaching-lock-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.teaching-lock-input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--input-bg, var(--bg-card));
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
}

.teaching-lock-input:focus {
  outline: none;
  border-color: var(--text-secondary);
}

.teaching-lock-error {
  margin: 0;
  font-size: 0.82rem;
  color: var(--danger, #c0392b);
}

.teaching-lock-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Account controls share the theme / font / size column. */
.sidebar-controls .controls-account {
  width: 100%;
}

.sidebar-controls #nav-user-email {
  display: block;
  width: 100%;
  text-align: left;
  overflow-wrap: anywhere;
}

.sidebar-controls #nav-user-email[hidden],
.sidebar-controls #nav-role-badge[hidden],
.sidebar-controls #nav-settings[hidden],
.sidebar-controls #nav-login[hidden],
.sidebar-controls #nav-logout[hidden] {
  display: none !important;
}

.sidebar-controls .controls-account-actions .nav-role-badge,
.sidebar-controls .controls-account-actions a,
.sidebar-controls .controls-signout {
  background: none;
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-align: left;
  font-family: inherit;
  text-decoration: none;
  line-height: 1.4;
  letter-spacing: normal;
  width: auto;
  border-radius: 0;
  box-sizing: border-box;
}

.sidebar-controls .controls-account-actions a,
.sidebar-controls .controls-signout {
  cursor: pointer;
}

.sidebar-controls .controls-account-actions a:hover,
.sidebar-controls .controls-account-actions a.active {
  background: var(--accent-light);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.sidebar-controls .controls-signout {
  border-color: #c0392b;
  margin-top: 1rem;
}

.sidebar-controls .controls-signout:hover {
  border-color: #c0392b;
  color: #c0392b;
  background: rgba(192, 57, 43, 0.06);
}

.sidebar-controls {
  width: var(--controls-width);
  flex-shrink: 0;
  align-self: flex-start;
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-primary);
  border-left: none;
  padding: 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  font-size: 0.8rem;
}

.panel-toggle {
  position: fixed;
  bottom: 0.85rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.65rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
}

.panel-toggle:hover,
.panel-toggle:focus-visible {
  color: var(--text-primary);
}

.panel-toggle-nav { left: calc(var(--nav-width) - 2rem); }
.panel-toggle-controls { right: calc(var(--controls-width) - 2rem); }

.nav-sidebar,
.sidebar-controls { padding-bottom: 3.25rem; }

html[data-nav-collapsed="1"] { --nav-width: 2.2rem; }
html[data-controls-collapsed="1"] { --controls-width: 2.2rem; }

html[data-nav-collapsed="1"] .nav-sidebar,
html[data-controls-collapsed="1"] .sidebar-controls {
  overflow: hidden;
  padding-left: 0;
  padding-right: 0;
}

html[data-nav-collapsed="1"] .nav-sidebar > :not(.panel-toggle),
html[data-controls-collapsed="1"] .sidebar-controls > :not(.panel-toggle) {
  display: none !important;
}

html[data-nav-collapsed="1"] .panel-toggle-nav { left: 0.22rem; }
html[data-controls-collapsed="1"] .panel-toggle-controls { right: 0.22rem; }

@media (max-width: 900px) {
  .panel-toggle {
    position: static;
    margin-top: 0.35rem;
  }
  .panel-toggle-nav,
  .panel-toggle-controls,
  html[data-nav-collapsed="1"] .panel-toggle-nav,
  html[data-controls-collapsed="1"] .panel-toggle-controls {
    left: auto;
    right: auto;
  }
}

.sidebar-controls .controls-group {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
}

.sidebar-controls .controls-group-label {
  text-align: left;
}

.sidebar-controls .controls-theme,
.sidebar-controls .controls-font,
.sidebar-controls .controls-font-size {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.2rem;
  align-items: flex-start;
}

/* Legacy single right sidebar — keep for any old refs, hidden */
.right-sidebar {
  display: none;
}

.right-sidebar-user {
  display: none;
}

.right-sidebar-controls {
  display: none;
}

.main-content {
  flex: 1;
  min-width: 480px;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.nav-role-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 400;
  text-transform: uppercase;
  padding: 0.3rem 0.7rem;
  letter-spacing: 0.05em;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  line-height: 1.4;
  box-sizing: border-box;
  border-radius: var(--radius);
}

.badge-admin,
.badge-moderator,
.badge-regular,
.badge-visitor,
.badge-guest {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.top-right-controls {
  display: none;
}

.top-right-bar {
  display: none;
}

/* Legacy right sidebar — now unused, hidden */
.controls-sidebar {
  display: none;
}

.controls-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.controls-group-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.controls-theme {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.controls-theme button {
  background: none;
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.controls-theme button:hover {
  background: var(--accent-light);
  color: var(--text-primary);
}

.controls-theme button.active {
  background: var(--accent-light);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.controls-font {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.font-option {
  background: none;
  border: 1px solid var(--border);
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.font-option:hover {
  background: var(--accent-light);
  color: var(--text-primary);
}

.font-option.active {
  background: var(--accent-light);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.font-option[data-font="inter"] { font-family: Inter, system-ui, sans-serif; }
.font-option[data-font="georgia"] { font-family: Georgia, 'Times New Roman', serif; }
.font-option[data-font="system"] { font-family: system-ui, -apple-system, sans-serif; }

.controls-font-size {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.font-size-option {
  background: none;
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.font-size-option:hover {
  background: var(--accent-light);
  color: var(--text-primary);
}

.font-size-option.active {
  background: var(--accent-light);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* ---------- Navigation (legacy top bar — hidden when using sidebar layout) ---------- */
.nav {
  display: none;
}

.nav-drawer {
  display: none;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:active { opacity: 0.8; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--text-primary);
  color: var(--bg-primary);
}
.btn-primary:hover:not(:disabled) { background: var(--text-secondary); color: var(--bg-primary); }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-danger {
  background: var(--text-secondary);
  color: var(--bg-primary);
}
.btn-danger:hover:not(:disabled) { background: var(--text-primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--accent-light);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
}

.btn-lg {
  font-size: 1rem;
  padding: 0.7rem 1.6rem;
}

/* ---------- Theme Toggle (legacy — now in right sidebar) ---------- */
.theme-toggle {
  display: none;
}

/* ---------- Layout ---------- */
.page-wrapper {
  flex: 1;
  padding: 0;
  min-height: 0;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container-sm {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section {
  padding: 4rem 0;
}

.section-sm {
  padding: 2.5rem 0;
}

/* ---------- Hero ---------- */
.hero {
  padding: 5rem 0 4rem;
  text-align: center;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.hero h1 {
  margin-bottom: 1rem;
}

.hero-subtitle {
  font-size: 1.15rem;
  max-width: 600px;
  margin: 0 auto 2rem;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color var(--transition);
}

.card:hover {
  border-color: var(--text-muted);
}

/* Flat hairline grid — individual card shadows removed */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-grid .card {
  border: none;
  border-radius: 0;
}

.card-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  background: var(--bg-input);
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.card h3 { margin-bottom: 0.4rem; }
.card p  { font-size: 0.9rem; }

.card-links {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* ---------- Section Header ---------- */
.section-header {
  margin-bottom: 2.5rem;
}

.section-header h2 { margin-bottom: 0.4rem; }

/* ---------- Forms ---------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 0.65rem 0.9rem;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--text-muted);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.form-error {
  font-size: 0.82rem;
  color: var(--form-error);
  display: none;
}

.form-error.visible { display: block; }

.form-success {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: none;
}

.form-success.visible { display: block; }

/* Auth card */
.auth-card {
  max-width: 420px;
  margin: 3rem auto 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 2rem 1.5rem;
}

.auth-card h2 { margin-bottom: 0.3rem; }
.auth-card .auth-sub { margin-bottom: 1.5rem; font-size: 0.9rem; }

.settings-stack {
  max-width: 480px;
  margin: 2rem auto 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 0 1rem;
}

.settings-stack[hidden] { display: none; }

.settings-card {
  margin: 0;
  max-width: none;
}

.settings-current {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0 0 0.25rem;
}

.settings-current strong {
  color: var(--text-primary);
  font-weight: 600;
}

.auth-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 0.25rem;
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 0.45rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: calc(var(--radius) - 1px);
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  border: none;
  background: transparent;
  font-family: var(--font-sans);
}

.auth-tab.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.auth-divider {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 1rem 0;
  position: relative;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}

.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }

/* ---------- Forum / Discussion Posts (legacy + new) ---------- */
.post-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.post-form h3 { margin-bottom: 1.25rem; }

/* Legacy list/item styles (kept for compatibility) */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  transition: border-color var(--transition);
}

.post-item:hover { border-color: var(--border-focus); }

.post-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.post-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.post-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.post-author {
  font-weight: 600;
  color: var(--text-primary);
}

.post-body {
  font-size: 0.92rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.post-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ---------- New List / Detail Classes ---------- */

/* List header bar above rows */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.list-header-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Clickable list rows */
.post-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--transition), border-left-color var(--transition);
}

.post-row:hover,
.post-row:focus {
  background: var(--bg-card);
  border-left-color: var(--text-muted);
  outline: none;
}

.post-row-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.post-thread-tag {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  opacity: 0.9;
  white-space: nowrap;
  flex-shrink: 0;
}

.post-row-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Back button */
.back-btn {
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  transition: color var(--transition);
}

.back-btn:hover { color: var(--text-primary); }

/* Post detail view */
.post-detail-header {
  margin-bottom: 1.25rem;
}

.post-detail-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.post-detail-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.post-detail-body {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 1.5rem;
}

.post-detail-image {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  display: inline-block;
}

.post-detail-image img {
  max-height: 480px;
  max-width: 100%;
  width: auto;
  display: block;
}

.post-detail-actions {
  display: flex;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* File input styled label */
.file-input-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.file-input-label:hover {
  background: var(--bg-input);
  border-color: var(--text-muted);
}

.file-input-label input[type="file"] {
  display: none;
}

.file-input-label:has(input:disabled) {
  opacity: 0.45;
  cursor: default;
}

/* Image preview */
.image-preview {
  position: relative;
  display: inline-block;
  margin-top: 0.75rem;
}

.image-preview img {
  max-height: 160px;
  max-width: 100%;
  border: 1px solid var(--border);
  display: block;
}

.image-preview-remove {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--text-primary);
  color: var(--bg-primary);
  border: none;
  width: 22px;
  height: 22px;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ---------- Announcements ---------- */
.announcement-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 2px solid var(--text-muted);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  transition: border-color var(--transition);
}

.announcement-item:hover { border-color: var(--text-muted); }

.announcement-title {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}

.announcement-body {
  color: var(--text-secondary);
  font-size: 0.93rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.announcement-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

/* Announcement list rows (new) */
.announcement-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--transition), border-left-color var(--transition);
}

.announcement-row:hover,
.announcement-row:focus {
  background: var(--bg-card);
  border-left-color: var(--text-muted);
  outline: none;
}

.announcement-row-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.announcement-row-snippet {
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.announcement-row-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ---------- Access Gate ---------- */
.access-gate {
  text-align: center;
  padding: 2rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}

.access-gate .gate-icon {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.access-gate h3 { margin-bottom: 0.4rem; }
.access-gate p  { font-size: 0.9rem; margin-bottom: 1rem; }

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 1rem; margin-bottom: 0.75rem; color: var(--text-muted); }
.empty-state p { font-size: 0.95rem; }

/* ---------- Loading Spinner ---------- */
.spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.spinner-ring {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--text-muted);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.1rem;
  font-size: 0.9rem;
  max-width: 340px;
  animation: slideIn 0.2s ease;
  position: relative;
}

.toast.success { border-left: 2px solid var(--text-muted); }
.toast.error   { border-left: 2px solid var(--text-secondary); }
.toast.info    { border-left: 2px solid var(--border); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ---------- Features Grid ---------- */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  overflow: hidden;
}

.feature-card {
  background: var(--bg-card);
  border: none;
  border-radius: 0;
  padding: 1.5rem;
  text-align: center;
}

.feature-icon {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.feature-card h3 { font-size: 1rem; margin-bottom: 0.35rem; }
.feature-card p  { font-size: 0.85rem; }

/* ---------- Stats strip ---------- */
.stats-strip {
  display: flex;
  justify-content: center;
  gap: 3rem;
  flex-wrap: wrap;
  padding: 2.5rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.stat-item { text-align: center; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--text-primary); }
.stat-label { font-size: 0.82rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- Page title bar ---------- */
.page-title-bar {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 1.75rem 0 1.25rem;
  margin-bottom: 2rem;
}

.page-title-bar h1 { margin-bottom: 0.25rem; font-size: 1.8rem; }
.page-title-bar p { font-size: 0.9rem; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: auto;
}

.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--text-primary); }

/* ============================================================
   Rich Text Editor (Quill)
   ============================================================ */

.editor-wrapper {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.editor-wrapper:has(.ql-expanded) {
  overflow: visible;
}

.ql-toolbar.ql-snow {
  background: var(--bg-secondary);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  flex-wrap: wrap;
}

.ql-container.ql-snow {
  background: var(--bg-input);
  border: none;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

.editor-content {
  min-height: 200px;
}

.ql-editor {
  color: var(--text-primary);
  min-height: 200px;
  line-height: 1.75;
  padding: 0.75rem 1rem;
}

.ql-container.ql-snow .ql-editor p {
  margin-bottom: 0.75rem;
}

.ql-editor.ql-blank::before {
  color: var(--text-muted);
  font-style: normal;
}

/* Toolbar icons → our text-secondary */
.ql-snow .ql-stroke           { stroke: var(--text-secondary); }
.ql-snow .ql-fill             { fill:   var(--text-secondary); }
.ql-snow .ql-picker            { color:  var(--text-secondary); }

.ql-snow .ql-picker-options {
  background:   var(--bg-secondary);
  border-color: var(--border);
  z-index: 1200;
}

.ql-snow .ql-picker-item { color: var(--text-secondary); }

.ql-snow .ql-picker-item:hover,
.ql-snow .ql-picker-label:hover,
.ql-snow button:hover .ql-stroke,
.ql-snow button.ql-active .ql-stroke { stroke: var(--text-primary); }

.ql-snow button:hover .ql-fill,
.ql-snow button.ql-active .ql-fill   { fill:   var(--text-primary); }

.ql-snow .ql-picker-label:hover,
.ql-snow .ql-picker.ql-expanded .ql-picker-label {
  color:        var(--text-primary);
  border-color: var(--border);
}

.ql-snow .ql-picker.ql-expanded .ql-picker-options {
  border-color: var(--border);
}

.ql-snow .ql-picker.ql-lineheight,
.ql-snow .ql-picker.ql-paraspacing {
  width: 48px;
}
.ql-snow .ql-picker.ql-lineheight .ql-picker-options,
.ql-snow .ql-picker.ql-paraspacing .ql-picker-options {
  min-width: 5.5rem;
}
.ql-snow .ql-picker.ql-lineheight .ql-picker-item::before,
.ql-snow .ql-picker.ql-paraspacing .ql-picker-item::before {
  content: attr(data-label);
}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label::before,
.ql-snow .ql-picker.ql-paraspacing .ql-picker-label::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  line-height: 18px;
  background-color: currentColor;
  -webkit-mask: var(--spacing-icon) center / 18px 18px no-repeat;
  mask: var(--spacing-icon) center / 18px 18px no-repeat;
}
.ql-snow .ql-picker.ql-lineheight {
  --spacing-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M8 4.25h8M8 9h8M8 13.75h8M3.75 2.75v12.5M3.75 2.75 2 4.6M3.75 2.75l1.75 1.85M3.75 15.25 2 13.4M3.75 15.25l1.75-1.85'/%3E%3C/svg%3E");
}
.ql-snow .ql-picker.ql-paraspacing {
  --spacing-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M8 2.75h8M8 5.5h8M8 12.5h8M8 15.25h8M3.75 7.2v3.6M2 8.8 3.75 7.2 5.5 8.8M2 9.2 3.75 10.8 5.5 9.2'/%3E%3C/svg%3E");
}

/* Font family CSS classes (Quill sets these) */
.ql-font-georgia { font-family: Georgia, 'Times New Roman', serif; }
.ql-font-courier { font-family: 'Courier New', Courier, monospace; }

/* Custom audio button in toolbar */
.ql-audio {
  font-size: 0.85rem !important;
  line-height: 1 !important;
  padding: 0 0.15rem !important;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  width: auto !important;
}
.ql-audio:hover { color: var(--text-primary) !important; }

.ql-snow .ql-box {
  width: auto !important;
  padding: 0 0.45rem !important;
  font-size: 0.72rem !important;
  font-weight: 600;
  color: var(--text-secondary);
}
.ql-snow .ql-box.ql-active { color: var(--text-primary); }

/* ============================================================
   Publication Cards (News / Blog list)
   ============================================================ */

.pub-card {
  display: flex;
  gap: 1rem;
  padding: 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--transition), border-left-color var(--transition);
}

.pub-card:hover,
.pub-card:focus {
  background: var(--bg-card);
  border-left-color: var(--text-muted);
  outline: none;
}

.pub-card-thumb {
  width: 88px;
  height: 66px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
}

.pub-card-thumb-placeholder {
  width: 88px;
  height: 66px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.pub-card-content { flex: 1; min-width: 0; }

.pub-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pub-card-snippet {
  font-size: 0.82rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 0.25rem;
}

.pub-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ============================================================
   Scheduled Badge
   ============================================================ */

.scheduled-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ============================================================
   Post Detail — Thumbnail & Rich Content
   ============================================================ */

.post-detail-thumb {
  margin-bottom: 1.25rem;
  border-radius: var(--radius);
  overflow: hidden;
}

.post-detail-thumb img {
  width: 100%;
  height: auto;
  display: block;
}

/* Rich HTML content rendered in detail view */
.rich-content {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.75;
  word-break: break-word;
  margin-bottom: 1.5rem;
}

.rich-content h1,
.rich-content h2,
.rich-content h3,
.rich-content h4,
.rich-content h5,
.rich-content h6 {
  color: var(--text-primary);
  margin: 1.1rem 0 0.4rem;
  font-weight: 700;
}

.rich-content p           { margin-bottom: 0.75rem; color: var(--text-secondary); }
.rich-content a           { color: var(--text-primary); text-decoration: underline; }

.rich-content blockquote {
  border-left: 3px solid var(--text-muted);
  padding-left: 1rem;
  color: var(--text-muted);
  margin: 0.75rem 0;
  font-style: italic;
}

.rich-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-secondary);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

.rich-content pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  margin: 0.75rem 0;
}

.rich-content pre code { background: none; padding: 0; }

.rich-content img,
.rich-content video,
.rich-content audio  { max-width: 100%; margin: 0.5rem 0; display: block; }

.rich-content ol,
.rich-content ul {
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
  list-style: revert;
}

.rich-content li { margin-bottom: 0.25rem; }

/* ============================================================
   File Attachments
   ============================================================ */

.attach-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.attach-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}

.attach-item.attach-uploading {
  color: var(--text-muted);
  font-style: italic;
}

.attach-link {
  flex: 1;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-size {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.attach-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
}

.attach-section { margin-bottom: 1.5rem; }

.attach-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

/* ============================================================
   Thumbnail Preview (in form)
   ============================================================ */

.thumb-preview {
  position: relative;
  display: inline-block;
  margin-top: 0.75rem;
}

.thumb-preview img {
  max-height: 120px;
  max-width: 100%;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.thumb-remove {
  display: inline-block;
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* ============================================================
   Form hint text
   ============================================================ */

.form-hint {
  display: block;
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* Small thumbnail indicator in forum list */
.post-has-thumb {
  font-size: 0.75rem;
  opacity: 0.6;
}

/* ============================================================
   About / Profile Page
   ============================================================ */

#join-edit-btn[hidden],
#join-edit-wrap[hidden],
#join-display[hidden],
#research-edit-btn[hidden],
#research-edit-wrap[hidden],
#research-display[hidden],
#research-overview[hidden],
#research-section[hidden],
#winn-view[hidden] {
  display: none !important;
}

.research-overview {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  gap: 2rem;
  align-items: start;
}

.research-photo,
.research-photo-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.research-text p {
  margin: 0 0 0.9rem;
  line-height: 1.6;
}

.research-text p:last-child {
  margin-bottom: 0;
}

.container.join-wide {
  max-width: none;
  padding-left: 2rem;
  padding-right: 2rem;
}

.join-display {
  max-width: none;
  margin-bottom: 0;
  font-size: 0.95rem;
  line-height: 1.7;
}

.open-positions {
  margin: 0 0 1.75rem;
}

.open-positions > p {
  margin: 0 0 0.85rem;
  color: var(--text-secondary);
}

.open-positions-list {
  list-style: none;
  margin: 0;
  padding: 0.2rem 1.25rem 0.15rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.open-positions li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 0;
  border-top: 1px dashed var(--border);
  background: var(--bg-card);
  font-weight: 600;
  color: var(--text-primary);
}

.open-positions li:first-child {
  border-top: none;
}

.open-positions-soon {
  flex: none;
  padding: 0.28rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.join-display h1,
.join-display h2,
.join-display h3 {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-primary);
  margin: 1.15rem 0 0.5rem;
}

.join-display .join-review-note {
  margin-top: 0.85rem;
  margin-left: 1.5rem;
  font-style: italic;
  color: var(--text-secondary);
}
.join-display h1 { font-size: 1.75em; line-height: 1.25; }
.join-display h2 { font-size: 1.5em; line-height: 1.3; }
.join-display h3 { font-size: 1.17em; line-height: 1.35; }

.join-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 1.15rem 1.25rem 1.2rem;
  margin: 0 0 1rem;
}

.join-box > :first-child { margin-top: 0; }
.join-box > :last-child { margin-bottom: 0; }

.join-box p {
  font-size: 0.95rem;
  line-height: 1.7;
  margin: 0 0 0.75rem;
}

.join-edit-hint {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-muted);
}

#join-editor .ql-editor [data-box] {
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 0.15rem 0.9rem;
  margin-top: 0;
  margin-bottom: 0;
}

#join-editor .ql-editor [data-box].box-start {
  border-top: 1px solid var(--border);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  padding-top: 0.75rem;
  margin-top: 0.7rem;
}

#join-editor .ql-editor [data-box].box-end {
  border-bottom: 1px solid var(--border);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  padding-bottom: 0.8rem;
  margin-bottom: 0.7rem;
}

#join-edit-wrap .ql-editor {
  min-height: 28rem;
  font-size: 0.95rem;
  line-height: 1.7;
}

.join-pathways-wrap {
  border: 1px solid var(--border);
  background: var(--bg-card);
  padding: 0.2rem 1.25rem 0.15rem;
  margin: 0.85rem 0 0.75rem;
  overflow-x: auto;
}

.join-pathways {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
}

.join-pathways td {
  padding: 0.95rem 0;
  border-bottom: 1px dashed var(--border);
  background: var(--bg-card);
  text-align: left;
  vertical-align: top;
  color: var(--text-secondary);
}

.join-pathways tr:last-child td {
  border-bottom: none;
}

.join-pathways td.join-pathway-action {
  width: 1%;
  white-space: nowrap;
  padding-right: 1.15rem;
}

.join-pathways .join-pathway-label {
  display: block;
}

.join-pathways .join-pathway-note {
  margin: 0.45rem 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.join-pathways .join-pathway-note p {
  margin: 0;
  color: inherit;
  font-size: inherit;
}

.join-pathways .join-pathway-note ul {
  margin: 0.3rem 0 0;
  padding-left: 1.15rem;
  color: inherit;
}

.join-pathways .join-pathway-note li {
  margin-bottom: 0.15rem;
}

.join-pathways .btn {
  min-width: 9.5rem;
  width: 100%;
}

.join-display .join-pathways a.btn {
  text-decoration: none;
}

.join-display .join-pathways a.btn-primary,
.join-display .join-pathways a.btn-primary:hover {
  color: var(--bg-primary);
}

.join-display .join-pathways a.btn-secondary,
.join-display .join-pathways a.btn-secondary:hover {
  color: var(--text-primary);
}

.join-apply {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.join-apply a {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 3.2rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}

.join-apply a:hover { border-color: var(--text-muted); }
.join-apply a[hidden] { display: none !important; }

@media (max-width: 900px) {
  .join-apply { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .join-pathways,
  .join-pathways tbody,
  .join-pathways tr,
  .join-pathways td {
    display: block;
    width: auto;
    white-space: normal;
    text-align: left;
  }
  .join-pathways tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    padding: 0.85rem 1rem;
  }
  .join-pathways td {
    border: 0;
    padding: 0.15rem 0;
  }
  .join-pathways td.join-pathway-action {
    width: auto;
    white-space: normal;
    margin-bottom: 0.75rem;
  }
}

/* ---------- Application forms ---------- */
.apply-card {
  width: min(960px, 100%);
}

.apply-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.apply-card h1 {
  font-size: 1.8rem;
  margin: 0 0 0.4rem;
}

.apply-intro {
  margin: 0 0 1.1rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.apply-progress {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.45rem;
}

.apply-progress > div {
  height: 100%;
  background: var(--text-primary);
  width: 0;
}

.apply-step {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.apply-page-title {
  font-size: 1.25rem;
  margin: 0 0 1rem;
}

.apply-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 1.25rem;
  row-gap: 0;
}

.apply-span { grid-column: 1 / -1; }

.apply-grid > .form-group {
  margin: 0;
  gap: 0;
}

.apply-grid > .form-group:has(.apply-field-head) {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 2;
}

.apply-field-head {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.12rem;
  padding-bottom: 0.28rem;
}

.apply-field-control { padding-bottom: 1rem; }

.apply-field-head .apply-hint {
  margin: 0;
  line-height: 1.25;
}

.apply-hint {
  display: block;
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.45;
  white-space: pre-line;
}

.apply-required { color: var(--text-primary); }

.apply-options {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0;
}

.form-group .apply-option {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  width: auto;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-primary);
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-primary);
}

.form-group .apply-option input {
  width: auto;
  flex: 0 0 auto;
  margin: 0.2rem 0 0;
  padding: 0;
}

.apply-scale {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(140px, 0.8fr);
  gap: 0.5rem 1rem;
  align-items: center;
  margin-top: 0;
}

.apply-scale span { font-size: 0.95rem; color: var(--text-primary); }

.apply-skill-heading {
  margin: 1.15rem 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.apply-skill-table { border-top: 1px solid var(--border); }

.apply-skill-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(12rem, 0.95fr) auto;
  gap: 0.55rem 0.85rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.apply-skill-row > span {
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--text-primary);
}

.apply-skill-row select { width: 100%; min-width: 0; font-size: 0.85rem; }

.apply-skill-learn,
.apply-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text-secondary);
}

.apply-skill-learn input,
.apply-check input {
  width: auto;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
}

.apply-skill-detail { margin: 0 0 0.55rem; }

.apply-skill-software { margin-top: 0.75rem; }

.apply-skill-software-label {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

.apply-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  margin-top: 0.4rem;
}

.apply-skill-software input[type="text"] { margin-top: 0.55rem; }

.apply-exit {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0;
}

.apply-review {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.apply-review div {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.apply-review dt {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.apply-review dd {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.apply-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.apply-actions [hidden] { display: none !important; }

.apply-done h2 { font-size: 1.4rem; margin: 0 0 0.6rem; }
.apply-done p { font-size: 0.95rem; line-height: 1.7; }

.apply-admin { margin-top: 2rem; }
.apply-admin-list { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.apply-admin-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  background: var(--bg-card);
  font-size: 0.9rem;
}
.apply-admin-row summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  color: var(--text-primary);
}
.apply-admin-row summary::-webkit-details-marker { display: none; }
.apply-admin-row summary::before {
  content: "▸";
  color: var(--text-muted);
  flex: none;
}
.apply-admin-row[open] summary::before { content: "▾"; }
.apply-admin-row.is-new { box-shadow: inset 3px 0 0 var(--text-primary); }
.apply-admin-received {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
  flex: none;
}
.apply-admin-new {
  flex: none;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--text-primary);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}
.apply-admin-who { min-width: 0; }
.apply-admin-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
}
.apply-admin-download { flex: none; }
.apply-admin-delete {
  width: 1.7rem;
  padding-left: 0;
  padding-right: 0;
  line-height: 1;
}
.apply-admin-row.is-responded { opacity: 0.48; }
.apply-admin-row.is-responded summary,
.apply-admin-row.is-responded dl { color: var(--text-muted); }
.apply-admin-status {
  flex: 1 0 100%;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}
.apply-admin-row dl { margin: 0.7rem 0 0; }
.apply-admin-row dt { color: var(--text-muted); font-size: 0.8rem; }
.apply-admin-row dd { margin: 0 0 0.45rem; white-space: pre-wrap; }
.apply-skill-sum { margin: 0 0 0.4rem; line-height: 1.45; }
.apply-skill-sum strong {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}

@media (max-width: 720px) {
  .apply-grid,
  .apply-scale,
  .apply-skill-row { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .research-overview { grid-template-columns: 1fr; }
}

.about-hero {
  padding: 3.5rem 0 3rem;
}

.about-profile {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 2.5rem;
  align-items: flex-start;
}

.profile-photo-img {
  width: 180px;
  height: 234px;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
}

.profile-photo-placeholder {
  width: 180px;
  height: 234px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.profile-eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.profile-name {
  font-size: clamp(1.3rem, 2.5vw, 1.7rem);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: 0.3rem;
}

.profile-role {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.1rem;
}

.profile-text {
  font-size: 0.93rem;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 0.85rem;
  max-width: 600px;
}

.profile-bio-content.rich-content {
  max-width: 600px;
  margin-bottom: 0.85rem;
  font-size: 0.93rem;
}

.profile-bio-content.rich-content p:last-child {
  margin-bottom: 0;
}

.profile-bio-content.rich-content strong {
  font-weight: 700;
}

.profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.profile-tag {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.2rem 0.7rem;
  white-space: nowrap;
}

.profile-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* About sections */
.about-section {
  padding: 2.75rem 0;
  border-top: 1px solid var(--border);
}

.about-section-header {
  margin-bottom: 1.75rem;
}

.about-section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.about-section-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.about-section-header.has-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.about-section-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.section-eye-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex: 0 0 auto;
}

.section-eye-btn[hidden] { display: none; }

.section-eye-btn:hover,
.section-eye-btn.is-hidden {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.about-section.is-visitor-hidden .collab-list,
.about-section.is-visitor-hidden .projects-list,
.about-section.is-visitor-hidden .about-section-header p {
  opacity: 0.45;
}

/* Collaborators — two per row; name over affiliation, small photo beside both lines */
.collab-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 2rem;
}

.collab-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.collab-drag {
  appearance: none;
  width: 0.85rem;
  height: 1.35rem;
  flex: 0 0 auto;
  margin-right: -0.35rem;
  padding: 0;
  border: none;
  background-color: transparent;
  background-image: radial-gradient(circle, currentColor 1.15px, transparent 1.25px);
  background-size: 4px 5px;
  background-position: center;
  color: var(--text-muted);
  cursor: grab;
  touch-action: none;
}

.collab-drag:active,
.collab-entry.is-dragging .collab-drag {
  cursor: grabbing;
}

.collab-entry.is-dragging {
  opacity: 0.45;
}

.collab-entry.is-drop-before { box-shadow: inset 2px 0 0 var(--text-primary); }
.collab-entry.is-drop-after { box-shadow: inset -2px 0 0 var(--text-primary); }
.collab-entry.is-drop-above { box-shadow: inset 0 2px 0 var(--text-primary); }
.collab-entry.is-drop-below { box-shadow: inset 0 -2px 0 var(--text-primary); }

.collab-entry.is-editing {
  background: var(--bg-secondary);
}

.collab-form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

#collab-delete-btn {
  margin-left: auto;
  border-color: #c0392b;
  color: #c0392b;
}

#collab-delete-btn[hidden] {
  display: none !important;
}

.edit-collab-btn {
  margin-left: auto;
  flex-shrink: 0;
}

.collab-entry:nth-child(-n+2) { border-top: 1px solid var(--border); }

.collab-person {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1;
  color: inherit;
  text-decoration: none;
}

.collab-photo {
  width: 3rem;
  height: 3rem;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: block;
}

.collab-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.collab-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.12rem;
}

.collab-entry-name {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
}

a.collab-person:hover .collab-entry-name { text-decoration: underline; }

.collab-entry-inst {
  display: block;
  font-size: 0.77rem;
  color: var(--text-muted);
  line-height: 1.35;
}

@media (max-width: 520px) {
  .collab-list { grid-template-columns: 1fr; column-gap: 0; }
  .collab-entry:nth-child(-n+2) { border-top: none; }
  .collab-entry:first-child { border-top: 1px solid var(--border); }
}

/* Selected projects — text-first */
.projects-list {
  display: flex;
  flex-direction: column;
}

.project-item {
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--border);
}

.project-item:first-child { border-top: 1px solid var(--border); }
.project-item:last-child  { border-bottom: none; }

.project-title {
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.project-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 640px;
}

/* ============================================================
   Post preview panel
   ============================================================ */

.preview-panel {
  margin-top: 1.5rem;
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.preview-banner {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   Highlight.js — code block rendering in detail views
   ============================================================ */

/* Quill saves code blocks as <pre class="ql-syntax">; hljs adds .hljs to it */
pre.ql-syntax {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  tab-size: 2;
}

/* After hljs processes the element it gets .hljs — let its background/color win */
pre.ql-syntax.hljs { border: none; }

/* Standard <pre><code class="hljs"> also gets radius + padding adjustment */
.rich-content pre:has(code.hljs) {
  padding: 0;
  background: transparent;
  border: none;
}
.rich-content pre code.hljs {
  display: block;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app-layout {
    flex-wrap: wrap;
  }
  .nav-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.75rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    gap: 0.5rem;
  }
  .nav-sidebar .nav-brand {
    padding: 0;
    margin-bottom: 0;
    border-bottom: none;
    margin-right: 0.5rem;
  }
  .nav-brand-logo {
    width: 3.75rem;
  }
  .logo-admin {
    width: 100%;
    padding: 0.35rem 0 0;
  }
  .nav-sidebar .nav-links {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1;
    order: 1;
    width: 100%;
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--border);
  }
  .nav-sidebar .nav-right {
    flex-direction: row;
    border-top: none;
    margin-top: 0;
    padding-top: 0;
  }
  .sidebar-controls {
    width: 100%;
    padding: 0.75rem 1rem;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 768px) {
  .hero { padding: 3.5rem 0 2.5rem; }
  .section { padding: 2.5rem 0; }
  .auth-card { margin: 1.5rem 1rem 0; padding: 1.5rem; }
  .stats-strip { gap: 2rem; }
  .about-profile { grid-template-columns: 1fr; gap: 1.5rem; }
  .profile-photo-placeholder,
  .profile-photo-img { width: 120px; height: 156px; font-size: 1.6rem; }
}

@media (max-width: 480px) {
  .card-grid { grid-template-columns: 1fr; }
  .features-grid { grid-template-columns: 1fr 1fr; }
  .post-header { flex-direction: column; }
  .post-row { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
  .post-row-meta { white-space: normal; }
}

/* ---- Comments ---- */
.comments-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.comments-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.comments-empty {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.comment {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.comment:last-child { border-bottom: none; }

.comment-meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.3rem;
}

.comment-author {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.comment-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.comment-body {
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  margin-bottom: 0.4rem;
}

.comment-replies {
  margin-top: 0.5rem;
  margin-left: 1.25rem;
  border-left: 2px solid var(--border);
  padding-left: 1rem;
}

.comment-reply {
  padding: 0.5rem 0;
  border-bottom: none;
}

.reply-form {
  margin-top: 0.5rem;
  margin-left: 1.25rem;
}

.comment-form {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.comment-textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 0.75rem;
  resize: vertical;
  transition: border-color var(--transition);
}

.comment-textarea:focus {
  outline: none;
  border-color: var(--text-muted);
}

.comment-form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.comment-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.comment-is-deleted { opacity: 0.6; }

.comment-deleted-msg {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.25rem 0;
}

/* ============================================================
   Consultation — Calendar
   ============================================================ */

.cal-wrapper {
  border: 1px solid var(--border);
  background: var(--bg-card);
  margin-bottom: 1.5rem;
  max-width: 420px;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.cal-month-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.cal-weekdays span {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: center;
  padding: 0.35rem 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
}

.cal-day {
  background: var(--bg-primary);
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: default;
  position: relative;
  transition: background var(--transition), color var(--transition);
  user-select: none;
}

.cal-day.other-month {
  opacity: 0.25;
}

.cal-day.today {
  outline: 1px solid var(--text-muted);
  outline-offset: -2px;
}

.cal-day.has-slots {
  cursor: pointer;
  color: var(--text-primary);
  font-weight: 600;
}

.cal-day.has-slots:hover {
  background: var(--bg-card);
}

/* Small dot under dates with slots */
.cal-day.has-slots::after {
  content: '';
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
}

.cal-day.selected {
  background: var(--text-primary);
  color: var(--bg-primary);
}

.cal-day.selected::after {
  background: var(--bg-primary);
}

/* ============================================================
   Consultation — Slot rows (user picks a time)
   ============================================================ */

.slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  transition: background var(--transition), border-left-color var(--transition);
}

.slot-row:hover {
  background: var(--bg-card);
  border-left-color: var(--text-muted);
}

.slot-row.unavailable {
  opacity: 0.45;
}

.slot-row-time {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.slot-row-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* ============================================================
   Consultation — Status badges
   ============================================================ */

.status-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.status-pending  { color: var(--text-secondary); }
.status-approved { color: var(--text-primary); border-color: var(--text-muted); }
.status-rejected { color: var(--text-muted); text-decoration: line-through; }

/* ============================================================
   Consultation — Admin booking rows
   ============================================================ */

.booking-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  transition: background var(--transition), border-left-color var(--transition);
}

.booking-row:hover {
  background: var(--bg-card);
  border-left-color: var(--text-muted);
}

.booking-row-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.booking-row-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

.booking-row-slot {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.booking-row-topic {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.booking-row-contact {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.booking-row-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

.booking-status-select {
  font-size: 0.78rem;
  font-family: inherit;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

/* ============================================================
   Consultation — Admin slot management rows
   ============================================================ */

.admin-slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  transition: background var(--transition);
}

.admin-slot-row:hover {
  background: var(--bg-card);
  border-left-color: var(--text-muted);
}

.admin-slot-row-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
}

.admin-slot-row-time {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.admin-slot-row-notes {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.admin-slot-row-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* ---- My Bookings (user consultation view) ---- */

.my-booking-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-secondary);
  margin-bottom: 0.75rem;
  transition: border-color 0.15s;
}

.my-booking-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.my-booking-date {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.my-booking-topic {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.my-booking-cal-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

/* ── News feed articles ──────────────────────────────────── */
.news-article {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
}

.news-article:last-child {
  border-bottom: none;
}

.news-article-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.news-article-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.news-article-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* ── Like button (news + writing) ────────────────────────── */
.news-like-btn,
.writing-like-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.news-like-btn:hover,
.writing-like-btn:hover {
  background: var(--bg-card);
  border-color: var(--text-muted);
}

.news-like-btn.is-liked,
.writing-like-btn.is-liked {
  color: #e05;
  border-color: #e05;
  background: rgba(238, 0, 85, 0.06);
}

/* ── Post navigation strip ───────────────────────────────── */
.post-nav-strip {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 2rem 0 1rem;
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.post-nav-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
  border: 1px solid var(--border);
}

.post-nav-item:hover {
  background: var(--bg-input);
}

.post-nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.post-nav-current {
  background: var(--accent);
  border-color: var(--accent);
  cursor: default;
}

.post-nav-current:hover {
  background: var(--accent);
}

.post-nav-title {
  display: block;
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--text-primary);
}

.post-nav-current .post-nav-title {
  color: #fff;
  font-weight: 600;
}

.post-nav-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.post-nav-pages {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  flex: 1;
  justify-content: center;
}

.post-nav-page {
  min-width: 2rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-primary);
  transition: background 0.15s;
}

.post-nav-page:hover {
  background: var(--bg-input);
}

.post-nav-page-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---------- Project timeline ---------- */
.tl-toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 1rem 0 0.6rem;
  flex-wrap: wrap;
}

.tl-legend {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.tl-type-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.9rem;
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.tl-type-key > span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tl-swatch {
  width: 0.55rem;
  height: 0.55rem;
  flex: 0 0 auto;
  box-sizing: border-box;
}

.tl-swatch.is-grant,
.tl-bar.is-grant .tl-bar-fill { background: #3b6ea5; }
.tl-swatch.is-paper,
.tl-bar.is-paper .tl-bar-fill { background: #2f7d4f; }
.tl-swatch.is-presentation,
.tl-bar.is-presentation .tl-bar-fill { background: #c47a1a; }
.tl-swatch.is-other,
.tl-bar.is-other .tl-bar-fill { background: #6e6e6e; }

.tl-bar.is-grant { background: rgba(59, 110, 165, 0.22); border-color: #3b6ea5; }
.tl-bar.is-paper { background: rgba(47, 125, 79, 0.22); border-color: #2f7d4f; }
.tl-bar.is-presentation { background: rgba(196, 122, 26, 0.24); border-color: #c47a1a; }
.tl-bar.is-other { background: rgba(110, 110, 110, 0.2); border-color: #6e6e6e; }

[data-theme="dark"] .tl-swatch.is-grant,
[data-theme="dark"] .tl-bar.is-grant .tl-bar-fill { background: #7eaddb; }
[data-theme="dark"] .tl-swatch.is-paper,
[data-theme="dark"] .tl-bar.is-paper .tl-bar-fill { background: #6dbe8e; }
[data-theme="dark"] .tl-swatch.is-presentation,
[data-theme="dark"] .tl-bar.is-presentation .tl-bar-fill { background: #e2a44a; }
[data-theme="dark"] .tl-swatch.is-other,
[data-theme="dark"] .tl-bar.is-other .tl-bar-fill { background: #b0b0b0; }

[data-theme="dark"] .tl-bar.is-grant { background: rgba(126, 173, 219, 0.22); border-color: #7eaddb; }
[data-theme="dark"] .tl-bar.is-presentation { background: rgba(226, 164, 74, 0.22); border-color: #e2a44a; }
[data-theme="dark"] .tl-bar.is-paper { background: rgba(109, 190, 142, 0.22); border-color: #6dbe8e; }
[data-theme="dark"] .tl-bar.is-other { background: rgba(176, 176, 176, 0.2); border-color: #b0b0b0; }

.tl-scroll {
  overflow: auto;
  max-height: min(70vh, 640px);
  border: 1px solid var(--border);
  background: var(--bg-primary);
}

.tl-canvas-inner { position: relative; min-height: 100%; }

.tl-row {
  display: flex;
  align-items: stretch;
  min-height: 44px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.tl-row-axis {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 32px;
  cursor: default;
  background: var(--bg-primary);
}

.tl-row.is-selected { background: var(--bg-secondary); }
.tl-row.is-selected .tl-label { background: var(--bg-secondary); }

.tl-label {
  position: sticky;
  left: 0;
  z-index: 3;
  width: var(--tl-label-w, 168px);
  flex: 0 0 var(--tl-label-w, 168px);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.7rem 0 0.6rem;
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  font-size: 0.82rem;
}

.tl-label-corner { z-index: 5; overflow: visible; }

.tl-label-resize {
  position: absolute;
  top: 0;
  right: -6px;
  width: 8px;
  cursor: col-resize;
  touch-action: none;
  z-index: 2;
}

.tl-label-resize::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 2px;
  background: transparent;
}

.tl-label-resize:hover::before,
.tl-scroll.is-resizing .tl-label-resize::before {
  background: var(--text-muted);
}

body.tl-resizing,
body.tl-resizing * {
  cursor: col-resize !important;
  user-select: none;
}

.tl-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.tl-progress {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex: 0 0 auto;
}

.tl-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
  flex: 0 0 auto;
}

.tl-remove:hover { color: var(--text-primary); }

.tl-track { position: relative; flex: 0 0 auto; }

.tl-axis { height: 32px; }

.tl-tick {
  position: absolute;
  top: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  transform: translateX(4px);
}

.tl-tick::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -8px;
  bottom: -16px;
  width: 1px;
  background: var(--border);
}

.tl-bar {
  position: absolute;
  top: 16px;
  height: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  box-sizing: border-box;
  overflow: hidden;
}

.tl-bar-fill {
  display: block;
  height: 100%;
  background: var(--text-secondary);
}

.tl-mark {
  position: absolute;
  top: 14px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  background: var(--bg-primary);
  border: 1px solid var(--text-primary);
  box-sizing: border-box;
  z-index: 1;
}

.tl-mark::before {
  content: "";
  position: absolute;
  inset: -6px;
}

.tl-mark.is-milestone { border-radius: 50%; }
.tl-mark.is-due { border-radius: 0; }
.tl-mark.is-done { background: var(--text-primary); }
.tl-mark.is-overdue { border-width: 2px; }

.tl-hover {
  position: fixed;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  max-width: 16rem;
  padding: 0.3rem 0.45rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  line-height: 1.3;
  pointer-events: none;
}

.tl-hover[hidden] { display: none; }

.tl-hover-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-hover-meta {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.tl-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--text-muted);
  z-index: 2;
  pointer-events: none;
}

.tl-muted { color: var(--text-muted); font-size: 0.85rem; margin: 0.35rem 0 0; }

.tl-detail {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.tl-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.tl-detail h3 { margin-bottom: 0.2rem; }

.tl-type {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tl-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem 1.25rem;
  margin: 0.9rem 0 0.2rem;
}

.tl-facts dt {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tl-facts dd { margin: 0.15rem 0 0; }

.tl-note.rich-content { margin: 0.9rem 0 0; }

.tl-detail .attach-section { margin: 0.9rem 0 0; }

.tl-details-editor.editor-content,
.tl-details-editor .ql-editor { min-height: 140px; }

.tl-marks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1.15rem 0 0.25rem;
}

.tl-marks-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tl-marks { margin: 0 0 1rem; display: flex; flex-direction: column; }

.tl-mark-edit-btn { margin-left: auto; flex: 0 0 auto; }

.tl-mark-edit {
  padding: 0.65rem 0 0.8rem;
  border-bottom: 1px solid var(--border);
}

.tl-mark-edit-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.7fr;
  gap: 0.6rem;
}

.tl-mark-edit-grid .form-group { margin-bottom: 0; }

.tl-mark-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.btn.tl-delete {
  margin-left: auto;
  color: #c0392b;
  border-color: #c0392b;
}

.btn.tl-delete:hover:not(:disabled) {
  color: #c0392b;
  border-color: #c0392b;
  background: rgba(192, 57, 43, 0.06);
}

.tl-mark-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.tl-mark-kind {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  width: 5.5rem;
  flex: 0 0 auto;
}

.tl-mark-title { flex: 1; min-width: 0; }
.tl-mark-date { color: var(--text-muted); font-size: 0.8rem; flex: 0 0 auto; }
.tl-mark-row.is-done .tl-mark-title { color: var(--text-muted); }
.tl-mark-row.is-overdue .tl-mark-date { color: var(--text-primary); }

.tl-check {
  width: 0.7rem;
  height: 0.7rem;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.tl-check.is-done { background: var(--text-primary); border-color: var(--text-primary); }

.tl-date-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.tl-edit, .tl-add-mark { margin-top: 0.85rem; }

@media (max-width: 700px) {
  .tl-facts { grid-template-columns: 1fr; }
  .tl-type-key { margin-left: 0; }
  .tl-mark-edit-grid { grid-template-columns: 1fr; }
}

#tl-admin-bar[hidden],
#tl-project-form-wrap[hidden],
#tl-scroll[hidden],
#tl-detail[hidden],
#tl-empty[hidden] { display: none; }

#nav-members[hidden] { display: none !important; }

/* ---------- Member directory ---------- */
.org-chart {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow-x: auto;
}

.org-tree {
  display: flex;
  align-items: center;
  width: max-content;
  padding: 0.2rem 0 0.4rem;
}

.org-root {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.org-node {
  display: flex;
  align-items: center;
}

.org-person {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.org-kids {
  display: flex;
  flex-direction: column;
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.org-kids > li {
  display: flex;
  align-items: center;
  position: relative;
  padding: 0.35rem 0;
}

.org-rail {
  position: absolute;
  left: 0;
  width: 1px;
  background: var(--text-muted);
  pointer-events: none;
}

.org-parents > .org-rail {
  left: auto;
  right: 0;
}

.org-rail[hidden] { display: none !important; }

.org-joint,
.org-stem {
  width: 1.15rem;
  height: 1px;
  background: var(--text-muted);
  flex: 0 0 auto;
}

.org-loose {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.6rem;
}

.org-loose-branch {
  display: flex;
  align-items: center;
}

.org-levels {
  border: 1px solid var(--border);
  margin-bottom: 1.75rem;
  overflow-x: auto;
}

.org-levels table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.org-levels th,
.org-levels td {
  padding: 0.5rem 0.7rem;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
  font-weight: 400;
}

.org-levels thead th { border-top: 0; font-weight: 600; }

.org-levels th:first-child,
.org-levels td:first-child { border-left: 0; }

.org-levels tbody th {
  text-align: left;
  font-weight: 500;
  white-space: nowrap;
}

.org-level-note {
  color: var(--text-secondary);
}

.org-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  color: var(--text-secondary);
}

.org-mark::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border: 1.5px solid currentColor;
  flex: 0 0 auto;
}

.org-mark.is-full {
  font-weight: 600;
  color: var(--text-primary);
}

.org-mark.is-full::before { background: currentColor; }

.org-mark.is-own::before {
  background: linear-gradient(to right, currentColor 50%, transparent 50%);
}

.org-mark.is-none {
  color: var(--text-muted);
}

.org-mark.is-none::before { display: none; }

.org-level-key {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.org-level-key .org-mark { margin-right: 0.15rem; }

.org-card {
  flex: 0 0 auto;
  width: 13.5rem;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 0.65rem 0.75rem 0.7rem;
}

.org-card-name {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.org-card-email {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  word-break: break-word;
}

a.org-card-email {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a.org-card-email:hover { color: var(--text-secondary); }

.org-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 0.2rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.org-card-level {
  display: inline-block;
  margin-top: 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.org-card-level.is-editable {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  width: 7.4rem;
  cursor: pointer;
  padding: 0.22rem 0.38rem 0.16rem 0.32rem;
  margin-left: -0.32rem;
  border: 1px solid var(--border);
}

.org-card-level.is-editable:hover {
  background: var(--bg-input);
}

.org-role-title {
  line-height: 1;
  white-space: nowrap;
}

.org-card-level.is-editable select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  appearance: none;
  border: 0;
}

.org-card-level.is-editable select:focus {
  outline: none;
}

.org-card-level.is-editable:focus-within {
  outline: none;
  border-color: var(--text-muted);
}

.org-role-arrow {
  width: 0.42rem;
  height: 0.42rem;
  margin-top: -0.06rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  flex: 0 0 auto;
  color: var(--text-secondary);
}

.org-lead {
  width: calc(100% + 0.32rem);
  margin-top: 0.35rem;
}

.org-lead-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.org-empty,
.comment-locked {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.comment-locked { text-align: left; }

@media (max-width: 700px) {
  .org-level-list > div { grid-template-columns: 1fr; }
}

#org-chart[hidden],
#org-gate[hidden],
#org-gate-login[hidden],
#nav-members[hidden] { display: none !important; }

/* Lab member profiles */
.member-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.member-card {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 1rem 1.15rem;
  align-items: start;
  min-width: 0;
  padding: 1.1rem 1rem 1.2rem;
  background: var(--bg-primary);
}

.member-photo {
  width: 5.5rem;
  height: 5.5rem;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: block;
}

.member-photo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.member-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.member-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
}

.member-edit-btn { flex-shrink: 0; }

.member-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.4;
}

.member-bio {
  margin-top: 0.55rem;
}

.member-bio p {
  margin: 0 0 0.45rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

.member-bio p:last-child { margin-bottom: 0; }

.member-email {
  display: block;
  margin-top: 0.45rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  word-break: break-word;
}

a.member-email {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a.member-email:hover { color: var(--text-secondary); }

.member-card.is-editing {
  grid-column: 1 / -1;
  align-items: start;
}

.member-photo-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.member-fields {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.member-fields label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.member-fields input,
.member-fields textarea {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9rem;
}

.member-fields textarea { resize: vertical; line-height: 1.5; }

.member-edit-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.15rem;
}

@media (max-width: 560px) {
  .member-card { grid-template-columns: 4.25rem 1fr; gap: 0.75rem; }
  .member-photo { width: 4.25rem; height: 4.25rem; }
}

/* ---------- DOSE-Control staff overview ---------- */
.dose-access {
  border: 1px solid var(--border);
  padding: 0.9rem 1rem 0.75rem;
  margin-bottom: 1.25rem;
}
.dose-access-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}
.dose-access-row label {
  font-size: 0.85rem;
  font-weight: 600;
}
.dose-access-row select {
  flex: 1;
  min-width: 14rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.6rem;
}
.dose-granted {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.75rem 0 0;
}
.dose-request-label {
  margin: 0.85rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
}
#dose-request-block[hidden] { display: none !important; }
#dose-requests { margin-top: 0.4rem; }
.dose-granted li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0;
  font-size: 0.85rem;
  border-bottom: 1px dashed var(--border);
}
.dose-granted li:last-child,
.dose-granted li.dose-granted-empty {
  border-bottom: 0;
  padding-bottom: 0;
}
#dose-requests li:last-child:not(.dose-granted-empty) {
  border-bottom: 1px dashed var(--border);
  padding-bottom: 0.45rem;
}
.dose-request-person {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}
.dose-request-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.dose-confirm {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 1.15rem 1.25rem 1rem;
  max-width: 26rem;
  width: calc(100% - 2rem);
}
.dose-confirm::backdrop { background: rgba(0, 0, 0, 0.45); }
.dose-confirm p { margin: 0; }
#dose-confirm-meta { margin-top: 0.4rem; }
#dose-confirm-meta[hidden] { display: none !important; }
.dose-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}
.dose-granted-empty { color: var(--text-muted); }
#smw-dash[hidden],
#smw-panel-overview[hidden],
#smw-panel-onboarding[hidden] { display: none !important; }
#smw-dash { margin-top: 0.35rem; }
#smw-panel-onboarding .form-error { margin-top: 0.65rem; }
.smw-schedule {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.smw-schedule th,
.smw-schedule td {
  padding: 0.4rem 0.55rem;
  border-top: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
  background: var(--bg-primary);
}
.smw-schedule thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-top: 0;
  font-weight: 600;
  color: var(--text-secondary);
}
.smw-schedule th:first-child,
.smw-schedule td:first-child,
.smw-schedule tbody th {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
}
.smw-schedule thead th:first-child { z-index: 3; }
.smw-schedule td { color: var(--text-muted); }
.smw-schedule td.is-in {
  background: var(--text-primary);
  color: var(--bg-primary);
  font-weight: 600;
}
.smw-schedule td.is-now { text-decoration: underline; text-underline-offset: 0.15em; }
.smw-app-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}
.smw-app-row [hidden] { display: none !important; }
.smw-app-link {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.dose-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.dose-tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 0.35rem 0 0.55rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text-muted);
  cursor: pointer;
}
.dose-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}
.dose-new-user {
  padding: 0.9rem 0;
  border-top: 1px solid var(--border);
}
.dose-new-user h3 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
  font-weight: 600;
}
.dose-new-user h3 span {
  margin-left: 0.55rem;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
}
.dose-setup {
  display: grid;
  grid-template-columns: 11.5rem minmax(0, 1fr);
  gap: 0.4rem 1rem;
  margin: 0;
}
.dose-setup dt {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.dose-setup dd {
  margin: 0;
  color: var(--text-primary);
  font-size: 0.88rem;
}
.dose-setup dd.dose-missing,
.dose-setup li.dose-missing {
  color: #c0392b;
}
.dose-setup ol {
  margin: 0.2rem 0 0;
  padding-left: 1.15rem;
}
.dose-setup li { margin: 0.12rem 0; }
#dose-panel-participants[hidden],
#dose-panel-new[hidden],
#dose-panel-recruit[hidden],
#dose-panel-rates[hidden],
#dose-panel-resources[hidden],
#dose-panel-documentation[hidden],
#dose-panel-debug[hidden],
#dose-panel-tickets[hidden] { display: none !important; }
.dose-ticket-form {
  display: grid;
  gap: 0.85rem;
  max-width: 36rem;
  margin: 0 0 1.25rem;
}
.dose-ticket-form[hidden] { display: none; }
.dose-ticket-field {
  display: grid;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.dose-ticket-field input,
.dose-ticket-field select,
.dose-ticket-field textarea,
.dose-multi summary {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.7rem;
}
.dose-ticket-field textarea {
  resize: vertical;
  min-height: 6.5rem;
  line-height: 1.45;
}
.dose-ticket-field input:focus,
.dose-ticket-field select:focus,
.dose-ticket-field textarea:focus,
.dose-multi summary:focus { outline: none; border-color: var(--text-muted); }
.dose-multi { position: relative; }
.dose-multi summary {
  cursor: pointer;
  list-style: none;
  text-align: left;
}
.dose-multi summary::-webkit-details-marker { display: none; }
.dose-multi-menu {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  max-height: 14rem;
  overflow: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-top: 0;
}
.dose-multi-heading {
  margin: 0;
  padding: 0.5rem 0.7rem 0.15rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.dose-multi-menu label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  width: 100%;
  padding: 0.4rem 0.75rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.3;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.dose-multi-menu input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  flex: none;
}
.dose-ticket-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.dose-ticket-actions-start { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.dose-ticket-body > .dose-ticket-actions { margin-top: 0.85rem; max-width: 36rem; }
.dose-ticket-body .dose-ticket-confirm { margin: 0; color: var(--text-primary); font-size: 0.85rem; }
.dose-ticket-actions > [data-close-ask] { margin-left: auto; }
.dose-tickets {
  margin: 0;
  padding: 0;
  list-style: none;
}
.dose-ticket-order,
.dose-ticket-toggle {
  display: grid;
  grid-template-columns: 3.6rem 4.4rem 3.1rem 9.7rem minmax(0, 1fr) 7.4rem;
  column-gap: 0.85rem;
  align-items: start;
}
.dose-ticket-order {
  margin: 0.35rem 0 0.15rem;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
}
.dose-ticket-col,
.dose-ticket-order .dose-sort { white-space: nowrap; }
.dose-ticket-toggle {
  width: 100%;
  padding: 0.75rem 0;
  border: 0;
  border-top: 1px solid var(--border);
  background: none;
  color: var(--text-primary);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.dose-ticket-title,
.dose-ticket-when,
.dose-ticket-to,
.dose-ticket-id,
.dose-ticket-priority {
  color: var(--text-primary);
  font-size: 0.84rem;
  font-weight: 400;
}
.dose-ticket-title,
.dose-ticket-to {
  min-width: 0;
  overflow-wrap: break-word;
}
.dose-ticket-id,
.dose-ticket-when,
.dose-ticket-priority { white-space: nowrap; }
.dose-ticket-to { text-align: left; }
.dose-ticket-mark {
  justify-self: start;
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 400;
  line-height: 1.3;
  padding: 0.02rem 0.35rem;
  text-transform: uppercase;
}
.dose-ticket-mark.is-fresh {
  border-color: var(--ticket-fresh);
  color: var(--ticket-fresh);
}
.dose-ticket-mark.is-day {
  border-color: var(--ticket-day);
  color: var(--ticket-day);
}
.dose-ticket-mark.is-late {
  border-color: var(--ticket-late);
  color: var(--ticket-late);
}
.dose-ticket-resolve {
  display: grid;
  gap: 0.55rem;
  max-width: 36rem;
  margin-top: 0.85rem;
}
.dose-ticket-resolution { color: var(--text-muted); font-size: 0.8rem; }
.dose-ticket-comment {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--text-muted);
}
.dose-ticket-body {
  padding: 0 0 0.9rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.dose-ticket-body p { margin: 0 0 0.4rem; white-space: pre-wrap; }
.dose-ticket-meta { color: var(--text-muted); font-size: 0.8rem; }
.dose-export {
  position: relative;
  display: flex;
  align-items: center;
}
.dose-export-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 0.25rem);
  left: 0;
  min-width: 5.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border);
}
.dose-export-menu[hidden] { display: none; }
.dose-export-item {
  display: block;
  width: 100%;
  background: none;
  border: 0;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  white-space: nowrap;
}
.dose-export-item:hover { background: var(--border); }
.dose-debug-logs {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.45;
}
.dose-debug-logs:not(:empty) {
  height: calc(10 * (0.7rem + 1.45 * 0.75rem + 1px));
  overflow-x: hidden;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
}
.dose-debug-logs li {
  display: grid;
  grid-template-columns: 12.5rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
}
.dose-debug-logs time { color: var(--text-muted); white-space: nowrap; }
.dose-debug-logs span { white-space: pre-wrap; overflow-wrap: anywhere; }
.dose-resources {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
}
.dose-resource-card {
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
  min-width: 0;
  padding: 1rem 1.1rem 1.15rem;
  border: 1px solid var(--border);
  background: var(--bg-primary);
}
.dose-resource-card h2 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  font-weight: 600;
}
.dose-resource-logo {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  object-fit: contain;
}
[data-theme="dark"] .dose-resource-logo.is-apple { filter: invert(1); }
.dose-resource-item h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}
.dose-resource-item p {
  margin: 0.28rem 0 0.7rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.45;
}
.dose-resource-uri {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}
.dose-resource-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.dose-resource-names {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
  list-style: disc;
}
.dose-resource-names li {
  margin: 0.2rem 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.dose-resources code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}
.dose-resource-card .btn {
  white-space: normal;
  text-align: center;
}
.dose-resource-card-wide { grid-column: 1 / -1; }
.dose-backend {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.dose-backend p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.45;
}
.dose-backend a {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 0.12em;
}
.dose-dictionary {
  max-height: 22rem;
  overflow: auto;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 0.9rem 1rem 1rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.45;
}
.dose-dictionary h3,
.dose-dictionary h4,
.dose-dictionary h5 {
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
}
.dose-dictionary h3 { margin: 1.15rem 0 0.4rem; font-size: 0.95rem; }
.dose-dictionary h3:first-child { margin-top: 0; }
.dose-dictionary h4 { margin: 1rem 0 0.35rem; font-size: 0.85rem; }
.dose-dictionary h5 { margin: 0.85rem 0 0.3rem; font-size: 0.82rem; }
.dose-dictionary p { margin: 0.3rem 0 0.55rem; white-space: nowrap; }
.dose-dictionary code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--text-primary);
}
.dose-dictionary hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}
.dose-dictionary table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  margin: 0.35rem 0 0.75rem;
  font-size: 0.8rem;
}
.dose-dictionary th,
.dose-dictionary td {
  text-align: left;
  vertical-align: top;
  padding: 0.35rem 0.55rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.dose-dictionary th {
  color: var(--text-primary);
  font-weight: 600;
}
.dose-backend-tree {
  margin: 0;
  font-family: Menlo, "SF Mono", ui-monospace, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-primary);
  white-space: pre;
  overflow-x: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 0.9rem 1rem;
}
.dose-backend-tree.is-scroll {
  max-height: calc(10 * 1.45em + 1.8rem + 2px);
  overflow: auto;
}
.dose-code { position: relative; }
.dose-code-copy {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
}
.dose-code-copy:hover { color: var(--text-primary); }
.dose-code-copy .dose-copy-check,
.dose-code-copy.is-copied .dose-copy-icon { display: none; }
.dose-code-copy.is-copied .dose-copy-check { display: block; }
.dose-tree-note { color: var(--text-muted); }
.dose-card-mark {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: block;
}
.dose-permission-flows {
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  align-items: flex-start;
}
.dose-permission-flow {
  flex: 1 1 0;
  min-width: 0;
  max-width: 500px;
}
.dose-permission-flow > h3 {
  margin: 0 0 0.45rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.dose-permission-flow > h3.dose-resource-kicker {
  margin-top: 0.85rem;
  font-size: 0.72rem;
}
.dose-permission-flow video {
  width: 100%;
  max-width: 500px;
  height: auto;
  display: block;
  background: #000;
}
.dose-permission-policy {
  margin-top: 0;
}
.dose-onboarding-protocols {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.dose-onboarding-protocols .dose-ui-protocol { margin-top: 0; }
.dose-onboarding-protocols .dose-resource-card > h2 { color: var(--form-error); }
.dose-onboarding-protocols .dose-protocol-setup > h2 { color: #9ec1ff; }
[data-theme="light"] .dose-onboarding-protocols .dose-protocol-setup > h2 { color: #1d4ed8; }
.dose-setup-manual h3 {
  margin: 1rem 0 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}
.dose-setup-manual h3,
.dose-setup-manual > p:not(:first-child) {
  margin-left: 1.25rem;
}
.dose-setup-manual p,
.dose-setup-manual li {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.45;
}
.dose-setup-manual > p { margin-top: 0.45rem; }
.dose-setup-manual > p:first-child,
.dose-setup-manual h3 + p { margin-top: 0; }
.dose-setup-manual p + p { margin-top: 0.45rem; }
.dose-setup-manual .dose-setup-label { margin-top: 0.65rem; }
.dose-setup-manual .dose-setup-checks {
  list-style: none;
  margin: 0.35rem 0 0 2.4rem;
  padding-left: 0;
}
.dose-setup-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
}
.dose-setup-check input {
  width: 0.85rem;
  height: 0.85rem;
  margin: 0.22em 0 0;
  flex: 0 0 auto;
  accent-color: var(--text-primary);
}
.dose-setup-manual .dose-setup-checks li + li { margin-top: 0.35rem; }
.dose-setup-manual .dose-setup-snippet {
  margin: 0.4rem 0 0.15rem 1.35rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-primary);
  white-space: pre;
  overflow-x: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
}
.dose-setup-manual strong { color: var(--text-primary); font-weight: 600; }
.dose-setup-manual .dose-setup-flag { color: var(--form-error); }
.dose-setup-manual code,
.dose-setup-manual .dose-ui-formula {
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--text-primary);
}
.dose-setup-manual .dose-ui-formula { display: block; margin-top: 0.35rem; }
.dose-onboarding-protocols .dose-resource-card > h2:has(.dose-protocol-toggle[aria-expanded="false"]) {
  border-bottom: 0;
  padding-bottom: 0;
}
.dose-protocol-toggle {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.dose-protocol-toggle::after {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-0.12rem);
  flex: 0 0 auto;
}
.dose-protocol-toggle[aria-expanded="true"]::after {
  transform: rotate(-135deg) translateY(-0.12rem);
}
.dose-onboarding-protocols a {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 0.12em;
}
#dose-interfaces,
#dose-permissions,
#dose-firebase-structure { scroll-margin-top: 1rem; }
.dose-onboarding-protocols .dose-permission-policy > p:first-child,
.dose-onboarding-protocols .dose-ui-protocol > p:first-child { margin-top: 0; }
.dose-permission-policy > .dose-resource-kicker {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--form-error);
}
.dose-permission-policy p,
.dose-permission-policy li {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.45;
}
.dose-permission-policy > p { margin-top: 0.35rem; }
.dose-permission-sop {
  margin-top: 0.9rem;
  padding-left: 1.25rem;
}
.dose-permission-sop > h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.dose-permission-sop > h3 + ol + h3 {
  margin-top: 0.9rem;
}
.dose-permission-policy code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--text-primary);
}
.dose-permission-policy ol {
  margin: 0.2rem 0 0;
  padding-left: 1.2rem;
}
.dose-permission-policy li + li { margin-top: 0.35rem; }
.dose-permission-policy ol ul {
  margin: 0.25rem 0 0;
  padding-left: 1.15rem;
  list-style: disc;
}
.dose-permission-policy ol ul li + li { margin-top: 0.12rem; }
.dose-permission-policy strong { color: var(--text-primary); font-weight: 600; }
.dose-permission-note { margin-top: 0.75rem; }
.dose-ui-protocol { margin-top: 0.85rem; }
.dose-ui-protocol > .dose-resource-kicker {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--form-error);
}
.dose-ui-protocol p {
  margin: 0.55rem 0 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.45;
}
.dose-ui-protocol > .dose-resource-kicker + p { margin-top: 0.35rem; }
.dose-ui-protocol strong { color: var(--text-primary); font-weight: 600; }
.dose-ui-protocol ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.45;
}
.dose-ui-protocol ol li + li { margin-top: 0.55rem; }
.dose-ui-formula {
  font-family: var(--font-mono);
  color: var(--text-primary);
}
.dose-ui-block { margin-top: 1.15rem; }
.dose-ui-block:first-of-type { margin-top: 0; }
.dose-ui-protocol + .dose-ui-block { margin-top: 1.15rem; }
.dose-ui-block > h3 {
  margin: 0 0 0.45rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.dose-ui-shots {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: flex-start;
}
.dose-ui-shot {
  flex: 1 1 0;
  min-width: 0;
  max-width: 500px;
  margin: 0;
}
.dose-ui-shot img {
  width: 100%;
  max-width: 500px;
  height: auto;
  display: block;
  background: #000;
  border: 1px solid #a3a3a3;
}
.dose-ui-shot figcaption {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.3;
  text-align: center;
}

.dose-compliance {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14rem;
  gap: 1.25rem;
  align-items: start;
  container-type: inline-size;
}
.dose-compliance.is-full { grid-template-columns: minmax(0, 1fr); }
.dose-compliance-kpis,
.dose-recruit-kpis {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  min-width: 0;
}
.dose-compliance-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dose-recruit-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dose-recruit-kpis .dose-stat strong {
  font-size: 1.05rem;
  line-height: 1.15;
  white-space: nowrap;
}
.dose-recruit-year { display: block; }
.dose-updated {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 0.55rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}
.dose-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
}
.dose-icon-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }
.dose-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.dose-icon-btn:disabled:hover {
  color: var(--text-secondary);
  border-color: var(--border);
}
.dose-rate-aside { margin-top: calc((100cqi - 14rem - 1.25rem) * 20 / 760); }
.dose-rate-aside h2 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.dose-rate-aside p {
  margin: 0 0 0.6rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.4;
}
.dose-rate-aside ul { list-style: none; margin: 0; padding: 0; }
.dose-rate-aside li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}
.dose-rate-aside li span:last-child { color: var(--text-muted); }
.dose-rate-restore {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.dose-rate-restore-name {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.dose-rate-restore[aria-pressed="true"] .dose-rate-restore-name { font-weight: 600; }
.dose-rate-plot { overflow: visible; }
.dose-rate-frame { position: relative; }
.dose-rate-info {
  position: absolute;
  z-index: 2;
  top: calc(20 / 420 * 100%);
  left: calc(742 / 760 * 100% + 0.4rem);
  background: var(--bg-primary);
}
.dose-rate-plot svg { display: block; width: 100%; height: auto; }
.dose-rate-plot text { font-family: var(--font-sans); }
.dose-rate-plot .axis,
.dose-rate-ylabel,
.dose-rate-target-label,
.dose-rate-key,
.dose-rate-caption {
  font-size: 0.75rem;
}
.dose-rate-plot .axis { fill: var(--text-muted); }
.dose-rate-plot .grid { stroke: var(--border); stroke-width: 1; }
.dose-rate-target { stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 4 3; }
.dose-rate-line { fill: none; stroke-width: 2; }
.dose-rate-group { stroke: var(--text-primary); stroke-width: 2.6; }
.dose-rate-band { fill: var(--text-primary); opacity: 0.14; }
.dose-rate-swatch-group { background: var(--text-primary); height: 0.28rem; }
.dose-rate-series.is-dim,
.dose-rate-key.is-dim,
.dose-recruit-series.is-dim,
.dose-recruit-key.is-dim { opacity: 0.15; }
.dose-rate-series.is-off,
.dose-recruit-series.is-off { display: none; }
.dose-rate-key.is-off,
.dose-recruit-key.is-off { opacity: 0.4; text-decoration: line-through; }
.dose-recruit-projected { stroke-dasharray: 6 4; stroke-width: 1.6; }
.dose-recruit-swatch-dashed {
  height: 0;
  background: none !important;
  border-top: 2px dashed currentColor;
}
.dose-rate-caption {
  margin: 0.55rem 0 0;
  padding-left: calc(78 / 760 * 100%);
  color: var(--text-muted);
  line-height: 1.4;
}
.dose-rate-tip {
  position: fixed;
  z-index: 30;
  max-width: 16rem;
  padding: 0.45rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.78rem;
  line-height: 1.4;
  pointer-events: none;
}
.dose-rate-tip strong { display: block; font-weight: 600; }
.dose-rate-tip span { display: block; color: var(--text-secondary); }
.dose-rate-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin: 0.8rem 0 0;
  padding: 0 0 0 calc(78 / 760 * 100%);
  list-style: none;
}
.dose-rate-key {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.dose-rate-swatch {
  width: 0.85rem;
  height: 0.18rem;
  border-radius: 1px;
}
.dose-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 1rem;
  row-gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.dose-rates-filter { margin-bottom: 0.85rem; }
.dose-toolbar-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  min-width: 0;
}
.dose-toolbar > #dose-ticket-new {
  align-self: stretch;
  font-size: 0.9rem;
  line-height: normal;
  padding: 0.45rem 0.7rem;
}
.dose-toolbar-note {
  margin: 0;
  min-width: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.45;
}
.dose-toolbar-note .dose-info { vertical-align: -0.15em; margin-left: 0.15rem; }
.dose-toolbar input[type="search"] {
  width: 14rem;
  max-width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.7rem;
}
.dose-toolbar input[type="search"]:focus { outline: none; border-color: var(--text-muted); }
.dose-toolbar select {
  max-width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.7rem;
}
.dose-toolbar select:focus { outline: none; border-color: var(--text-muted); }
.dose-access-row select,
.dose-ticket-field select,
.dose-toolbar select {
  --dose-select-pad: 0.7rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='2.45 5.35 11.1 6'%3E%3Cpath d='M3.2 6.1 8 10.6l4.8-4.5' fill='none' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--dose-select-pad) center;
  background-size: 0.7rem auto;
  padding-right: calc(var(--dose-select-pad) + 0.7rem + 0.55rem);
}
[data-theme="light"] .dose-access-row select,
[data-theme="light"] .dose-ticket-field select,
[data-theme="light"] .dose-toolbar select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='2.45 5.35 11.1 6'%3E%3Cpath d='M3.2 6.1 8 10.6l4.8-4.5' fill='none' stroke='%23444' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.dose-access-row select { --dose-select-pad: 0.6rem; }
.dose-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.dose-check input { width: auto; }
.dose-field { display: inline-flex; align-items: center; gap: 0.2rem; }
.dose-th { display: inline-flex; align-items: center; gap: 0.28rem; }
.dose-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.95rem;
  height: 0.95rem;
  padding: 0;
  border: 1.25px solid currentColor;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font: 600 0.62rem/1 var(--font-sans, inherit);
  cursor: pointer;
  flex: 0 0 auto;
}
.dose-info::before { content: "i"; }
.dose-info:hover,
.dose-info[aria-expanded="true"] { color: var(--text-primary); }
.dose-info:focus-visible { outline: 2px solid var(--text-muted); outline-offset: 2px; }
.dose-help {
  position: fixed;
  z-index: 80;
  display: flex;
  flex-direction: column;
  width: min(18.5rem, calc(100vw - 16px));
  max-height: min(14rem, calc(100vh - 16px));
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  font-size: 0.78rem;
  line-height: 1.45;
}
.dose-help.is-long {
  width: min(36rem, calc(100vw - 16px));
  max-height: min(32rem, calc(100vh - 16px));
  font-size: 0.86rem;
  line-height: 1.5;
}
.dose-help[hidden] { display: none; }
.dose-help-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.65rem 0.2rem;
}
.dose-help.is-long .dose-help-bar { padding: 0.75rem 0.95rem 0.35rem; }
.dose-help-bar h2 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--text-primary);
}
.dose-help.is-long .dose-help-bar h2 { font-size: 1.02rem; }
.dose-help-close {
  border: 0;
  background: none;
  padding: 0.1rem 0.15rem;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}
.dose-help-close:hover { color: var(--text-primary); }
.dose-help-close:focus-visible { outline: 2px solid var(--text-muted); outline-offset: 2px; }
.dose-help-body { overflow: auto; padding: 0.15rem 0.7rem 0.7rem; }
.dose-help.is-long .dose-help-body { padding: 0.2rem 0.95rem 0.95rem; }
.dose-help p { margin: 0.4rem 0 0; }
.dose-help ol,
.dose-help ul { margin: 0.45rem 0 0; padding-left: 1.15rem; }
.dose-help li { margin: 0.28rem 0; }
.dose-help h3 {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--text-primary);
}
.dose-help code { font-family: var(--font-mono); font-size: 0.92em; }
.dose-help strong { color: var(--text-primary); font-weight: 600; }

.dose-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.dose-stat { background: var(--bg-primary); padding: 0.85rem 1rem; }
.dose-stat strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
}
.dose-stat span {
  display: block;
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.3;
}

.dose-status { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.75rem; }
.dose-table-wrap { overflow-x: auto; border: 1px solid var(--border); }
.dose-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.dose-table th,
.dose-table td {
  padding: 0.55rem 0.7rem;
  border-top: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.dose-table thead th {
  border-top: 0;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.dose-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
}
.dose-sort:hover { color: var(--text-primary); }
.dose-sort:focus-visible { outline: 2px solid var(--text-muted); outline-offset: 2px; }
.dose-sort-arrow {
  display: inline-block;
  width: 0.7rem;
  font-size: 0.68rem;
  line-height: 1;
}
.dose-user {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}
.dose-user:hover { color: var(--accent-hover); }
.dose-sub { display: block; color: var(--text-muted); font-size: 0.75rem; font-weight: 400; }
.dose-mono { font-family: var(--font-mono); font-size: 0.75rem; white-space: nowrap; }
.dose-action { min-width: 7.5rem; }
.dose-action.is-urgent { color: #c0392b; font-weight: 400; }
.dose-action.is-quiet { color: var(--text-muted); }
.dose-detail td { background: var(--bg-secondary); }
.dose-detail p { margin: 0.15rem 0; color: var(--text-secondary); font-size: 0.82rem; }
.dose-detail .dose-upcoming {
  margin: 0.1rem 0 0.25rem;
  padding-left: 1.15rem;
  color: var(--text-secondary);
  font-size: 0.82rem;
}
.dose-detail .dose-upcoming li { margin: 0.08rem 0; }
.dose-note { margin-top: 0.9rem; color: var(--text-muted); font-size: 0.78rem; }
.dose-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.dose-pager[hidden] { display: none; }
.dose-pager span { color: var(--text-muted); font-size: 0.78rem; }
.dose-legend {
  margin-top: 1.1rem;
  display: grid;
  grid-template-columns: 11.5rem minmax(0, 1fr);
  gap: 0.45rem 1rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.dose-legend dt,
.dose-legend dd { margin: 0; }
.dose-legend dt { color: var(--text-primary); }
.dose-legend dd ul { margin: 0.35rem 0 0; padding-left: 1.1rem; }
.dose-legend dd li { margin: 0.2rem 0; }
.dose-legend dd strong { color: var(--text-primary); font-weight: 600; }
.dose-request-sent { margin: 0; font-size: 0.9rem; color: var(--text-secondary); }
.auth-card .form-error { margin-top: 0.75rem; }
#dose-gate-login[hidden],
#dose-gate-request[hidden],
#dose-gate-sent[hidden] { display: none !important; }

@media (max-width: 720px) {
  .dose-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Course pages (AES.413 and similar) ---------- */
.course-lead {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 42rem;
  margin: 0 0 1.25rem;
}

.course-objectives-intro { margin-bottom: 0.45rem; }

.course-objectives {
  margin: 0 0 0 0.85rem;
  padding-left: 1.25rem;
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.55;
}

.course-objectives li { margin: 0.35rem 0; }

ul.course-objectives { list-style: disc; }

.course-structure-note { margin-top: 1.15rem; }

.course-section {
  margin: 0 0 2.75rem;
}

.course-section h2 {
  font-size: 1.25rem;
  margin: 0 0 0.85rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
}

.course-schedule-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 0.85rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
}

.course-schedule-head h2 {
  margin: 0;
  padding: 0;
  border: 0;
}

.course-toggle-all {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  color: var(--text-muted);
  background: none;
  border: 0;
  cursor: pointer;
}

.course-toggle-all svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.course-toggle-all .is-close { display: none; }
.course-toggle-all[aria-expanded="true"] .is-open { display: none; }
.course-toggle-all[aria-expanded="true"] .is-close { display: block; }

.course-toggle-all:hover,
.course-toggle-all:focus-visible {
  color: #448c8a;
}

.course-toggle-all:focus-visible {
  outline: 2px solid #448c8a;
  outline-offset: 3px;
}

.course-week {
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
}

.course-week h3 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.course-session { margin: 0 0 0.9rem; }
.course-session:last-child { margin-bottom: 0; }

.course-session h4 {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.course-session p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-primary);
}

.course-instruction-part {
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.45;
  color: var(--text-primary);
}

.course-instruction-label {
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

.course-instruction-part:has(> .course-tag) {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 0.6rem;
  row-gap: 0.1rem;
  align-items: start;
}

.course-instruction-part > .course-tag {
  grid-row: 1 / span 2;
  margin-top: 0.18rem;
}

.course-instruction-part > p {
  grid-column: 2;
  margin: 0;
}

.course-instruction-part + .course-instruction {
  margin-top: 0.3rem;
}

.course-instruction {
  margin: 0;
  padding-left: 1.65rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-primary);
  list-style: decimal;
}

.course-instruction li {
  margin: 0.2rem 0 0;
  padding-left: 0.55rem;
}

.course-instruction code,
.course-instruction-part code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 0.02rem 0.28rem;
  border-radius: 3px;
}

.course-instruction + .course-instruction-part,
.course-instruction-part + .course-instruction-part {
  margin-top: 0.85rem;
}

.course-readings,
.course-sources,
.course-due {
  list-style: none;
  margin: 0;
  padding: 0;
}

.course-week > .course-due {
  margin: 0 0 0.9rem;
}

.course-lecture,
.course-lab {
  margin: 0.15rem 0 0;
}

.course-lecture + .course-lab {
  margin-top: 0.55rem;
}

.course-lecture summary,
.course-lab summary {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: fit-content;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.course-lecture summary::-webkit-details-marker,
.course-lab summary::-webkit-details-marker { display: none; }

.course-lecture summary::before,
.course-lab summary::before {
  content: "▸";
  color: var(--text-muted);
  font-weight: 500;
  font-size: 1.4rem;
  line-height: 1;
}

.course-lecture[open] summary::before,
.course-lab[open] summary::before { content: "▾"; }

.course-lecture summary:hover,
.course-lecture summary:focus-visible,
.course-lab summary:hover,
.course-lab summary:focus-visible {
  color: #448c8a;
}

.course-lecture summary:focus-visible,
.course-lab summary:focus-visible {
  outline: 2px solid #448c8a;
  outline-offset: 3px;
}

.course-lecture .course-session,
.course-lab .course-session {
  margin: 0.75rem 0 0 1.15rem;
}

.course-readings li,
.course-due li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  align-items: baseline;
  padding: 0.28rem 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.course-readings li,
.course-sources li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 0.6rem;
  row-gap: 0;
  align-items: start;
  padding: 0.05rem 0;
  font-size: 0.9rem;
  line-height: 1.25;
}

.course-readings li > .course-tag,
.course-sources li > .course-tag {
  grid-row: 1 / span 2;
  margin-top: 0.12rem;
}

.course-readings .course-cite,
.course-sources .course-cite {
  display: block;
  margin: 0;
  line-height: 1.15;
}

.course-tag {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
}

.course-tag.is-required {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.course-tag.is-due {
  color: #c05621;
  border-color: #c05621;
}

[data-theme="dark"] .course-tag.is-due {
  color: #e2a44a;
  border-color: #e2a44a;
}

.course-tag.is-assigned {
  color: #3b6ea5;
  border-color: #3b6ea5;
}

[data-theme="dark"] .course-tag.is-assigned {
  color: #7eaddb;
  border-color: #7eaddb;
}

.course-cite {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.course-readings a,
.course-sources a {
  color: var(--text-primary);
  text-decoration: none;
}
.course-readings a:hover,
.course-sources a:hover { color: #448c8a; }

.course-figure-open {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.course-figure-open:hover,
.course-figure-open:focus-visible {
  color: #448c8a;
}

dialog.course-figure {
  position: fixed;
  inset: 0;
  width: min(
    calc(1100px + var(--nav-width) / 2),
    calc(100vw - var(--nav-width) - var(--controls-width) + var(--nav-width) / 2)
  );
  max-width: calc(100vw - 2rem);
  height: fit-content;
  max-height: calc(100vh - 2rem);
  margin: auto;
  padding: 0.6rem;
  border: 0;
  background: #f5f5f5;
  overflow: auto;
}

@media (max-width: 900px) {
  dialog.course-figure {
    width: min(calc(1100px + var(--nav-width) / 2), calc(100vw - 2rem));
  }
}

.course-figure::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.course-figure img {
  display: block;
  width: 100%;
  height: auto;
}

.course-figure-gallery {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.35rem;
}

.course-figure-nav {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #111;
  font: 500 1.35rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.course-figure-nav:hover,
.course-figure-nav:focus-visible {
  color: #448c8a;
}

.course-figure-caption {
  margin: 0.55rem 0 0.1rem;
  text-align: center;
  color: #333;
  font-size: 0.85rem;
  font-weight: 600;
}

.course-figure-close {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #111;
  font: 400 1.35rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.course-figure-close:hover,
.course-figure-close:focus-visible {
  color: #448c8a;
}

.course-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 2.5rem;
  margin: 0;
}

.course-facts div { margin: 0; }
.course-facts dt {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}
.course-facts dd {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-primary);
}
.course-facts a {
  text-decoration: underline;
  text-underline-offset: 0.16em;
}
.course-facts a:hover { color: #448c8a; }

.course-grade {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.course-grade span:last-child {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}
.course-grade.is-total {
  font-weight: 600;
}
.course-grade.is-total span:last-child {
  color: var(--text-primary);
}

.course-eval {
  max-width: 42rem;
  margin-top: 1.75rem;
}
.course-eval-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 1.35rem 0 0.4rem;
}
.course-eval-head h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}
.course-eval-head .course-toggle-all {
  width: 1.25rem;
  height: 1.25rem;
}
.course-eval-head .course-toggle-all svg {
  width: 0.9rem;
  height: 0.9rem;
}
.course-rubric {
  margin-top: 0.85rem;
  padding-left: 1.15rem;
}
.course-rubric + .course-rubric {
  margin-top: 0.2rem;
}
.course-samples {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  margin: 0.45rem 0 0;
  padding-left: 1.15rem;
}
.course-samples-label {
  font-size: 0.92rem;
  font-weight: 600;
}
.course-rubric-head {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
}
.course-rubric-head h4 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
}
.course-rubric-view,
.course-rubric-download {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 0.16em;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.course-rubric-view:hover,
.course-rubric-download:hover { color: var(--text-primary); }
.course-rubric-body {
  margin: 0.7rem 0 0.25rem;
  padding: 0.85rem 1rem 0.35rem;
  border: 1px solid var(--border);
}
.course-rubric-kicker {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}
.course-rubric-body > p,
.course-rubric-body fieldset p {
  margin: 0 0 0.7rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
.course-rubric-body h5 {
  margin: 1.15rem 0 0.4rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}
.course-rubric-body h6 {
  margin: 0.95rem 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}
.course-rubric-body a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.14em;
}
.course-rubric-body a:hover { color: var(--text-primary); }
.course-rubric-body code {
  font-family: var(--font-mono);
  font-size: 0.86em;
}
.course-rubric-scroll {
  overflow-x: auto;
  margin: 0 0 0.85rem;
}
.course-rubric-scroll:has(.is-wide) {
  overflow-x: scroll;
  padding-bottom: 0.35rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-focus) transparent;
}
.course-rubric-scroll:has(.is-wide)::-webkit-scrollbar { height: 8px; }
.course-rubric-scroll:has(.is-wide)::-webkit-scrollbar-thumb { background: var(--border-focus); }
.course-rubric-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-primary);
}
.course-rubric-body table.is-wide {
  width: max-content;
  min-width: 100%;
}
.course-rubric-body table.is-wide th { white-space: nowrap; }
.course-rubric-body table.is-wide td { max-width: 18rem; }
.course-rubric-body table.is-wide td:first-child {
  max-width: none;
  white-space: nowrap;
}
.course-rubric-body th,
.course-rubric-body td {
  text-align: left;
  vertical-align: top;
  padding: 0.4rem 0.7rem 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.course-rubric-body th {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.course-rubric-body fieldset {
  margin: 0 0 0.85rem;
  padding: 0;
  border: 0;
}
.course-rubric-body legend {
  margin: 0 0 0.25rem;
  padding: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}
.course-rubric-body .course-rubric-options {
  list-style: none;
  margin: 0.15rem 0 0;
  padding: 0;
}
.course-rubric-options li { margin: 0.18rem 0; }
.course-rubric-options label {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text-primary);
  cursor: pointer;
}
.course-rubric-options input {
  margin: 0.22rem 0 0;
  accent-color: var(--text-primary);
}
.course-rubric-write {
  display: block;
  margin: 0 0 0.9rem;
}
.course-rubric-write span {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}
.course-rubric-write small {
  display: block;
  margin: 0.15rem 0 0.35rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-secondary);
}
.course-rubric-write textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.45rem 0.55rem;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  resize: vertical;
}

.course-eval h4 {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0.85rem 0 0.35rem;
}
.course-eval p {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-primary);
}
.course-eval ul {
  margin: 0 0 0.75rem;
  padding-left: 1.15rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-primary);
  list-style: disc;
}
.course-eval li { margin: 0.35rem 0; }
.course-eval li strong { font-weight: 600; }

.course-scale {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  column-gap: 2.75rem;
  row-gap: 0.4rem;
  margin-top: 1.35rem;
  font-size: 0.92rem;
  color: var(--text-primary);
}
.course-scale p {
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.course-scale span {
  display: inline-block;
  min-width: 1.7rem;
  margin-right: 0.35rem;
  font-weight: 600;
}

.course-staff p { margin: 0.15rem 0; }
.course-staff .course-cite { display: block; }

/* Narrow windows use the wrapped layout, which collapses the page.
   Show a single message instead of rendering that layout. */
@media (max-width: 900px) {
  .app-layout,
  .teaching-lock-modal {
    display: none !important;
  }

  html.teaching-page-locked body {
    visibility: visible !important;
  }

  body {
    overflow: hidden;
    background: var(--bg-primary);
  }

  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: var(--bg-primary);
    visibility: visible;
  }

  body::after {
    content: "This website is best experienced on a larger screen.\APlease visit us on a desktop or tablet for the optimal experience.";
    position: fixed;
    z-index: 100001;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(36rem, calc(100vw - 3rem));
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1.05rem;
    font-weight: 400;
    line-height: 1.55;
    text-align: center;
    white-space: pre-line;
    visibility: visible;
  }
}
