:root {
  color-scheme: dark;
  --bg: #08090b;
  --side: #0d0f13;
  --panel: #111318;
  --panel-soft: #151820;
  --input: #090b0f;
  --line: #252932;
  --line-soft: #1a1e26;
  --text: #f4f5f7;
  --muted: #8d96a5;
  --faint: #5f6978;
  --accent: #ffffff;
  --accent-ink: #090b0f;
  --good: #8fe7b0;
  --bad: #ff8599;
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100svh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: clip;
}

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

button {
  cursor: pointer;
}

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

code {
  color: var(--text);
}

.shell {
  min-height: 100svh;
}

.auth-shell {
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(440px, 100%);
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.auth-heading {
  display: grid;
  gap: 7px;
  margin-bottom: 20px;
}

.auth-heading h1 {
  font-size: 1.3rem;
}

.auth-heading p:last-child,
.auth-help {
  color: var(--muted);
  line-height: 1.45;
}

.auth-login,
.auth-setup,
.auth-password-form {
  display: grid;
  gap: 12px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--faint);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  flex: 1;
  content: "";
  background: var(--line);
}

.auth-feedback {
  min-height: 1.4em;
  margin-top: 14px;
  color: var(--bad);
  line-height: 1.45;
}

.auth-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.auth-settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.auth-settings > .auth-password-form {
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.topbar,
.brand,
.status-strip {
  display: none;
}

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

.mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--bg);
  background: var(--text);
  border-radius: 10px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.05rem;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.brand p,
.section-heading p,
.field span,
.check,
.task-meta,
.draft-meta,
.eyebrow {
  color: var(--muted);
}

.brand p {
  margin-top: 3px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.eyebrow {
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 0.68rem;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 8px;
}

.metric {
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
}

.metric strong {
  display: block;
  font-size: 1rem;
  letter-spacing: -0.05em;
}

.metric span {
  color: var(--muted);
  font-size: 0.74rem;
}

.settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.settings h2,
.modal-heading,
.span-2 {
  grid-column: 1 / -1;
}

.modal-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 4px;
}

.settings-dialog {
  width: min(720px, calc(100vw - 28px));
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.draft-controls span,
.check {
  font-size: 0.8rem;
}

textarea,
input,
select {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  padding: 10px 11px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: #d8dde6;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  column-gap: 0;
  row-gap: 8px;
  justify-content: flex-end;
}

.primary,
.ghost,
.icon-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
}

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

.ghost,
.icon-button {
  color: var(--text);
  background: transparent;
}

.icon-action {
  position: relative;
  display: grid;
  width: 42px;
  min-width: 42px;
  padding: 0;
  place-items: center;
}

.icon-action svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.menu-caret {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 0;
  height: 0;
  border-top: 4px solid currentColor;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  opacity: 0.72;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.78fr) minmax(520px, 1.22fr);
  min-height: 100svh;
}

.drafts,
.runs {
  min-width: 0;
  max-width: 100%;
  padding: 12px;
  overflow: auto;
}

.draft-toolbar,
.run-toolbar {
  position: sticky;
  top: 8px;
  z-index: 5;
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  margin: 0 0 14px;
  padding: 8px;
  background: rgba(8, 9, 11, 0.94);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  backdrop-filter: blur(10px);
}

.draft-toolbar::after,
.run-toolbar::after {
  position: absolute;
  right: 0;
  bottom: -13px;
  left: 0;
  height: 12px;
  content: "";
  pointer-events: none;
  background: linear-gradient(to bottom, var(--bg), rgba(8, 9, 11, 0));
}

.draft-tools {
  min-width: 0;
}

.add-menu-wrap {
  position: relative;
}

#draftMeta,
#queueMeta {
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.workspace-feedback {
  min-height: 0;
  margin: 6px 2px 0;
  color: var(--muted);
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.workspace-feedback:empty {
  display: none;
}

.workspace-feedback[data-tone="error"] {
  color: var(--bad);
}

.run-toolbar {
  grid-template-columns: minmax(140px, 1fr) minmax(110px, 0.65fr) auto auto auto auto;
  justify-content: space-between;
}

.run-toolbar > #clearButton {
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.run-search {
  height: 32px;
  padding: 5px 9px;
  border-radius: 10px;
  font-size: 0.76rem;
}

.run-filter-menu {
  position: relative;
}

.filter-button {
  position: relative;
  min-height: 38px;
  width: 64px;
  padding: 0 18px 0 11px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.76rem;
  text-align: left;
}

.filter-button:hover,
.filter-button[aria-expanded="true"] {
  color: var(--text);
  border-color: #3a414d;
}

.filter-button .menu-caret {
  right: 10px;
  bottom: 16px;
}

.filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 112px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.filter-menu[hidden] {
  display: none;
}

.filter-menu button {
  min-height: 30px;
  padding: 0 9px;
  color: var(--muted);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 0.72rem;
}

.filter-menu button:hover {
  color: var(--text);
  background: var(--panel-soft);
}

.filter-menu button.active {
  color: var(--accent-ink);
  background: var(--accent);
}

.codex-usage {
  display: inline-flex;
  min-height: 38px;
  width: 148px;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.76rem;
  white-space: nowrap;
}

.codex-usage:hover {
  color: var(--text);
  border-color: #3a414d;
}

.codex-usage span:last-child {
  overflow: visible;
}

.usage-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: var(--faint);
  border-radius: 50%;
}

.codex-usage[data-state="ok"] .usage-dot {
  background: var(--good);
}

.codex-usage[data-state="warn"] .usage-dot {
  background: #ffd166;
}

.codex-usage[data-state="limit"] .usage-dot,
.codex-usage[data-state="error"] .usage-dot {
  background: var(--bad);
}

.codex-usage[data-state="loading"] .usage-dot {
  background: var(--muted);
  animation: usage-pulse 900ms ease-in-out infinite;
}

@keyframes usage-pulse {
  50% {
    opacity: 0.35;
  }
}

.batch-heading {
  position: sticky;
  top: 65px;
  z-index: 3;
  width: 100%;
  padding: 5px 2px;
  color: var(--faint);
  text-align: left;
  background: var(--bg);
  border: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.batch-heading:hover {
  color: var(--text);
}

.drafts {
  border-right: 1px solid var(--line);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.section-heading > p {
  font-size: 0.82rem;
}

.preset-button {
  min-height: 28px;
  padding: 0 9px;
  border-radius: 10px;
  font-size: 0.76rem;
}

.template-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  display: grid;
  min-width: 180px;
  max-width: min(260px, calc(100vw - 24px));
  max-height: min(70svh, 420px);
  overflow-y: auto;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.template-menu[hidden] {
  display: none;
}

.template-menu button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--text);
  text-align: left;
  background: color-mix(in srgb, var(--template-color, transparent) 18%, transparent);
  border: 0;
  border-radius: 8px;
}

.template-menu button:hover {
  background: color-mix(in srgb, var(--template-color, var(--panel-soft)) 32%, var(--panel-soft));
}

.template-menu-heading {
  padding: 8px 10px 4px;
  color: var(--faint);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.preset-editor {
  display: grid;
  gap: 10px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.preset-editor-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

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

.preset-help {
  color: var(--muted);
  font-size: 0.8rem;
}

.batch-feedback {
  min-height: 1.1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.batch-feedback[data-tone="error"] {
  color: var(--bad);
}

.bucket-draft-list {
  display: grid;
  gap: 8px;
  max-height: min(54vh, 520px);
  overflow: auto;
}

.bucket-draft-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 124px;
  gap: 10px;
  align-items: center;
  padding: 9px;
  background: var(--input);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.merge-candidate-row {
  grid-template-columns: auto minmax(0, 1fr);
}

.bucket-draft-row input {
  width: auto;
}

.bucket-draft-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.bucket-draft-main strong,
.bucket-draft-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bucket-draft-main strong {
  font-size: 0.82rem;
}

.bucket-draft-main small {
  color: var(--muted);
  font-size: 0.72rem;
}

.bucket-draft-action {
  min-height: 32px;
  padding: 5px 8px;
  border-radius: 10px;
  font-size: 0.76rem;
}

.preset-editor-list {
  display: grid;
  gap: 10px;
  max-height: 430px;
  overflow: auto;
}

.preset-editor-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(140px, 0.45fr) minmax(240px, 1fr);
  gap: 10px;
  padding: 10px 44px 10px 10px;
  background: var(--input);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
}

.preset-editor-item .remove-preset {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 28px;
  width: 28px;
  border-radius: 8px;
}

.preset-editor-item textarea,
#batchValuesInput {
  min-height: 118px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
}

.draft-list,
.task-list {
  display: grid;
  min-width: 0;
  max-width: 100%;
  gap: 6px;
}

.draft,
.task {
  min-width: 0;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
}

.task {
  content-visibility: auto;
  contain-intrinsic-size: 76px;
}

.task-render-error {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
}

.task-render-error-message {
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

body[data-density="comfortable"] .task-top {
  padding: 11px 12px;
}

body[data-density="comfortable"] .task-preview {
  margin-top: 5px;
  font-size: 0.76rem;
}

.draft {
  position: relative;
  padding: 8px;
}

.draft.focused {
  border-color: #4a5362;
}

.draft.invalid {
  border-color: rgba(255, 133, 153, 0.55);
}

.draft-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, 0.44fr) minmax(0, 0.9fr) auto;
  align-items: end;
  gap: 7px;
  margin-bottom: 8px;
}

.draft-select-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.draft-select-field span {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.draft-select-field .draft-pi-note {
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: none;
}

.draft-project,
.draft-provider,
.draft-model {
  min-width: 0;
}

.draft-project,
.draft-provider,
.draft-model {
  height: 32px;
  padding: 5px 8px;
  border-radius: 9px;
  font-size: 0.78rem;
}

.effort-buttons {
  display: flex;
  grid-column: 1 / span 3;
  min-width: 0;
  padding: 2px;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.runner-toggles {
  display: flex;
  grid-column: 4;
  grid-row: 2;
  min-width: 0;
  gap: 5px;
}

.worktree-toggle,
.pi-toggle {
  display: inline-flex;
  flex: 1 1 auto;
  min-height: 32px;
  align-items: center;
  gap: 7px;
  justify-content: center;
  padding: 0 8px;
  color: var(--muted);
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.72rem;
}

.draft-actions {
  grid-column: 4;
  grid-row: 1;
  display: flex;
  gap: 5px;
}

.worktree-toggle input,
.pi-toggle input {
  width: 13px;
  height: 13px;
  accent-color: var(--accent);
}

.worktree-toggle:has(input:checked),
.pi-toggle:has(input:checked) {
  color: var(--text);
  border-color: #3a404c;
}

.pi-toggle:has(input:disabled) {
  opacity: 0.5;
}

.draft-head select:disabled,
.effort-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.effort-button {
  min-height: 26px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.effort-button.active {
  color: var(--accent-ink);
  background: var(--accent);
}

.icon-button {
  width: 38px;
  padding: 0;
}

.draft-actions .icon-button {
  min-height: 28px;
  width: 28px;
  border-radius: 9px;
}

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

.run-draft svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.draft-prompt {
  min-height: 150px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
  padding: 8px;
}

.template-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  align-items: flex-start;
  min-height: 0;
  overflow: visible;
  padding: 6px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.template-summary[hidden] {
  display: none;
}

.template-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  color: var(--text);
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 700;
}

.template-pill::before {
  content: "";
  display: block;
  width: 7px;
  height: 7px;
  background: var(--template-color);
  border-radius: 999px;
}

.template-args {
  display: flex;
  flex: 1 1 220px;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.template-arg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.template-arg:has(.template-pr-info) {
  display: grid;
  grid-template-columns: auto 76px minmax(0, 1fr);
  flex: 1 1 100%;
  gap: 6px;
  min-width: 0;
}

.template-arg span,
.template-no-args {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.template-arg span {
  display: inline-flex;
  min-height: 30px;
  gap: 6px;
  align-items: center;
  padding: 0 2px;
  font-weight: 700;
  text-transform: uppercase;
}

.template-git-button {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: currentColor;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.template-git-button svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.template-arg input {
  flex: 0 0 76px;
  height: 30px;
  width: 76px;
  min-width: 76px;
  color: var(--text);
  background: var(--input);
  border-color: var(--line);
  border-radius: 9px;
  padding: 4px 8px;
  font-size: 0.76rem;
}

.template-arg input::placeholder {
  color: var(--faint);
}

.template-arg textarea {
  flex: 1 1 100%;
  min-height: 76px;
  color: var(--text);
  background: var(--input);
  border-color: var(--line);
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 0.8rem;
}

.template-arg.missing span,
.template-arg.missing input,
.template-arg.missing textarea {
  border-color: rgba(255, 133, 153, 0.68);
}

.arg-chips {
  display: flex;
  min-height: 30px;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}

.arg-chips button {
  min-height: 22px;
  max-width: 72px;
  overflow: hidden;
  padding: 0 6px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.66rem;
}

.arg-chips button:hover {
  color: var(--text);
  border-color: #4a5362;
}

.template-arg:has(.template-pr-info) input {
  border-radius: 9px;
}

.template-pr-info {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 30px;
  align-items: center;
  color: var(--muted);
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.template-pr-status {
  display: inline-flex;
  height: 20px;
  align-items: center;
  margin-left: 8px;
  padding: 0;
  white-space: nowrap;
  color: var(--muted);
  background: transparent;
  border-radius: 0;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: none;
}

.template-pr-status[data-state="OPEN"] {
  color: var(--good);
  background: transparent;
}

.template-pr-status[data-state="MERGED"] {
  color: color-mix(in srgb, var(--template-color) 65%, var(--text));
  background: transparent;
}

.template-pr-status[data-state="CLOSED"],
.template-pr-status[data-state="ERROR"] {
  color: var(--bad);
  background: transparent;
}

.template-pr-title {
  min-width: 0;
  overflow: hidden;
  padding: 0 8px 0 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-refresh-button {
  display: grid;
  width: 24px;
  height: 24px;
  margin-right: 3px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 0.76rem;
}

.template-refresh-button:hover {
  color: var(--text);
  background: var(--panel-soft);
}

.task-top {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 7px 9px;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.task-top > span:first-child {
  min-width: 0;
}

.task-title {
  display: block;
  max-width: 58ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
}

.task-title::before {
  display: inline-block;
  max-width: 90px;
  margin-right: 6px;
  overflow: hidden;
  padding: 1px 6px;
  color: #b9c5d6;
  text-overflow: ellipsis;
  vertical-align: 1px;
  white-space: nowrap;
  content: attr(data-project);
  background: #121722;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-size: 0.62rem;
}

.task-title[data-project=""]::before {
  display: none;
}

.task-meta {
  display: block;
  margin-top: 2px;
  font-size: 0.7rem;
}

.task-preview {
  display: block;
  max-width: min(86ch, 100%);
  overflow: hidden;
  margin-top: 2px;
  color: #c7ced8;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.7rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  min-width: 34px;
  padding: 4px 7px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.badge::before {
  content: attr(data-icon);
  font-size: 0.74rem;
}

.task-side {
  display: flex;
  align-items: center;
  gap: 6px;
}

.copy-workdir,
.info-workdir {
  display: grid;
  width: 28px;
  min-height: 28px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.copy-workdir svg,
.info-workdir svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.copy-workdir.copied,
.info-workdir.active {
  color: var(--good);
  border-color: rgba(143, 231, 176, 0.45);
}

.job-info {
  margin-bottom: 8px;
  padding: 7px 9px;
  color: #cfd6e1;
  background: var(--input);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.35;
}

.task[data-status="running"] .badge {
  color: var(--text);
  border-color: #d8dde6;
}

.task[data-status="completed"] .badge {
  color: var(--good);
}

.task[data-status="failed"] .badge,
.task[data-status="cancelled"] .badge {
  color: var(--bad);
}

.task-body {
  display: none;
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
  padding: 0 10px 10px;
}

.task.open .task-body {
  display: block;
}

.task-chat {
  display: grid;
  min-width: 0;
  max-width: 100%;
  gap: 8px;
  margin-bottom: 7px;
}

.chat-messages {
  display: grid;
  min-width: 0;
  max-width: 100%;
  gap: 5px;
  max-height: min(420px, 46svh);
  overflow: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  padding: 0;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.chat-message {
  min-width: 0;
  max-width: min(82ch, 92%);
  overflow-wrap: anywhere;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.chat-message.user {
  justify-self: end;
  background: #161a21;
}

.chat-message.assistant {
  justify-self: start;
  background: #0d1015;
}

.chat-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chat-message pre {
  margin: 0;
  color: #dfe5ee;
  font: inherit;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-content {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #dfe5ee;
  font-size: 0.78rem;
  line-height: 1.4;
}

.chat-content.markdown-body p,
.chat-content.markdown-body ul,
.chat-content.markdown-body ol,
.chat-content.markdown-body pre,
.chat-content.markdown-body blockquote {
  margin-bottom: 0.28rem;
}

.follow-up-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.follow-up-input {
  min-width: 0;
  min-height: 42px;
  resize: vertical;
  padding: 8px 10px;
  color: var(--text);
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.follow-up-send {
  align-self: end;
  min-height: 42px;
}

.output-detail {
  min-width: 0;
  overflow-wrap: anywhere;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--input);
  border: 1px solid var(--line);
}

.logs {
  display: grid;
  min-width: 0;
  max-width: 100%;
  gap: 2px;
  min-height: 0;
  max-height: min(38svh, 320px);
  overflow: auto;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: #edf1f7;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.task-details {
  min-width: 0;
  max-width: 100%;
  margin-bottom: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(9, 12, 17, 0.62);
}

.task-details > summary {
  padding: 6px 9px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
  list-style-position: inside;
}

.task-details > summary::marker {
  color: var(--accent);
}

.task-details[open] > summary {
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
}

.task-details-body {
  min-width: 0;
  max-width: 100%;
  padding: 6px 8px 8px;
}

.task-details .job-info {
  margin: 0 0 6px;
}

.output-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  padding: 3px 5px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.output-row:hover {
  background: rgba(255, 255, 255, 0.025);
  border-color: var(--line-soft);
}

.output-icon {
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  color: var(--muted);
  background: #10141a;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-size: 0.62rem;
}

.output-body {
  display: grid;
  min-width: 0;
  max-width: 100%;
  gap: 2px;
}

.output-body strong {
  color: var(--text);
  font-size: 0.74rem;
}

.output-detail {
  color: #cfd6e1;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.3;
  background: transparent;
  border: 0;
}

.markdown-body {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #dce3ed;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.32;
}

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

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

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body pre,
.markdown-body blockquote {
  margin: 0 0 0.32rem;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.15rem;
}

.markdown-body li + li {
  margin-top: 0.18rem;
}

.markdown-body code {
  padding: 0.1rem 0.28rem;
  background: #10141a;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  font: inherit;
}

.markdown-body pre {
  max-width: 100%;
  overflow: auto;
  padding: 7px;
  background: #090c11;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
  border: 0;
}

.markdown-body a {
  color: #9fd3ff;
}

.markdown-body blockquote {
  padding-left: 0.8rem;
  color: var(--muted);
  border-left: 2px solid var(--line);
}

.output-body > span.output-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-message .output-icon {
  color: var(--accent-ink);
  background: var(--accent);
}

.output-command .output-icon {
  color: #9fd3ff;
}

.output-tool .output-icon,
.output-file .output-icon {
  color: #c8b6ff;
}

.output-reasoning .output-icon,
.output-plan .output-icon {
  color: #ffd166;
}

.output-error .output-icon,
.output-failed .output-icon,
.output-cancelled .output-icon {
  color: var(--bad);
}

.output-completed .output-icon {
  color: var(--good);
}

.actions {
  display: flex;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.actions .task-primary-action {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.74rem;
}

.actions .task-primary-icon-action {
  display: grid;
  width: 42px;
  min-width: 42px;
  padding: 0;
  place-items: center;
}

.task-primary-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.task-action-menu {
  position: relative;
}

.task-action-menu > summary {
  list-style: none;
}

.task-action-menu > summary::-webkit-details-marker {
  display: none;
}

.task-action-menu-list {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  display: grid;
  min-width: 176px;
  max-width: min(240px, calc(100vw - 28px));
  gap: 3px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.task-action-menu-list .ghost {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  text-align: left;
  white-space: nowrap;
}

.empty {
  padding: 48px 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 18px;
}

.palette-dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.palette {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.palette input {
  height: 40px;
}

.palette-list {
  display: grid;
  gap: 4px;
  max-height: 320px;
  overflow: auto;
}

.palette-list button {
  min-height: 34px;
  color: var(--text);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 0 10px;
}

.palette-list button:hover {
  background: var(--panel-soft);
}

@media (max-width: 1180px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .drafts {
    border-bottom: 1px solid var(--line);
  }

  .drafts {
    border-right: 0;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions button {
    flex: 1;
  }
}

@media (max-width: 640px) {
  .drafts,
  .runs {
    overflow-x: hidden;
    padding: 10px;
  }

  .settings {
    grid-template-columns: 1fr;
  }
  .run-toolbar {
    grid-template-columns: minmax(56px, 0.85fr) minmax(88px, 1.35fr) 42px 42px;
    min-width: 0;
  }

  .run-toolbar > #queueMeta,
  .run-toolbar > .run-search {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .run-toolbar > #queueMeta {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .run-toolbar > .run-search {
    width: 100%;
  }

  .run-toolbar > .run-filter-menu {
    grid-column: 1;
    min-width: 0;
    width: 100%;
  }

  .run-toolbar > .codex-usage {
    grid-column: 2;
    width: 100%;
    min-width: 0;
    padding: 0 8px;
    gap: 5px;
  }

  .run-toolbar > #densityButton {
    grid-column: 3;
  }

  .run-toolbar > #clearButton {
    grid-column: 4;
  }

  .filter-button {
    width: 100%;
    min-width: 0;
  }

  .codex-usage span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}


/* Keep the desktop appearance; adapt controls and flow to touch screens. */
.mobile-navigation { display: none; }

@media (max-width: 1180px) and (min-width: 761px) {
  .run-toolbar {
    grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  }
  .run-toolbar > #queueMeta { grid-column: 1 / -1; }
}

@media (max-width: 760px), (max-width: 1180px) and (pointer: coarse) {
  html { scroll-padding-top: calc(70px + env(safe-area-inset-top)); }
  body { -webkit-text-size-adjust: 100%; }
  body:has(dialog[open]) { overflow: hidden; }
  button, a, label, select { -webkit-tap-highlight-color: transparent; }
  button, a { touch-action: manipulation; }
  :is(button, a):focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

  .mobile-navigation {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
    background: rgba(8, 9, 11, 0.94);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line-soft);
  }
  .mobile-navigation a {
    display: grid;
    flex: 1;
    place-items: center;
    text-decoration: none;
    font-size: 0.85rem;
  }
  .workspace { display: block; }
  .auth-shell { min-height: 100dvh; padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .auth-panel { padding: 18px; border-radius: 14px; }
  .auth-settings { grid-template-columns: 1fr; align-items: stretch; }
  .auth-settings-actions { justify-content: stretch; }
  .auth-settings-actions > button { flex: 1; }
  .auth-settings > .auth-password-form { grid-template-columns: 1fr; }
  .drafts, .runs {
    overflow-x: clip;
    overflow-y: visible;
    padding: 10px max(10px, env(safe-area-inset-right)) 16px max(10px, env(safe-area-inset-left));
  }
  .runs { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .draft-toolbar, .run-toolbar { position: relative; top: auto; }
  .batch-heading { position: static; min-height: 44px; overflow-wrap: anywhere; }
  .draft-toolbar { gap: 6px; }
  #draftMeta { white-space: normal; text-align: right; }
  .draft, .task, .field, .settings, .preset-editor, .preset-editor-list { min-width: 0; }

  .primary, .ghost, .icon-button, .icon-action, .filter-button, .codex-usage,
  .copy-workdir, .info-workdir, .template-refresh-button, .template-git-button,
  .draft-actions .icon-button, .template-menu button, .filter-menu button,
  .actions .ghost, .palette-list button, .preset-button {
    min-height: 44px;
  }
  .icon-action, .icon-button, .draft-actions .icon-button,
  .copy-workdir, .info-workdir, .template-refresh-button, .template-git-button {
    width: 44px;
    min-width: 44px;
    flex-shrink: 0;
  }
  input:not([type="checkbox"]), select, textarea,
  .draft-prompt, .draft-project, .draft-provider, .draft-model, .template-arg input,
  .template-arg textarea, #batchValuesInput, .run-search, .bucket-draft-action {
    font-size: 16px;
    min-height: 44px;
  }
  input[type="checkbox"] { width: 20px; height: 20px; flex: 0 0 20px; accent-color: var(--accent); }
  .check { min-height: 44px; }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .settings-dialog, .palette-dialog {
    max-width: calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow: auto;
    overscroll-behavior: contain;
    scroll-padding-block: 80px 12px;
  }
  .settings-dialog { padding: 14px; }
  .modal-heading {
    position: sticky;
    top: -14px;
    z-index: 2;
    align-items: center;
    gap: 8px;
    padding-block: 8px;
    background: var(--panel);
  }
  .modal-heading > div { min-width: 0; }
  .preset-editor-heading { flex-wrap: wrap; align-items: center; }
  .preset-editor-item { grid-template-columns: minmax(0, 1fr); padding: 10px; }
  .preset-editor-item .remove-project { justify-self: end; }
  .preset-help, .batch-feedback { overflow-wrap: anywhere; line-height: 1.5; }
  .preset-editor-list { max-height: none; overflow: visible; }

  .draft-head { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 8px; }
  .draft-head > .draft-select-field:nth-child(3) { grid-column: 1; grid-row: 2; }
  .draft-actions { grid-column: 2; grid-row: 2; justify-content: flex-end; }
  .effort-buttons { grid-column: 1 / -1; grid-row: 3; }
  .effort-button { min-width: 0; min-height: 44px; flex: 1; padding: 0 4px; }
  .runner-toggles { grid-column: 1 / -1; grid-row: 4; }
  .worktree-toggle, .pi-toggle { min-height: 44px; }
  .draft-prompt { line-height: 1.5; min-height: 180px; }
  .template-menu {
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    top: calc(128px + env(safe-area-inset-top));
    min-width: 0;
    max-width: none;
    max-height: calc(100dvh - 148px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  .template-menu button { padding: 10px; overflow-wrap: anywhere; }
  .template-pill { max-width: 100%; overflow-wrap: anywhere; }
  .template-arg, .template-args { max-width: 100%; }
  .template-arg:not(:has(.template-pr-info)) { flex: 1 1 100%; }
  .template-arg:not(:has(.template-pr-info)) input { flex: 1 1 140px; width: 100%; }
  .template-arg:has(.template-pr-info) { grid-template-columns: auto minmax(76px, 1fr); }
  .arg-chips { flex-wrap: wrap; overflow: visible; grid-column: 1 / -1; }
  .arg-chips button { min-height: 44px; max-width: none; }
  .template-arg:has(.template-pr-info) input { width: 100%; }
  .template-pr-info { min-height: 44px; }
  .template-pr-title { white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }

  .run-toolbar { grid-template-columns: minmax(64px, 0.8fr) minmax(0, 1.2fr) 44px 44px; min-width: 0; }
  .run-toolbar > #queueMeta, .run-toolbar > .run-search { grid-column: 1 / -1; min-width: 0; width: 100%; }
  .run-toolbar > #queueMeta { white-space: normal; line-height: 1.5; }
  .run-toolbar > .run-filter-menu { grid-column: 1; width: 100%; min-width: 0; }
  .run-toolbar > .codex-usage { grid-column: 2; min-width: 0; width: 100%; padding: 0 6px; }
  .run-toolbar > #densityButton { grid-column: 3; }
  .run-toolbar > #clearButton { grid-column: 4; }
  .filter-button { width: 100%; min-width: 0; }
  .run-toolbar > .codex-usage { white-space: normal; padding-block: 6px; }
  .codex-usage span:last-child { min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
  .filter-menu { left: 0; right: auto; }
  .filter-button .menu-caret { bottom: 19px; }

  .task-top { flex-wrap: wrap; align-items: start; padding: 10px; }
  .task-top > span:first-child { flex: 1 1 100%; }
  .task-title { white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
  .task-meta { overflow-wrap: anywhere; line-height: 1.5; }
  .task.open .task-preview { white-space: normal; overflow-wrap: anywhere; }
  .task-side { justify-content: flex-end; width: 100%; }
  .chat-message { max-width: 100%; }
  .follow-up-form { grid-template-columns: 1fr; }
  .follow-up-send { width: 100%; }
  .logs { max-height: min(38dvh, 300px); overscroll-behavior-y: auto; }
  .task-details-summary { min-height: 36px; }
  .output-body strong, .output-detail, .markdown-body, .job-info { font-size: 0.82rem; line-height: 1.5; overflow-wrap: anywhere; }
  .job-info { white-space: pre-wrap; }
  .markdown-body { min-width: 0; }
  .markdown-body table { display: block; max-width: 100%; overflow-x: auto; white-space: normal; }
  .markdown-body th, .markdown-body td { min-width: 100px; padding: 6px; }
  .markdown-body img { max-width: 100%; height: auto; }
  .markdown-body pre { white-space: pre; }
  .actions { display: flex; }
  .actions .task-primary-action { flex: 1; min-height: 44px; }
  .actions .task-primary-icon-action { flex: 0 0 44px; width: 44px; min-width: 44px; }
  .actions .task-action-menu > summary,
  .actions > .delete { min-height: 44px; }
  .task-action-menu-list { right: 0; bottom: calc(100% + 8px); }
  .task-action-menu-list .ghost { padding: 6px 10px; overflow-wrap: anywhere; }
  .bucket-draft-row { grid-template-columns: 24px minmax(0, 1fr); }
  .bucket-draft-row > input { min-height: 44px; width: 24px; margin: 0; }
  .bucket-draft-action { grid-column: 2; }
  .bucket-draft-main strong, .bucket-draft-main small { white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }
  .bucket-draft-list { max-height: none; overflow: visible; }
  .palette input { height: 44px; }
  .palette-list { max-height: min(320px, 50dvh); }
}
