:root {
  --ui-bg: #151d22;
  --ui-paper: #1c272e;
  --ui-soft: #24323a;
  --ui-text: #edf3f5;
  --ui-muted: #c0ccd3;
  --ui-line: #718793;
  --ui-accent: #78d8c5;
  --ui-selected: #213e3c;
  --ui-nav: #11191e;
  --ui-nav-text: #dce7ec;
  --ui-on-accent: #102521;
  --ui-warning: #efc57c;
  --ui-warning-bg: #3e3422;
  --ui-danger: #ffacb8;
  color-scheme: dark;
  font: 1rem/1.6 system-ui, "Segoe UI", "Yu Gothic UI", sans-serif;
  background: var(--ui-bg);
  color: var(--ui-text);
  line-break: strict;
}

* { box-sizing: border-box; }
body { margin: 0; overflow-wrap: anywhere; }
a { color: var(--ui-accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.75rem; font-weight: 650; line-height: 1.35; letter-spacing: -.025em; }
h2 { font-size: 1.125rem; font-weight: 650; line-height: 1.5; }
h3 { font-size: 1rem; font-weight: 600; margin: 24px 0 10px; }
form { margin: 0; min-width: 0; }
label { display: grid; gap: 6px; min-width: 0; font-size: .875rem; color: var(--ui-muted); }
input, select, textarea, button, .primary {
  min-width: 0;
  min-height: 44px;
  max-width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--ui-line);
  border-radius: 8px;
  font: inherit;
  color: var(--ui-text);
  background: var(--ui-paper);
}
label :is(input, select, textarea) { width: 100%; font-size: 1rem; }
input::placeholder { color: var(--ui-muted); opacity: 1; }
input[type="hidden"] { display: none; }
textarea { resize: vertical; line-height: 1.7; overflow-wrap: anywhere; white-space: pre-wrap; }
textarea[readonly], input[readonly] { background: var(--ui-soft); }
button, .primary { cursor: pointer; }
button:hover { border-color: var(--ui-accent); background: var(--ui-soft); }
.primary { display: inline-flex; justify-content: center; align-items: center; background: var(--ui-accent); border-color: var(--ui-accent); color: var(--ui-on-accent); text-decoration: none; font-weight: 600; }
.primary:hover { background: var(--ui-accent); border-color: var(--ui-text); text-decoration: underline; }
.quiet { background: transparent; }
:is(button, a, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--ui-accent); outline-offset: 3px; }
button:active, .primary:active { border-color: var(--ui-text); }
button:disabled { cursor: default; color: var(--ui-muted); background: var(--ui-soft); }
::selection { background: var(--ui-accent); color: var(--ui-on-accent); }
.muted { color: var(--ui-muted); font-size: .875rem; }

.console-shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; overflow: auto; background: var(--ui-nav); color: var(--ui-nav-text); padding: 26px 16px; }
.brand { display: block; font-size: 1.25rem; line-height: 1.35; letter-spacing: -.025em; font-weight: 650; color: var(--ui-nav-text); text-decoration: none; }
.nav { display: grid; gap: 6px; margin-top: 24px; }
.nav a { display: block; min-height: 44px; padding: 11px 14px; border-radius: 8px; color: var(--ui-nav-text); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--ui-soft); }
.nav a[aria-current="page"] { background: var(--ui-selected); color: var(--ui-accent); }
.workspace { width: 100%; min-width: 0; max-width: 1800px; margin: 0 auto; padding: 20px 28px 36px; }
.topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.topbar > div { min-width: 0; }
.topbar .muted { margin-top: 6px; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-panel, .list-panel, .detail, .history-page { min-width: 0; border: 1px solid var(--ui-line); border-radius: 10px; background: var(--ui-paper); }
.filter-panel { padding: 16px; margin-bottom: 16px; }
.filters { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.filters label { flex: 1 1 160px; }
.filters .search-field { flex: 2 1 260px; }
.clear-filter { display: inline-flex; min-height: 44px; align-items: center; padding: 8px 4px; font-size: .875rem; }
.allocation-time { margin-top: 12px; font-variant-numeric: tabular-nums; }
.columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.list-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; padding: 16px; }
.table-wrap { width: 100%; min-width: 0; overflow-x: auto; }
.task-table { width: 100%; min-width: 900px; table-layout: fixed; border-collapse: collapse; text-align: left; }
.col-id { width: 76px; }
.col-project { width: 168px; }
.col-agent { width: 216px; }
.col-status { width: 144px; }
.col-progress { width: 80px; }
.task-table :is(th, td) { min-width: 0; padding: 12px; border-bottom: 1px solid var(--ui-line); vertical-align: middle; }
.task-table th { background: var(--ui-soft); color: var(--ui-muted); font-size: .875rem; font-weight: 600; }
.task-table td { font-size: .9375rem; }
.task-table tbody tr:last-child td { border-bottom: 0; }
.task-table tbody tr:hover { background: var(--ui-soft); }
.task-table tr.selected { background: var(--ui-selected); }
.task-table tr.selected td:first-child { box-shadow: inset 3px 0 var(--ui-accent); }
.cell-text {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.task-table td a { color: var(--ui-text); text-decoration: none; }
.task-table td a:hover { color: var(--ui-accent); text-decoration: underline; }
.task-title { font-weight: 600; padding: 7px 0; }
.task-id, .progress-cell { font-variant-numeric: tabular-nums; }
.task-id { padding: 7px 0; color: var(--ui-muted); }
.progress-cell { text-align: right; }
.agent-name { margin-top: 4px; color: var(--ui-muted); font-size: .875rem; }
.badge { display: block; width: 100%; min-width: 0; padding: 3px 8px; border-radius: 6px; background: var(--ui-soft); color: var(--ui-muted); font-size: .875rem; }
.badge[data-status="doing"] { background: var(--ui-selected); color: var(--ui-accent); }
.badge[data-status="block"] { background: var(--ui-warning-bg); color: var(--ui-warning); }
.badge[data-status="recovery_unverified"] { color: var(--ui-danger); }
.empty { color: var(--ui-muted); text-align: center; overflow-wrap: anywhere; }
.pager { display: flex; flex-wrap: wrap; gap: 12px 24px; padding: 8px 16px; border-top: 1px solid var(--ui-line); }
.pager:empty { display: none; }
.pager a { display: inline-flex; align-items: center; min-height: 44px; }

.detail { padding: 20px; scroll-margin-top: 16px; }
.detail-heading { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 8px 16px; margin-bottom: 20px; }
.detail-heading h2 { flex: 1 1 200px; overflow-wrap: anywhere; }
.detail-heading a { min-height: 44px; display: inline-flex; align-items: center; font-size: .875rem; }
.detail form { display: grid; gap: 16px; }
.detail-fact { overflow-wrap: anywhere; }
.field-help { margin-top: -10px; }
.detail-links { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 20px 0; font-size: .875rem; }
.detail-links a { display: inline-flex; align-items: center; min-height: 44px; }
.history { border-top: 1px solid var(--ui-line); padding: 16px 0; overflow-wrap: anywhere; }
.history time { display: block; color: var(--ui-muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.history p { margin-top: 6px; white-space: pre-wrap; }
.history-page { padding: 24px; }
.back-link { display: inline-flex; min-height: 44px; align-items: center; margin-bottom: 8px; }
.draft { display: grid; gap: 20px; }
.notice, .error { padding: 12px 16px; border: 1px solid var(--ui-accent); border-radius: 8px; background: var(--ui-selected); margin-bottom: 16px; overflow-wrap: anywhere; }
.error { color: var(--ui-danger); border-color: var(--ui-danger); background: var(--ui-paper); }
.draft .error { margin: 0; }

.auth-page { display: grid; min-height: 100dvh; align-items: start; justify-items: center; padding: 10vh 16px 32px; }
.login { width: 100%; max-width: 480px; min-width: 0; padding: 32px; background: var(--ui-paper); border: 1px solid var(--ui-line); border-radius: 10px; }
.login .brand { margin-bottom: 24px; color: var(--ui-text); }
.login h1 { font-size: 1.5rem; margin-bottom: 8px; }
.login > .muted { margin-bottom: 24px; }
.login form { display: grid; gap: 20px; }
.auth-link { margin-top: 20px; }
.auth-link a { display: inline-flex; min-height: 44px; align-items: center; }
.connect-number { margin: 24px 0; padding: 16px; background: var(--ui-soft); border-radius: 8px; }
.connect-number p { color: var(--ui-muted); font-size: .875rem; margin-bottom: 8px; }
#connect-id { display: block; font: 1rem/1.8 ui-monospace, Consolas, monospace; overflow-wrap: anywhere; user-select: all; }
.login form + .muted { margin-top: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: 12px; padding: 10px 16px; background: var(--ui-accent); color: var(--ui-on-accent); transform: translateY(-200%); z-index: 1; }
.skip-link:focus { transform: none; }

@media (min-width: 1600px) {
  .has-detail { grid-template-columns: minmax(0, 1fr) 380px; }
}
@media (max-width: 1199px) {
  .console-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 16px 20px; border-bottom: 1px solid var(--ui-line); }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-top: 12px; }
  .workspace { padding: 20px; }
}
@media (max-width: 680px) {
  h1 { font-size: 1.5rem; }
  .sidebar { padding: 16px 12px; }
  .brand { font-size: 1.125rem; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { padding: 20px 12px; }
  .topbar { align-items: start; }
  .top-actions { width: 100%; }
  .filters { display: grid; grid-template-columns: minmax(0, 1fr); }
  .filters label, .filters .search-field { width: 100%; }
  .clear-filter { justify-content: center; }
  .list-heading, .detail, .history-page { padding: 16px; }
  .login { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto; }
}
