:root {
  --sidebar-width: 236px;
  --page-gutter: clamp(24px, 2.8vw, 56px);
  --bg: #08090b;
  --sidebar: #0d0f13;
  --surface: #11141a;
  --surface-2: #161a22;
  --surface-3: #1b202a;
  --panel-2: var(--surface-2);
  --ink: #f4f7fb;
  --muted: #9aa3b2;
  --muted-2: #697383;
  --accent: var(--green);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.15);
  --green: #52d273;
  --blue: #75a7ff;
  --amber: #f5bd55;
  --red: #ff7474;
  --purple: #b99cff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] {
  --bg: #f5f7fb;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --surface-3: #e9eef5;
  --panel-2: var(--surface-2);
  --ink: #151922;
  --muted: #596273;
  --muted-2: #7b8493;
  --accent: var(--green);
  --line: rgba(20, 27, 38, 0.11);
  --line-strong: rgba(20, 27, 38, 0.18);
  --green: #128a45;
  --blue: #235fc6;
  --amber: #9a640c;
  --red: #c83e3e;
  --purple: #7455d6;
  --shadow: 0 18px 54px rgba(20, 27, 38, 0.08);
}

* {
  box-sizing: border-box;
}

#codex-browser-sidebar-comments-root {
  pointer-events: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.site-shell {
  min-height: 100vh;
}

.topbar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  align-items: stretch;
  gap: 22px;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.header-actions {
  display: grid;
  gap: 8px;
  margin-top: 0;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: #f2f6ff;
  color: #06070a;
  font-size: 13px;
  font-weight: 850;
}

.brand strong,
.brand em {
  display: block;
  line-height: 1.1;
}

.brand strong {
  font-size: 16px;
  font-weight: 780;
}

.brand em {
  margin-top: 5px;
  color: var(--muted-2);
  font-size: 12px;
  font-style: normal;
}

.theme-toggle {
  display: inline-grid;
  width: 72px;
  height: 34px;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 3px;
  cursor: pointer;
}

.theme-icon {
  display: grid;
  min-width: 28px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
}

.theme-icon::before {
  display: block;
  font-size: 14px;
  line-height: 1;
}

.theme-icon.sun::before {
  content: "☀";
}

.theme-icon.moon::before {
  content: "☾";
}

:root[data-theme="dark"] .theme-icon.moon,
:root[data-theme="light"] .theme-icon.sun {
  background: rgba(82, 210, 115, 0.16);
  color: var(--green);
}

.main-nav {
  display: grid;
  gap: 4px;
  align-content: start;
}

.main-nav a,
.nav-toggle,
.btn {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 620;
}

.main-nav a:hover,
.main-nav a.active,
.nav-toggle:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
}

.main-nav a.active {
  color: var(--green);
}

.nav-toggle {
  display: none;
  background: transparent;
}

.safety-strip {
  position: fixed;
  left: var(--sidebar-width);
  right: 0;
  top: 0;
  z-index: 15;
  min-height: 36px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 9, 11, 0.82);
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 620;
  backdrop-filter: blur(16px);
}

:root[data-theme="light"] .safety-strip {
  background: rgba(245, 247, 251, 0.86);
}

main {
  width: calc(100vw - var(--sidebar-width));
  margin-left: var(--sidebar-width);
  padding: 66px var(--page-gutter) 64px;
}

.stream-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.stream-header h1,
.page-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.12;
  font-weight: 760;
}

.stream-header p,
.page-intro {
  margin: 7px 0 0;
  color: var(--muted-2);
  font-size: 14px;
  line-height: 1.6;
}

.header-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted-2);
  font-size: 12px;
}

.header-metrics span {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 4px 10px;
}

.header-metrics strong {
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.toolbar {
  display: grid;
  grid-template-columns: auto auto auto minmax(260px, 1fr);
  gap: 9px;
  align-items: center;
  margin: 0 0 18px;
}

.field {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 11px;
  font-size: 13px;
  outline: none;
}

.field:focus {
  border-color: rgba(82, 210, 115, 0.48);
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented button {
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: rgba(82, 210, 115, 0.12);
  color: var(--green);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(280px, 22vw, 380px);
  gap: clamp(22px, 2vw, 34px);
  align-items: start;
}

.stream {
  display: grid;
  gap: 18px;
}

.day-group {
  display: grid;
  gap: 0;
}

.day-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
}

.day-heading button {
  border: 0;
  background: transparent;
  color: var(--muted-2);
  font-size: 12px;
  cursor: pointer;
}

.day-items {
  display: grid;
}

.signal-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--line);
}

.signal-card:last-child {
  border-bottom-color: transparent;
}

.item-time {
  color: var(--muted-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}

.signal-body {
  min-width: 0;
  max-width: 980px;
}

.signal-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.4;
}

.spark,
.signal-meta strong {
  color: var(--green);
}

.signal-meta strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.signal-title {
  display: inline-block;
  margin-top: 7px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 720;
  line-height: 1.48;
}

.signal-title:hover {
  color: var(--green);
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.text-action {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
}

.text-action:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--green);
}

.text-action:disabled {
  opacity: 0.7;
  cursor: default;
}

.pagination-bar,
.pagination-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 18px 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.pagination-bar .load-more {
  min-width: 112px;
  background: var(--surface);
  color: var(--ink);
}

.summary {
  margin: 8px 0 0;
  color: color-mix(in srgb, var(--ink) 74%, var(--muted));
  font-size: 14px;
  line-height: 1.72;
  display: -webkit-box;
  max-height: calc(1.72em * 3);
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.why {
  margin-top: 10px;
  color: color-mix(in srgb, var(--ink) 84%, var(--muted));
  font-size: 14px;
  line-height: 1.7;
}

.why strong,
.next-step strong {
  color: var(--muted);
}

.next-step {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.meta-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.chip {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
}

.chip.market-us { color: var(--blue); }
.chip.market-hk { color: var(--green); }
.chip.market-cn { color: var(--red); }
.chip.market-global { color: var(--amber); }

.source-link {
  display: inline-flex;
  margin-top: 12px;
  color: var(--green);
  font-weight: 660;
}

.side-stack {
  position: sticky;
  top: 58px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.panel,
.daily-section,
.source-card,
.form-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 14px;
}

.panel h3,
.section-title {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 14px;
}

.status-list {
  display: grid;
  gap: 8px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.status-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.status-row strong {
  color: var(--ink);
}

.status-row.warning-row strong {
  color: #b42318;
}

.calibration-list {
  margin-top: 14px;
}

.page-title {
  margin-bottom: 8px;
}

.page-intro {
  max-width: 760px;
  margin-bottom: 18px;
}

.daily-section,
.source-card,
.form-panel {
  padding: 18px;
  margin-bottom: 14px;
}

.daily-section h2,
.source-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.daily-list {
  display: grid;
  gap: 10px;
}

.daily-item {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.daily-item:last-child {
  border-bottom: 0;
}

.daily-item strong {
  display: block;
  margin-bottom: 6px;
  line-height: 1.5;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 14px;
}

.source-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 4px;
}

.source-summary span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 5px 11px;
  font-size: 13px;
}

.source-summary strong {
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.source-section {
  margin-top: 22px;
}

.source-section h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.system-card,
.metric-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.system-card.wide {
  min-height: 260px;
}

.system-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.system-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.system-card-head h2 {
  margin: 0;
}

.metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 92px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.metric-card strong {
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 30px;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.run-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.run-summary span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 5px 10px;
  font-size: 12px;
}

.run-summary strong {
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.source-card p {
  color: var(--muted);
  line-height: 1.65;
}

.source-card.is-enabled {
  border-left: 3px solid var(--green);
}

.research-toolbar {
  grid-template-columns: auto auto auto minmax(260px, 1fr);
}

.research-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(280px, 22vw, 380px);
  gap: clamp(22px, 2vw, 34px);
  align-items: start;
}

.research-list {
  display: grid;
  gap: 12px;
}

.brief-panel,
.brief-preview {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brief-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 16px;
}

.research-chat-panel {
  align-items: stretch;
}

.research-chat-panel.compact-chat {
  margin: 0 0 14px;
}

.research-question {
  flex: 1 1 360px;
  min-height: 78px;
  resize: vertical;
}

.brief-panel h2,
.brief-head h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.selection-hint {
  margin: 6px 0 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.brief-preview {
  margin-bottom: 14px;
  padding: 16px;
}

.chat-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147483100;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid rgba(82, 210, 115, 0.42);
  border-radius: 999px;
  background: var(--green);
  color: #062012;
  box-shadow: var(--shadow);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 760;
}

.chat-fab strong {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2147483110;
  background: rgba(12, 18, 32, 0.24);
  backdrop-filter: blur(2px);
}

.research-chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 2147483120;
  width: min(50vw, 760px);
  min-width: 420px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  border-left: 1px solid var(--line);
  background: var(--bg);
  box-shadow: -18px 0 46px rgba(0, 0, 0, 0.16);
  padding: 0;
  transform: translateX(104%);
  transition: transform 180ms ease, width 180ms ease;
  overflow: hidden;
}

.research-chat-drawer.open {
  transform: translateX(0);
}

.research-chat-drawer.fullscreen {
  width: 100vw;
  min-width: 100vw;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, var(--surface));
  padding: 14px 18px;
}

.drawer-head h2 {
  margin: 2px 0 0;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 720;
}

.drawer-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.chat-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.chat-head-row .selection-hint {
  margin: 0;
}

.model-select-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 680;
}

.model-select {
  max-width: 240px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 3px 9px;
  font-size: 12px;
  outline: none;
}

.provider-select {
  max-width: 150px;
}

.model-name-select {
  max-width: min(280px, 42vw);
}

.model-select:focus {
  border-color: rgba(82, 210, 115, 0.48);
}

.chat-kicker {
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.drawer-actions {
  display: inline-flex;
  gap: 8px;
}

.icon-action {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

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

.drawer-result {
  min-height: 0;
  overflow: auto;
}

.chat-thread {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 28px clamp(18px, 4vw, 54px) 26px;
  scroll-behavior: smooth;
}

.chat-message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.chat-message.user {
  justify-content: flex-end;
}

.message-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
}

.chat-message.user .message-avatar {
  display: none;
}

.message-bubble {
  max-width: min(100%, 640px);
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  color: var(--ink);
}

.chat-message.user .message-bubble {
  max-width: min(78%, 560px);
  border-radius: 18px;
  background: var(--surface-2);
  padding: 10px 13px;
}

.message-bubble p {
  margin: 0;
  font-size: 14px;
  line-height: 1.72;
}

.message-meta {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.message-title {
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 760;
}

.chat-composer {
  border-top: 0;
  background: linear-gradient(180deg, rgba(8, 9, 11, 0), var(--bg) 26%);
  padding: 18px clamp(16px, 4vw, 48px) 22px;
}

.chat-input-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: end;
  max-width: 720px;
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
  padding: 8px 8px 8px 14px;
}

.chat-composer .research-question {
  min-height: 38px;
  max-height: 150px;
  border: 0;
  border-radius: 0;
  background: transparent;
  resize: none;
  padding: 8px 0;
  line-height: 1.55;
}

.chat-composer .research-question:focus {
  border-color: transparent;
}

.chat-send {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.chat-send:disabled {
  opacity: 0.55;
  cursor: default;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 8px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: typingPulse 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 120ms;
}

.typing-dots span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes typingPulse {
  0%, 80%, 100% { opacity: 0.28; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.chat-message.thinking .message-bubble {
  width: min(100%, 520px);
}

.thinking-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(82, 210, 115, 0.42);
  animation: thinkingPulse 1.35s infinite ease-out;
}

.thinking-marquee {
  position: relative;
  overflow: hidden;
  height: 4px;
  margin: 14px 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
}

.thinking-marquee span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--green), transparent);
  animation: thinkingMarquee 1.2s infinite ease-in-out;
}

.thinking-lines {
  display: grid;
  gap: 8px;
}

.thinking-lines span {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 62%, var(--ink)), var(--surface-2));
  background-size: 220% 100%;
  animation: skeletonSweep 1.4s infinite linear;
}

.thinking-lines span:nth-child(1) {
  width: 92%;
}

.thinking-lines span:nth-child(2) {
  width: 78%;
  animation-delay: 120ms;
}

.thinking-lines span:nth-child(3) {
  width: 48%;
  animation-delay: 240ms;
}

@keyframes thinkingPulse {
  70% { box-shadow: 0 0 0 12px rgba(82, 210, 115, 0); }
  100% { box-shadow: 0 0 0 0 rgba(82, 210, 115, 0); }
}

@keyframes thinkingMarquee {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(240%); }
}

@keyframes skeletonSweep {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}

.brief-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.note-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.brief-markdown {
  max-height: 520px;
  overflow: auto;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.brief-markdown.rendered-markdown,
.chat-thread .brief-markdown.rendered-markdown {
  max-height: none !important;
  overflow: visible !important;
  border: 0;
  background: transparent;
  padding: 0;
  white-space: normal;
  font: inherit;
}

.brief-markdown.rendered-markdown h3,
.brief-markdown.rendered-markdown h4,
.brief-markdown.rendered-markdown h5 {
  margin: 18px 0 8px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

.brief-markdown.rendered-markdown h3:first-child,
.brief-markdown.rendered-markdown h4:first-child,
.brief-markdown.rendered-markdown h5:first-child {
  margin-top: 0;
}

.brief-markdown.rendered-markdown p {
  margin: 8px 0;
  color: color-mix(in srgb, var(--ink) 86%, var(--muted));
  font-size: 14px;
  line-height: 1.75;
}

.brief-markdown.rendered-markdown strong {
  color: var(--ink);
  font-weight: 760;
}

.brief-markdown.rendered-markdown code {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-2);
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.markdown-code-block {
  margin: 12px 0 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px 13px;
  color: var(--ink);
  white-space: pre;
  font: 13px/1.72 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.markdown-code-block code {
  border: 0;
  background: transparent;
  padding: 0;
  white-space: pre;
  font: inherit;
}

.brief-markdown.rendered-markdown a {
  color: var(--green);
  text-decoration: none;
}

.brief-markdown.rendered-markdown blockquote {
  margin: 10px 0;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
  padding: 3px 0 3px 12px;
}

.brief-markdown.rendered-markdown hr {
  height: 1px;
  margin: 16px 0;
  border: 0;
  background: var(--line);
}

.markdown-table-wrap {
  width: 100%;
  margin: 12px 0 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, var(--bg));
}

.markdown-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.55;
}

.markdown-table th,
.markdown-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.markdown-table th {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 760;
  white-space: nowrap;
}

.markdown-table tr:last-child td {
  border-bottom: 0;
}

.markdown-table .md-align-center {
  text-align: center;
}

.markdown-table .md-align-right {
  text-align: right;
}

.brief-markdown.rendered-markdown ul,
.brief-markdown.rendered-markdown ol {
  margin: 8px 0 14px;
  padding-left: 22px;
}

.brief-markdown.rendered-markdown li {
  margin: 6px 0;
  color: color-mix(in srgb, var(--ink) 86%, var(--muted));
  font-size: 14px;
  line-height: 1.7;
}

.citation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.citation-list a {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
}

.note-open {
  width: 100%;
  border: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.note-open:hover {
  color: var(--text);
  background: var(--surface-2);
}

.note-card .signal-title,
.note-title-button {
  display: inline;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 18px;
  font-weight: 760;
  line-height: 1.35;
  padding: 0;
  text-align: left;
}

.note-title-button:hover {
  color: var(--accent);
}

.research-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.research-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.note-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  padding-top: 4px;
}

.note-select input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.stream-note-select {
  float: right;
  margin-left: 10px;
  padding-top: 1px;
}

.review-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  white-space: nowrap;
  border: 1px solid rgba(245, 189, 85, 0.36);
  border-radius: 999px;
  background: rgba(245, 189, 85, 0.1);
  color: var(--amber);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.research-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.research-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 9px 10px;
}

.research-grid span,
.confirmation-row > span {
  display: block;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.4;
}

.research-grid strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 4px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.confirmation-row {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: var(--line);
  background: var(--surface-2);
  cursor: pointer;
}

.btn.primary {
  border-color: rgba(82, 210, 115, 0.35);
  background: rgba(82, 210, 115, 0.12);
  color: var(--green);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.form-grid .full {
  grid-column: 1 / -1;
}

textarea.field {
  min-height: 118px;
  resize: vertical;
}

.form-message {
  margin-top: 12px;
  color: var(--muted);
}

.empty-state,
.loading-state {
  display: grid;
  min-height: 320px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
}

.pulse {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(82, 210, 115, 0.16);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1050px) {
  .layout,
  .research-layout {
    grid-template-columns: 1fr;
  }

  .side-stack {
    position: static;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

@media (max-width: 1180px) {
  .toolbar,
  .research-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar input,
  .research-toolbar input {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .topbar {
    position: sticky;
    inset: 0 0 auto;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 14px;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 0;
    margin-left: auto;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .main-nav {
    display: none;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main-nav.open {
    display: grid;
  }

  .safety-strip {
    position: sticky;
    left: 0;
    top: 69px;
    padding: 9px 16px;
  }

  main {
    width: 100%;
    margin: 0 auto;
    padding: 22px 14px 54px;
  }

  .stream-header {
    display: grid;
  }

  .header-metrics {
    justify-content: flex-start;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar input {
    grid-column: auto;
  }

  .side-stack,
  .source-grid,
  .form-grid,
  .research-grid,
  .system-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .research-chat-drawer {
    width: 100vw;
    min-width: 100vw;
  }

  .chat-composer {
    grid-template-columns: 1fr;
  }

  .message-bubble {
    max-width: 92%;
  }
}

@media (max-width: 520px) {
  .signal-card {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .item-time {
    font-size: 12px;
  }

  .signal-title {
    font-size: 16px;
  }
}
