/*
 * Note UI alignment theme v1
 * Visual baseline: Figma "运营参谋｜账号诊断与报告｜完整UI复刻"
 * Scope: presentation only. No business logic, routes, API bindings, or state rules.
 */

:root {
  color-scheme: light;

  --brand-default: #d62d46;
  --brand-subtle: #fff0f3;
  --text-primary: #262626;
  --text-secondary: #bababa;
  --surface-default: #ffffff;
  --surface-canvas: #fafafa;
  --surface-subtle: #f5f5f5;
  --border-subtle: #ececec;
  --border-control: #d7dbe0;

  /* Compatibility aliases for the existing note UI. */
  --ink: var(--text-primary);
  --muted: var(--text-secondary);
  --line: var(--border-subtle);
  --soft: var(--surface-subtle);
  --paper: var(--surface-default);
  --accent: var(--brand-default);
  --accent-soft: var(--brand-subtle);
  --radius: 8px;
  --shadow: 0 8px 24px rgba(38, 38, 38, 0.04);
}

html {
  background: var(--surface-subtle);
}

body {
  color: var(--text-primary);
  background: var(--surface-subtle);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.62;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(214, 45, 70, 0.26);
  outline-offset: 2px;
}

/* --- Page shell --------------------------------------------------------- */

.app-shell {
  width: min(1500px, calc(100% - 40px));
  min-height: calc(100vh - 40px);
  margin: 20px auto;
  grid-template-columns: 252px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--surface-default);
  box-shadow: var(--shadow);
  backdrop-filter: none;
}

.sidebar {
  padding: 22px 16px 18px;
  border-right: 1px solid var(--border-subtle);
  background: var(--surface-default);
}

.brand {
  gap: 10px;
  padding: 0 8px 20px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: #fff;
  background: var(--brand-default);
  font-size: 15px;
  font-weight: 600;
}

.brand strong {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  line-height: 26px;
}

.brand span {
  margin-top: 0;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 18px;
}

.main-nav {
  gap: 4px;
}

.nav-button {
  min-height: 44px;
  padding: 0 12px;
  gap: 10px;
  border-radius: 8px;
  color: #737373;
  font-size: 13px;
  font-weight: 400;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.nav-button:hover {
  color: var(--text-primary);
  background: var(--surface-canvas);
}

.nav-button.active {
  color: var(--text-primary);
  background: var(--brand-subtle);
  box-shadow: none;
  font-weight: 500;
}

.nav-index {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: #8c8c8c;
  background: var(--surface-subtle);
  font-size: 11px;
  font-weight: 500;
}

.nav-button.active .nav-index {
  color: #fff;
  background: var(--brand-default);
}

.nav-status {
  width: 7px;
  height: 7px;
  background: var(--border-control);
}

.nav-status.done {
  background: rgba(214, 45, 70, 0.5);
}

.product-nav {
  padding-top: 16px;
  gap: 4px;
  border-top: 1px solid var(--border-subtle);
}

.product-nav a {
  min-height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  color: #8c8c8c;
  font-size: 12px;
}

.product-nav a:hover,
.product-nav a[aria-current="page"] {
  color: var(--text-primary);
  background: var(--brand-subtle);
}

.product-nav a span {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  color: var(--brand-default);
  background: var(--brand-subtle);
  font-weight: 500;
}

/* --- Workspace and top bar --------------------------------------------- */

.workspace {
  min-width: 0;
  padding: 28px 32px 44px;
  background: var(--surface-canvas);
}

.topbar {
  gap: 20px;
}

.topbar h1 {
  margin: 2px 0 0;
  color: var(--text-primary);
  font-size: 26px;
  font-weight: 500;
  line-height: 39px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--brand-default);
  font-size: 11px;
  font-weight: 500;
  line-height: 18px;
  letter-spacing: 0;
  text-transform: none;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.account-chip {
  min-height: 32px;
  max-width: 220px;
  padding: 0 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  color: #8c8c8c;
  background: var(--surface-default);
  font-size: 12px;
  font-weight: 400;
}

.action-status {
  margin: 14px 0 -4px;
  color: #8c8c8c;
  font-size: 12px;
  line-height: 20px;
}

/* --- Buttons ------------------------------------------------------------ */

.button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--border-control);
  border-radius: 8px;
  color: var(--text-primary);
  background: var(--surface-default);
  box-shadow: none;
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.button:hover {
  transform: none;
  border-color: #c5cbd2;
  background: var(--surface-canvas);
}

.button-dark,
.button-accent {
  color: #fff;
  border-color: var(--brand-default);
  background: var(--brand-default);
}

.button-dark:hover,
.button-accent:hover {
  border-color: #bd233b;
  background: #bd233b;
}

.button-ghost {
  border-color: var(--border-subtle);
  background: transparent;
}

.button-danger {
  color: var(--danger);
  border-color: #edc9c5;
  background: #fff6f5;
}

.button:disabled {
  opacity: 0.45;
}

.button-row {
  gap: 8px;
  margin-top: 18px;
}

/* --- Progress ----------------------------------------------------------- */

.stepper {
  margin: 24px 0 20px;
  gap: 8px;
}

.step {
  height: 4px;
  border-radius: 2px;
  background: var(--border-subtle);
}

.step.done {
  background: rgba(214, 45, 70, 0.5);
}

.step.current {
  background: var(--brand-default);
}

/* --- Layout and cards --------------------------------------------------- */

.view {
  min-height: 650px;
}

.view-grid {
  grid-template-columns: minmax(0, 1.42fr) minmax(260px, 0.58fr);
  gap: 18px;
}

.stack {
  gap: 16px;
}

.card {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-default);
  box-shadow: none;
}

.card-header {
  padding: 18px 18px 0;
  gap: 12px;
}

.card-header h2,
.card-header h3 {
  color: var(--text-primary);
  font-weight: 500;
  letter-spacing: 0;
}

.card-header h2 {
  font-size: 18px;
  line-height: 28px;
}

.card-header h3 {
  font-size: 16px;
  line-height: 26px;
}

.card-header p,
.section-intro {
  margin: 4px 0 0;
  color: #8c8c8c;
  font-size: 13px;
  line-height: 21px;
}

.section-intro {
  margin-bottom: 16px;
}

.card-body {
  padding: 18px;
}

.card-body > h3:first-child {
  margin-top: 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  line-height: 22px;
}

.metric-grid {
  gap: 8px;
}

.metric {
  padding: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.metric span {
  color: #8c8c8c;
  font-size: 11px;
  line-height: 18px;
}

.metric strong {
  margin-top: 6px;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 500;
}

.metric small {
  color: #8c8c8c;
}

/* --- Forms -------------------------------------------------------------- */

.field-grid {
  gap: 16px;
}

.field {
  gap: 7px;
}

.field label,
.field-label {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  line-height: 21px;
}

.field label .required {
  color: var(--brand-default);
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border-control);
  border-radius: 8px;
  outline: none;
  color: var(--text-primary);
  background: var(--surface-canvas);
  font-size: 12px;
  line-height: 20px;
  box-shadow: none;
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field select {
  height: 44px;
  padding: 0 12px;
}

.field textarea {
  min-height: 112px;
  padding: 12px;
  resize: vertical;
  line-height: 1.68;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-secondary);
}

.field input:not([type="checkbox"]):not([type="radio"]):focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--brand-default);
  background: var(--surface-default);
  box-shadow: 0 0 0 3px rgba(214, 45, 70, 0.08);
}

.field small {
  color: #8c8c8c;
  font-size: 11px;
  line-height: 18px;
}

.choice-grid {
  gap: 8px;
}

.choice-card {
  padding: 14px;
  border: 1px solid var(--border-control);
  border-radius: 8px;
  background: var(--surface-default);
  box-shadow: none;
}

.choice-card:hover {
  border-color: #c5cbd2;
  background: var(--surface-canvas);
}

.choice-card:has(input:checked) {
  border-color: var(--brand-default);
  background: var(--brand-subtle);
  box-shadow: inset 0 0 0 1px var(--brand-default);
}

.choice-card strong {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
}

.choice-card span {
  margin-top: 4px;
  color: #8c8c8c;
  font-size: 11px;
  line-height: 18px;
}

.account-picker {
  gap: 8px;
}

.account-choice {
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--border-control);
  border-radius: 8px;
  color: var(--text-primary);
  background: var(--surface-default);
}

.account-choice:hover,
.account-choice.selected {
  border-color: var(--brand-default);
  background: var(--brand-subtle);
  box-shadow: 0 0 0 2px rgba(214, 45, 70, 0.08);
}

.account-choice strong {
  font-size: 13px;
  font-weight: 500;
}

.account-choice span {
  color: #8c8c8c;
  font-size: 11px;
}

.account-choice-new {
  border-style: dashed;
  background: var(--surface-canvas);
}

/* --- Notices, tags, and status ----------------------------------------- */

.notice {
  padding: 12px 13px;
  gap: 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 20px;
}

.notice strong {
  margin-bottom: 2px;
  font-weight: 500;
}

.notice-info {
  color: #35586f;
  background: #eef6fa;
}

.notice-warn {
  color: #795720;
  background: var(--amber-soft);
}

.notice-danger {
  color: #873e37;
  background: #fff0ef;
}

.notice-success {
  color: #276a4c;
  background: var(--green-soft);
}

.tag {
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--border-subtle);
  border-radius: 13px;
  color: #8c8c8c;
  background: var(--surface-default);
  font-size: 11px;
  font-weight: 400;
  line-height: 18px;
}

.tag.good {
  color: #276a4c;
  border-color: #dcefe4;
  background: var(--green-soft);
}

.tag.warn {
  color: #795720;
  border-color: #f2dfb3;
  background: var(--amber-soft);
}

/* --- Topic, task, material, and saved-item cards ----------------------- */

.topic-list,
.saved-task-list,
.material-list,
.risk-list,
.check-list {
  gap: 10px;
}

.topic-card {
  padding: 16px;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-default);
}

.topic-card:hover {
  border-color: var(--border-control);
}

.topic-card.selected {
  border-color: var(--brand-default);
  background: var(--brand-subtle);
  box-shadow: 0 0 0 2px rgba(214, 45, 70, 0.08);
}

.topic-number {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: #8c8c8c;
  background: var(--surface-subtle);
  font-size: 12px;
  font-weight: 500;
}

.topic-card.selected .topic-number {
  color: #fff;
  background: var(--brand-default);
}

.topic-card h3 {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  line-height: 26px;
}

.topic-card p {
  color: #8c8c8c;
  font-size: 12px;
  line-height: 20px;
}

.saved-task-row,
.material-item,
.check-row,
.risk-item {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-default);
  box-shadow: none;
}

.saved-task-row {
  padding: 16px;
}

.saved-task-row h3 {
  color: var(--text-primary);
  font-weight: 500;
}

.saved-task-row p {
  color: #8c8c8c;
}

.material-item {
  padding: 14px;
}

.check-row {
  padding: 13px 14px;
  gap: 10px;
  align-items: flex-start;
}

.check-row:hover {
  border-color: var(--border-control);
  background: var(--surface-canvas);
}

.check-row input[type="checkbox"],
.check-row input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--brand-default);
}

.check-row strong {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  line-height: 21px;
}

.check-row span span {
  color: #8c8c8c;
  font-size: 11px;
  line-height: 18px;
}

/* --- Draft and long-form content --------------------------------------- */

.title-option,
.draft-panel,
.editor-panel {
  border-color: var(--border-subtle);
  border-radius: 8px;
  box-shadow: none;
}

.title-option:has(input:checked),
.title-option.selected {
  border-color: var(--brand-default);
  background: var(--brand-subtle);
  box-shadow: 0 0 0 2px rgba(214, 45, 70, 0.08);
}

.draft-body,
.package-content,
.preview-body {
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.82;
}

.draft-body,
.package-content {
  max-width: 760px;
}

.editor-toolbar,
.preview-toolbar {
  border-color: var(--border-subtle);
  background: var(--surface-default);
}

.editor-toolbar {
  border-radius: 8px;
}

.editor-toolbar button,
.icon-button,
.segmented {
  border-radius: 8px;
}

/* --- Risk check --------------------------------------------------------- */

.risk-item {
  padding: 14px;
  gap: 10px;
}

.risk-item.warn {
  border-color: #f2dfb3;
  background: var(--amber-soft);
}

.risk-item.pass {
  border-color: #dcefe4;
  background: var(--green-soft);
}

.risk-item > span {
  width: 22px;
  flex: 0 0 22px;
  font-size: 15px;
  line-height: 21px;
}

.risk-item strong {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  line-height: 21px;
}

.risk-item p {
  margin: 4px 0 0;
  color: #737373;
  font-size: 12px;
  line-height: 20px;
}

/* --- Package and review ------------------------------------------------- */

.package-section {
  padding: 18px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.package-section:first-child {
  padding-top: 0;
}

.package-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.package-section h3 {
  margin: 0 0 10px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  line-height: 22px;
}

.package-content {
  white-space: pre-wrap;
}

.count-line {
  min-height: 40px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.count-line:last-child {
  border-bottom: 0;
}

.count-line span {
  color: #8c8c8c;
  font-size: 12px;
}

.count-line strong {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
}

/* --- Empty, loading, toast, and preview -------------------------------- */

.empty-state {
  padding: 44px 24px;
}

.empty-icon {
  width: 54px;
  height: 54px;
  margin-bottom: 14px;
  border-radius: 8px;
  color: var(--brand-default);
  background: var(--brand-subtle);
  font-size: 22px;
}

.empty-state h2 {
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 500;
  line-height: 30px;
}

.empty-state p {
  margin-top: 8px;
  color: #8c8c8c;
  font-size: 13px;
  line-height: 21px;
}

.loading-progress,
.loading-progress-bar,
.skeleton {
  border-radius: 8px;
}

.loading-progress-bar {
  background: var(--brand-default);
}

.toast {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  background: var(--surface-default);
  box-shadow: 0 8px 24px rgba(38, 38, 38, 0.1);
  font-size: 12px;
}

.preview-dialog {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--surface-default);
  box-shadow: 0 20px 60px rgba(38, 38, 38, 0.14);
}

.preview-toolbar {
  border-bottom: 1px solid var(--border-subtle);
}

.preview-toolbar strong {
  color: var(--text-primary);
  font-weight: 500;
}

.preview-toolbar span,
.preview-notes {
  color: #8c8c8c;
}

.segmented.active {
  color: #fff;
  border-color: var(--brand-default);
  background: var(--brand-default);
}

/* --- Responsive --------------------------------------------------------- */

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .workspace {
    padding-right: 24px;
    padding-left: 24px;
  }

  .view-grid {
    grid-template-columns: 1fr;
  }

  .view-grid > aside {
    order: 2;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    min-height: calc(100vh - 20px);
    margin: 10px auto;
    grid-template-columns: 1fr;
    border-radius: 8px;
  }

  .sidebar {
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border-subtle);
  }

  .brand {
    padding: 0 4px 12px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .main-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .nav-button {
    width: auto;
    min-width: max-content;
    min-height: 38px;
    padding: 0 10px;
  }

  .nav-status {
    display: none;
  }

  .product-nav {
    display: none;
  }

  .workspace {
    padding: 22px 16px 36px;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar h1 {
    font-size: 24px;
    line-height: 36px;
  }

  .stepper {
    margin-top: 20px;
  }
}

@media (max-width: 640px) {
  html {
    background: var(--surface-canvas);
  }

  .app-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .workspace {
    padding: 20px 16px 32px;
  }

  .topbar {
    display: grid;
    gap: 12px;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .topbar-actions .button {
    min-height: 40px;
  }

  .field-grid,
  .field-grid.three,
  .choice-grid,
  .metric-grid,
  .account-picker {
    grid-template-columns: 1fr;
  }

  .card-header {
    padding: 16px 16px 0;
  }

  .card-body {
    padding: 16px;
  }

  .button-row.end {
    justify-content: stretch;
  }

  .button-row.end .button {
    flex: 1 1 100%;
  }

  .topic-card {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .topic-card > .button,
  .topic-card > :last-child {
    grid-column: 1 / -1;
  }

  .saved-task-row {
    padding: 14px;
  }

  .preview-dialog {
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
  }
}
