body { height: 100vh; height: 100dvh; overflow: hidden; }
.main { height: calc(100vh - var(--header-height)); height: calc(100dvh - var(--header-height)); display: grid; grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
.sidebar { grid-column: 1; grid-row: 1 / 3; min-height: 0; overflow-y: auto; background: #f8f9fa; border-right: 1px solid var(--line); }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; }
.sidebar-title { font-size: 12px; color: var(--muted); font-weight: 550; }
.new-btn { display: inline-flex; gap: 4px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px; font-size: 12px; }
.new-btn:hover { border-color: #b8bec8; }
.new-btn svg { width: 14px; height: 14px; }
.req-list { padding: 2px 6px 12px; }
.req-item { padding: 7px 8px; margin-bottom: 2px; width: 100%; border: 0; background: transparent; text-align: left; font-size: 12px; line-height: 1.5; border-radius: var(--radius); cursor: pointer; overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.req-item:hover { background: #edf0f3; }
.req-item.active { background: #e9edf3; color: #182a48; box-shadow: inset 2px 0 #526b93; }
.sidebar-collapsed .main { grid-template-columns: 0 minmax(0, 1fr); }
.sidebar-collapsed .sidebar { display: none; }
.progress-rail { grid-column: 2; grid-row: 1; display: none; align-items: center; gap: 4px; min-width: 0; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.progress-rail.show { display: flex; flex-wrap: wrap; }
.stage { flex: none; }
.stage-dot { display: flex; align-items: center; gap: 6px; background: transparent; border: 1px solid transparent; border-radius: var(--radius); color: var(--muted); padding: 5px 9px; font-size: 12px; min-height: 32px; white-space: nowrap; }
.stage-dot:hover { background: var(--soft); border-color: var(--line); }
.stage-code { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; opacity: .7; }
.stage-dot.current { background: #edf2fd; color: #254f9e; border-color: #dce5f8; }
.stage-dot.completed { color: var(--success); }
.stage-dot.failed { color: var(--danger); background: #fdf0f0; }
.stage-connector { flex: none; width: 10px; height: 1px; background: var(--line); }
.task-picker { display: none; margin-left: auto; min-width: 160px; max-width: min(320px, 100%); flex: 1; }
.task-picker.show { display: block; }
.task-select { width: 100%; min-height: 32px; padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; text-overflow: ellipsis; }
.content { grid-column: 2; grid-row: 2; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.create-form, .session-view, .activity-view, .confirm-view { display: none; min-height: 0; width: 100%; flex: 1; overflow: auto; }
.create-form.active, .activity-view.active, .confirm-view.active { display: block; }
.session-view.active { display: flex; overflow: hidden; }
.session-iframe { display: block; width: 100%; height: 100%; border: 0; flex: 1; }
.form-wrapper { width: min(100%, 960px); padding: 16px 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; align-items: start; }
.form-wrapper > .form-heading, .form-wide, #createTaskNotice { grid-column: 1 / -1; }
.form-wrapper > .btn-primary { justify-self: start; }
.form-heading { margin-bottom: 0; }
.form-heading h1 { font-size: 16px; font-weight: 600; }
.form-heading p { color: var(--muted); margin-top: 4px; font-size: 12px; }
.form-group { margin-bottom: 0; min-width: 0; }
.form-label { display: block; margin-bottom: 7px; font-weight: 550; font-size: 12px; }
.form-input, .form-textarea, .form-select { width: 100%; min-width: 0; border: 1px solid #cdd2d9; border-radius: var(--radius); background: #fff; padding: 6px 9px; min-height: 32px; }
.form-group .console-select-trigger { min-height: 32px; padding: 6px 9px; }
.form-textarea { min-height: 128px; resize: vertical; line-height: 1.6; }
.form-hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.mode-options { display: flex; gap: 16px; }
.mode-card { position: relative; flex: 1; padding: 10px 0 10px 24px; cursor: pointer; border-top: 1px solid var(--line); }
.mode-card input { position: absolute; top: 13px; left: 0; margin: 0; accent-color: var(--accent); width: 14px; height: 14px; }
.mode-card:has(input:checked) { border-top-color: var(--ink); }
.mode-title { font-weight: 550; }
.mode-desc { margin-top: 4px; color: var(--muted); font-size: 12px; }
.activity-messages { padding: 6px 16px 16px; }
.activity-view { position: relative; overflow-anchor: none; }
#activityRefreshError:not(:empty) { padding: 8px 16px; color: var(--danger); background: #fff8f8; }
#activityNewMessages { position: sticky; top: 6px; z-index: 1; float: right; margin-right: 16px; padding: 5px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--accent); }
.activity-session-header { padding: 12px 0 8px; margin-top: 8px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--muted); }
.activity-msg, .activity-item { padding: 10px 0; border-bottom: 1px solid #eef0f3; overflow-wrap: anywhere; }
.activity-time { color: var(--muted); font-size: 11px; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.activity-text { white-space: pre-wrap; line-height: 1.7; }
.activity-part { margin: 8px 0; }
.part-label { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.part-body { margin: 0; font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.activity-part.text .part-body { font-family: inherit; font-size: 13px; line-height: 1.8; }
.activity-part.reasoning .part-body { color: var(--muted); font-family: inherit; }
.activity-part.tool .part-body, .activity-part.patch .part-body { background: var(--soft); padding: 10px 12px; border-radius: 3px; max-height: 360px; overflow: auto; }
.activity-part.error .part-label { color: var(--danger); }
.activity-msg.user { border-left: 2px solid var(--line); padding-left: 12px; }
.confirm-wrapper { padding: 16px; }
.confirm-title { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.confirm-wave { color: var(--muted); margin: 4px 0; }
.confirm-draft { margin: 12px 0; padding: 12px; background: var(--soft); font: 12px/1.7 ui-monospace, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.confirm-actions { padding-top: 8px; }
@media (max-width: 1000px) { .main { grid-template-columns: 190px minmax(0, 1fr); } .progress-rail { padding: 6px 10px; gap: 2px; } .stage-dot { padding: 5px 6px; } }
@media (max-width: 700px) {
  .main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
  .sidebar { grid-column: 1; grid-row: 1; max-height: 144px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-header { padding: 6px 12px; }
  .req-list { display: flex; overflow-x: auto; padding: 2px 8px 8px; gap: 4px; }
  .req-item { min-width: 150px; max-width: 210px; margin: 0; }
  .progress-rail { grid-column: 1; grid-row: 2; }
  .content { grid-column: 1; grid-row: 3; }
  .sidebar-collapsed .main { grid-template-columns: minmax(0, 1fr); }
  .form-wrapper { padding: 12px; grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .form-textarea { min-height: 110px; }
  .activity-messages { padding: 8px 16px 24px; }
  .task-picker { max-width: none; }
  .mode-options { gap: 12px; }
}
/* The message header already identifies the speaker; plain text needs no second label. */
.activity-part.text > .part-label { display: none; }
@media (max-height: 700px) {
  .form-wrapper { padding-top: 12px; padding-bottom: 12px; }
  .form-textarea { min-height: 110px; }
}
.task-notice { flex: none; padding: 8px 16px; border-bottom: 1px solid #ecd8d8; background: #fff8f8; max-height: 45%; overflow: auto; }
.task-notice[hidden] { display: none; }
.task-notice strong { color: var(--danger); font-size: 13px; }
.task-notice p { margin: 4px 0 8px; color: var(--muted); font-size: 12px; }
.task-notice summary { cursor: pointer; font-size: 12px; }
.task-notice pre { margin: 8px 0 0; font: 12px/1.6 ui-monospace, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-actions { display: flex; flex-wrap:wrap; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }
.task-actions[hidden] { display: none; }
#requirementsError { padding:0 12px; overflow-wrap:anywhere; }
.request-error { color:var(--danger); padding:8px 0; overflow-wrap:anywhere; }
.task-actions button { border:1px solid var(--line); background:white; padding:5px 8px; border-radius:var(--radius); }
.task-actions button.danger-button { color:var(--danger); }
.task-actions > [role=status] { flex-basis:100%; overflow-wrap:anywhere; }
#splitHistoryButton { border:1px solid var(--line); background:white; padding:5px 8px; border-radius:var(--radius); cursor:pointer; }
.request-error button, #repoLoadError button { justify-self: start; padding: 5px 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); font-size: 12px; }
#createTaskNotice { color:var(--danger); overflow-wrap:anywhere; }
#createTaskNotice:empty, #requirementsError:empty { display: none; }
.task-machine-info { color: var(--muted); font-size: 11px; margin-left: 12px; white-space: nowrap; }
.task-machine-info[hidden] { display: none; }

.repo-add-link { border:0; padding:0; background:none; color:var(--accent); }

.integration-view{display:none;min-height:0;width:100%;flex:1;overflow:auto;padding:24px;box-sizing:border-box}
.integration-view.active{display:block}
@media(max-width:760px){.integration-view{padding:16px}}
