:root {
  color-scheme: dark;
  --bg: #0b0d0e;
  --panel: #111416;
  --panel-2: #171b1d;
  --line: #262b2e;
  --text: #f3f4f2;
  --muted: #92999b;
  --accent: #ff4655;
  --accent-hover: #ff6370;
  --topbar-bg: rgba(11, 13, 14, .92);
}

:root[data-theme="oled"] {
  --bg: #000;
  --panel: #070707;
  --panel-2: #0c0c0c;
  --line: #202020;
  --text: #fff;
  --muted: #8b8b8b;
  --topbar-bg: rgba(0, 0, 0, .94);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font: 500 11px/1 "DM Mono", monospace;
  letter-spacing: .16em;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,70,85,.08), transparent 34%),
    var(--bg);
}

.login-card { width: min(100%, 420px); }
.mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 54px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 78% 100%, 22% 100%);
  color: white;
  font-weight: 800;
}
.mark.small { width: 30px; height: 30px; margin: 0; font-size: 12px; }
.login-card h1 {
  margin: 0;
  font-size: clamp(36px, 8vw, 52px);
  line-height: 1.05;
  letter-spacing: -.045em;
}
.login-card > .muted { margin: 20px 0 44px; }
label {
  display: block;
  margin: 0 0 9px;
  color: #b9bec0;
  font-size: 12px;
  font-weight: 600;
}
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: var(--panel);
  color: var(--text);
}
input { height: 50px; padding: 0 15px; }
textarea { padding: 14px 15px; resize: vertical; }
input:focus, textarea:focus { border-color: #646b6e; }
.password-row { position: relative; }
.password-row input { padding-right: 70px; }
.icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
}
.reveal-button {
  position: absolute;
  top: 0;
  right: 8px;
  height: 50px;
  font-size: 12px;
}
.primary-button, .new-button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}
.primary-button {
  width: 100%;
  height: 50px;
  margin-top: 14px;
}
.primary-button:hover, .new-button:hover { background: var(--accent-hover); }
.form-status { min-height: 20px; color: #ff8d96; font-size: 13px; }

.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5vw;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 700 12px/1 "DM Mono", monospace;
  letter-spacing: .14em;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.saved-state { color: var(--muted); font-size: 12px; }
.quiet-button, .back-button, .danger-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: #c6cacc;
}
.quiet-button, .danger-button { height: 40px; padding: 0 16px; }
.danger-button { color: #ff8992; }
.new-button { height: 40px; padding: 0 18px; }
.new-button span { margin-right: 7px; font-size: 18px; }
.theme-button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: #c6cacc;
  font: 500 11px/1 "DM Mono", monospace;
}
.theme-button:hover { border-color: #444a4d; color: var(--text); }
.theme-dot {
  width: 10px;
  height: 10px;
  border: 1px solid #596063;
  border-radius: 50%;
  background: #111416;
  box-shadow: inset 0 0 0 2px #111416;
}
:root[data-theme="oled"] .theme-dot {
  border-color: #fff;
  background: #000;
  box-shadow: inset 0 0 0 2px #000;
}

.library-view, .editor-view {
  width: min(1180px, 90vw);
  margin: 0 auto;
  padding: 76px 0 100px;
}
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 46px;
}
.page-heading h2 {
  margin: 0;
  font-size: clamp(38px, 6vw, 58px);
  letter-spacing: -.05em;
}
.page-heading .muted { margin: 12px 0 0; }
.library-actions { display: flex; align-items: center; gap: 10px; }
.filter-wrap { position: relative; }
.filter-button, .settings-button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: #d6d9da;
  font-weight: 600;
}
.filter-button:hover, .settings-button:hover { border-color: #4b5255; }
.filter-button.active { border-color: var(--accent); color: #ff7b86; }
.filter-popover {
  position: absolute;
  top: 48px;
  right: 0;
  z-index: 5;
  width: 270px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
}
.filter-popover-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.filter-popover-head strong { font-size: 14px; }
.filter-popover-head button, .clear-selection {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 11px;
}
.filter-popover label { margin-top: 13px; }
.filter-popover select {
  width: 100%;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}
.mobile-new { display: none; }
.review-list { border-top: 1px solid var(--line); }
.review-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  align-items: center;
  gap: 36px;
  padding: 25px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
}
.review-row:hover .review-title { color: var(--accent); }
.review-title { font-size: 18px; font-weight: 600; }
.review-meta { color: var(--muted); font: 12px/1.4 "DM Mono", monospace; }
.review-details { display: flex; gap: 8px; justify-content: flex-end; }
.detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px 0 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #c9cdce;
  font-size: 11px;
}
.detail-chip img { width: 25px; height: 25px; border-radius: 50%; object-fit: cover; }
.review-visual {
  width: 58px;
  height: 58px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}
.review-visual img { width: 100%; height: 100%; display: block; object-fit: cover; }
.review-visual.agent img { object-fit: contain; object-position: center bottom; }
.review-visual.thought {
  display: grid;
  place-items: center;
  border-color: rgba(255, 70, 85, .4);
  background: linear-gradient(145deg, rgba(255,70,85,.18), var(--panel));
  font-size: 29px;
}
.review-arrow { color: var(--muted); font-size: 20px; }
.empty-state {
  padding: 90px 20px;
  border: 1px dashed var(--line);
  text-align: center;
}
.empty-state .primary-button { width: auto; padding: 0 25px; }
.empty-plus {
  width: 48px; height: 48px; display: grid; place-items: center;
  margin: 0 auto 24px; border: 1px solid var(--line); border-radius: 50%;
  color: var(--accent); font-size: 24px;
}
.empty-state h3 { margin: 0; font-size: 24px; }
.empty-state p { color: var(--muted); }

.back-button { padding: 10px 14px; margin-bottom: 42px; }
.editor-header {
  display: flex;
  align-items: end;
  gap: 20px;
  margin-bottom: 38px;
}
.settings-button span:first-child { font-size: 17px; }
.title-field { flex: 1; }
.title-field input {
  height: auto;
  padding: 0 0 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: clamp(27px, 4vw, 42px);
  font-weight: 700;
  letter-spacing: -.04em;
}
.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, .75fr);
  gap: 44px;
}
.editor-grid.notes-collapsed { grid-template-columns: minmax(0, 1fr); }
.url-row { display: flex; gap: 10px; margin-bottom: 18px; }
.url-row .quiet-button { height: 50px; white-space: nowrap; }
.video-frame {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #050606;
}
.video-frame iframe { width: 100%; height: 100%; border: 0; }
.video-placeholder { padding: 20px; color: #686f71; text-align: center; }
.notes-column {
  padding-left: 38px;
  border-left: 1px solid var(--line);
}
.composer-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  margin-bottom: 27px;
}
.composer-heading h3 { margin: 0; font-size: 23px; line-height: 1.2; }
.collapse-button, .open-notes-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 500 11px/1.4 "DM Mono", monospace;
  white-space: nowrap;
}
.collapse-button:hover, .open-notes-button:hover { color: var(--text); }
.open-notes-button {
  position: fixed;
  top: 96px;
  right: 22px;
  z-index: 2;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
}
.saved-notes { margin-top: 44px; }
.notes-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 27px;
}
.notes-heading h3 { margin: 0; font-size: 27px; }
.notes-heading span { color: var(--muted); font: 11px "DM Mono", monospace; }
.note-form {
  padding: 20px;
  border-radius: 9px;
  background: var(--panel);
}
.note-form label:not(:first-child) { margin-top: 17px; }
.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}
.tag-picker legend {
  width: 100%;
  margin-bottom: 9px;
  color: #b9bec0;
  font-size: 12px;
  font-weight: 600;
}
.tag-picker label { margin: 0 !important; cursor: pointer; }
.tag-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.tag-picker span, .note-tag {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: 500 10px/1 "DM Mono", monospace;
}
.tag-picker input:checked + span {
  border-color: rgba(255, 70, 85, .7);
  background: rgba(255, 70, 85, .1);
  color: #ff7b86;
}
.tag-picker input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }
.notes-list { border-top: 1px solid var(--line); }
.note-card {
  position: relative;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 18px;
  padding: 24px 44px 24px 0;
  border-bottom: 1px solid var(--line);
}
.timestamp {
  align-self: start;
  margin: 1px 0 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: 500 12px "DM Mono", monospace;
}
.note-card p { margin: 0; color: #d5d8d8; font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.note-content { min-width: 0; }
.note-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.note-tag { min-height: 24px; color: #b9bec0; }
.remove-note {
  position: absolute;
  top: 19px;
  right: 0;
  border: 0;
  background: transparent;
  color: #737a7c;
  font-size: 18px;
}
.no-notes {
  margin: 0;
  padding: 30px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .76);
  backdrop-filter: blur(8px);
}
.settings-modal-card {
  width: min(820px, 100%);
  max-height: min(850px, calc(100vh - 48px));
  overflow: auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  box-shadow: 0 30px 100px rgba(0,0,0,.6);
}
.modal-header { display: flex; justify-content: space-between; align-items: start; }
.modal-header h2 { margin: 0; font-size: 31px; letter-spacing: -.035em; }
.modal-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 23px;
}
.selection-summary { display: flex; gap: 9px; min-height: 34px; margin: 22px 0 8px; }
.thought-toggle {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 20px 0 4px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
}
.thought-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(255,70,85,.1);
  font-size: 21px;
}
.thought-copy { min-width: 0; flex: 1; }
.thought-copy strong, .thought-copy small { display: block; }
.thought-copy strong { color: var(--text); font-size: 13px; }
.thought-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.thought-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.toggle-track {
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  padding: 3px;
  border-radius: 999px;
  background: #313638;
}
.toggle-track span {
  width: 18px;
  height: 18px;
  display: block;
  border-radius: 50%;
  background: #a8adaf;
  transition: transform .18s ease, background .18s ease;
}
.thought-toggle input:checked + .toggle-track { background: var(--accent); }
.thought-toggle input:checked + .toggle-track span { transform: translateX(18px); background: white; }
.thought-toggle input:focus-visible + .toggle-track { outline: 2px solid var(--text); outline-offset: 3px; }
.picker-section.disabled { opacity: .32; pointer-events: none; }
.keybind-setting {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 10px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.keybind-setting > div { min-width: 0; flex: 1; }
.keybind-setting strong, .keybind-setting small { display: block; }
.keybind-setting strong { font-size: 13px; }
.keybind-setting small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.keybind-button {
  min-width: 98px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #4a5052;
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font: 500 11px/1 "DM Mono", monospace;
}
.keybind-button.recording { border-color: var(--accent); color: #ff7b86; }
.picker-section { margin-top: 28px; }
.picker-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.picker-heading h3 { margin: 0; font-size: 13px; }
.visual-picker { display: grid; gap: 8px; }
.map-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.agent-picker { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.visual-option {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: white;
}
.visual-option.map-option { aspect-ratio: 1.55; }
.visual-option.agent-option { aspect-ratio: .78; }
.visual-option img { width: 100%; height: 100%; display: block; object-fit: cover; }
.visual-option.agent-option img { object-fit: contain; object-position: center bottom; }
.visual-option span {
  position: absolute;
  inset: auto 0 0;
  padding: 20px 7px 7px;
  background: linear-gradient(transparent, rgba(0,0,0,.9));
  font-size: 11px;
  font-weight: 700;
  text-align: left;
}
.visual-option.selected { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.picker-loading { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.modal-done { margin-top: 28px; }

@media (max-width: 840px) {
  .topbar { padding: 0 20px; }
  .topbar .new-button, .saved-state { display: none; }
  .library-view, .editor-view { width: calc(100% - 40px); padding-top: 48px; }
  .mobile-new { display: block; }
  .editor-grid { grid-template-columns: 1fr; }
  .map-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .agent-picker { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .notes-column { padding: 34px 0 0; border: 0; border-top: 1px solid var(--line); }
  .open-notes-button { position: static; width: 100%; margin-top: 24px; }
}

@media (max-width: 540px) {
  .wordmark > span:last-child { display: none; }
  .theme-button { width: 40px; justify-content: center; padding: 0; }
  .theme-button span:last-child { display: none; }
  .page-heading { align-items: start; }
  .review-row { grid-template-columns: 1fr auto; gap: 12px; }
  .review-details, .review-meta { grid-column: 1; justify-content: flex-start; }
  .review-arrow { grid-column: 2; grid-row: 1 / span 3; }
  .editor-header { align-items: center; }
  .settings-button span:last-child { display: none; }
  .settings-button { width: 40px; justify-content: center; padding: 0; }
  .note-card { grid-template-columns: 1fr; gap: 9px; }
  .settings-modal-card { padding: 20px; }
  .map-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
