:root {
  --bg: #09090b;
  --bg-soft: #111113;
  --bg-elevated: #18181b;
  --panel: #1e1e22;
  --panel-strong: #27272a;
  --panel-border: rgba(255, 255, 255, 0.06);
  --panel-glass: rgba(24, 24, 27, 0.8);
  --panel-glass-border: rgba(255, 255, 255, 0.08);
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --muted: #71717a;
  --dimmed: #3f3f46;
  --accent: #38bdf8;
  --accent-muted: rgba(56, 189, 248, 0.12);
  --accent-glow: rgba(56, 189, 248, 0.2);
  --accent-strong: #0ea5e9;
  --secondary: #f59e0b;
  --secondary-muted: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-muted: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  --info: #38bdf8;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.4);
  --shadow-accent: 0 0 0 1px rgba(56, 189, 248, 0.15);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(56, 189, 248, 0.3);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 14px;
  --radius-full: 999px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 350ms;
}

/* --- Keyframes --- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(100%); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(8px); } }
@keyframes votePopUp { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes countChange { 0% { transform: translateY(0); opacity: 1; } 50% { transform: translateY(-6px); opacity: 0; } 51% { transform: translateY(6px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes progressPulse { 0%, 100% { opacity: 0.8; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

* {
  box-sizing: border-box;
}

a {
  text-decoration: none;
  color: inherit;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--dimmed); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

@font-face {
  font-family: "Calibri";
  src: url("./fonts/calibri.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Calibri";
  src: url("./fonts/calibrib.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Calibri";
  src: url("./fonts/calibrii.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Calibri";
  src: url("./fonts/calibriz.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Times New Roman";
  src: url("./fonts/times.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Times New Roman";
  src: url("./fonts/timesbd.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Times New Roman";
  src: url("./fonts/timesi.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Times New Roman";
  src: url("./fonts/timesbi.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Cambria";
  src: url("./fonts/cambria.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cambria";
  src: url("./fonts/cambriab.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cambria";
  src: url("./fonts/cambriai.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Cambria";
  src: url("./fonts/cambriaz.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Arial";
  src: url("./fonts/arial.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Arial";
  src: url("./fonts/arialbd.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Arial";
  src: url("./fonts/ariali.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Arial";
  src: url("./fonts/arialbi.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Courier New";
  src: url("./fonts/Courier_New.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Courier New";
  src: url("./fonts/Courier_New_Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Courier New";
  src: url("./fonts/Courier_New_Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Courier New";
  src: url("./fonts/Courier_New_Bold_Italic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.read-only .panel {
  opacity: 0.5;
}

.hidden {
  display: none !important;
}

/* --- Page Layout --- */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Topbar / Navbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 0 clamp(16px, 3vw, 32px);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--duration-fast);
}

.brand:hover {
  color: var(--accent);
}

.construction-hint {
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  max-width: 480px;
}

/* Nav links as subtle text-style buttons */
.topbar-actions .btn-secondary {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
}

.topbar-actions .btn-secondary:hover {
  color: var(--text);
  background: transparent;
  border: none;
}

.topbar-actions .btn {
  padding: 7px 16px;
  font-size: 13px;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  max-width: 520px;
}

/* --- Annotation Controls --- */
.annotation-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.annotation-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
  justify-content: center;
}

.annotation-view-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.annotation-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.annotation-view-hash {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.annotation-view-note {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.annotation-view-note.empty {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  padding: 0;
}

.mobile-block-message {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin: 0;
  word-break: break-word;
}

.annotation-view-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.annotation-view-votes {
  display: flex;
  align-items: center;
  gap: 6px;
}

#annotationViewBack {
  align-self: flex-end;
  width: auto;
}

/* --- Discussion --- */
.discussion-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  flex: 1;
  min-height: 0;
}

.discussion-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.discussion-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 500;
}

.discussion-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

.comment {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.comment.reply-highlight {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-muted);
}

.comment-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.comment-body {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.comment-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.comment-reply {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--duration-fast);
}

.comment-reply:hover {
  color: var(--accent);
}

.comment-delete {
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color var(--duration-fast);
}

.comment-delete:hover {
  color: var(--danger);
}

.comment-delete:disabled {
  opacity: 0.5;
  cursor: default;
}

.comment-indent {
  margin-left: 18px;
}

.discussion-form textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 70px;
  width: 100%;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.discussion-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.discussion-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.discussion-hint {
  font-size: 12px;
  color: var(--muted);
}

.discussion-actions {
  margin-top: auto;
  display: flex;
  gap: 10px;
}

.discussion-actions .btn {
  flex: 1;
}

.annotation-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* --- Browse Layout --- */
.browse-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
  padding: 24px clamp(16px, 3vw, 32px) 32px;
  min-height: 0;
}

.notifications-layout {
  grid-template-columns: 1fr;
}

/* --- About Page --- */
.about-page {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 48px 24px 64px;
}

.about-content {
  max-width: 720px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 56px;
}

.about-hero {
  text-align: center;
  padding: 24px 0 8px;
}

.about-title {
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin: 0 0 18px;
  letter-spacing: -0.02em;
}

.about-subtitle {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto;
}

.about-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.about-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 0;
}

.about-body {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0;
}

.about-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.about-step {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}

.about-step:hover {
  transform: translateY(-2px);
  border-color: var(--border-accent);
}

.about-step-number {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.about-step-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.about-step-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.about-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.about-status-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.about-status-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.about-status-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.about-contrib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.about-contrib-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.about-contrib-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.about-contrib-card .btn {
  align-self: flex-start;
  margin-top: 4px;
}

/* --- Feature Form --- */
.feature-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feature-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.feature-textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.feature-input:focus,
.feature-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.feature-form-footer {
  display: flex;
  align-items: center;
  gap: 14px;
}

.feature-form-footer .btn {
  flex-shrink: 0;
}

.feature-status {
  font-size: 13px;
  color: var(--muted);
}

.feature-status a {
  color: var(--accent);
  text-decoration: none;
}

.feature-status-ok {
  color: var(--accent);
}

.feature-status-err {
  color: var(--danger);
}

/* --- Start / Landing Page --- */
.start-page {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 48px 24px 64px;
}

.start-content {
  max-width: 800px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 64px;
}

.start-hero {
  text-align: center;
  padding: 40px 0 8px;
}

.start-title {
  font-size: clamp(26px, 5vw, 44px);
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  margin: 0 0 18px;
  letter-spacing: -0.025em;
}

.start-subtitle {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 480px;
  margin: 0 auto 28px;
}

.start-hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.start-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.start-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 0;
}

/* Progress bar */
.start-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.start-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.start-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  min-width: 2px;
  transition: width 0.6s ease;
}

.start-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

.start-progress-pct {
  font-weight: 600;
  color: var(--accent);
}

/* Stat cards */
.start-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.start-stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.start-stat:hover {
  border-color: var(--border-accent);
}

.start-stat-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
}

.start-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 500;
}

/* Ranked lists */
.start-lists {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
}

.start-list-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.start-ranked-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  counter-reset: rank;
}

.start-ranked-list li {
  counter-increment: rank;
}

.start-ranked-list li a {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--duration-fast) var(--ease-out);
}

.start-ranked-list li a:hover {
  border-color: var(--border-accent);
}

.start-ranked-list li a::before {
  content: counter(rank);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  min-width: 18px;
}

.start-ranked-name {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.start-ranked-stat {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.start-empty {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* --- Notifications --- */
.notifications-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notification-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--duration-fast) var(--ease-out);
  animation: fadeInUp 0.3s var(--ease-out) both;
}

.notification-card:hover {
  border-color: var(--border-strong);
}

.notification-card.unread {
  border-left: 3px solid var(--accent);
  background: rgba(56, 189, 248, 0.03);
}

.notification-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.notification-time {
  margin-left: auto;
  color: var(--dimmed);
}

.notification-body {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

/* --- Browse --- */
.browse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.browse-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.browse-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  min-height: 200px;
  max-height: calc(100vh - 280px);
  overflow-y: auto;
}

.browse-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}

.browse-card:hover {
  border-color: var(--border-accent);
  background: rgba(56, 189, 248, 0.04);
}

.browse-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.browse-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.browse-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.browse-meta img {
  width: 14px;
  height: 14px;
  filter: brightness(0) saturate(100%) invert(47%) sepia(5%) saturate(500%) hue-rotate(200deg)
    brightness(95%) contrast(90%);
}

.browse-actions {
  display: flex;
  justify-content: center;
}

/* --- Annotation Notes --- */
.annotation-notes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding-right: 4px;
}

.annotation-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.annotation-actions .btn {
  width: 100%;
}

.pdf-comment-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.pdf-comment-form textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 72px;
  width: 100%;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.pdf-comment-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.annotation-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.annotation-status {
  font-size: 13px;
  color: var(--muted);
}

#annotationSortSelect {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  transition: border-color var(--duration-fast) var(--ease-out);
}

#annotationSortSelect:focus {
  outline: none;
  border-color: var(--accent);
}

.annotation-note {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--duration-fast) var(--ease-out);
  cursor: pointer;
  position: relative;
}

.annotation-note:hover {
  border-color: var(--border-accent);
}

.annotation-note.hovered {
  border-color: var(--border-accent);
}

.annotation-note-meta {
  font-size: 11px;
  color: var(--muted);
}

.annotation-note-meta.by-you,
.comment-meta.by-you,
.comment-meta .by-you {
  color: var(--secondary);
}

.annotation-note-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.annotation-note-text a,
.annotation-view-note a {
  color: var(--accent);
  text-decoration: none;
}

.annotation-note-text.empty {
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  display: inline-block;
  width: fit-content;
}

.annotation-note-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.annotation-note-label {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
}

.pdf-comment-card {
  cursor: default;
}

.pdf-comment-card:hover {
  cursor: pointer;
}

.annotation-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 14px 0 2px;
  font-weight: 500;
}

.browse-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.browse-count {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 6px;
}

.annotation-selected-title.hidden {
  display: none;
}

.annotation-selected-title {
  margin: 0 0 6px;
}

.annotation-section-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- Vote Buttons --- */
.vote-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--duration-fast) var(--ease-out);
}

.vote-btn:hover:not(:disabled) {
  border-color: var(--border-accent);
  background: var(--accent-muted);
}

.vote-btn.vote-animating {
  animation: votePopUp 250ms var(--ease-out);
}

.vote-score.score-changing {
  animation: countChange 250ms var(--ease-out);
}

.copy-link-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--duration-fast);
}

.copy-link-btn:hover {
  color: var(--accent);
}

.copy-link-btn img {
  width: 14px;
  height: 14px;
  display: block;
  filter: brightness(0) saturate(100%) invert(47%) sepia(5%) saturate(500%) hue-rotate(200deg);
}

.vote-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.vote-score {
  font-size: 12px;
  color: var(--muted);
  min-width: 18px;
  text-align: center;
}

.vote-icon {
  width: 16px;
  height: 16px;
  display: block;
  filter: brightness(0) saturate(100%) invert(80%);
}

.vote-btn.up.active .vote-icon {
  filter: brightness(0) saturate(100%) invert(70%) sepia(50%) saturate(1000%) hue-rotate(165deg)
    brightness(110%) contrast(95%);
}

.vote-btn.down.active .vote-icon {
  filter: brightness(0) saturate(100%) invert(24%) sepia(84%) saturate(6248%) hue-rotate(353deg)
    brightness(103%) contrast(104%);
}

.vote-btn.up.active {
  border-color: var(--border-accent);
  color: var(--accent);
}

.vote-btn.down.active {
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}

.annotation-notes.hidden {
  display: none;
}

/* --- Main Layout (Document Viewer) --- */
.layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: clamp(12px, 2vw, 20px);
  flex: 1;
  overflow: hidden;
  padding: 16px clamp(16px, 3vw, 32px) 20px;
}

.panel {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  transition: border-color var(--duration-fast) var(--ease-out);
}

/* --- Tabs --- */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 3px;
}

.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 7px 10px;
  border-radius: calc(var(--radius-md) - 3px);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
  font-weight: 500;
}

.tab:hover {
  color: var(--text-secondary);
  background: var(--bg-elevated);
}

.tab.active {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: transparent;
}

.tab-text.active {
  color: var(--text);
}

.tab-hints {
  color: #f87171;
}

.tab-notes {
  color: var(--secondary);
}

.tab.tab-text {
  color: var(--accent);
}

.tab-hints.active {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
}

.tab-notes.active {
  background: var(--secondary-muted);
  color: var(--secondary);
}

.tab-text:hover {
  background: var(--accent-muted);
}

.tab-hints:hover {
  background: rgba(248, 113, 113, 0.08);
}

.tab-notes:hover {
  background: var(--secondary-muted);
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.tab-panel.active {
  display: flex;
}

.tab-panel.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* --- Fields / Inputs --- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.field input,
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.field input::placeholder {
  color: var(--dimmed);
}

.field input[type="range"] {
  padding: 0;
  border: none;
  background: transparent;
  height: 26px;
}

/* --- Buttons --- */
.btn {
  border: none;
  background: var(--accent);
  color: #09090b;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}

.btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn:active {
  transform: scale(0.98);
  filter: brightness(0.95);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

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

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary.active {
  background: var(--accent);
  color: #09090b;
  border-color: transparent;
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-outline:hover {
  background: var(--accent-muted);
}

.btn-outline-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-outline-danger:hover {
  background: var(--danger-muted);
}

/* --- Account Menu --- */
.account-menu {
  position: relative;
}

.account-menu summary {
  list-style: none;
}

.account-menu summary::-webkit-details-marker {
  display: none;
}

.account-button {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-secondary);
  position: relative;
  transition: border-color var(--duration-fast), color var(--duration-fast);
}

.account-button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.account-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.account-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  min-width: 160px;
  padding: 6px;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 60;
  animation: fadeInDown 0.15s var(--ease-out);
}

.account-username {
  font-size: 11px;
  color: var(--muted);
  padding: 8px 10px 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.account-menu[open] .account-dropdown {
  display: block;
}

.account-dropdown a,
.account-dropdown .account-link {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  background: transparent;
  border: none;
  text-align: left;
  width: 100%;
  cursor: pointer;
  position: relative;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.account-dropdown a:hover,
.account-dropdown .account-link:hover {
  background: var(--panel-strong);
  color: var(--text);
}

.notif-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  margin-left: 6px;
  vertical-align: middle;
}

.account-button .notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  margin: 0;
}

/* --- Canvas / Document Viewer --- */
.canvas-wrap {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 60vh;
  flex: 1;
  overflow: hidden;
}

.canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.file-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pdf-vote-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pdf-vote-frame {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg);
}

.pdf-vote-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: border-color var(--duration-fast), color var(--duration-fast), background var(--duration-fast);
}

.pdf-vote-btn img {
  width: 14px;
  height: 14px;
  filter: brightness(0) saturate(100%) invert(47%) sepia(5%) saturate(500%) hue-rotate(200deg)
    brightness(95%) contrast(90%);
}

.pdf-vote-btn.active {
  background: var(--accent-muted);
  border-color: var(--border-accent);
  color: var(--accent);
}

.pdf-vote-btn.down.active {
  background: var(--danger-muted);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.pdf-vote-btn.down.active img {
  filter: brightness(0) saturate(100%) invert(24%) sepia(84%) saturate(6248%) hue-rotate(353deg)
    brightness(103%) contrast(104%);
}

.pdf-vote-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pdf-vote-score {
  font-size: 14px;
  color: var(--muted);
  min-width: 18px;
  text-align: right;
  margin-left: -4px;
  margin-top: 2px;
  font-weight: 500;
}

.canvas-header h2 {
  margin: 0;
  font-size: 18px;
}

.canvas-header p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.file-title {
  margin-top: 4px;
  font-size: 18px !important;
  font-weight: 600 !important;
  line-height: 1.3;
  color: var(--text);
  word-break: break-all;
  letter-spacing: -0.01em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}

.search-wrap input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  min-width: 160px;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.browse-search-btn {
  padding: 7px 14px;
  font-size: 13px;
}

.toggle-row {
  display: flex;
  gap: 6px;
}

.size-row {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 8px;
  align-items: center;
}

#sizeInput {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 100%;
  transition: border-color var(--duration-fast) var(--ease-out);
}

#sizeInput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

#colorPicker {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

#colorSwatch {
  width: 44px;
  height: 30px;
  padding: 0;
  justify-content: center;
  align-items: center;
}

#colorSwatch .swatch-letter {
  font-size: 18px;
  font-weight: 700;
  font-family: "Times New Roman", serif;
  color: var(--accent);
  line-height: 1;
}

textarea#notesInput {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  min-height: 140px;
  resize: vertical;
  width: 100%;
  transition: border-color var(--duration-fast) var(--ease-out);
}

textarea#notesInput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.canvas-body {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 12px;
  flex: 1;
  min-height: 0;
  height: 100%;
}

.canvas {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  height: 100%;
  position: relative;
}

svg {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 2;
}

#heatmapCanvas {
  position: absolute;
  inset: 16px;
  z-index: 3;
  pointer-events: none;
}

image {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.overlay-text {
  fill: var(--accent);
  font-size: 28px;
  font-weight: 600;
  dominant-baseline: middle;
}

.text-box {
  fill: transparent;
  stroke: rgba(56, 189, 248, 0.4);
  stroke-width: 1.5;
}

.resize-handle {
  fill: var(--accent);
  stroke: var(--bg);
  stroke-width: 2;
  cursor: nwse-resize;
}

.annotation-preview {
  fill: var(--accent);
  stroke: var(--bg);
  stroke-width: 2;
  pointer-events: none;
}

.annotation-anchor {
  fill: var(--accent);
  stroke: var(--bg);
  stroke-width: 2;
  cursor: pointer;
  fill-opacity: 0.6;
  stroke-opacity: 0.9;
  transition: fill-opacity 0.12s ease, stroke-opacity 0.12s ease;
}

.annotation-anchor.annotation-anchor-other {
  fill: var(--secondary);
  stroke: #1a1400;
}

.annotation-anchor:hover,
.annotation-anchor[data-hovered="1"] {
  fill-opacity: 1;
  stroke-opacity: 1;
}

.hover-circle {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1;
  pointer-events: none;
  mix-blend-mode: difference;
}

.text-group:not(.active) .text-box,
.text-group:not(.active) .resize-handle {
  display: none;
}

.text-group {
  cursor: grab;
}

.text-group.dragging {
  cursor: grabbing;
}

.editable-text {
  cursor: text;
}

.text-editor {
  display: inline-block;
  min-width: 20px;
  min-height: 18px;
  outline: none;
  white-space: pre;
}

.hint-arrow {
  stroke: #f87171;
  stroke-width: 3;
  fill: none;
}

.hint-hit {
  stroke: transparent;
  stroke-width: 18;
  fill: none;
  cursor: pointer;
}

.hint-handle {
  fill: #f87171;
  stroke: #7f1d1d;
  stroke-width: 2;
  cursor: pointer;
}

/* --- Context Menu --- */
.context-menu {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 4px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
}

.context-menu button {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.context-menu button:hover {
  background: var(--panel-strong);
  color: var(--text);
}

/* --- Confirm Dialog --- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  animation: fadeIn var(--duration-fast) var(--ease-out);
}

.confirm-dialog {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-width: 280px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: scaleIn var(--duration-normal) var(--ease-out);
}

.confirm-title {
  font-size: 15px;
  font-weight: 600;
}

.confirm-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.hint {
  font-size: 12px;
  color: var(--dimmed);
  text-align: right;
}

/* --- Minimap --- */
.minimap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.minimap-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.minimap-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

#minimapSvg {
  width: 100%;
  height: auto;
  display: block;
}

#minimapHeatmap {
  opacity: 0.6;
}

#minimapViewport {
  fill: rgba(56, 189, 248, 0.08);
  stroke: var(--accent);
  stroke-width: 4;
}

.minimap-hint {
  font-size: 11px;
  color: var(--dimmed);
}

.minimap-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.minimap-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.minimap-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}

#minimapPageInput {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 100%;
  transition: border-color var(--duration-fast) var(--ease-out);
}

#minimapPageInput:focus {
  outline: none;
  border-color: var(--accent);
}

.coffee-link {
  position: fixed;
  right: clamp(20px, 4vw, 52px);
  bottom: -2px;
  font-size: 12px;
  color: var(--dimmed);
  text-decoration: none;
  padding: 4px 0;
  border: none;
  background: transparent;
  transition: color var(--duration-fast);
  z-index: 5;
}

.coffee-link:hover {
  color: var(--text-secondary);
}

/* --- Skeleton Loading --- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--panel) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s infinite linear;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.skeleton-card { height: 48px; }
.skeleton-annotation { height: 80px; }

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slideUp var(--duration-slow) var(--ease-out);
  pointer-events: auto;
  max-width: 360px;
}

.toast-success { border-color: rgba(56, 189, 248, 0.3); }
.toast-error { border-color: rgba(239, 68, 68, 0.3); }
.toast-exit { animation: fadeOut var(--duration-normal) var(--ease-out) forwards; }

/* --- Auth Pages --- */
.auth-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex: 1;
  padding: 8vh 16px 0;
}

.auth-card {
  max-width: 400px;
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  animation: fadeInUp 0.3s var(--ease-out);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-muted);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.auth-footer {
  font-size: 12px;
  color: var(--dimmed);
  line-height: 1.5;
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: none;
}

/* --- Empty States --- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state-desc {
  font-size: 13px;
  color: var(--muted);
  max-width: 320px;
  line-height: 1.6;
}

/* --- Staggered Animations --- */
.animate-fade-in { animation: fadeInUp 0.5s var(--ease-out) both; }
.animate-fade-in-delay-1 { animation: fadeInUp 0.5s var(--ease-out) 0.1s both; }
.animate-fade-in-delay-2 { animation: fadeInUp 0.5s var(--ease-out) 0.2s both; }

.animate-on-scroll {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}

.animate-on-scroll.animate-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   RESPONSIVE — Tablet (< 900px)
   ========================================================================== */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    overflow-y: auto;
    height: auto;
    min-height: auto;
  }

  .panel {
    height: auto;
    max-height: 50vh;
  }

  .canvas-wrap {
    min-height: 50vh;
  }

  .canvas-body {
    grid-template-columns: 1fr;
  }

  .minimap {
    min-height: 180px;
  }

  .canvas-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-actions {
    width: 100%;
  }

  .search-wrap {
    flex: 1;
  }

  .search-wrap input {
    min-width: 0;
    flex: 1;
  }

  .construction-hint {
    display: none;
  }

  .browse-list {
    max-height: none;
  }
}

/* ==========================================================================
   RESPONSIVE — Mobile (< 640px)
   ========================================================================== */
@media (max-width: 640px) {
  body {
    overflow-y: auto;
    overflow-x: hidden;
  }

  .page {
    min-height: 100vh;
    height: auto;
  }

  /* Topbar mobile */
  .topbar {
    padding: 0 12px;
  }

  .topbar-row {
    height: 48px;
    gap: 8px;
  }

  .brand {
    font-size: 15px;
  }

  .topbar-actions {
    gap: 2px;
  }

  .topbar-actions .btn-secondary {
    padding: 6px 8px;
    font-size: 12px;
  }

  .topbar-actions .btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Layout mobile */
  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
    overflow-y: auto;
    height: auto;
    min-height: auto;
  }

  .panel {
    height: auto;
    max-height: none;
    padding: 16px;
    order: 2;
  }

  .canvas-wrap {
    min-height: 60vh;
    padding: 12px;
    order: 1;
  }

  .canvas-body {
    grid-template-columns: 1fr;
  }

  .minimap {
    min-height: 140px;
  }

  .canvas-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .file-title {
    font-size: 16px !important;
  }

  .file-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .pdf-vote-frame {
    align-self: flex-start;
  }

  .header-actions {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }

  .search-wrap {
    width: 100%;
  }

  .search-wrap input {
    min-width: 0;
    flex: 1;
    width: 100%;
  }

  /* Browse mobile */
  .browse-layout {
    padding: 16px 12px 24px;
    gap: 16px;
  }

  .browse-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .browse-header-actions {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }

  .browse-header-actions .search-wrap {
    width: 100%;
  }

  .browse-header-actions select,
  .browse-header-actions button {
    width: 100%;
  }

  .browse-list {
    grid-template-columns: 1fr;
    max-height: none;
    padding: 12px;
  }

  .browse-card {
    padding: 12px;
  }

  /* Start page mobile */
  .start-page {
    padding: 24px 16px 48px;
  }

  .start-content {
    gap: 40px;
  }

  .start-hero {
    padding: 16px 0 0;
  }

  .start-subtitle {
    font-size: 14px;
    margin-bottom: 20px;
  }

  .start-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .start-stat-value {
    font-size: 28px;
  }

  .start-stat {
    padding: 16px 12px;
  }

  .start-lists {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  /* About page mobile */
  .about-page {
    padding: 24px 16px 48px;
  }

  .about-content {
    gap: 40px;
  }

  .about-steps {
    grid-template-columns: repeat(2, 1fr);
  }

  .about-status-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .about-contrib-grid {
    grid-template-columns: 1fr;
  }

  /* Auth mobile */
  .auth-layout {
    padding: 4vh 12px 0;
  }

  .auth-card {
    padding: 24px;
  }

  /* Notifications mobile */
  .notification-meta {
    font-size: 11px;
  }

  /* Confirm dialog mobile */
  .confirm-dialog {
    min-width: auto;
    margin: 0 16px;
  }

  /* Toast mobile */
  .toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    max-width: none;
  }

  /* Annotation panel mobile */
  .annotation-actions .btn {
    padding: 10px 14px;
    font-size: 14px;
  }

  .tabs {
    gap: 2px;
  }

  .tab {
    padding: 8px 6px;
    font-size: 11px;
  }

  /* Hints mobile */
  .hint {
    text-align: center;
    font-size: 11px;
  }

  .minimap-hint {
    text-align: center;
  }

  /* Discussion mobile */
  .discussion-list {
    max-height: none;
  }

  .comment-indent {
    margin-left: 12px;
  }
}

/* ==========================================================================
   RESPONSIVE — Small phones (< 380px)
   ========================================================================== */
@media (max-width: 380px) {
  .brand {
    font-size: 14px;
  }

  .topbar-actions .btn-secondary {
    padding: 5px 6px;
    font-size: 11px;
  }

  .topbar-actions .btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  .start-stats {
    grid-template-columns: 1fr;
  }

  .about-steps {
    grid-template-columns: 1fr;
  }

  .about-status-grid {
    grid-template-columns: 1fr;
  }

  .pdf-vote-btn span {
    display: none;
  }
}
