:root {
  color-scheme: light;
  --ink: #172942;
  --text: #344b66;
  --muted: #5d7089;
  --line: #dbe5f1;
  --blue: #1859c9;
  --blue-dark: #1246a1;
  --tint: #eaf2ff;
  --surface: #fff;
  --page: #f4f7fc;
  --radius: 14px;
  font: 14px/1.55 "DM Sans", system-ui, "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--page); color: var(--ink); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, input, textarea { color: inherit; }
a { color: var(--blue); }
:focus-visible { outline: 2px solid #246df0; outline-offset: 3px; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: #ad3328; }
.eyebrow { color: var(--blue); font-size: 12px; font-weight: 650; }

.app-shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar {
  display: flex; flex-direction: column; gap: 10px;
  width: 244px; flex: 0 0 auto; padding: 22px 16px 14px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.brand, .side-bottom { display: flex; align-items: center; gap: 11px; }
.brand { padding: 2px 4px 9px; }
.brand strong, .brand small, .account b, .account small { display: block; }
.brand strong { font-size: 16px; letter-spacing: -.025em; }
.brand small, .account small { font-size: 11px; color: var(--muted); }
.brand-mark, .avatar {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 45px; height: 45px; border-radius: 12px;
  color: white; background: var(--blue); font-size: 21px; font-weight: 720;
}
.brand-mark.small { width: 38px; height: 38px; font-size: 19px; }
.avatar { width: 33px; height: 33px; font-size: 11px; color: var(--blue); background: var(--tint); }
.new-task, .primary, .send-btn {
  border: 0; border-radius: 10px; color: white; background: var(--blue); font-weight: 650;
}
.new-task, .primary { min-height: 42px; padding: 9px 13px; }
.new-task { text-align: left; margin-bottom: 7px; }
.new-task:hover, .primary:hover, .send-btn:hover:not(:disabled) { background: var(--blue-dark); }
.side-label { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; font-weight: 620; }
.side-label button, .icon-btn { border: 0; padding: 5px 7px; background: transparent; color: var(--muted); border-radius: 7px; }
.side-label button:hover, .icon-btn:hover { background: var(--tint); color: var(--blue); }
#task-filter { min-width: 0; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--page); font-size: 13px; }
.task-list { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; }
.task-item {
  display: block; width: 100%; text-align: left; margin: 2px 0; padding: 8px 9px;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text);
}
.task-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.task-item small { display: flex; align-items: center; gap: 5px; margin-top: 3px; color: var(--muted); font-size: 11px; }
.task-item:hover, .task-item.active { background: var(--tint); border-color: #d7e5ff; }
.task-item.active { color: var(--blue-dark); }
.live-dot, .task-dot { display: inline-block; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 100%; background: #8798ad; }
.live-dot, .task-dot.completed { background: #2a8a61; }
.task-dot.running, .task-dot.media_waiting { background: #246ce1; }
.task-dot.failed { background: #b95043; }
.task-list-empty { font-size: 12px; color: var(--muted); padding: 2px 8px; }
.side-bottom { border-top: 1px solid var(--line); padding: 10px 3px 2px; }
.account { flex: 1; min-width: 0; }
#logout { font-size: 12px; }

.main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 0 24px; flex: 0 0 57px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.topbar-title { font-weight: 650; }
.connection-status { display: flex; align-items: center; gap: 7px; margin-left: auto; color: var(--muted); font-size: 12px; }
.mobile-only, .mobile-new, .sidebar-backdrop { display: none; }
.content {
  display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%;
  max-width: 1540px; margin: 0 auto; padding: 0 24px;
}
.welcome { flex: 1; min-height: 0; overflow: auto; display: grid; align-content: center; width: min(100%, 760px); margin: 0 auto; padding: 20px 2px; }
.welcome h1 { font-size: clamp(26px, 3.5vw, 44px); line-height: 1.2; letter-spacing: -.035em; margin: 0 0 9px; }
.welcome p { margin: 0; }
.suggestions { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
.suggestion {
  text-align: left; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); min-width: 0;
}
.suggestion span, .suggestion small { display: block; }
.suggestion span { font-weight: 650; }
.suggestion small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.suggestion:hover { border-color: #91b5ef; background: #f8fbff; }
.suggestion { grid-column: span 2; }
.suggestion:is([data-workflow="media"],[data-workflow="wechat"]) { grid-column: span 3; background: #edf5ff; border-color: #c6dcfa; }
.suggestion:is([data-workflow="media"],[data-workflow="wechat"]):hover { background: #e5f0ff; border-color: #91b5ef; }
.welcome-tools, .idea-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.welcome-tools .outline { flex-shrink: 0; }
.article-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 9px 12px; background: #f4f8ff; border-bottom: 1px solid #d9e5f6; }
.article-actions span { color: var(--muted); font-size: 12px; }
.article-actions button:disabled { opacity: .62; }
:is(#ideas-dialog, #presentation-dialog) { width: min(550px, calc(100% - 32px)); max-height: 80dvh; padding: 18px; border: 1px solid #d0def1; border-radius: 14px; color: inherit; background: #fff; }
:is(#ideas-dialog, #presentation-dialog)::backdrop { background: #10284760; }
.idea-heading h2 { margin: 0; font-size: 20px; }
.presentation-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 17px; }
.presentation-choices label { display: block; font-weight: 650; margin-bottom: 6px; }
.presentation-choices p { line-height: 1.55; margin: 7px 0 12px; font-size: 13px; }
.presentation-choices select, #presentation-versions { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--text); font: inherit; }
#presentation-versions { width: auto; max-width: 100%; font-size: 12px; }
.presentation-swatches { display: flex; gap: 5px; margin-top: 9px; height: 12px; }
.presentation-swatches span { width: 24px; border: 1px solid #17365d26; border-radius: 3px; }
#presentation-form .send-btn { margin-top: 8px; }
#presentation-context { margin: 2px 0 6px; color: var(--blue-dark); }
#idea-form { display: grid; gap: 8px; margin-top: 15px; }
#idea-form textarea { width: 100%; min-height: 78px; resize: vertical; padding: 9px; border: 1px solid #c6d6ed; border-radius: 8px; font: inherit; }
#idea-form button { justify-self: start; }
.idea-list { list-style: none; padding: 0; margin: 12px 0 0; }
.idea-list li { border-top: 1px solid #e1eaf7; padding: 10px 0; }
.idea-list p { margin: 0 0 7px; white-space: pre-wrap; overflow-wrap: anywhere; }
.idea-list .outline { margin-right: 5px; }

.composer-wrap { width: 100%; padding: 0 0 max(16px, env(safe-area-inset-bottom)); }
.welcome:not(.hidden) ~ .composer-wrap { max-width: 760px; margin: 0 auto; }
.composer { padding: 11px 13px 9px; border: 1px solid #c9d8eb; border-radius: var(--radius); background: var(--surface); box-shadow: 0 4px 14px #173c6810; }
.composer:focus-within, .composer.dragging { border-color: #729fe9; box-shadow: 0 0 0 3px #c9dcfc85; }
.composer.dragging { background: #f3f8ff; }
.composer textarea { display: block; width: 100%; min-height: 48px; max-height: 25vh; padding: 2px; border: 0; outline: 0; background: transparent; resize: vertical; }
.composer textarea::placeholder { color: #657d98; }
.composer-footer, .composer-footer > div { display: flex; align-items: center; gap: 8px; }
.composer-footer { justify-content: space-between; margin-top: 5px; }
.composer-footer > div { flex-wrap: wrap; }
.attach-btn, .outline, .workflow-selection, .preview-actions button, .preview-actions a, .task-switcher button {
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--blue-dark); padding: 6px 9px; font-size: 12px; text-decoration: none;
}
.attach-btn:hover, .outline:hover, .preview-actions :is(button,a):hover { background: var(--tint); }
.keyboard-hint { font-size: 11px; color: var(--muted); }
.workflow-selection { background: var(--tint); }
.send-btn { min-height: 36px; padding: 5px 13px; flex: 0 0 auto; }
.send-btn:disabled { opacity: .52; }
.composer-status { margin: 6px 0 0; font-size: 12px; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 5px; max-height: 70px; overflow: auto; }
.attachment-list:not(:empty) { margin: 3px 0 6px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; border-radius: 6px; padding: 3px 7px; background: var(--tint); color: var(--blue-dark); font-size: 12px; }
.attachment-chip.error { color: #ad3328; background: #fff1ee; }
.attachment-chip button { border: 0; padding: 0 2px; color: inherit; background: transparent; }

.task-view { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-height: 0; padding: 16px 0; }
.task-view.has-artifacts { grid-template-columns: minmax(260px, .9fr) minmax(0, 1.1fr); }
.task-view.preview-expanded { grid-template-columns: minmax(0, 1fr); }
.task-view.preview-expanded .task-left { display: none; }
.task-left { overflow: auto; min-height: 0; min-width: 0; padding: 2px 2px 10px; scrollbar-width: thin; }
.task-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.task-heading h2 { font-size: clamp(19px, 2.2vw, 25px); line-height: 1.3; margin: 3px 0; overflow-wrap: anywhere; }
.status-pill {
  flex: 0 0 auto; padding: 4px 9px; border-radius: 999px; background: #eef1f5;
  color: var(--text); font-size: 12px; font-weight: 650;
}
.status-pill.running, .status-pill.media_waiting { background: var(--tint); color: var(--blue-dark); }
.status-pill.completed { background: #e8f7ee; color: #236c48; }
.status-pill.failed { background: #fff0eb; color: #993b2f; }
.overall-progress { margin: 12px 0 8px; }
.progress-caption { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.progress-caption b { color: var(--blue-dark); }
.progress-track { height: 7px; background: #e1eaf6; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--blue); border-radius: inherit; transition: width .25s ease; }
.task-activity, .learning-summary { margin: 6px 0; padding: 7px 9px; border-radius: 7px; color: var(--text); background: #eaf1fb; font-size: 12px; overflow-wrap: anywhere; }
.task-activity.needs-check { color: #864516; background: #fff2de; }
.learning-summary { background: transparent; padding: 2px 0; color: var(--muted); }
.result-card, .plan-card, .execution-details { margin: 12px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.result-card { display: flex; align-items: flex-start; gap: 9px; padding: 12px; }
.result-body { min-width: 0; flex: 1; }
.result-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.result-bar button { flex: none; }
.result-icon { flex: 0 0 25px; display: grid; place-items: center; height: 25px; background: #e8f7ee; border-radius: 50%; color: #236c48; font-weight: 700; }
.result-card.failed .result-icon { background: #fff0eb; color: #993b2f; }
.result-heading, .plan-card h3 { margin: 0 0 5px; font-size: 14px; font-weight: 650; }
.result-summary { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.plan-card { padding: 10px 12px; }
.plan-card ol { list-style: none; margin: 0; padding: 0; }
.plan-card li { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; padding: 6px 0; color: var(--text); font-size: 13px; }
.plan-card li + li { border-top: 1px solid #edf2f8; }
.plan-card li > small { margin-left: auto; flex: 0 0 auto; color: var(--muted); }
.step-copy { min-width: 0; overflow-wrap: anywhere; }
.step-state { flex: 0 0 16px; color: var(--muted); }
.step-completed .step-state { color: #236c48; }
.step-running .step-state { color: var(--blue); }
.step-failed .step-state { color: #993b2f; }
.step-evidence { display: block; color: var(--muted); font-size: 12px; }
.execution-details { padding: 9px 12px; }
.execution-details summary { cursor: pointer; color: var(--text); font-size: 12px; font-weight: 600; }
.timeline { padding: 4px 0 0; }
.event { position: relative; border-left: 1px solid var(--line); margin-left: 3px; padding: 4px 8px 5px 14px; color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
.event::before { content: ""; position: absolute; left: -4px; top: 10px; width: 7px; height: 7px; border-radius: 100%; background: #688ab9; }
.event.tool_error::before { background: #ae601d; }
.event.artifact::before, .event.incident_resolved::before { background: #2a8a61; }
.event time { display: block; color: var(--muted); font-size: 11px; }
.event-detail { margin-top: 3px; }
.event-detail summary { font-weight: 450; color: var(--blue-dark); }
.event pre { padding: 6px 8px; margin: 3px 0; max-height: 180px; overflow: auto; background: var(--page); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; }
.task-switcher { display: none; }

.preview-pane {
  display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.preview-heading { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 10px 11px; border-bottom: 1px solid var(--line); }
.preview-heading > div:first-child { min-width: 0; }
.preview-heading h3 { font-size: 14px; margin: 0; }
.preview-heading p { margin: 2px 0 0; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.preview-actions { display: flex; flex: 0 0 auto; gap: 5px; align-items: center; }
.artifact-list { display: flex; flex: 0 0 auto; gap: 6px; padding: 7px 9px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.artifact-row { display: flex; flex: 0 0 auto; max-width: 240px; border: 1px solid var(--line); border-radius: 8px; }
.artifact-row.active { background: var(--tint); border-color: #9ebbe8; }
.artifact-select { display: flex; align-items: center; gap: 6px; padding: 5px 7px; min-width: 0; background: transparent; border: 0; text-align: left; }
.artifact-badge { display: grid; place-items: center; min-width: 26px; padding: 2px 4px; border-radius: 5px; background: var(--tint); color: var(--blue-dark); font-size: 10px; font-weight: 700; }
.artifact-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.artifact-name small { display: block; color: var(--muted); font-size: 10px; }
.artifact-download { display: grid; place-items: center; min-width: 30px; border-left: 1px solid var(--line); text-decoration: none; }
.artifact-preview { flex: 1; min-height: 0; background: #edf2f9; }
.preview-frame, .preview-image, .preview-video { display: block; width: 100%; height: 100%; border: 0; }
.preview-image, .preview-video { object-fit: contain; }
.preview-video { background: #111c2f; }
.preview-empty { display: grid; place-items: center; height: 100%; padding: 16px; color: var(--muted); text-align: center; }

.login-shell { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 18px; background: radial-gradient(ellipse at 50% 0, #dbe9ff 0, var(--page) 62%); }
.login-card { width: min(100%, 410px); padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 11px 36px #1a40741c; }
.login-card h1 { margin: 4px 0; font-size: 26px; }
.login-card label { font-size: 13px; }
.password-wrap { display: flex; margin: 5px 0 12px; border: 1px solid #b7c9df; border-radius: 8px; }
.password-wrap input { min-width: 0; flex: 1; padding: 8px; border: 0; border-radius: 8px; background: transparent; }
.password-wrap button { border: 0; background: transparent; color: var(--blue); padding: 6px 9px; }
.primary.full { width: 100%; }
.secure-note { color: var(--muted); font-size: 11px; }

#skills-dialog {
  width: min(580px, 94vw); max-height: 78vh; padding: 14px 15px;
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink);
}
#skills-dialog::backdrop { background: #10284760; }
.skills-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.skills-heading h2 { font-size: 18px; margin: 0; }
#skill-filter {
  width: 100%; margin: 10px 0 3px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--page);
}
#skills-results article { padding: 8px 1px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#skills-results p { margin: 3px 0; color: var(--muted); font-size: 12px; }
#skills-results small { display: block; color: #864516; }

@media (max-width: 1000px) {
  .content { padding-inline: 14px; }
  .task-view.has-artifacts { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .task-view.has-artifacts .task-switcher { display: flex; gap: 7px; }
  .task-switcher button { flex: 1; min-height: 36px; }
  .task-switcher button[aria-pressed="true"] { border-color: #9ebbe8; background: var(--tint); }
  #mobile-preview-count:not(:empty) { margin-left: 3px; font-weight: 650; }
  .task-view:not(.show-deliverables) .preview-pane, .task-view.show-deliverables .task-left { display: none; }
  .task-view:not(.show-deliverables) .task-left { display: block; }
  #expand-preview { display: none; }
}
@media (max-width: 760px) {
  .sidebar {
    position: fixed; z-index: 5; inset: 0 auto 0 0; width: min(84vw, 290px);
    transform: translateX(-101%); visibility: hidden; transition: transform .18s ease, visibility .18s;
  }
  .sidebar.open { transform: none; visibility: visible; }
  .sidebar-open .sidebar-backdrop { display: block; position: fixed; z-index: 4; inset: 0; border: 0; background: #132c4e52; }
  .mobile-only, .mobile-new { display: inline-flex; }
  .topbar { flex-basis: 49px; padding-inline: 12px; gap: 8px; }
  .topbar-title { display: none; }
  .content { padding-inline: 10px; }
  .welcome { align-content: safe center; }
  .suggestions { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 14px; gap: 7px; }
  .suggestion, .suggestion:is([data-workflow="media"],[data-workflow="wechat"]) { grid-column: span 1; }
  .suggestion { padding: 10px; }
  .keyboard-hint { display: none; }
  .task-view { padding: 9px 0; gap: 8px; }
  .composer-wrap { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
@media (max-width: 480px) {
  .presentation-choices { grid-template-columns: minmax(0, 1fr); gap: 5px; }
}
.turn-list { list-style: none; margin: 0; padding: 0 10px 8px; max-height: 210px; overflow: auto; }
.turn-list li { padding: 8px 0; border-top: 1px solid var(--line); }
.turn-list p { margin: 4px 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.turn-list small, #turn-context { color: var(--muted); }
.turn-list button[aria-current="true"] { border-color: #397bcb; background: var(--tint); }
