:root {
  color-scheme: light;
  --background: #f2f5f8;
  --surface: #fff;
  --text: #1f3144;
  --muted: #54667a;
  --line: #d9e2eb;
  --blue: #235273;
  --blue-hover: #173e5a;
  --blue-soft: #e9f1f7;
  --green: #245b46;
  --green-soft: #e7f3ec;
  --amber: #70511c;
  --amber-soft: #fbf2df;
  --error: #9e312f;
  --error-soft: #fff1ee;
  --radius: 14px;
  font-family: "Inter", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei",
    system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  background: var(--background);
  color: var(--text);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 280px; margin: 0; }
h1, h2, h3, p, ol, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: clamp(1.65rem, 3.5vw, 2.45rem); font-weight: 700; letter-spacing: -.035em; }
h2 { font-size: 1.14rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
a, button, input, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #327fa9; outline-offset: 3px; }
button, input { font: inherit; }
button, .primary, .secondary {
  min-height: 40px;
  padding: .5rem .85rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
button:not(:disabled), summary, a { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
.primary { background: var(--blue); color: white; }
.primary:hover:not(:disabled) { background: var(--blue-hover); }
.secondary { background: white; border-color: #bfcfdd; color: var(--blue); }
.secondary:hover:not(:disabled) { background: var(--blue-soft); }
.quiet { color: var(--muted); background: transparent; padding-inline: .5rem; }
.quiet:hover:not(:disabled) { color: var(--text); background: var(--blue-soft); }
.muted { color: var(--muted); }
.small { font-size: .86rem; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner, .page { max-width: 1430px; padding-inline: 28px; margin-inline: auto; }
.header-inner { min-height: 63px; display: flex; align-items: center; gap: 12px; }
.brand, .header-actions { display: flex; align-items: center; gap: 11px; }
.header-actions { margin-left: auto; }
.brand { font-weight: 700; white-space: nowrap; }
.brand-mark {
  display: inline-grid; place-items: center; width: 31px; height: 31px;
  border-radius: 8px; color: #fff; background: var(--blue); font-size: .91rem;
}
.mode, .status, .progress-label {
  display: inline-block; width: fit-content; flex: 0 0 auto;
  border-radius: 6px; padding: 3px 9px; font-size: .77rem; font-weight: 650;
  line-height: 1.5; white-space: nowrap;
}
.mode, .progress-label, .status.ready, .status.previewed, .status.submitted {
  background: var(--blue-soft); color: var(--blue);
}
.status.neutral, .status.locked { background: #edf1f4; color: #4b5e71; }
.status.queued, .status.collecting, .status.unknown { background: var(--amber-soft); color: var(--amber); }
.status.accepted { background: var(--green-soft); color: var(--green); }
.status.error { background: var(--error-soft); color: var(--error); }

.page { padding-top: 34px; padding-bottom: 44px; }
.boot { color: var(--muted); padding-top: 28px; }
.panel {
  min-width: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: 0 2px 4px #25384b06;
}
.login-layout {
  min-height: min(590px, calc(100vh - 141px));
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, 395px);
  align-items: center; column-gap: clamp(30px, 8vw, 100px);
  max-width: 945px; margin-inline: auto;
}
.login-intro h1 { font-size: clamp(2.25rem, 5.3vw, 4rem); line-height: 1.14; }
.login-intro p { color: var(--muted); max-width: 31em; margin-top: 16px; line-height: 1.75; }
.login-route { display: flex; flex-wrap: wrap; list-style: none; padding: 0; gap: 8px; margin-top: 24px; }
.login-route li { color: var(--blue); background: var(--blue-soft); padding: 4px 9px; border-radius: 6px; font-size: .87rem; }
.login-form { display: flex; flex-direction: column; align-items: stretch; padding: 28px; }
.login-form h2 { font-size: 1.4rem; margin-bottom: 23px; }
.login-form label { font-weight: 650; font-size: .9rem; margin-bottom: 7px; }
.login-form input {
  min-height: 44px; min-width: 0; padding: .48rem .65rem; color: var(--text);
  border: 1px solid #bfcfdd; border-radius: 8px; background: #fafcfe;
}
.login-button { margin-top: 16px; }
.login-form .small { margin-top: 13px; }
.form-error { margin-top: 8px; color: var(--error); overflow-wrap: anywhere; }

.page-heading { margin-bottom: 22px; }
.page-heading p { margin-top: 8px; }
.workspace-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.1fr);
  grid-template-rows: min-content auto;
  align-items: start; gap: 18px;
}
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.setup-panel, .workflow-panel { padding: 19px 21px; }
.setup-panel { grid-column: 1; }
.workflow-panel { grid-column: 2; grid-row: 1; }
.workflow-header p { margin-top: 5px; }
.download { display: inline-flex; align-items: center; }
.material {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  margin-top: 16px; background: var(--blue-soft); border-radius: 9px;
}
.element {
  display: inline-grid; place-items: center; color: var(--blue); background: white;
  flex: 0 0 46px; height: 46px; border: 1px solid #cbdce8;
  border-radius: 8px; font-size: 1.4rem; font-weight: 650;
}
.material p { margin-top: 3px; }
.facts { margin-top: 9px; font-size: .88rem; }
.facts > div {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid #e7edf2; padding: .49rem 0;
}
.facts dt { flex: 0 0 auto; color: var(--muted); }
.facts dd { min-width: 0; text-align: right; overflow-wrap: anywhere; }
.digest, .plan-details { font-size: .84rem; color: var(--muted); margin-top: 9px; }
.digest code, .receipt-hash { display: block; word-break: break-all; margin-top: 6px; }
.setup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.stages { list-style: none; padding: 0; margin-top: 14px; }
.stage {
  position: relative; display: grid; grid-template-columns: 31px minmax(0, 1fr);
  gap: 12px; padding: 13px 0; border-top: 1px solid #e7edf2;
}
.stage:last-child { padding-bottom: 2px; }
.step-number {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue-soft); color: var(--blue); font-size: .8rem; font-weight: 700;
}
.stage[data-status="accepted"] .step-number { background: var(--green-soft); color: var(--green); }
.stage[data-status="locked"] .step-number { background: #edf1f4; color: #4b5e71; }
.stage-body { min-width: 0; }
.stage-head, .stage-meta, .result-metrics { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 10px; }
.stage-head { justify-content: space-between; min-height: 29px; }
.stage-meta { margin-top: 4px; font-size: .84rem; color: var(--muted); }
.stage-meta span { overflow-wrap: anywhere; }
.stage-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.stage-controls p { flex: 1 1 165px; }
.plan-details { margin-top: 8px; }
.plan-details dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .28rem .65rem; margin-top: .48rem; }
.plan-details dd { overflow-wrap: anywhere; color: var(--text); }
.plan-details pre {
  max-height: 14rem; margin: .45rem 0 0; padding: .65rem; overflow: auto;
  white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 6px; background: #f1f5f8;
}
.result-summary {
  padding: 8px 10px; margin-top: 8px; background: #f2f8f4; border-radius: 7px;
  color: #234b3b;
}
.result-metrics { font-size: .86rem; }
.result-summary summary { margin-top: 4px; font-size: .82rem; }
.receipt-hash { font-size: .77rem; }
.stage-note { margin-top: 6px; font-size: .86rem; }
.stage-error { margin-top: 8px; color: var(--error); font-size: .86rem; overflow-wrap: anywhere; }
.banner {
  margin-bottom: 14px; padding: 8px 12px; border-radius: 8px; font-size: .88rem;
  overflow-wrap: anywhere;
}
.banner.error { background: var(--error-soft); color: var(--error); }
.banner.working { background: var(--blue-soft); color: var(--blue); }

@media (max-width: 760px) {
  .workspace-grid { grid-template-columns: 1fr; grid-template-rows: auto; }
  .setup-panel, .workflow-panel { grid-column: auto; grid-row: auto; }
  .login-layout { gap: 22px; grid-template-columns: 1fr; min-height: auto; padding-top: 12px; }
  .login-intro h1 br { display: none; }
  .login-form { padding: 22px; }
}
@media (max-width: 440px) {
  .header-inner, .page { padding-inline: 13px; }
  .header-inner { min-height: 57px; }
  .header-actions, .brand { gap: 6px; }
  .page { padding-top: 21px; }
  .brand { font-size: .87rem; }
  .brand-mark { width: 26px; height: 26px; }
  .mode { padding-inline: 5px; }
  .quiet { padding-inline: .2rem; font-size: .78rem; }
  .setup-panel, .workflow-panel { padding: 15px; }
  .stage { gap: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}

.login-form input + label { margin-top: 13px; }
.identity {
  max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .86rem; color: var(--muted); font-weight: 650;
}
.top-nav {
  display: flex; align-items: center; gap: 3px; margin-left: 10px;
  padding: 3px; background: #294761; border-radius: 8px;
}
.top-nav button {
  min-height: 32px; padding: 4px 10px; color: #edf4fa; background: transparent;
  font-size: .84rem; font-weight: 550;
}
.top-nav button[aria-pressed="true"] { background: #52728d; color: white; font-weight: 700; }
.top-nav button:hover { background: #456780; }
.top-nav button[aria-pressed="true"]:hover { background: #52728d; }
.top-nav button:focus-visible { outline-color: #2273a3; }

.project-shell { display: grid; grid-template-columns: 225px minmax(0, 1fr); align-items: start; gap: 20px; }
.project-main { min-width: 0; }
.project-panel { padding: 16px; }
.project-panel .panel-header { align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.project-panel .quiet { min-height: 32px; padding-block: 2px; }
.project-panel > .primary { width: 100%; margin-top: 12px; white-space: normal; }
.project-filters { display: grid; gap: 5px; margin-top: 10px; }
.project-filters label { font-size: .8rem; color: var(--muted); }
.project-filters select {
  width: 100%; min-width: 0; min-height: 34px; padding-inline: .35rem;
  border: 1px solid #bfcfdd; border-radius: 7px; background: #fafcfe; color: var(--text);
}
.project-list { list-style: none; display: grid; gap: 6px; padding: 0; margin-top: 12px; }
.project-option {
  display: grid; gap: 3px; width: 100%; text-align: left; white-space: normal;
  border: 1px solid transparent; color: var(--text); background: #f7f9fb;
}
.project-option:hover { background: var(--blue-soft); }
.project-option[aria-current="page"] { border-color: #bfd3e1; color: #1b4c6e; background: #e7f0f7; }
.project-option-name, .project-option-meta { overflow-wrap: anywhere; }
.project-option-meta { font-size: .76rem; color: var(--muted); font-weight: 450; }
.project-option-id { font: .75rem/1.5 ui-monospace, monospace; }
.project-list-empty { padding-block: 5px; }
.empty-panel { padding: clamp(18px, 4vw, 35px); min-height: 180px; }
.empty-panel h1 { font-size: clamp(1.3rem, 3vw, 1.7rem); }
.empty-panel p { margin-top: 10px; }
.empty-panel button { margin-top: 15px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; }
.page-heading div { min-width: 0; overflow-wrap: anywhere; }
.workspace-grid { grid-template-rows: auto; }
.workflow-note { border-top: 1px solid #e7edf2; padding-top: 10px; margin-top: 12px; }
.status.running, .status.pending, .status.needs-review { background: var(--amber-soft); color: var(--amber); }
.status.completed { background: var(--blue-soft); color: var(--blue); }
.status.failed, .status.cancelled, .status.timeout { background: var(--error-soft); color: var(--error); }

.reports-panel, .history-panel {
  grid-column: 1 / -1; padding: 15px 21px; min-width: 0;
}
.reports-panel .panel-header p { margin-top: 5px; overflow-wrap: anywhere; }
.section-empty { margin-top: 10px; }
.record-list { display: grid; gap: 8px; list-style: none; padding: 0; margin-top: 12px; }
.record {
  padding: 10px 12px; border: 1px solid #e1e8ef; border-radius: 8px;
  background: #f7f9fb; overflow-wrap: anywhere;
}
.report-record, .record-actions { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.report-record { justify-content: space-between; }
.report-copy { min-width: 0; }
.report-copy p { margin-top: 4px; }
.reports-panel .download { min-height: 36px; }
.report-controls { display: flex; flex-wrap: wrap; align-items: end; justify-content: flex-end; gap: 8px; }
.report-controls label { display: grid; gap: 3px; color: var(--muted); font-size: .8rem; }
.report-controls select {
  min-width: 0; min-height: 40px; padding-inline: .5rem; border: 1px solid #bfcfdd;
  border-radius: 8px; color: var(--text); background: #fafcfe;
}
.advice-panel {
  margin-top: 8px; padding: 7px 10px; border: 1px solid #e1e8ef; border-radius: 7px;
  background: #f7f9fb; font-size: .86rem; overflow-wrap: anywhere;
}
.advice-panel ul { margin: 4px 0 0; padding-left: 18px; }
.advice-panel p { margin-top: 3px; }

.account-grid { display: grid; grid-template-columns: minmax(245px, 1fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.account-form, .account-list-panel { padding: 17px 21px; }
.account-form { display: grid; gap: 6px; }
.account-form h2 { margin-bottom: 4px; }
.account-form label { padding-top: 4px; font-size: .88rem; font-weight: 650; }
.account-form > button { margin-top: 7px; justify-self: start; }
.password-dialog { width: min(100% - 32px, 430px); max-height: calc(100% - 32px); margin: auto; }
.password-dialog::backdrop { background: rgb(21 44 66 / 38%); }
.password-dialog .account-form { padding: 20px; }
.password-dialog .small { margin: 2px 0 4px; }
.password-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.form-success { color: #27634f; margin: 4px 0 10px; }
.account-record p { margin-top: 4px; }
.account-edit, .retry-form {
  display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; margin-top: 8px;
}
.account-edit label, .retry-form label { display: grid; gap: 4px; min-width: 0; font-size: .86rem; color: var(--text); }
.account-edit label:not(.account-enabled), .retry-form label { flex: 1 1 140px; }
.account-edit .account-enabled { display: flex; align-items: center; min-height: 40px; }
.account-edit .account-enabled input { min-height: auto; }
.account-form input, .account-form select, .account-edit select, .account-edit input:not([type="checkbox"]), .retry-form input {
  width: 100%; min-width: 0; min-height: 37px; padding: .4rem .55rem;
  border: 1px solid #bfcfdd; border-radius: 7px; background: #fafcfe; color: var(--text);
}
select { font: inherit; }

.consultation-panel { margin-bottom: 18px; }
.consultation-panel > summary {
  min-height: 46px; padding: 11px 20px; color: var(--blue);
}
.consultation-body { padding: 0 20px 16px; }
.consultation-body .panel-header { align-items: center; }
#consultation-status:empty, .consultation-messages:empty { display: none; }
.consultation-messages {
  display: grid; gap: 8px; max-height: 28rem; overflow: auto;
  padding: 0; list-style: none; margin-top: 9px;
}
.consultation-messages li {
  min-width: 0; padding: 8px 11px; border-radius: 7px; background: var(--blue-soft);
}
.consultation-messages .consultation-answer { background: #f4f7fa; }
.consultation-messages p { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 3px; }
.consultation-form { display: grid; gap: 6px; margin-top: 10px; }
.consultation-form label { font-weight: 650; font-size: .88rem; }
.consultation-form textarea, .deepseek-key-form input, .deepseek-month-form input {
  width: 100%; min-width: 0; min-height: 38px; padding: .42rem .55rem;
  border: 1px solid #bfcfdd; border-radius: 7px; font: inherit; color: var(--text); background: #fafcfe;
}
.consultation-form textarea { resize: vertical; }
.consultation-actions { align-items: end; }
.consultation-actions label { display: grid; gap: 2px; min-width: 0; font-size: .83rem; }
.consultation-actions input { width: 100%; max-width: 100%; font-size: .82rem; }
.consultation-usage { border-top: 1px solid var(--line); margin-top: 13px; padding-top: 10px; }
.usage-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 110px), 1fr));
  gap: 6px 10px; margin: 7px 0;
}
.usage-grid > div { min-width: 0; padding: 5px 8px; border-radius: 5px; background: #ecf2f7; }
.usage-grid dt { color: var(--muted); font-size: .78rem; }
.usage-grid dd { font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.deepseek-users-panel { padding: 15px 20px; }
.deepseek-month-form, .deepseek-key-form { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.deepseek-month-form { align-items: center; }
.deepseek-month-form input { width: auto; }
.deepseek-month-form label, .deepseek-key-form label { font-size: .86rem; }
.deepseek-key-form label { display: grid; gap: 3px; flex: 1 1 205px; }
.deepseek-key-form { margin-top: 9px; }
#deepseek-feedback { margin-top: 6px; }

@media (max-width: 1030px) {
  .project-shell { grid-template-columns: 190px minmax(0, 1fr); gap: 13px; }
  .workspace-grid { gap: 13px; grid-template-columns: minmax(185px, 1fr) minmax(0, 2fr); }
  .setup-panel, .workflow-panel, .reports-panel, .history-panel { padding-inline: 13px; }
}
@media (max-width: 890px) {
  .project-shell { grid-template-columns: 1fr; }
  .project-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 12px; }
  .project-panel > .primary { width: fit-content; margin: 0 0 0 auto; }
  .project-filters { width: 100%; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; margin-top: 4px; }
  .project-list {
    width: 100%; display: flex; gap: 6px; padding-bottom: 3px; overflow-x: auto; margin-top: 5px;
  }
  .project-list li { max-width: min(205px, 75vw); flex: 0 0 auto; }
  .project-list-empty { width: 100%; }
}
@media (max-width: 680px) {
  .workspace-grid, .account-grid { grid-template-columns: 1fr; grid-template-rows: auto; }
  .setup-panel, .workflow-panel { grid-column: auto; grid-row: auto; }
  .reports-panel, .history-panel { padding-inline: 15px; }
  .consultation-panel > summary, .consultation-body, .deepseek-users-panel { padding-inline: 15px; }
  .header-inner { flex-wrap: wrap; gap: 5px 10px; padding-block: 8px; }
  .top-nav { margin: 0; order: 3; flex: 1 0 100%; }
  .top-nav button { flex: 1; }
  .page { padding-top: 15px; }
  .page-heading { margin-bottom: 13px; }
  .identity { max-width: min(13vw, 8rem); }
  .record-actions { gap: 6px; }
  .reports-panel .panel-header { flex-wrap: wrap; }
  .report-controls { justify-content: flex-start; }
}
@media (max-width: 400px) {
  .identity { display: none; }
  .header-actions { gap: 4px; }
  .report-record { align-items: flex-start; }
}
