:root {
  --bg: #fbfbfd;
  --panel: #ffffff;
  --border: #e6e6eb;
  --border-strong: #d9d9e1;
  --text: #1f1f24;
  --muted: #6d6d76;
  --muted-strong: #4e4e57;
  --accent: #0a84ff;
  --accent-weak: rgba(10, 132, 255, 0.12);
  --accent-strong: rgba(10, 132, 255, 0.18);
  --danger: #d64545;
  --shadow: 0 8px 24px rgba(18, 18, 22, 0.06);
  --radius: 12px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --pill-bg: #f4f5fb;
  --pill-active: #e9f2ff;
  --question: rgba(255, 180, 0, 0.18);
  --action: rgba(84, 204, 154, 0.2);
  --evidence: rgba(10, 132, 255, 0.08);
  --decision: rgba(86, 84, 214, 0.08);
  --changed: rgba(10, 132, 255, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  line-height: 1.45;
}

button,
input,
select {
  font-family: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 0;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  padding: 20px 18px 16px;
  gap: 14px;
}

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

.sidebar__bottom {
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.search {
  position: relative;
}

.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fafafd;
  color: var(--text);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
  background: #fff;
}

.btn {
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 10px 12px;
  font-size: 0.95rem;
  cursor: pointer;
  background: #f1f1f6;
  color: var(--text);
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.btn:hover {
  background: #ededf4;
}

.btn:active {
  transform: translateY(1px);
}

.btn--small {
  padding: 6px 10px;
  font-size: 0.88rem;
  border-radius: var(--radius-xs);
}

.btn:focus-visible,
.icon-btn:focus-visible,
.note-row:focus-visible,
.tool-btn:focus-visible,
.title-input:focus-visible,
.editor:focus-visible,
.segmented:focus-visible,
.stat-pill:focus-visible,
.select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-weak);
  border-color: var(--accent);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.btn--primary:hover {
  background: #0077ed;
  border-color: #0077ed;
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted-strong);
}

.btn--ghost:hover {
  background: #f5f5fa;
  color: var(--text);
}

.intent-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.intent-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--pill-bg);
  color: var(--muted-strong);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 120ms ease;
}

.intent-chip.is-active {
  background: var(--pill-active);
  border-color: rgba(10, 132, 255, 0.28);
  color: var(--text);
}

.sidebar__stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.stat-pill {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #f7f7fc;
  color: var(--muted-strong);
  text-align: left;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.stat-pill:hover {
  background: #f1f2fa;
}

.stat-pill.is-active {
  background: var(--pill-active);
  border-color: rgba(10, 132, 255, 0.28);
  color: var(--text);
}

.sidebar__toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #f6f6fb;
  color: var(--muted-strong);
  cursor: pointer;
  font-size: 0.9rem;
}

.segmented.is-active {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.01);
}

.notes-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.notes-list:empty::before {
  content: "No notes yet";
  color: var(--muted);
  padding: 12px 8px;
}

.note-row {
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px;
  background: transparent;
  cursor: pointer;
  display: grid;
  gap: 4px;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.note-row:hover {
  background: #f4f4f9;
}

.note-row.is-active {
  background: #eef4ff;
  border-color: rgba(10, 132, 255, 0.2);
}

.note-row__title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.note-row__title {
  font-weight: 600;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-row__intent {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(10, 132, 255, 0.22);
  background: rgba(10, 132, 255, 0.08);
  color: var(--muted-strong);
  white-space: nowrap;
}

.note-row__snippet {
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.25em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-row__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.82rem;
}

.note-row__pin {
  opacity: 0.8;
  display: none;
}

.note-row.is-pinned .note-row__pin {
  display: inline;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main__header {
  padding: 18px 22px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.main__header-row,
.main__meta-row,
.main__controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main__controls-row {
  flex-wrap: wrap;
}

.main__spacer {
  flex: 1;
}

.back-button {
  display: none;
}

.title-input {
  flex: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 1.4rem;
  font-weight: 650;
  background: transparent;
  outline: none;
}

.last-edited {
  color: var(--muted);
  font-size: 0.9rem;
}

.actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: #f8f8fc;
  color: var(--muted-strong);
  padding: 6px 8px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.icon-btn:hover {
  background: #f1f1f8;
}

.icon-btn.danger {
  color: var(--danger);
  border-color: rgba(214, 69, 69, 0.25);
  background: rgba(214, 69, 69, 0.06);
}

.icon-btn.danger:hover {
  background: rgba(214, 69, 69, 0.12);
}

.export-menu {
  position: relative;
}

.export-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
  display: grid;
  gap: 4px;
  z-index: 4;
}

.export-item {
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  text-align: left;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
}

.export-item:hover,
.export-item:focus-visible {
  background: #f3f4fb;
  border-color: var(--border);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px 2px;
}

.tool-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: #f7f7fb;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--muted-strong);
  font-size: 0.9rem;
}

.tool-btn:hover {
  background: #efeff7;
}

.tool-btn.is-active {
  background: var(--pill-active);
  border-color: rgba(10, 132, 255, 0.28);
  color: var(--text);
}

.tool-btn--evidence {
  font-weight: 600;
}

.toolbar__divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 2px;
}

.intent-select,
.thinking-select {
  display: grid;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.intent-select__label {
  padding-left: 2px;
}

.select {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 6px 8px;
  background: #f7f7fc;
  color: var(--text);
  min-width: 110px;
}

.thinking-timer {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f7f8ff;
  color: var(--muted-strong);
  font-size: 0.85rem;
}

.thinking-timer.is-ending {
  border-color: rgba(214, 69, 69, 0.28);
  color: var(--danger);
  background: rgba(214, 69, 69, 0.06);
}

.thinking-prompt {
  border: 1px solid var(--border);
  background: #f7f8ff;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted-strong);
}

.thinking-prompt__actions {
  display: flex;
  gap: 6px;
}

.editor-shell {
  flex: 1;
  padding: 18px 24px 28px;
  overflow: auto;
}

.editor {
  min-height: 60vh;
  padding: 18px 18px 24px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid transparent;
  outline: none;
  box-shadow: var(--shadow);
}

.editor.hidden {
  display: none;
}

.editor > * {
  margin: 0 0 10px;
}

.editor h1,
.editor h2,
.editor h3 {
  margin-top: 4px;
  margin-bottom: 10px;
}

.editor h1 {
  font-size: 1.6rem;
}

.editor h2 {
  font-size: 1.35rem;
}

.editor h3 {
  font-size: 1.12rem;
}

.editor ul,
.editor ol {
  padding-left: 20px;
}

.todo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.todo span {
  flex: 1;
  min-width: 0;
}

.todo input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.question-line {
  border-left: 3px solid rgba(255, 180, 0, 0.6);
  padding-left: 10px;
  background: var(--question);
  border-radius: var(--radius-xs);
}

.action-line {
  border-left: 3px solid rgba(84, 204, 154, 0.7);
  padding-left: 10px;
  background: var(--action);
  border-radius: var(--radius-xs);
}

.evidence-block {
  border: 1px solid rgba(10, 132, 255, 0.18);
  background: var(--evidence);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.evidence-block::before {
  content: "Evidence";
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}

.decision-snapshot {
  border: 1px solid rgba(86, 84, 214, 0.2);
  background: var(--decision);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.decision-snapshot__title {
  font-weight: 600;
  margin-bottom: 4px;
}

.decision-snapshot__meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 6px;
}

.takeaway-block {
  border: 1px dashed rgba(10, 132, 255, 0.4);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: rgba(10, 132, 255, 0.05);
}

.changed-block {
  background: var(--changed);
  transition: background-color 1200ms ease;
}

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: #1f1f24;
  color: #fff;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  z-index: 10;
}

.empty-state {
  max-width: 420px;
  margin: 80px auto 0;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  margin-bottom: 6px;
  color: var(--text);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 20;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 12, 18, 0.32);
}

.modal__panel {
  position: relative;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-width: 320px;
  max-width: 420px;
  padding: 16px;
  z-index: 1;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal__body {
  display: grid;
  gap: 10px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f7f7fb;
}

.toggle input {
  width: 16px;
  height: 16px;
}

.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;
}

body.is-modal-open {
  overflow: hidden;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 280px minmax(0, 1fr);
  }
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .back-button {
    display: inline-flex;
  }

  .app.is-editor-view .sidebar {
    display: none;
  }

  .editor-shell {
    padding: 14px 16px 20px;
  }

  .main__header {
    padding: 14px 16px 8px;
  }
}

[hidden] {
  display: none !important;
}
