:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #1c2430;
  --muted: #667085;
  --line: #d9dee7;
  --blue: #245d9c;
  --teal: #16736b;
  --red: #b42318;
  --amber: #b54708;
  --green: #147a43;
  --shadow: 0 16px 40px rgba(28, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
}

.header-actions,
.toolbar,
.module-head,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  gap: 24px;
  padding: 24px 32px 40px;
}

.audit-panel,
.results {
  min-width: 0;
}

.panel-section,
.module,
.score-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-section {
  padding: 18px;
  margin-bottom: 16px;
}

.section-title {
  margin-bottom: 14px;
}

.section-title span,
.module-head span,
.score-card small {
  color: var(--muted);
  font-size: 12px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 156px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 93, 156, 0.14);
}

.scan-status {
  margin: -2px 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 700;
}

.scan-status.loading {
  border-color: rgba(36, 93, 156, 0.3);
  background: rgba(36, 93, 156, 0.08);
  color: var(--blue);
}

.scan-status.success {
  border-color: rgba(20, 122, 67, 0.28);
  background: #dcfae6;
  color: var(--green);
}

.scan-status.warning {
  border-color: rgba(181, 71, 8, 0.28);
  background: #fef0c7;
  color: var(--amber);
}

.audit-progress {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  margin-bottom: 12px;
}

.audit-progress[aria-hidden="true"] {
  display: none;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 13px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--teal);
  transition: width 180ms ease;
}

.audit-progress ol {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 12px;
}

.audit-progress li.active {
  color: var(--blue);
  font-weight: 700;
}

.audit-progress li.done {
  color: var(--green);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.file-drop {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}

.quick-signals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-top: 8px;
}

.quick-signals label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
}

.quick-signals input {
  width: auto;
}

.primary,
.ghost {
  border: 1px solid var(--blue);
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 700;
}

.primary {
  background: var(--blue);
  color: #fff;
}

.ghost {
  background: #fff;
  color: var(--blue);
}

.compact {
  padding: 7px 10px;
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 12px 14px;
  font-weight: 700;
}

.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.score-card {
  padding: 18px;
}

.score-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.score-card strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 34px;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.pitch-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
}

.pitch-hero {
  grid-column: 1 / -1;
}

.module {
  padding: 18px;
  min-height: 220px;
}

.module.wide {
  grid-column: 1 / -1;
}

.domain-list,
.finding-list,
.check-list,
.query-list,
.keyword-list,
.page-audit-list,
.diagnostic-list,
.snapshot-summary {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.domain-row,
.finding,
.check-row,
.query-row,
.task-card,
.snapshot-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.dual-engine {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.dual-engine > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 16px;
  min-width: 0;
}

.dual-engine span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dual-engine strong {
  display: block;
  margin: 8px 0;
  font-size: 36px;
  line-height: 1;
}

.dual-engine p {
  margin-bottom: 0;
  color: #344054;
  overflow-wrap: anywhere;
}

.pitch-hero blockquote {
  margin: 14px 0 0;
  border-left: 4px solid var(--blue);
  background: #f8fafc;
  padding: 12px 14px;
  color: #263547;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.55;
}

.diagnostic-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.diagnostic-row p {
  margin: 6px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.diagnostic-action {
  margin-top: 10px;
  border-left: 3px solid var(--line);
  padding-left: 10px;
}

.diagnostic-action span {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.diagnostic-action p {
  margin-top: 3px;
}

.tool-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.tool-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tool-card-head strong {
  display: block;
  font-size: 15px;
}

.tool-card-head p,
.tool-purpose {
  margin: 4px 0 0;
  color: var(--muted);
}

.tool-purpose {
  color: #344054;
}

.tool-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.tool-facts div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px;
  min-width: 0;
}

.tool-facts dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tool-facts dd {
  margin: 0;
  color: #263547;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.keyword-group {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.keyword-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.keyword-tags span {
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.keyword-group p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.page-audit-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.page-audit-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.page-audit-head strong {
  overflow-wrap: anywhere;
}

.page-audit-row p {
  margin: 6px 0 8px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.domain-row {
  display: grid;
  grid-template-columns: 110px 1fr 46px;
  align-items: center;
  gap: 10px 12px;
}

.bar {
  height: 8px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 999px;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.reason-list {
  grid-column: 1 / -1;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
}

.reason-list li + li {
  margin-top: 3px;
}

.finding {
  display: grid;
  gap: 8px;
}

.finding-head,
.task-meta,
.query-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-2);
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.badge.high,
.badge.critical {
  background: #fee4e2;
  color: var(--red);
}

.badge.medium {
  background: #fef0c7;
  color: var(--amber);
}

.badge.low,
.badge.done {
  background: #dcfae6;
  color: var(--green);
}

.badge.neutral {
  background: #f2f4f7;
  color: var(--muted);
}

.badge.audience-B2B {
  background: #e0f2fe;
  color: #075985;
}

.badge.audience-B2C {
  background: #fae8ff;
  color: #86198f;
}

.check-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: start;
}

.check-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: #fee4e2;
  color: var(--red);
  font-weight: 800;
}

.check-mark.pass {
  background: #dcfae6;
  color: var(--green);
}

.query-row {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
  gap: 12px;
  align-items: start;
}

.query-row > div {
  min-width: 0;
}

.query-row strong {
  display: block;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.45;
}

.query-row small {
  color: var(--muted);
  display: block;
  overflow-wrap: anywhere;
  word-break: normal;
}

.query-answer {
  margin: 10px 0 0;
  color: #344054;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.query-evidence {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-height: 160px;
  overflow: auto;
  border-left: 3px solid #dbeafe;
  padding-left: 12px;
}

.query-pages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.query-pages span {
  border-radius: 999px;
  background: #f2f4f7;
  color: #475467;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.toolbar {
  justify-content: flex-start;
  margin-bottom: 14px;
}

.toolbar label {
  width: 180px;
}

.task-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}

.task-column {
  display: grid;
  align-content: start;
  gap: 10px;
  background: rgba(238, 242, 246, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 240px;
}

.task-column h3 {
  margin: 0;
  font-size: 14px;
}

.task-card {
  display: grid;
  gap: 10px;
  box-shadow: none;
}

.task-card h4 {
  margin: 0;
  font-size: 15px;
}

.task-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.task-note {
  margin-bottom: 0;
  font-size: 12px;
}

.task-note textarea {
  min-height: 58px;
  padding: 8px;
  font-size: 12px;
}

.task-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.task-actions select {
  padding: 7px 8px;
  font-size: 12px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

@media (max-width: 1120px) {
  .workspace,
  .dashboard-grid,
  .pitch-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .header-actions,
  .two-col,
  .quick-signals,
  .dual-engine,
  .diagnostic-row,
  .tool-facts,
  .score-grid,
  .task-board {
    grid-template-columns: 1fr;
  }

  .tool-card-head {
    display: grid;
  }

  .header-actions {
    display: grid;
  }

  .workspace {
    padding: 16px;
  }

  .tabs {
    overflow-x: auto;
  }

  .domain-row,
  .query-row {
    grid-template-columns: 1fr;
  }
}
