:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #dedee3;
  --line-soft: #ececf0;
  --accent: #0071e3;
  --accent-soft: #eef6ff;
  --success: #147d64;
  --warning: #8a6218;
  --danger: #b42318;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }

.task-topbar {
  height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
}
.task-brand { display: inline-flex; align-items: center; gap: 10px; width: max-content; }
.task-brand img { width: 34px; height: 27px; object-fit: contain; }
.task-brand strong, .task-brand small { display: block; }
.task-brand strong { font-size: 16px; }
.task-brand small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.task-topbar nav { display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 8px; background: #eeeef1; }
.task-topbar nav a { border-radius: 6px; padding: 7px 18px; color: var(--muted); font-size: 13px; font-weight: 650; }
.task-topbar nav a[aria-current="page"] { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.member-state { justify-self: end; color: var(--muted); font-size: 12px; }

.task-workspace {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: 278px minmax(540px, 1fr) 286px;
}
.task-sidebar, .evidence-panel { min-width: 0; background: var(--surface-soft); }
.task-sidebar { border-right: 1px solid var(--line); padding: 22px 16px; }
.sidebar-heading, .detail-heading, .section-heading, .task-modal header, .task-modal footer {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.sidebar-heading span, .detail-heading span, .section-heading span, .task-modal header span {
  color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.sidebar-heading h1 { margin: 3px 0 0; font-size: 24px; letter-spacing: 0; }
.icon-button { width: 34px; height: 34px; min-height: 34px; border: 1px solid var(--line); border-radius: 50%; padding: 0; color: var(--ink); background: #fff; font-size: 21px; }
.task-list { display: grid; gap: 5px; margin-top: 20px; }
.task-list-item { width: 100%; display: grid; gap: 6px; border: 0; border-radius: 7px; padding: 12px; text-align: left; color: var(--ink); background: transparent; }
.task-list-item:hover { background: #ececf0; }
.task-list-item.is-active { background: #e7f1ff; }
.task-list-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.task-list-item span { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.empty-copy { margin: 12px 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.task-main { min-width: 0; padding: 42px 46px 80px; background: #fff; }
.task-empty { min-height: 70vh; display: grid; place-items: center; align-content: center; text-align: center; }
.empty-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); background: var(--accent-soft); font-size: 23px; }
.task-empty h2 { margin: 20px 0 8px; font-size: 24px; }
.task-empty p { max-width: 470px; margin: 0 0 22px; color: var(--muted); line-height: 1.7; }
.empty-actions { display: flex; justify-content: center; gap: 8px; }
button, .task-login a, .artifact-section a {
  min-height: 38px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--accent); border-radius: 8px; padding: 0 14px; color: #fff; background: var(--accent); font-weight: 650;
}
button:hover, .task-login a:hover, .artifact-section a:hover { filter: brightness(.96); }
button.secondary { border-color: var(--line); color: var(--ink); background: #fff; }
button.danger { border-color: #f2b8b5; color: var(--danger); background: #fff6f5; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(0,113,227,.18); outline-offset: 2px; }

.task-detail { width: min(920px, 100%); margin: 0 auto; }
.detail-heading { align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 28px; }
.detail-heading h1 { margin: 6px 0 9px; font-size: 30px; letter-spacing: 0; }
.detail-heading p { max-width: 680px; margin: 0; color: var(--muted); line-height: 1.7; white-space: pre-wrap; }
.detail-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.run-timeline { list-style: none; margin: 0; padding: 30px 0 38px; display: grid; grid-template-columns: repeat(7, 1fr); }
.run-stage { min-width: 0; position: relative; padding-top: 22px; text-align: center; color: var(--muted); font-size: 11px; font-weight: 650; }
.run-stage::before { content: ""; width: 10px; height: 10px; position: absolute; top: 0; left: calc(50% - 5px); border: 2px solid #c7c7cc; border-radius: 50%; background: #fff; z-index: 2; }
.run-stage:not(:first-child)::after { content: ""; height: 1px; position: absolute; top: 5px; left: -50%; right: 50%; background: #d8d8dd; }
.run-stage.is-completed { color: var(--success); }
.run-stage.is-completed::before { border-color: var(--success); background: var(--success); }
.run-stage.is-active { color: var(--accent); }
.run-stage.is-active::before { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0,113,227,.12); }
.run-stage.is-failed { color: var(--danger); }
.run-stage.is-failed::before { border-color: var(--danger); background: var(--danger); }

.artifact-section { border-top: 1px solid var(--line); padding-top: 28px; }
.section-heading h2 { margin: 5px 0 0; font-size: 22px; }
.artifact-preview { margin-top: 22px; color: #242426; font-size: 15px; line-height: 1.78; }
.artifact-preview h1 { margin: 0 0 28px; font-size: 30px; }
.artifact-preview h2 { border-top: 1px solid var(--line-soft); margin: 34px 0 12px; padding-top: 22px; font-size: 20px; }
.artifact-preview h3 { margin: 24px 0 10px; font-size: 17px; }
.artifact-preview ul, .artifact-preview ol { padding-left: 22px; }
.artifact-preview blockquote { border-left: 3px solid var(--accent); margin: 18px 0; padding-left: 16px; color: var(--muted); }
.artifact-preview code { border-radius: 4px; padding: 2px 4px; background: #f2f2f5; }
.review-form { display: grid; gap: 14px; border-top: 1px solid var(--line); margin-top: 30px; padding-top: 24px; }
.review-actions { display: flex; justify-content: flex-end; gap: 8px; }
.tool-approval-section { display: grid; gap: 16px; margin-top: 28px; padding: 20px; border: 1px solid #f2d69b; border-radius: 8px; background: #fffbeb; }
.tool-approval-section span { color: var(--warning); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.tool-approval-section h2 { margin: 5px 0 6px; font-size: 19px; }
.tool-approval-section p { margin: 0; color: var(--muted); font-size: 13px; }

.evidence-panel { border-left: 1px solid var(--line); padding: 18px 16px; transition: width .2s ease; }
.evidence-toggle { width: 100%; justify-content: space-between; border-color: transparent; padding: 0 5px; color: var(--ink); background: transparent; }
.evidence-content { display: grid; gap: 10px; margin-top: 16px; }
.evidence-card { border-top: 1px solid var(--line); padding: 12px 4px 0; }
.evidence-card strong { display: block; font-size: 12px; }
.evidence-card p { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
.task-workspace.is-evidence-collapsed { grid-template-columns: 278px minmax(540px, 1fr) 52px; }
.task-workspace.is-evidence-unavailable { grid-template-columns: 278px minmax(540px, 1fr); }
.task-workspace.is-evidence-collapsed .evidence-content { display: none; }
.task-workspace.is-evidence-collapsed .evidence-toggle span:first-child { writing-mode: vertical-rl; }

.task-login { width: min(420px, calc(100% - 32px)); margin: 14vh auto 0; border: 1px solid var(--line); border-radius: 8px; padding: 34px; text-align: center; background: #fff; }
.task-login img { width: 50px; height: 38px; object-fit: contain; }
.task-login h1 { margin: 18px 0 8px; font-size: 24px; }
.task-login p { margin: 0 0 22px; color: var(--muted); line-height: 1.7; }
.task-login-explainer { border: 1px solid #d8e9ff; border-radius: 7px; margin: 0 0 12px; padding: 13px 14px; text-align: left; background: var(--accent-soft); }
.task-login-explainer strong { font-size: 13px; }
.task-login-explainer p { margin: 5px 0 0; font-size: 12px; line-height: 1.6; }
.task-login-guide-button { width: 100%; margin: 0 0 18px; }
.task-login-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 0 18px; padding: 4px; border-radius: 8px; background: #f0f0f2; }
.task-login-tabs button { min-height: 34px; border: 0; background: transparent; }
.task-login-tabs button.is-active { background: #fff; box-shadow: 0 1px 5px rgba(0,0,0,.08); }
.task-login-form { display: grid; gap: 13px; text-align: left; }
.task-login-form > button { width: 100%; margin-top: 2px; }
.task-login a.task-login-back { min-height: auto; display: inline-block; margin-top: 20px; border: 0; padding: 0; color: var(--muted); background: transparent; font-size: 12px; font-weight: 600; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(20,20,22,.3); backdrop-filter: blur(8px); }
.task-modal { width: min(580px, 100%); display: grid; gap: 17px; border: 1px solid var(--line); border-radius: 8px; padding: 24px; background: #fff; box-shadow: 0 24px 80px rgba(0,0,0,.18); }
.task-modal h2 { margin: 5px 0 0; font-size: 23px; }
.task-modal-flow { margin: -4px 0 0; border-radius: 7px; padding: 11px 12px; color: var(--muted); background: var(--surface-soft); font-size: 12px; line-height: 1.6; }
label { display: grid; gap: 7px; color: #3a3a3c; font-size: 12px; font-weight: 650; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; color: var(--ink); background: #fff; line-height: 1.5; }
textarea { resize: vertical; }
.switch-row { grid-template-columns: 1fr auto; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.switch-row strong, .switch-row small { display: block; }
.switch-row small { margin-top: 4px; color: var(--muted); font-weight: 450; }
.switch-row input { width: 19px; height: 19px; accent-color: var(--accent); }
.form-message { min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; }
.field-help { color: var(--muted); font-size: 11px; font-weight: 450; line-height: 1.5; }
.task-modal footer { justify-content: flex-end; }

.task-guide {
  width: min(420px, calc(100% - 24px));
  max-height: calc(100vh - 92px);
  position: fixed;
  top: 76px;
  right: 12px;
  z-index: 42;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 70px rgba(29, 29, 31, 0.16);
  transform: translateX(calc(100% + 32px));
  opacity: 0;
  pointer-events: none;
  transition: transform .22s ease, opacity .18s ease;
}
.task-guide.is-open { transform: translateX(0); opacity: 1; pointer-events: auto; }
.guide-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.guide-heading span { color: var(--accent); font-size: 11px; font-weight: 700; }
.guide-heading h2 { margin: 5px 0 0; font-size: 22px; }
.guide-scope { border: 1px solid #d8e9ff; border-radius: 7px; margin: 20px 0; padding: 14px; background: var(--accent-soft); }
.guide-scope strong { font-size: 13px; }
.guide-scope p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.guide-steps { list-style: none; display: grid; gap: 0; margin: 0 0 20px; padding: 0; }
.guide-steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; border-top: 1px solid var(--line-soft); padding: 13px 0; }
.guide-steps li > b { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); background: var(--accent-soft); font-size: 11px; }
.guide-steps strong, .guide-steps small { display: block; }
.guide-steps strong { font-size: 13px; }
.guide-steps small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.55; }
#guide-new-task-button { width: 100%; }

@media (max-width: 1080px) {
  .task-workspace, .task-workspace.is-evidence-collapsed { grid-template-columns: 240px minmax(0, 1fr); }
  .evidence-panel { display: none; }
  .task-main { padding: 34px 28px 70px; }
}
@media (max-width: 720px) {
  .task-topbar { grid-template-columns: 1fr auto; padding: 0 14px; }
  .task-topbar nav { display: none; }
  .task-workspace { display: block; }
  .task-sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; }
  .task-list { display: flex; overflow-x: auto; }
  .task-list-item { width: 210px; flex: 0 0 210px; }
  .task-main { padding: 26px 18px 60px; }
  .detail-heading { display: grid; }
  .run-timeline { overflow-x: auto; grid-template-columns: repeat(7, 90px); }
  .review-actions { display: grid; grid-template-columns: 1fr; }
  .empty-actions { display: grid; width: 100%; }
  .task-guide { top: 68px; right: 8px; width: calc(100% - 16px); max-height: calc(100vh - 76px); }
}
