:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2129;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #1f6feb33;
  --yellow: #d29922;
  --yellow-dim: #d2992233;
  --red: #f85149;
  --red-dim: #f8514933;
  --orange: #db6d28;
  --orange-dim: #db6d2833;
  --blue: #58a6ff;
  --blue-dim: #58a6ff33;
  --green: #3fb950;
  --green-dim: #3fb95033;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- Top Bar --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-brand {
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  margin-right: 16px;
  white-space: nowrap;
}

.tab {
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: all 0.15s;
  position: relative;
}

.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

.tab .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--yellow);
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}

/* --- Main Layout --- */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-section {
  padding: 12px 16px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

.doc-item {
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  transition: all 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.doc-item:hover { background: var(--surface-2); color: var(--text); }
.doc-item.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-dim); }

.doc-item .note-count {
  font-size: 10px;
  background: var(--yellow-dim);
  color: var(--yellow);
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
}

.sidebar-meta {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}

.sidebar-meta strong { color: var(--text); }
.sidebar-meta a { color: var(--accent); text-decoration: none; }

/* --- Content --- */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.content h1, .content h2, .content h3 { margin: 16px 0 8px; }
.content h1 { font-size: 20px; color: var(--text); }
.content h2 { font-size: 16px; color: var(--accent); }
.content h3 { font-size: 14px; color: var(--text); }
.content p { margin: 6px 0; line-height: 1.65; font-size: 14px; }
.content ul, .content ol { margin: 6px 0 6px 24px; font-size: 14px; line-height: 1.6; }
.content li { margin: 3px 0; }
.content hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.content pre { background: var(--surface); padding: 12px; border-radius: 6px; overflow-x: auto; font-size: 13px; margin: 8px 0; }
.content code { background: var(--surface-2); padding: 2px 5px; border-radius: 3px; font-size: 13px; }
.content table { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.content th, .content td { padding: 6px 12px; border: 1px solid var(--border); }
.content th { background: var(--surface); font-weight: 600; }
.content strong { color: var(--text); }
.content em { color: var(--text-muted); }

/* --- Reviewable Paragraphs --- */
.reviewable {
  position: relative;
  padding: 4px 8px;
  border-radius: 4px;
  margin: 2px -8px;
  transition: background 0.15s;
}

.reviewable:hover {
  background: var(--surface-2);
}

.reviewable .add-note-btn {
  position: absolute;
  right: -40px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.1s;
}

.reviewable:hover .add-note-btn { display: flex; }
.reviewable .add-note-btn:hover { transform: translateY(-50%) scale(1.1); }

/* --- Notes --- */
.note-block {
  margin: 6px 0;
  padding: 10px 14px;
  border-radius: 6px;
  border-left: 3px solid;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
}

.note-block.edit { background: var(--yellow-dim); border-color: var(--yellow); }
.note-block.remove { background: var(--red-dim); border-color: var(--red); }
.note-block.rewrite { background: var(--orange-dim); border-color: var(--orange); }
.note-block.question { background: var(--blue-dim); border-color: var(--blue); }
.note-block.approve { background: var(--green-dim); border-color: var(--green); }
.note-block.applied { opacity: 0.4; }

.note-block .note-text { margin-bottom: 4px; }
.note-block .note-meta { font-size: 11px; color: var(--text-muted); }
.note-block .note-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }
.note-block .note-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}
.note-block .note-actions button:hover { color: var(--text); }

/* --- Note Form --- */
.note-form {
  margin: 8px 0;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.note-form textarea {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 60px;
}

.note-form textarea:focus { outline: none; border-color: var(--accent); }

.note-form-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.note-form select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
}

.btn {
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.btn-primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

/* --- Resume iframe --- */
.resume-frame {
  width: 100%;
  height: calc(100vh - 160px);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
}

.resume-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

/* --- Bottom Guide Bar --- */
.guidebar {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  font-size: 12px;
  display: flex;
  gap: 24px;
  align-items: center;
  color: var(--text-muted);
  overflow-x: auto;
  white-space: nowrap;
}

.guidebar a { color: var(--accent); text-decoration: none; }
.guidebar .guide-label { font-weight: 600; color: var(--text); }
.guidebar .status-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.status-badge.open { background: var(--green-dim); color: var(--green); }
.status-badge.closed { background: var(--red-dim); color: var(--red); }

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state h2 { font-size: 18px; margin-bottom: 8px; color: var(--text); }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
