:root {
  color-scheme: light dark;
  --bg: #f7f7f2;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --text: #16201d;
  --muted: #61706b;
  --border: #d7dfda;
  --accent: #0f7b68;
  --accent-strong: #095b4d;
  --danger: #b53333;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111715;
    --surface: #18211f;
    --surface-2: #1f2b28;
    --text: #edf3ef;
    --muted: #9dafaa;
    --border: #33423e;
    --accent: #5ec9b4;
    --accent-strong: #8ce0d0;
    --danger: #ff8b8b;
  }
}

:root[data-identity="canvas"] {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #e7f0ef;
  --text: #17201d;
  --muted: #5f6f67;
  --border: #d3ded6;
  --accent: #0d806b;
  --accent-strong: #9a5a1f;
  --danger: #b53333;
  --identity-hot: #ff8f70;
  --identity-cool: #6dc7c2;
}

:root[data-identity="ops"] {
  --bg: #121614;
  --surface: #191f1d;
  --surface-2: #222926;
  --text: #f2f4ef;
  --muted: #a7b1aa;
  --border: #3a453f;
  --accent: #5bd6c6;
  --accent-strong: #ffb454;
  --danger: #ff7f75;
  --identity-hot: #ff8b73;
  --identity-cool: #72a8ff;
}

:root[data-identity="orbit"] {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #edf2f8;
  --text: #182033;
  --muted: #657084;
  --border: #d4dce8;
  --accent: #356dff;
  --accent-strong: #c24b5f;
  --danger: #b53333;
  --identity-hot: #ef8a59;
  --identity-cool: #20a899;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 650;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

.app-shell {
  min-height: 100dvh;
}

.login-view {
  display: grid;
  align-content: center;
  gap: 24px;
  min-height: 100dvh;
  max-width: 420px;
  margin: 0 auto;
  padding: 24px;
}

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

.brand-lockup h1,
.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.login-form,
.stack-form {
  display: grid;
  gap: 12px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.error-text {
  min-height: 1.3em;
  margin: 0;
  color: var(--danger);
}

.main-view {
  min-height: 100dvh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 3;
}

.topbar p,
.pane-title h2,
.thread-toolbar h2,
.thread-toolbar p {
  margin: 0;
}

.topbar p,
.thread-toolbar p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.85rem;
}

.ghost-button,
.small-button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.88rem;
}

.danger {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  color: var(--danger);
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 67px;
  z-index: 2;
}

.tab {
  flex: 1 0 auto;
  min-width: 78px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  min-height: 36px;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.identity-panel.active {
  display: grid;
  gap: 18px;
}

.identity-hero {
  display: grid;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.identity-hero-copy {
  display: grid;
  gap: 8px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.identity-hero h2,
.preview-heading h2,
.identity-notes h3 {
  margin: 0;
  letter-spacing: 0;
}

.identity-hero h2 {
  font-size: clamp(1.55rem, 3vw, 2.25rem);
}

.identity-hero p:not(.eyebrow),
.identity-notes p,
.identity-notes li,
.work-tile p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.identity-moodboard {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.identity-layout {
  display: grid;
  gap: 16px;
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 0 14px 18px;
}

.identity-options {
  display: grid;
  gap: 10px;
}

.identity-option {
  display: grid;
  gap: 7px;
  width: 100%;
  min-height: 118px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.identity-option.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.identity-option-title {
  font-weight: 800;
}

.identity-option-copy {
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.35;
}

.swatches {
  display: flex;
  gap: 6px;
  align-self: end;
}

.swatches span {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--swatch);
}

.identity-preview {
  display: grid;
  gap: 12px;
}

.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-heading h2 {
  margin-top: 3px;
  font-size: 1.2rem;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  padding: 7px 10px;
  white-space: nowrap;
}

.agent-surface {
  display: grid;
  gap: 12px;
  min-height: 430px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 90%, var(--identity-cool)), transparent 60%),
    var(--surface);
}

.daily-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 74%, var(--surface));
}

.daily-strip span,
.work-tile span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.daily-strip strong,
.work-tile strong {
  overflow-wrap: anywhere;
}

.work-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.work-tile {
  display: grid;
  gap: 8px;
  min-height: 124px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, var(--accent));
}

.work-tile.primary {
  min-height: 156px;
  background: color-mix(in srgb, var(--surface) 88%, var(--identity-cool));
}

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 58%, var(--surface));
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--identity-hot));
}

.task-row {
  display: grid;
  gap: 7px;
}

.task-row span {
  display: block;
  height: 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 28%, var(--border));
}

.task-row span:nth-child(2) {
  width: 76%;
  background: color-mix(in srgb, var(--identity-hot) 36%, var(--border));
}

.task-row span:nth-child(3) {
  width: 54%;
}

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

.skill-dock span {
  min-height: 44px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 72%, var(--surface));
  color: var(--text);
  font-weight: 760;
  text-align: center;
}

.identity-notes {
  display: grid;
  gap: 10px;
}

.identity-notes article {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.identity-notes h3 {
  font-size: 0.95rem;
}

.identity-notes ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
}

.split-view {
  display: grid;
  min-height: calc(100dvh - 124px);
}

.thread-list-pane,
.thread-pane,
.tab-panel[data-panel="approvals"],
.tab-panel[data-panel="tmux"],
.tab-panel[data-panel="events"] {
  padding: 14px;
}

.thread-list-pane {
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.pane-title,
.thread-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.pane-title h2,
.thread-toolbar h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.thread-list,
.approval-list,
.tmux-list,
.event-log {
  display: grid;
  gap: 8px;
}

.thread-item,
.approval-item,
.tmux-item,
.event-item,
.message {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.thread-item,
.tmux-item {
  width: 100%;
  min-height: auto;
  padding: 10px;
  text-align: left;
  color: var(--text);
}

.thread-item.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.thread-item strong,
.tmux-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.thread-item span,
.tmux-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.thread-pane {
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto;
  gap: 12px;
}

.transcript {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 260px;
}

.message {
  padding: 12px;
}

.message.agent {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
}

.message .label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.message pre,
.event-item pre,
.approval-item pre,
.tmux-capture {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  padding-bottom: env(safe-area-inset-bottom);
}

.approval-item,
.event-item {
  padding: 10px;
}

.approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.event-item {
  border-left: 3px solid var(--border);
}

.event-item.notification {
  border-left-color: var(--accent);
}

.event-item.server-request {
  border-left-color: var(--danger);
}

.event-item strong {
  display: block;
  margin-bottom: 6px;
}

.tmux-capture {
  min-height: 220px;
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

[hidden] {
  display: none !important;
}

@media (min-width: 860px) {
  .tabs {
    top: 67px;
  }

  .split-view {
    grid-template-columns: minmax(280px, 360px) 1fr;
  }

  .thread-list-pane {
    border-bottom: 0;
    border-right: 1px solid var(--border);
  }

  .thread-pane {
    min-height: calc(100dvh - 124px);
  }

  .identity-hero {
    grid-template-columns: minmax(280px, 0.7fr) minmax(420px, 1.3fr);
    padding: 22px 24px;
  }

  .identity-layout {
    grid-template-columns: minmax(220px, 260px) minmax(380px, 1fr) minmax(240px, 300px);
    align-items: start;
    padding: 0 18px 24px;
  }

  .work-grid {
    grid-template-columns: 1.25fr 0.85fr;
  }

  .work-tile.primary {
    grid-row: span 2;
  }

  .skill-dock {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
