/* === Living Paper — Core Stylesheet v0.1 === */

:root {
  --lp-bg: #f8f9fa;
  --lp-surface: #ffffff;
  --lp-border: #dee2e6;
  --lp-text: #212529;
  --lp-text-secondary: #6c757d;
  --lp-primary: #2563eb;
  --lp-primary-light: #dbeafe;
  --lp-accent-orange: #E67E22;
  --lp-accent-green: #27AE60;
  --lp-accent-red: #E74C3C;
  --lp-highlight: #fef3c7;
  --lp-highlight-border: #f59e0b;
  --lp-verified: #d1fae5;
  --lp-flag: #fee2e2;
  --lp-unverified: #fef3c7;
  --lp-panel-width: 320px;
  --lp-header-height: 52px;
  --lp-radius: 8px;
  --lp-shadow: 0 1px 3px rgba(0,0,0,0.08);
  --lp-shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --lp-transition: 0.2s ease;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --font-serif: 'Georgia', 'Times New Roman', serif;
}

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

body {
  font-family: var(--font-sans);
  background: var(--lp-bg);
  color: var(--lp-text);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

/* === HEADER === */
.lp-header {
  height: var(--lp-header-height);
  background: var(--lp-surface);
  border-bottom: 1px solid var(--lp-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 100;
  position: relative;
}
.lp-header-left { display: flex; align-items: center; gap: 8px; }
.lp-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--lp-primary);
  letter-spacing: -0.3px;
}
.lp-badge {
  font-size: 11px;
  background: var(--lp-primary-light);
  color: var(--lp-primary);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}
.lp-header-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  overflow: hidden;
}
.lp-arxiv-id {
  font-family: var(--font-mono);
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--lp-text-secondary);
}
.lp-paper-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--lp-text-secondary);
}
.lp-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === BUTTONS === */
.lp-btn {
  padding: 6px 14px;
  border: 1px solid var(--lp-border);
  border-radius: 6px;
  background: var(--lp-surface);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-sans);
  transition: all var(--lp-transition);
}
.lp-btn:hover { background: #f1f5f9; }
.lp-btn-why {
  background: var(--lp-primary);
  color: white;
  border-color: var(--lp-primary);
  font-weight: 600;
}
.lp-btn-why:hover { background: #1d4ed8; }
.lp-btn-unfold {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
  font-weight: 500;
  font-size: 13px;
}
.lp-btn-small { padding: 3px 10px; font-size: 12px; }
.lp-btn-feedback {
  background: #f8f9fa;
  border-color: #ccc;
  font-size: 12px;
  color: #666;
}
.lp-icon-btn {
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lp-icon-btn:hover { background: #f1f5f9; }
.lp-interest-select {
  padding: 5px 10px;
  border: 1px solid var(--lp-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-sans);
  background: var(--lp-surface);
}

/* === MAIN THREE-PANEL === */
.lp-main {
  display: flex;
  height: calc(100vh - var(--lp-header-height));
}

/* === PANELS === */
.lp-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.lp-panel-left {
  flex: 1;
  border-right: 1px solid var(--lp-border);
  background: var(--lp-surface);
  min-width: 0;
}
.lp-panel-right {
  width: var(--lp-panel-width);
  background: var(--lp-surface);
  border-left: 1px solid var(--lp-border);
  flex-shrink: 0;
}
.lp-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--lp-border);
  background: #fafbfc;
}
.lp-panel-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--lp-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.lp-panel-tools { display: flex; gap: 4px; }

/* === PAPER CONTENT === */
.lp-paper-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.8;
  color: #1a1a1a;
}
.lp-paper-content h2 {
  font-family: var(--font-sans);
  font-size: 18px;
  margin: 28px 0 12px;
  color: #111;
}
.lp-paper-content h3 {
  font-family: var(--font-sans);
  font-size: 15px;
  margin: 20px 0 8px;
  color: #333;
}
.lp-paper-content p { margin-bottom: 12px; }
.lp-paper-content .equation {
  display: block;
  text-align: center;
  margin: 16px 0;
  padding: 12px;
  font-size: 16px;
}

/* Hotspot — hoverable equation/term */
.lp-hotspot {
  cursor: pointer;
  border-bottom: 2px dashed transparent;
  transition: all var(--lp-transition);
  position: relative;
}
.lp-hotspot:hover {
  background: var(--lp-highlight);
  border-bottom-color: var(--lp-highlight-border);
  border-radius: 3px;
}
.lp-hotspot.active {
  background: var(--lp-highlight);
  border-bottom-color: var(--lp-highlight-border);
  box-shadow: 0 0 0 3px var(--lp-highlight);
  border-radius: 4px;
}

/* Claim hotspot */
.lp-claim {
  border-left: 3px solid var(--lp-border);
  padding: 8px 14px;
  margin: 12px 0;
  background: #fafbfc;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--lp-transition);
}
.lp-claim:hover { border-left-color: var(--lp-primary); background: #f0f4ff; }
.lp-claim.active { border-left-color: var(--lp-primary); background: #eff6ff; }
.lp-claim.verified { border-left-color: var(--lp-accent-green); background: #f0fdf4; }
.lp-claim.flagged { border-left-color: var(--lp-accent-red); background: #fef2f2; }
.lp-claim-marker {
  font-size: 11px;
  font-family: var(--font-sans);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.lp-claim-marker.verified { color: var(--lp-accent-green); }
.lp-claim-marker.flagged { color: var(--lp-accent-red); }
.lp-claim-marker.unverified { color: var(--lp-accent-orange); }

/* === TABS === */
.lp-tabs {
  display: flex;
  border-bottom: 1px solid var(--lp-border);
  background: #fafbfc;
}
.lp-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  color: var(--lp-text-secondary);
  border-bottom: 2px solid transparent;
  transition: all var(--lp-transition);
}
.lp-tab:hover { color: var(--lp-text); }
.lp-tab.active {
  color: var(--lp-primary);
  border-bottom-color: var(--lp-primary);
}
.lp-tab-content { display: none; flex: 1; overflow-y: auto; }
.lp-tab-content.active { display: flex; flex-direction: column; }

/* === EXPLAIN PANEL === */
.lp-explain-panel { padding: 14px; }
.lp-explain-level {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--lp-text-secondary);
  margin-bottom: 12px;
}
.lp-explain-level select {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--lp-border);
  font-size: 13px;
}
.lp-explain-section {
  margin-bottom: 16px;
  padding: 12px;
  background: #f8fafc;
  border-radius: var(--lp-radius);
  border: 1px solid #e2e8f0;
}
.lp-explain-section h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #475569;
}
.lp-explain-section p {
  font-size: 13px;
  line-height: 1.7;
  color: #334155;
}

/* Empty state */
.lp-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}
.lp-empty-icon { font-size: 40px; margin-bottom: 12px; }
.lp-empty-state p {
  font-size: 13px;
  color: var(--lp-text-secondary);
  max-width: 240px;
}

/* Jargon terms */
.jargon-term {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}
.jargon-term-name {
  font-weight: 600;
  font-family: var(--font-mono);
  background: #e2e8f0;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
  white-space: nowrap;
}
.jargon-term-def { color: #475569; }

/* Derivation steps */
.derivation-step {
  padding: 8px 12px;
  margin: 6px 0;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--font-mono);
  cursor: pointer;
}
.derivation-step:hover { border-color: var(--lp-primary); }
.derivation-step .step-source {
  font-size: 11px;
  color: var(--lp-text-secondary);
  margin-top: 4px;
  font-family: var(--font-sans);
}

/* Connection cards */
.connection-card {
  padding: 10px 12px;
  margin: 6px 0;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--lp-transition);
}
.connection-card:hover { border-color: var(--lp-primary); box-shadow: var(--lp-shadow); }
.connection-card .conn-field {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.connection-card .conn-type { font-size: 11px; color: var(--lp-text-secondary); }

/* === VERIFY PANEL === */
.lp-verify-panel { padding: 14px; }
.lp-verify-status {
  text-align: center;
  padding: 16px;
  margin-bottom: 12px;
  border-radius: var(--lp-radius);
  font-weight: 600;
  font-size: 14px;
}
.lp-verify-status.verified { background: var(--lp-verified); color: #166534; }
.lp-verify-status.flagged { background: var(--lp-flag); color: #991b1b; }
.lp-verify-status.unverified { background: var(--lp-unverified); color: #92400e; }
.lp-verify-details { font-size: 13px; }
.lp-verify-item {
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  gap: 8px;
}
.lp-verify-item-icon { font-size: 16px; flex-shrink: 0; }
.lp-verify-item-text { color: #475569; font-size: 13px; }

/* === GRAPH PANEL === */
.lp-graph-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--lp-border);
  font-size: 13px;
}
.lp-graph-label { color: var(--lp-text-secondary); }
.lp-graph-container {
  flex: 1;
  position: relative;
  min-height: 280px;
}
#graphSvg { width: 100%; height: 100%; }
.lp-graph-legend {
  display: flex;
  gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid var(--lp-border);
  font-size: 11px;
  color: var(--lp-text-secondary);
}
.lp-legend-item { display: flex; align-items: center; gap: 4px; }
.lp-legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* === MODAL === */
.lp-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lp-modal {
  background: var(--lp-surface);
  border-radius: 12px;
  box-shadow: var(--lp-shadow-lg);
  max-width: 520px;
  width: 90%;
  max-height: 70vh;
  overflow-y: auto;
}
.lp-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--lp-border);
}
.lp-modal-header h3 { font-size: 16px; font-weight: 600; }
.lp-modal-close {
  width: 32px; height: 32px;
  border: none; background: transparent;
  font-size: 22px; cursor: pointer;
  border-radius: 50%;
}
.lp-modal-close:hover { background: #f1f5f9; }
.lp-modal-body { padding: 20px; font-size: 14px; line-height: 1.7; }

/* === FAB === */
.lp-fab {
  position: fixed;
  bottom: 24px;
  right: calc(var(--lp-panel-width) + 24px);
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--lp-primary);
  color: white;
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--lp-shadow-lg);
  z-index: 50;
  transition: all var(--lp-transition);
}
.lp-fab:hover { transform: scale(1.08); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .lp-panel-right { display: none; }
  .lp-panel-right.mobile-open {
    display: flex;
    position: fixed;
    top: var(--lp-header-height);
    right: 0; bottom: 0;
    width: 100%;
    z-index: 200;
  }
  .lp-paper-content { padding: 20px; font-size: 14px; }
  .lp-header-center { display: none; }
  .lp-fab { right: 24px; bottom: 24px; }
}

/* Scrollbar */
.lp-paper-content::-webkit-scrollbar,
.lp-tab-content::-webkit-scrollbar { width: 6px; }
.lp-paper-content::-webkit-scrollbar-track,
.lp-tab-content::-webkit-scrollbar-track { background: transparent; }
.lp-paper-content::-webkit-scrollbar-thumb,
.lp-tab-content::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* === DERIVATION PLAYGROUND === */
.dp-step {
  padding: 10px 12px;
  margin: 8px 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.dp-step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.dp-step-num {
  background: var(--lp-primary);
  color: white;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.dp-step-desc {
  font-size: 13px;
  color: #475569;
  font-weight: 500;
}
.dp-step-latex {
  font-size: 15px;
  padding: 6px 0;
}
.dp-step-result {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--lp-text-secondary);
  padding: 4px 0;
  border-top: 1px solid #e2e8f0;
  margin-top: 4px;
}
.dp-custom-result {
  padding: 12px;
  background: #f0fdf4;
  border-radius: 6px;
  border: 1px solid #86efac;
}
.dp-custom-input {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--lp-text-secondary);
  margin-bottom: 6px;
}
.dp-custom-output {
  font-size: 16px;
}
.dp-custom-text {
  font-family: var(--font-mono);
  font-size: 14px;
  color: #166534;
  font-weight: 600;
  margin-top: 4px;
}
.dp-status {
  font-size: 12px;
  color: #E67E22;
}
