:root {
  --background: #f7f7f8;
  --foreground: #1f2328;
  --panel: #ffffff;
  --line: #e5e5e7;
  --line-strong: #d1d5db;
  --muted: #6b7280;
  --accent: #111827;
  --accent-strong: #000000;
  --green: #16a34a;
  --danger: #b42318;
  --sidebar: #f1f2f4;
  --hover: #eceef1;
  --selection: #e7e9ed;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

h1,
h2,
p {
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 336px;
  background: var(--background);
}

.workspace-sidebar,
.settings-panel {
  min-height: 100vh;
  background: var(--sidebar);
}

.workspace-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  padding: 14px;
}

.workspace-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-bottom: 14px;
  color: inherit;
  text-decoration: none;
}

.brand-mark,
.nav-glyph,
.panel-glyph,
.empty-mark {
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: #111827;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-weight: 800;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 0.8rem;
}

.workspace-brand strong,
.sidebar-status strong {
  display: block;
  font-size: 0.92rem;
  line-height: 1.15;
}

.workspace-brand small,
.sidebar-status small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.workspace-nav {
  display: grid;
  gap: 3px;
}

.nav-item {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #374151;
  padding: 0 10px;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 650;
}

.nav-glyph {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.67rem;
}

.nav-item:hover,
.nav-item.selected {
  background: var(--selection);
  color: #111827;
}

.task-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.task-panel-head,
.balance-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.mini-button {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--foreground);
  font-weight: 850;
}

.mini-button:hover {
  border-color: var(--accent);
}

.task-search input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: rgba(255, 255, 255, 0.78);
  padding: 0 10px;
  color: var(--foreground);
  font-size: 0.84rem;
}

.task-count {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.task-list {
  min-height: 120px;
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: auto;
  padding-right: 2px;
}

.task-item {
  min-height: 52px;
  display: grid;
  gap: 3px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--foreground);
  padding: 8px 9px;
  text-align: left;
}

.task-item:hover,
.task-item.selected {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.task-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  line-height: 1.2;
}

.task-item small,
.task-empty {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
  padding: 10px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.chat-surface {
  min-width: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: var(--panel);
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  padding: 12px 20px;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: 1.08rem;
  line-height: 1.2;
  letter-spacing: 0;
  font-weight: 760;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-strip span {
  min-width: 64px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: #374151;
  padding: 6px 9px;
  text-align: center;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.73rem;
  font-weight: 700;
}

.transcript {
  overflow: auto;
  padding: 28px clamp(18px, 5vw, 72px);
  scroll-behavior: smooth;
}

.empty-state {
  min-height: 100%;
  display: grid;
  place-content: center;
  gap: 18px;
  text-align: left;
  color: var(--foreground);
}

.empty-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.empty-state h2 {
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  letter-spacing: 0;
  font-weight: 760;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 220px));
  gap: 8px;
}

.sample-prompt {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--foreground);
  padding: 12px;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 620;
  line-height: 1.45;
  transition: border-color 150ms ease, background 150ms ease;
}

.sample-prompt:hover {
  border-color: var(--line-strong);
  background: var(--hover);
}

.message-row {
  max-width: min(820px, 100%);
  margin: 0 0 20px;
}

.message-row.from-user {
  margin-left: auto;
  max-width: min(680px, 92%);
}

.message-meta {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.from-user .message-meta {
  text-align: right;
}

.message-content,
.reasoning-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 15px;
  line-height: 1.68;
  white-space: pre-wrap;
  font-size: 0.95rem;
}

.message-content {
  background: #ffffff;
}

.from-user .message-content {
  border-color: #d9dde3;
  background: #f3f4f6;
}

.reasoning-block {
  margin-bottom: 8px;
  background: #f9fafb;
  color: #374151;
}

.reasoning-block summary {
  font-weight: 800;
  cursor: pointer;
}

.reasoning-block p {
  margin-top: 10px;
  white-space: pre-wrap;
}

.thinking-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

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

.error-banner {
  margin: 0 clamp(18px, 5vw, 72px) 14px;
  border: 1px solid rgba(180, 35, 24, 0.3);
  border-radius: 8px;
  background: #fff2f0;
  color: var(--danger);
  padding: 12px 14px;
  font-weight: 700;
}

.composer {
  margin: 0 clamp(18px, 5vw, 72px) 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.composer textarea,
.system-prompt,
.key-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--foreground);
}

.composer textarea {
  min-height: 104px;
  resize: vertical;
  padding: 14px;
  line-height: 1.55;
}

.composer-actions {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.composer-actions > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.send-button,
.reset-button,
.segmented-control button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--foreground);
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  font-size: 1.2rem;
}

.icon-button:hover,
.reset-button:hover,
.segmented-control button:hover {
  border-color: var(--accent);
}

.send-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  padding: 0 13px;
  font-weight: 760;
}

.send-button:hover {
  background: var(--accent-strong);
}

.send-button:disabled {
  border-color: var(--line);
  background: #d1d5db;
  color: #6b7280;
}

.settings-panel {
  border-left: 1px solid var(--line);
  padding: 14px;
}

.panel-heading {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.panel-glyph {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  color: #374151;
  font-size: 0.72rem;
}

.panel-heading h2 {
  font-size: 0.95rem;
  font-weight: 760;
}

.model-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 11px 12px;
  margin-bottom: 14px;
}

.model-label {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.2;
}

.model-card strong {
  display: block;
  margin-top: 3px;
  font-size: 0.94rem;
}

.verified-mark {
  border: 1px solid rgba(22, 163, 74, 0.28);
  border-radius: 999px;
  color: #087a33;
  background: rgba(22, 163, 74, 0.08);
  padding: 4px 7px;
  font-size: 0.72rem;
  font-weight: 800;
}

.balance-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 11px 12px;
  margin-bottom: 14px;
}

.balance-card > strong {
  font-size: 1.18rem;
  line-height: 1.15;
}

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

.balance-grid span {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 8px;
}

.balance-grid small,
.balance-note,
.toggle-row small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.3;
}

.balance-grid b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.toggle-row {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 10px 12px;
  margin-bottom: 14px;
}

.toggle-row span {
  display: grid;
  gap: 2px;
}

.toggle-row strong {
  font-size: 0.86rem;
}

.toggle-row input {
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field > span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.key-field {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 0 12px;
}

.key-glyph {
  color: var(--muted);
  flex: 0 0 auto;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 800;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.segmented-control button {
  min-height: 34px;
  font-size: 0.82rem;
  font-weight: 740;
}

.segmented-control .selected {
  border-color: var(--line-strong);
  background: #111827;
  color: #ffffff;
}

.range {
  accent-color: var(--accent);
}

.field strong {
  font-size: 0.95rem;
}

.system-prompt {
  min-height: 154px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 11px;
  line-height: 1.55;
  font-size: 0.86rem;
}

.reset-button {
  width: 100%;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 740;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 72px minmax(0, 1fr) 312px;
  }

  .workspace-brand span:not(.brand-mark),
  .nav-item span:last-child,
  .sidebar-status span:last-child,
  .task-panel {
    display: none;
  }

  .workspace-sidebar {
    padding: 12px 10px;
  }

  .workspace-brand {
    justify-content: center;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .sidebar-status {
    justify-content: center;
  }
}

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

  .workspace-sidebar {
    min-height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace-nav {
    display: flex;
    flex: 1;
  }

  .workspace-brand {
    margin-bottom: 0;
  }

  .workspace-brand span:not(.brand-mark),
  .nav-item span:last-child {
    display: block;
  }

  .sidebar-status {
    display: none;
  }

  .task-panel {
    order: 3;
    width: 100%;
    display: grid;
    max-height: 220px;
    margin-top: 0;
  }

  .chat-surface,
  .settings-panel {
    min-height: auto;
  }

  .settings-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .transcript {
    min-height: 52vh;
    padding: 18px;
  }

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

  .composer {
    margin: 0 14px 14px;
  }

  .composer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .composer-actions > div {
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .workspace-sidebar {
    overflow-x: auto;
  }

  .workspace-brand span:not(.brand-mark) {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    padding: 0 12px;
  }

  .status-strip span {
    min-width: auto;
  }
}
