:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --ink: #141a24;
  --muted: #667085;
  --panel: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --line: #d8dee8;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-ink: #ffffff;
  --blue: #2563eb;
  --green: #15803d;
  --amber: #b45309;
  --danger: #b42318;
  --terminal: #101725;
  --terminal-ink: #dce8ff;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.primary:active {
  background: var(--accent-strong);
}

.secondary {
  background: var(--surface-2);
}

.danger {
  border-color: rgba(180, 35, 24, 0.25);
  color: var(--danger);
}

.shell {
  width: min(820px, 100%);
  margin: 0 auto;
  padding: 16px 14px calc(var(--composer-space, 232px) + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  justify-content: start;
  gap: 10px;
  margin: 0;
  padding: calc(10px + env(safe-area-inset-top)) 14px 12px;
  background: rgba(246, 247, 249, 0.92);
  border-bottom: 1px solid rgba(216, 222, 232, 0.7);
  border-radius: 0 0 8px 8px;
  backdrop-filter: blur(16px);
}

.topbar > div {
  min-width: 0;
}

.topbarActions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.navButton {
  display: inline-grid;
  min-height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 11px;
  font-size: 0.82rem;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.55rem;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 1rem;
  line-height: 1.25;
}

.pill,
.smallPill,
.statusBadge {
  display: inline-grid;
  min-height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.pill {
  min-width: 76px;
  max-width: 100%;
  padding: 0 12px;
  flex: 0 0 auto;
  justify-self: start;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill[data-tone="good"] {
  border-color: rgba(21, 128, 61, 0.28);
  color: var(--green);
}

.pill[data-tone="warn"] {
  border-color: rgba(180, 83, 9, 0.3);
  color: var(--amber);
}

.pill[data-tone="bad"] {
  border-color: rgba(180, 35, 24, 0.32);
  color: var(--danger);
}

.smallPill {
  min-height: 28px;
  padding: 0 10px;
  font-size: 0.76rem;
}

.panel,
.commandCenter {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.loginPanel {
  margin-top: 18px;
}

.compact {
  box-shadow: none;
}

.app {
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.hidden {
  display: none !important;
}

.label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 56px;
  max-height: 180px;
  resize: none;
  padding: 12px;
  line-height: 1.45;
}

.muted {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.mutedInline {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.connectionStrip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

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

.connectionStrip strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.currentThreadSurface {
  display: grid;
  gap: 10px;
}

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

.compactHeader {
  margin-bottom: 0;
}

.threadPicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 76px;
  padding: 12px;
  text-align: left;
}

.threadPickerText {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.threadPickerText strong,
.threadCard strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1.02rem;
  line-height: 1.25;
}

.threadPickerText span,
.threadCardMeta,
.threadCardPreview {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.threadPreview {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.quickActions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

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

.compactField {
  margin-bottom: 0;
}

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

.gitSummary > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px;
}

.gitSummary strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.wideButton {
  width: 100%;
}

.gitOutput {
  max-height: 190px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--terminal);
  color: var(--terminal-ink);
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

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

.fileToolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.filePath {
  display: flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.fileList {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.fileItem {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 9px 10px;
  text-align: left;
}

.fileItem.selected {
  border-color: rgba(15, 118, 110, 0.58);
  background: rgba(15, 118, 110, 0.08);
}

.fileKind {
  display: inline-grid;
  min-height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.fileInfo {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.fileInfo strong {
  overflow-wrap: anywhere;
  font-size: 0.9rem;
  line-height: 1.25;
}

.fileInfo span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.filePreview {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px;
}

.filePreviewHeader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.filePreviewHeader div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.filePreviewHeader strong {
  overflow-wrap: anywhere;
  font-size: 0.9rem;
  line-height: 1.25;
}

.filePreviewHeader span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.downloadButton {
  display: inline-grid;
  min-height: 36px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.filePreview img,
.filePreview video {
  display: block;
  width: 100%;
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #000000;
  object-fit: contain;
}

.filePreviewEmpty {
  min-height: 72px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 12px;
  text-align: center;
}

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

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

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

.threadList {
  display: grid;
  gap: 8px;
}

.threadCard {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 86px;
  padding: 12px;
  text-align: left;
}

.threadCard.selected {
  border-color: rgba(15, 118, 110, 0.58);
  background: rgba(15, 118, 110, 0.08);
}

.threadCardTop {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.threadCardMeta,
.threadCardPreview {
  display: block;
}

.targetMarker {
  justify-self: start;
  min-height: 26px;
  border: 1px solid rgba(37, 99, 235, 0.26);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--blue);
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 900;
}

.statusBadge {
  min-height: 30px;
  padding: 0 10px;
  flex: 0 0 auto;
}

.statusBadge.mini {
  min-height: 26px;
  padding: 0 8px;
  font-size: 0.72rem;
}

.tone-ready {
  border-color: rgba(21, 128, 61, 0.25);
  color: var(--green);
}

.tone-running {
  border-color: rgba(37, 99, 235, 0.28);
  color: var(--blue);
}

.tone-warn {
  border-color: rgba(180, 83, 9, 0.32);
  color: var(--amber);
}

.tone-bad {
  border-color: rgba(180, 35, 24, 0.32);
  color: var(--danger);
}

.tone-muted {
  color: var(--muted);
}

.emptyState {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  text-align: center;
}

.settingsDetails {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

.settingsDetails summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}

.settingsBody {
  padding-top: 4px;
}

.row {
  display: flex;
  gap: 10px;
}

.grow {
  flex: 1;
}

.transcriptPanel {
  min-height: 330px;
}

.transcript {
  display: grid;
  align-content: start;
  gap: 8px;
  height: min(48dvh, 520px);
  min-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--terminal);
  padding: 10px;
  color: var(--terminal-ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
}

.entry {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.entry .time {
  color: #93c5fd;
}

.entry.error {
  color: #fecaca;
}

.entry.user {
  color: #bbf7d0;
}

.entry.assistant {
  color: #e0f2fe;
}

.entry.approvalEntry {
  color: #fde68a;
}

.entry.gitEntry {
  color: #bfdbfe;
}

.emptyTranscript {
  display: grid;
  gap: 6px;
  place-items: center;
  min-height: 180px;
  color: #a8b8d4;
  text-align: center;
}

.emptyTranscript span {
  color: #8191ad;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.approvalList {
  display: grid;
  gap: 10px;
}

.approval {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(180, 83, 9, 0.28);
  border-radius: 8px;
  background: rgba(180, 83, 9, 0.06);
  padding: 10px;
}

.approval pre {
  max-height: 180px;
  overflow: auto;
  margin: 0;
  border-radius: 8px;
  background: #101828;
  color: #e5e7eb;
  padding: 10px;
  font-size: 0.78rem;
}

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

.composer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4;
  display: grid;
  gap: 8px;
  width: min(820px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: rgba(246, 247, 249, 0.94);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 30px rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(16px);
}

.composerContext {
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1118;
    --ink: #e8eef8;
    --muted: #9aa7bb;
    --panel: #121a25;
    --surface: #111827;
    --surface-2: #172033;
    --line: #2b3648;
    --terminal: #07111f;
    --shadow: none;
  }

  .topbar,
  .composer {
    background: rgba(12, 17, 24, 0.92);
  }
}

@media (min-width: 720px) {
  .gitActions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 720px) {
  .shell {
    padding-top: 20px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
  }

  .pill {
    justify-self: end;
  }

  .topbarActions {
    justify-self: end;
  }
}

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

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

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

  .downloadButton {
    width: 100%;
  }

  .row,
  .quickActions,
  .composerActions,
  .approvalActions {
    grid-template-columns: 1fr;
  }

  .row {
    display: grid;
  }
}
