/* =========================================================================
   Scratchpad — CSS Design System
   ========================================================================= */

/* ---------------------------------------------------------------------------
   CSS Custom Properties — Dark Theme (default)
   --------------------------------------------------------------------------- */

:root {
  --bg: #101010;
  --bg-2: #151515;
  --bg-3: #1b1b1b;
  --panel: #121212;
  --line: #2a2a2a;
  --line-soft: #202020;
  --text: #f3f3f3;
  --muted: #9a9a9a;
  --muted-2: #6f6f6f;
  --accent: #ffffff;
  --accent-soft: rgba(255, 255, 255, 0.12);
  --blue: #5da7ff;
  --yellow: rgba(255, 219, 87, 0.22);
  --yellow-strong: rgba(130, 180, 255, 0.3);
  --green: #57d187;
  --danger: #ff7878;
  --fab-bg: #e0a86e;
  --fab-text: #101010;
  --author-color: #e0a86e;
  --editor-bg: #101010;
  --preview-bg: #111111;
  --topbar-bg: #121212;
  --modal-bg: #171717;
  --code-bg: #171717;

  /* Derived / utility */
  --card-bg: #151515;
  --card-border: #2a2a2a;
  --input-bg: #1b1b1b;
  --hover-bg: rgba(255, 255, 255, 0.07);

  /* Layout */
  --toolbar-height: 60px;
  --thread-width: 352px;

  /* hljs */
  --hljs-keyword: #79b8ff;
  --hljs-string: #85e89d;
  --hljs-comment: #6a737d;
  --hljs-number: #f8e3ad;
  --hljs-type: #b392f0;
  --hljs-text: #f3f3f3;
}

/* ---------------------------------------------------------------------------
   Light Theme Overrides
   --------------------------------------------------------------------------- */

[data-theme="light"] {
  --bg: #ffffff;
  --bg-2: #f5f5f5;
  --bg-3: #ebebeb;
  --panel: #f8f8f8;
  --line: #e0e0e0;
  --line-soft: #ebebeb;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --muted-2: #999999;
  --accent: #000000;
  --accent-soft: rgba(0, 0, 0, 0.08);
  --blue: #0969da;
  --yellow: rgba(255, 219, 87, 0.35);
  --yellow-strong: rgba(0, 100, 220, 0.18);
  --green: #1a7f37;
  --danger: #d1242f;
  --fab-bg: #d4822e;
  --fab-text: #ffffff;
  --author-color: #d4822e;
  --editor-bg: #ffffff;
  --preview-bg: #fafafa;
  --topbar-bg: #f8f8f8;
  --modal-bg: #ffffff;
  --code-bg: #f0f0f0;

  --card-bg: #f5f5f5;
  --card-border: #e0e0e0;
  --input-bg: #f0f0f0;
  --hover-bg: rgba(0, 0, 0, 0.06);

  --hljs-keyword: #0550ae;
  --hljs-string: #116329;
  --hljs-comment: #8b949e;
  --hljs-number: #953800;
  --hljs-type: #8250df;
  --hljs-text: #1a1a1a;
}

/* ---------------------------------------------------------------------------
   Reset & Base
   --------------------------------------------------------------------------- */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------------------------------------------------------------------------
   Typography
   --------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5em;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

p {
  margin: 0 0 1em;
}

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

a:hover {
  text-decoration: underline;
}

code, pre, .editor-textarea {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
}

/* ---------------------------------------------------------------------------
   Layout System
   --------------------------------------------------------------------------- */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  height: var(--toolbar-height);
  padding: 0 12px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

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

.view-toggle.--centered {
  /* no longer needs absolute positioning — sits in center grid column */
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}

/* ---------------------------------------------------------------------------
   View Toggle Group
   --------------------------------------------------------------------------- */

.view-toggle {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  flex-shrink: 0;
}

.view-toggle button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

.view-toggle button:last-child {
  border-right: none;
}

.view-toggle button:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.view-toggle button.--active {
  background: var(--accent-soft);
  color: var(--text);
}

.view-toggle button.--disabled {
  opacity: 0.35;
  cursor: default;
}

.view-toggle button.--disabled:hover {
  background: transparent;
  color: var(--muted);
}

.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.editor-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  border-right: 1px solid var(--line);
  overflow: hidden;
  background: var(--editor-bg);
}

.preview-pane {
  flex: 1;
  overflow-y: auto;
  background: var(--preview-bg);
}

/* ---------------------------------------------------------------------------
   Workspace view modes
   --------------------------------------------------------------------------- */

/* Code-only: hide preview, center and constrain editor */
.workspace.--mode-code .preview-pane {
  display: none;
}

.workspace.--mode-code .editor-pane {
  max-width: 880px;
  margin: 0 auto;
  border-right: none;
}

/* Split: both panes visible (default) */
.workspace.--mode-split .editor-pane,
.workspace.--mode-split .preview-pane {
  flex: 1;
}

/* Preview-only: hide editor, preview fills workspace */
.workspace.--mode-preview .editor-pane {
  display: none;
}

.workspace.--mode-preview .preview-pane {
  flex: 1;
}

/* Mobile layout (<980px) */
@media (max-width: 979px) {
  /* Hide split-view button in view toggle — only code/preview available on mobile */
  .view-toggle button[data-mode="split"] {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
   Editor Textarea
   --------------------------------------------------------------------------- */

.editor-textarea {
  flex: 1;
  width: 100%;
  padding: 24px;
  background: var(--editor-bg);
  color: var(--text);
  border: none;
  outline: none;
  resize: none;
  font-size: 0.88rem;
  line-height: 1.58;
  tab-size: 2;
  overflow-y: auto;
}

.editor-textarea::placeholder {
  color: var(--muted-2);
}

/* ---------------------------------------------------------------------------
   Title Input
   --------------------------------------------------------------------------- */

.title-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  padding: 6px 8px;
  border-radius: 6px;
}

.title-input:focus {
  background: var(--accent-soft);
}

.title-input::placeholder {
  color: var(--muted-2);
}

/* ---------------------------------------------------------------------------
   Save Status
   --------------------------------------------------------------------------- */

.save-status {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  transition: opacity 600ms;
}

.save-status.status-fade {
  opacity: 0;
}

/* ---------------------------------------------------------------------------
   Buttons — .sp-btn-icon
   --------------------------------------------------------------------------- */

.sp-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

.sp-btn-icon:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.sp-btn-icon.--md {
  width: 34px;
  height: 34px;
}

.sp-btn-icon.--sm {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.sp-btn-icon.--sm svg {
  width: 14px;
  height: 14px;
}

.sp-btn-icon.--danger {
  color: var(--danger);
}

.sp-btn-icon.--danger:hover {
  background: rgba(255, 120, 120, 0.12);
  color: var(--danger);
}

.sp-btn-icon.--disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* ---------------------------------------------------------------------------
   Buttons — .sp-btn (pill shape)
   --------------------------------------------------------------------------- */

.sp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 500;
  transition: background 0.12s, color 0.12s, opacity 0.12s;
  white-space: nowrap;
}

.sp-btn.--md {
  height: 34px;
  padding: 0 16px;
  font-size: 0.875rem;
}

.sp-btn.--sm {
  height: 28px;
  padding: 0 12px;
  font-size: 0.8rem;
}

/* Variants */
.sp-btn.--primary {
  background: var(--accent);
  color: var(--bg);
}

.sp-btn.--primary:hover {
  opacity: 0.88;
}

.sp-btn.--ghost {
  background: var(--accent-soft);
  color: var(--text);
}

.sp-btn.--ghost:hover {
  background: var(--hover-bg);
}

.sp-btn.--danger {
  background: var(--danger);
  color: #fff;
}

.sp-btn.--danger:hover {
  opacity: 0.85;
}

.sp-btn.--link {
  background: transparent;
  color: var(--blue);
  padding: 0;
  border-radius: 0;
}

.sp-btn.--link:hover {
  text-decoration: underline;
}

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

/* ---------------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal-card {
  background: var(--modal-bg);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  padding: 24px;
  min-width: 320px;
  max-width: 600px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1rem;
}

/* ---------------------------------------------------------------------------
   Card
   --------------------------------------------------------------------------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 16px;
}

/* ---------------------------------------------------------------------------
   Input
   --------------------------------------------------------------------------- */

input[type="text"],
input[type="password"],
input[type="email"],
textarea.form-textarea,
select.form-select {
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.12s;
  width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
textarea.form-textarea:focus,
select.form-select:focus {
  border-color: var(--blue);
}

/* ---------------------------------------------------------------------------
   Highlight (text annotation)
   --------------------------------------------------------------------------- */

.highlight-annotation {
  background: var(--yellow);
  border-radius: 5px;
  pointer-events: none;
}

/* ---------------------------------------------------------------------------
   Selection Bubble
   --------------------------------------------------------------------------- */

.selection-bubble {
  position: fixed;
  background: var(--fab-bg);
  color: var(--fab-text);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  z-index: 300;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Disconnected Banner
   --------------------------------------------------------------------------- */

.disconnected-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: var(--danger);
  color: #fff;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 12px;
  z-index: 100;
}

/* ---------------------------------------------------------------------------
   Preview Content
   --------------------------------------------------------------------------- */

.preview-content {
  padding: 24px;
  max-width: 880px;
  margin: 0 auto;
  line-height: 1.7;
}

.preview-content h1 { font-size: 2.2rem; }
.preview-content h2 { font-size: 1.7rem; }
.preview-content h3 { font-size: 1.35rem; }
.preview-content h4 { font-size: 1.1rem; }

.preview-content pre {
  background: var(--code-bg);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  font-size: 0.85rem;
}

.preview-content code:not(pre > code) {
  background: var(--code-bg);
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 0.85em;
}

.preview-content blockquote {
  border-left: 3px solid var(--line);
  margin: 0;
  padding: 4px 16px;
  color: var(--muted);
}

.preview-content table {
  border-collapse: collapse;
  width: 100%;
}

.preview-content th,
.preview-content td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
}

.preview-content th {
  background: var(--bg-2);
}

/* Public page wider content */
.content-body {
  padding: 24px;
  max-width: 980px;
  margin: 0 auto;
  line-height: 1.7;
}

.content-body h1 { font-size: 2.2rem; }
.content-body h2 { font-size: 1.7rem; }

/* ---------------------------------------------------------------------------
   Highlight.js Token Colors
   --------------------------------------------------------------------------- */

.hljs { color: var(--hljs-text); }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in { color: var(--hljs-keyword); }
.hljs-string, .hljs-attr, .hljs-quote { color: var(--hljs-string); }
.hljs-comment, .hljs-doctag { color: var(--hljs-comment); font-style: italic; }
.hljs-number, .hljs-literal { color: var(--hljs-number); }
.hljs-type, .hljs-class, .hljs-title { color: var(--hljs-type); }

/* ---------------------------------------------------------------------------
   Mermaid Diagram Styles
   --------------------------------------------------------------------------- */

.mermaid-wrap {
  position: relative;
  background: var(--code-bg);
  border-radius: 8px;
  overflow: hidden;
  margin: 16px 0;
}

.mermaid-viewport {
  overflow: hidden;
  padding: 16px;
}

.mermaid-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}

.mermaid-toolbar button {
  background: var(--accent-soft);
  border: none;
  border-radius: 5px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 7px;
  line-height: 1.4;
}

.mermaid-toolbar button:hover {
  background: var(--hover-bg);
}

/* ---------------------------------------------------------------------------
   Preview FAB (mobile)
   --------------------------------------------------------------------------- */

/* preview-fab removed — replaced by view-mode toggle in topbar */

/* ---------------------------------------------------------------------------
   Auth Page
   --------------------------------------------------------------------------- */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 32px;
  width: 360px;
  max-width: 90vw;
}

.auth-card h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 20px;
}

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

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.875rem;
  color: var(--muted);
}

.auth-form input {
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 12px;
  outline: none;
}

.auth-form input:focus {
  border-color: var(--blue);
}

.auth-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1em;
}

/* ---------------------------------------------------------------------------
   Welcome Page
   --------------------------------------------------------------------------- */

.welcome-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.welcome-content {
  text-align: center;
  max-width: 480px;
  padding: 24px;
}

.welcome-content h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.welcome-content p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 28px;
}

.welcome-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ---------------------------------------------------------------------------
   Utilities
   --------------------------------------------------------------------------- */

.status-fade {
  opacity: 0;
  transition: opacity 600ms;
}

.hidden {
  display: none !important;
}

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

/* ---------------------------------------------------------------------------
   Agent Modal Pre
   --------------------------------------------------------------------------- */

.modal-card pre {
  background: var(--bg-3);
  border-radius: 8px;
  padding: 14px;
  font-size: 0.78rem;
  overflow-x: auto;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
}

/* Drag-and-drop import overlay */
#drag-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 800;
  pointer-events: none;
}

.drag-overlay-label {
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 2px dashed rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  padding: 32px 48px;
  letter-spacing: 0.01em;
}

/* ---------------------------------------------------------------------------
   Thread rail
   --------------------------------------------------------------------------- */

.thread-rail {
  width: var(--thread-width);
  flex-shrink: 0;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-2);
}

.thread-rail-list {
  flex: 1;
  overflow-y: auto;
}

@media (max-width: 1199px) {
  .thread-rail {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
   Thread card
   --------------------------------------------------------------------------- */

.thread-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 12px;
  margin: 0 8px;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.thread-card:hover {
  border-color: var(--blue);
}

.thread-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(93, 167, 255, 0.2);
}

/* .thread-card.resolved opacity removed — resolved threads now render in tray at full opacity */

.thread-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.thread-footer {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
  margin-top: 4px;
}

/* ---------------------------------------------------------------------------
   Resolved comments tray
   --------------------------------------------------------------------------- */

.resolved-tray {
  flex-shrink: 0;
  background: var(--bg-2);
  z-index: 1;
}

.resolved-tray-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-3);
  border-top: 1px solid var(--line);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  user-select: none;
}

.resolved-tray-header .resolved-tray-chevron {
  font-size: 0.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.resolved-tray-content {
  overflow-y: auto;
  padding: 0 0 8px;
  display: none;
}

.resolved-tray.expanded {
  max-height: 50%;
  display: flex;
  flex-direction: column;
}

.resolved-tray.expanded .resolved-tray-content {
  display: block;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* ---------------------------------------------------------------------------
   History tray
   --------------------------------------------------------------------------- */

.history-tray {
  flex-shrink: 0;
  background: var(--bg-2);
  z-index: 1;
}

.history-tray-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-3);
  border-top: 1px solid var(--line);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  user-select: none;
}

.history-tray-header .history-tray-chevron {
  font-size: 0.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.history-tray-content {
  overflow-y: auto;
  padding: 0 0 8px;
  display: none;
}

.history-tray.expanded {
  max-height: 50%;
  display: flex;
  flex-direction: column;
}

.history-tray.expanded .history-tray-content {
  display: block;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.history-entry {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.83rem;
}

.history-entry:last-child {
  border-bottom: none;
}

.history-entry-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.history-entry-time {
  font-size: 0.78rem;
  color: var(--muted-2);
}

.history-entry-author {
  font-weight: 600;
  color: var(--author-color);
  font-size: 0.8rem;
}

.history-trigger-badge {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--bg-3);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.history-entry-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 6px;
}

.history-restore-btn {
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 5px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.history-restore-btn:hover {
  background: var(--hover-bg);
  border-color: var(--muted-2);
}

/* ---------------------------------------------------------------------------
   Comment message
   --------------------------------------------------------------------------- */

.comment-message {
  font-size: 0.85rem;
}

.comment-message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

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

.comment-time {
  font-size: 0.75rem;
  color: var(--muted-2);
}

.comment-body {
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

/* ---------------------------------------------------------------------------
   Anchor highlight
   --------------------------------------------------------------------------- */

.anchor-highlight {
  background: var(--yellow);
  border-radius: 5px;
  border: none;
  cursor: pointer;
  padding: 0;
  pointer-events: auto;
  z-index: 10;
  transition: background 0.12s;
}

.anchor-highlight:hover,
.anchor-highlight.active {
  background: var(--yellow-strong);
}

/* ---------------------------------------------------------------------------
   Compose modal
   --------------------------------------------------------------------------- */

.compose-modal {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.compose-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.compose-modal-content {
  position: relative;
  background: var(--modal-bg);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  padding: 24px;
  width: 90vw;
  max-width: 480px;
}

.compose-modal-content h3 {
  margin: 0 0 16px;
  font-size: 1rem;
  font-weight: 600;
}

.compose-textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 12px;
  outline: none;
  resize: vertical;
  line-height: 1.5;
  transition: border-color 0.12s;
  box-sizing: border-box;
}

.compose-textarea:focus {
  border-color: var(--blue);
}

.compose-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* ---------------------------------------------------------------------------
   Identity modal
   --------------------------------------------------------------------------- */

.identity-modal {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.identity-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.identity-modal-content {
  position: relative;
  background: var(--modal-bg);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  padding: 24px;
  width: 90vw;
  max-width: 380px;
}

.identity-modal-content h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.identity-modal-content p {
  margin: 0 0 16px;
  font-size: 0.875rem;
  color: var(--muted);
}

.identity-name-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.12s;
  box-sizing: border-box;
}

.identity-name-input:focus {
  border-color: var(--blue);
}

.identity-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* ---------------------------------------------------------------------------
   Comment FAB (mobile)
   --------------------------------------------------------------------------- */

.comment-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--fab-bg);
  color: var(--fab-text);
  border: none;
  cursor: pointer;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 210;
}

@media (min-width: 1200px) {
  .comment-fab {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
   Login gate modal
   --------------------------------------------------------------------------- */

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-gate-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.login-gate-card {
  position: relative;
  z-index: 1;
  background: var(--modal-bg);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  padding: 28px 32px;
  min-width: 320px;
  max-width: 420px;
  width: 90vw;
}

.login-gate-card h2 {
  margin: 0 0 20px;
  font-size: 1.1rem;
  font-weight: 600;
}
