/* ==========================================================================
   Outreach Studio - design tokens
   Dark-first, one warm coral accent, editorial serif wordmark.
   ========================================================================== */

:root {
  --bg: #0b0d11;
  --bg-2: #0f1216;
  --panel: #12161d;
  --panel-2: #171c25;
  --line: #242b37;
  --line-2: #1a202a;

  --ink: #eef1f6;
  --ink-2: #a7b0be;
  --ink-3: #6c7686;

  --accent: #ff6a45;
  --accent-2: #ff8d70;
  --accent-ink: #210d07;

  --ok: #45d29a;
  --warn: #efb14a;
  --err: #ff6060;
  --user-bg: #1c2330;

  --radius: 14px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 24px 48px -30px rgba(0, 0, 0, 0.95);

  --font-ui: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

[data-theme="light"] {
  --bg: #f5f3ee;
  --bg-2: #efecE4;
  --panel: #fffdfa;
  --panel-2: #faf7f0;
  --line: #e2ddd0;
  --line-2: #ebe6da;

  --ink: #1b1a17;
  --ink-2: #5a564d;
  --ink-3: #8b8477;

  --accent: #d8451f;
  --accent-2: #b8381a;
  --accent-ink: #fff8f4;

  --ok: #1c8f5c;
  --warn: #a9741b;
  --err: #c53a3a;
  --user-bg: #ece6d9;

  --shadow: 0 1px 0 rgba(255, 255, 255, 0.6), 0 24px 44px -32px rgba(58, 44, 24, 0.4);
}

/* ==========================================================================
   Base
   ========================================================================== */

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

::selection {
  background: color-mix(in oklab, var(--accent) 30%, transparent);
}

.app {
  display: grid;
  grid-template-columns: 312px minmax(0, 1fr);
  height: 100dvh;
}

/* ==========================================================================
   Left rail
   ========================================================================== */

.rail {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px -8px color-mix(in oklab, var(--accent) 70%, transparent);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.1px;
}

.brand-name em {
  font-style: normal;
  color: var(--ink-3);
}

.btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.14s ease, transform 0.08s ease;
}

.btn-new:hover {
  filter: brightness(1.07);
}

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

.rail-scroll {
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.rail-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.sessions {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.session:hover {
  background: var(--panel);
  color: var(--ink);
}

.session[aria-current="true"] {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--ink);
}

.session-title {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
}

.rail-foot {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line-2);
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: s;
}

.steps li {
  display: flex;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink-2);
}

.steps li::before {
  counter-increment: s;
  content: counter(s);
  display: inline-grid;
  place-items: center;
  flex: none;
  margin-top: 1px;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
}

.server {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
}

.colophon {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}

.dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--ink-3);
}

.dot[data-state="ok"] {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 22%, transparent);
}

.dot[data-state="warn"] {
  background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--warn) 22%, transparent);
}

.dot[data-state="err"] {
  background: var(--err);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--err) 22%, transparent);
}

/* ==========================================================================
   Work area
   ========================================================================== */

.work {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line-2);
}

.thread {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

#threadTitle {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-chip {
  flex: none;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  white-space: nowrap;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.icon-btn:hover {
  background: var(--panel);
  color: var(--ink);
}

.menu-btn {
  display: none;
}

/* theme icon visibility */
.ico-moon {
  display: none;
}

[data-theme="light"] .ico-sun {
  display: none;
}

[data-theme="light"] .ico-moon {
  display: block;
}

/* ==========================================================================
   Stream
   ========================================================================== */

.stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 26px 10px;
}

.stream-inner {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 830px;
  margin: 0 auto;
}

/* ---- Empty state ---- */
.empty {
  max-width: 620px;
  margin: 5vh auto 0;
}

.eyebrow {
  margin-bottom: 13px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.empty h2 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(25px, 3.4vw, 35px);
  line-height: 1.14;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.empty h2 em {
  font-style: italic;
  color: var(--accent);
}

.empty p {
  margin: 0 0 24px;
  max-width: 50ch;
  color: var(--ink-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.chip {
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.14s ease, color 0.14s ease, transform 0.08s ease;
}

.chip:hover {
  border-color: color-mix(in oklab, var(--accent) 45%, var(--line));
  color: var(--ink);
}

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

/* ---- Messages ---- */
.msg {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.msg.user {
  justify-content: flex-end;
}

.bubble-user {
  max-width: 70ch;
  padding: 11px 15px;
  border: 1px solid var(--line-2);
  border-radius: 15px 15px 4px 15px;
  background: var(--user-bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ans {
  flex: 1;
  min-width: 0;
  max-width: 70ch;
}

.ans-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}

.ans-avatar {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--accent);
}

.ans-name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-2);
}

.ans-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
}

.ans-tools {
  margin-left: auto;
}

.mini-btn {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.mini-btn:hover {
  color: var(--ink);
  border-color: var(--ink-3);
}

.ans-body {
  font-size: 15px;
  overflow-wrap: anywhere;
}

.ans-body > :first-child {
  margin-top: 0;
}

.ans-body > :last-child {
  margin-bottom: 0;
}

.ans-body p {
  margin: 0 0 12px;
}

.ans-body h1,
.ans-body h2,
.ans-body h3,
.ans-body h4 {
  margin: 20px 0 9px;
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.25;
}

.ans-body h1 { font-size: 21px; }
.ans-body h2 { font-size: 18px; }
.ans-body h3 { font-size: 16px; }
.ans-body h4 { font-size: 15px; }

.ans-body ul,
.ans-body ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.ans-body li {
  margin: 3px 0;
}

.ans-body a {
  color: var(--accent-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ans-body strong {
  font-weight: 600;
}

.ans-body code {
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: var(--panel-2);
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.ans-body pre {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  overflow-x: auto;
}

.ans-body pre code {
  border: 0;
  padding: 0;
  background: none;
}

.ans-body blockquote {
  margin: 0 0 12px;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--line);
  color: var(--ink-2);
}

.ans-note {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--err);
}

/* ---- Research trail ---- */
.trail {
  margin: 0 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}

.trail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 13px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.trail-head .title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.trail-head .count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
}

.trail-head .caret {
  margin-left: auto;
  color: var(--ink-3);
  transition: transform 0.18s ease;
}

.trail[data-open="false"] .caret {
  transform: rotate(-90deg);
}

.trail[data-open="false"] .trail-body {
  display: none;
}

.trail-body {
  display: flex;
  flex-direction: column;
  padding: 2px 13px 13px;
}

.step {
  position: relative;
  display: grid;
  grid-template-columns: 15px 1fr;
  gap: 11px;
  padding-bottom: 11px;
}

.step:last-child {
  padding-bottom: 3px;
}

.step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 17px;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.step-dot {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  margin-top: 2px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  z-index: 1;
}

.step[data-status="running"] .step-dot {
  border-color: var(--accent);
}

.step[data-status="running"] .step-dot::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}

.step[data-status="done"] .step-dot {
  border-color: color-mix(in oklab, var(--ok) 55%, var(--line));
  background: color-mix(in oklab, var(--ok) 16%, var(--panel));
}

.step[data-status="done"] .step-dot::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

.step-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.step-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.step-name span {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent-2);
}

.step-detail {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.72); }
  50% { opacity: 1; transform: scale(1); }
}

/* ---- Thinking indicator ---- */
.thinking {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink-3);
  font-size: 13.5px;
}

.thinking .pips {
  display: inline-flex;
  gap: 4px;
}

.thinking .pips i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.1s ease-in-out infinite;
}

.thinking .pips i:nth-child(2) { animation-delay: 0.16s; }
.thinking .pips i:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

/* ==========================================================================
   Composer
   ========================================================================== */

.composer {
  padding: 14px 26px 20px;
  border-top: 1px solid var(--line-2);
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 830px;
  margin: 0 auto;
  padding: 7px 7px 7px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer-inner:focus-within {
  border-color: color-mix(in oklab, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 12%, transparent);
}

#input {
  flex: 1;
  max-height: 190px;
  padding: 9px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  resize: none;
  outline: none;
}

#input::placeholder {
  color: var(--ink-3);
}

.send {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  transition: filter 0.14s ease, transform 0.08s ease;
}

.send:hover:not(:disabled) {
  filter: brightness(1.08);
}

.send:active:not(:disabled) {
  transform: translateY(1px);
}

.send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 830px;
  margin: 9px auto 0;
}

.hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.btn-stop {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.btn-stop:hover {
  color: var(--err);
  border-color: color-mix(in oklab, var(--err) 50%, var(--line));
}

/* ==========================================================================
   Scrollbars
   ========================================================================== */

.stream::-webkit-scrollbar,
.rail-scroll::-webkit-scrollbar,
.ans-body pre::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.stream::-webkit-scrollbar-thumb,
.rail-scroll::-webkit-scrollbar-thumb,
.ans-body pre::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
  background-color: var(--line);
}

.stream::-webkit-scrollbar-thumb:hover,
.rail-scroll::-webkit-scrollbar-thumb:hover {
  background-color: var(--ink-3);
}

/* ==========================================================================
   Scrim (mobile)
   ========================================================================== */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

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

  .rail {
    position: fixed;
    inset: 0 auto 0 0;
    width: 292px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }

  .app[data-rail="open"] .rail {
    transform: none;
  }

  .menu-btn {
    display: grid;
  }

  .stream {
    padding: 22px 16px 8px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .composer {
    padding: 12px 16px 16px;
  }

  .empty {
    margin-top: 3vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
