* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  transition: background 0.2s, color 0.2s;
}

:root {
  --shell-max-width: min(1320px, calc(100vw - 64px));
}

.container {
  max-width: var(--shell-max-width);
  margin: 0 auto;
  padding: 0 32px;
}

.section-divider {
  width: 100%;
  height: 2px;
  background: var(--border);
  margin: 34px 0 30px;
}

#lrt-nav {
  position: sticky;
  top: 0;
  z-index: 9999;
  height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
}
#lrt-nav-inner {
  max-width: var(--shell-max-width);
  margin: 0 auto;
  padding: 0 32px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
#lrt-logo {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  transition: opacity 0.15s;
}
#lrt-logo:hover { opacity: 0.7; }
#lrt-logo .dot { color: var(--accent); }
#lrt-nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
#lrt-mobile-menu {
  display: none;
  position: relative;
}
#lrt-mobile-menu > summary {
  list-style: none;
}
#lrt-mobile-menu > summary::-webkit-details-marker {
  display: none;
}
.nav-menu-toggle {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.nav-menu-toggle:hover {
  background: var(--surface2);
  color: var(--text);
}
.nav-mobile-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(0,0,0,0.14);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 150;
}
.nav-mobile-panel .lrt-nav-link {
  display: block;
  width: 100%;
}
.nav-mobile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.nav-mobile-action-btn {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  padding: 9px 8px;
  cursor: pointer;
}
.nav-mobile-action-btn:hover {
  background: var(--surface2);
}
#lrt-nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-auth {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lrt-nav-link {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.lrt-nav-link:hover { background: var(--surface2); color: var(--text); }
.lrt-current { background: var(--surface2); color: var(--text); font-weight: 600; }
.lrt-gh-link {
  display: flex;
  align-items: center;
  padding: 5px 6px;
  flex-shrink: 0;
}
.lrt-gh-link svg { width: 18px; height: 18px; display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius, 8px);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
  font-family: inherit;
}
.btn-primary { background: var(--text); color: var(--surface); }
.btn-primary:hover:not(:disabled) { opacity: 0.85; }
.btn-primary:disabled { background: var(--text-faint, #888); cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface2); }
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  color: var(--text);
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-sm:hover:not(:disabled) { background: var(--surface2); }
.btn-sm:disabled { opacity: 0.45; cursor: not-allowed; }
.dark-toggle {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.dark-toggle:hover { background: var(--surface2); color: var(--text); }
.dark-toggle svg { width: 18px; height: 18px; display: block; }
.dark-toggle .icon-sun { display: none; }
.dark-toggle .icon-moon { display: block; }
body.dark .dark-toggle .icon-sun { display: block; }
body.dark .dark-toggle .icon-moon { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 28px 30px;
  width: 380px;
  max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal h3 { font-size: 17px; font-weight: 600; margin-bottom: 5px; }
.modal-subtitle { font-size: 13px; color: var(--text2); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

.settings-modal {
  width: min(560px, 96vw);
  max-height: 82vh;
  overflow-y: auto;
  padding: 22px 22px 18px;
}
.settings-modal a { color: var(--accent); text-decoration: none; }
.settings-modal a:hover { text-decoration: underline; }
.settings-section { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.settings-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.settings-section h4 { font-size: 13px; font-weight: 700; letter-spacing: 0.01em; margin-bottom: 12px; }
.provider-grid { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.provider-btn {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  color: var(--text2);
  transition: all 0.12s;
}
.provider-btn:hover { background: var(--surface2); color: var(--text); }
.provider-btn.active { background: #dbeafe; color: #1e40af; border-color: #93c5fd; box-shadow: inset 0 0 0 1px rgba(30,64,175,0.08); }
.settings-key-input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font-mono);
  background: var(--surface);
  color: var(--text);
}
.settings-key-input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.settings-label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.settings-hint { font-size: 12px; color: var(--text2); margin-top: 8px; line-height: 1.6; }
.settings-hint a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.settings-key-check-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.settings-check-btn {
  font-size: 12px;
  padding: 6px 10px;
}
.settings-cl-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--surface);
}
.settings-cl-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
}
.settings-cl-status.valid {
  color: #166534;
  border-color: #86efac;
  background: #f0fdf4;
}
.settings-cl-status.valid .settings-cl-status-dot {
  background: #16a34a;
}
.settings-cl-status.invalid {
  color: #991b1b;
  border-color: #fecaca;
  background: #fef2f2;
}
.settings-cl-status.invalid .settings-cl-status-dot {
  background: #dc2626;
}
.help-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-top: 6px;
  opacity: 0.8;
}
.help-toggle:hover { color: var(--accent); opacity: 1; }
.help-toggle .chevron { display: inline-block; transition: transform 0.15s; font-style: normal; }
.help-toggle.open .chevron { transform: rotate(90deg); }
.help-panel {
  margin-top: 7px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text2);
  border: 1px solid var(--border);
}
.help-panel ol { margin: 4px 0 0; padding-left: 18px; }
.help-panel li { margin-bottom: 3px; }
.help-panel a { color: var(--accent); text-decoration: none; }
.help-panel a:hover { text-decoration: underline; }
.help-panel code { background: var(--surface); padding: 1px 5px; border-radius: 3px; font-size: 11px; font-family: var(--font-mono); color: var(--text); }
body.dark .settings-cl-status {
  background: #111113;
  border-color: #3f3f46;
  color: #c8c8d2;
}
body.dark .settings-cl-status.valid {
  background: #052e16;
  border-color: #166534;
  color: #86efac;
}
body.dark .settings-cl-status.invalid {
  background: #2d0a0a;
  border-color: #7f1d1d;
  color: #fca5a5;
}

.author-section { padding: 0 0 92px; }
.author-inner {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  max-width: 700px;
}
.author-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.author-avatar-fallback {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-serif);
  font-size: 24px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.author-name {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.author-roles {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.7;
  margin-bottom: 12px;
}
.author-pubs {
  font-size: 14px;
  color: var(--text-faint, var(--text-subtle));
  line-height: 1.65;
  margin-bottom: 16px;
}
.author-pubs em { font-style: italic; }
.author-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.author-link {
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  transition: opacity 0.15s ease;
}
.author-link:hover { opacity: 0.75; }
.author-link-sep {
  color: var(--text-faint, var(--text-subtle));
  font-size: 14px;
}

.footer {
  max-width: min(1320px, calc(100vw - 64px));
  margin: 0 auto;
  padding: 28px 0 48px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 48px;
}
.footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 10px;
  transition: opacity 0.15s;
}
.footer-logo:hover { opacity: 0.7; }
.footer-tagline {
  font-size: 13px;
  color: var(--text-faint, var(--text-subtle));
  line-height: 1.6;
}
.footer-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.footer-col-title {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint, var(--text-subtle));
  margin-bottom: 4px;
}
.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.15s ease;
}
.footer-link:hover { color: var(--text); }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 24px;
  font-size: 13px;
  color: var(--text-faint, var(--text-subtle));
}
.footer-bottom a { color: var(--text-muted); transition: color 0.15s; }
.footer-bottom a:hover { color: var(--text); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface2) 12%);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 10px 26px rgba(0,0,0,0.16);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 300;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  max-width: min(480px, 90vw);
  white-space: normal;
  text-align: center;
  line-height: 1.4;
}
.toast.show { opacity: 1; }

@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 1100px) {
  #lrt-nav-links,
  .lrt-gh-link {
    display: none;
  }
  .nav-auth {
    display: flex;
    width: 0;
    min-width: 0;
    overflow: visible;
    gap: 0;
  }
  .nav-auth > .dark-toggle,
  .nav-auth > .btn-sm {
    display: none;
  }
  #lrt-mobile-menu {
    display: block;
  }
}

@media (max-width: 600px) {
  #lrt-nav-right {
    gap: 8px;
  }
  #lrt-nav-inner,
  .container,
  .footer {
    max-width: calc(100vw - 20px);
    padding-left: 10px;
    padding-right: 10px;
  }
  .author-section .container {
    padding-left: 20px;
    padding-right: 20px;
  }
  .author-inner { flex-direction: column; }
}

@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
}
