:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --line: #d9e2ef;
  --primary: #126f74;
  --primary-dark: #0f595d;
  --error: #b42318;
  --navy: #12304a;
  --mint: #d8f4eb;
  --amber: #e9a23b;
  --font-cjk: "PingFang TC", "Heiti TC", "Microsoft JhengHei", "Noto Sans CJK TC", "Noto Sans TC", "Arial Unicode MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-cjk);
  color: var(--text);
  background: var(--bg);
}

.shell {
  width: min(960px, calc(100% - 32px));
  margin: 48px auto;
  display: flex;
  flex-direction: column;
}

.panel,
.result-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 12px 30px rgba(31, 41, 55, 0.08);
}

.result-section {
  margin-top: 24px;
}

h1,
h2 {
  margin: 0 0 20px;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 22px;
}

.crawl-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  font-size: 16px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  color: #fff;
  background: var(--primary);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--primary-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.status-box {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.share-panel,
.email-form {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #b9e0d6;
  border-radius: 10px;
  background: #f4fcf9;
}

.share-panel strong,
.email-form label { display: block; color: var(--navy); font-weight: 700; }
.share-panel p,
.email-form p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.share-row,
.email-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 12px; align-items: center; }
.share-row a { min-width: 0; overflow-wrap: anywhere; color: var(--primary); font-size: 13px; }
.compact-button { min-height: 38px; padding: 0 14px; font-size: 14px; }
.email-message { min-height: 20px; }
.email-message.success { color: var(--primary-dark); font-weight: 700; }
.email-message.error { color: var(--error); font-weight: 700; }

.status-box p {
  margin: 8px 0;
  overflow-wrap: anywhere;
}

.loading-panel {
  margin: 16px 0 4px;
  padding: 17px;
  border: 1px solid #b9e0d6;
  border-radius: 12px;
  background: linear-gradient(135deg, #f1fffa, #f8fbff);
}

.loading-heading { display: flex; align-items: flex-start; gap: 12px; }
.loading-heading strong { display: block; color: var(--navy); font-size: 15px; }
.loading-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.loading-spinner { width: 19px; height: 19px; flex: 0 0 19px; margin-top: 2px; border: 3px solid #b9e0d6; border-top-color: var(--primary); border-radius: 50%; animation: spin 900ms linear infinite; }
.loading-track { position: relative; height: 22px; margin: 16px 0 10px; overflow: hidden; border-radius: 999px; background: #dbece8; }
.loading-track span { display: block; width: 5%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #5fc8a4); transition: width 500ms ease; }
.loading-track strong { position: absolute; inset: 0; display: grid; place-items: center; color: #12304a; font-size: 11px; line-height: 1; }
.loading-stats { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 12px; color: #45606a; font-size: 12px; font-weight: 700; }

@keyframes spin { to { transform: rotate(360deg); } }

.muted {
  color: var(--muted);
}

.group-summary p { margin-bottom: 4px; }
.group-detail-list { padding-left: 1em; white-space: pre-line; line-height: 1.65; }

.error {
  color: var(--error);
  font-weight: 700;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
}

.section-heading h3 {
  font-size: 18px;
}

.report-header {
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.report-header h2 {
  margin: 3px 0 8px;
  color: var(--navy);
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.25;
}

.report-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
}

.report-actions {
  margin-bottom: 14px;
}

.score-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
  margin: 0 0 30px;
}

.score-hero {
  min-height: 220px;
  padding: 28px;
  display: flex;
  align-items: center;
  gap: 28px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(125deg, #12304a, #126f74);
  box-shadow: 0 16px 32px rgba(18, 48, 74, .18);
}

.score-ring {
  width: 150px;
  height: 150px;
  flex: 0 0 150px;
  padding: 10px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#9ae4ce var(--score-angle, 0%), rgba(255, 255, 255, .2) 0);
}

.score-ring > div {
  width: 100%;
  height: 100%;
  display: grid;
  place-content: center;
  text-align: center;
  border-radius: 50%;
  background: var(--navy);
}

.score-ring strong { font-size: 48px; line-height: 1; }
.score-ring span, .score-copy p { color: rgba(255, 255, 255, .72); }
.score-copy h3 { margin: 6px 0 10px; font-size: 26px; }
.score-copy .score-label { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .08em; }
.score-copy .score-notice { margin: 0; max-width: 370px; font-size: 14px; line-height: 1.6; }

.score-card {
  padding: 24px;
  border: 1px solid #c9e8df;
  border-radius: 16px;
  background: linear-gradient(145deg, #f4fffb, #e4f8f0);
}

.score-card span,
.score-card small {
  display: block;
  color: var(--muted);
}

.score-card strong {
  display: inline-block;
  margin-top: 8px;
  color: var(--navy);
  font-size: 42px;
  line-height: 1;
}

.score-card small { margin-top: 8px; }

.dimension-section, .priority-section { margin: 0 0 30px; }
.section-heading { margin-bottom: 14px; }
.section-heading h3 { margin-top: 3px; color: var(--navy); font-size: 20px; }

.dimension-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.dimension-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdff; }
.dimension-card > div:first-child { display: grid; grid-template-columns: 1fr auto auto; gap: 4px; align-items: baseline; }
.dimension-card span { color: #42556b; font-size: 14px; font-weight: 700; }
.dimension-card strong { color: var(--navy); font-size: 25px; }
.dimension-card small, .dimension-card p { color: var(--muted); font-size: 12px; }
.dimension-card p { margin: 10px 0 0; }
.score-bar { height: 7px; margin-top: 14px; overflow: hidden; border-radius: 999px; background: #e7eef3; }
.score-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #126f74, #5fc8a4); }

.priority-list { display: grid; gap: 9px; }
.priority-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 15px 17px; border: 1px solid #f1d9ca; border-radius: 11px; background: #fffaf7; }
.priority-number { color: #a65025; font-size: 13px; font-weight: 800; }
.priority-item h4 { margin: 0 0 4px; color: #482e25; font-size: 15px; }
.priority-item p { margin: 0; color: #806b61; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.priority-item > strong { color: #b74419; font-size: 22px; }
.empty-priority { margin: 0; padding: 18px; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }

#resultSection { order: 2; }
#reportSection { order: 3; }

.print-button {
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

.report-table th,
.report-table td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.report-table th {
  background: #e9eef6;
  color: #334155;
  font-weight: 700;
}

.report-table th:nth-child(1),
.report-table td:nth-child(1) {
  width: 22%;
}

.report-table th:nth-child(2),
.report-table td:nth-child(2) {
  width: 18%;
}

.report-table th:nth-child(3),
.report-table td:nth-child(3) {
  width: 27%;
}

.report-table th:nth-child(4),
.report-table td:nth-child(4) {
  width: 33%;
}

.page-url {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9em;
}

.finding-description,
.finding-standard,
.finding-recommendation {
  margin: 0;
}

.finding-standard {
  margin-top: 8px;
  color: #53687a;
  font-size: 0.9em;
}

.finding-recommendation {
  color: #203f55;
  font-weight: 600;
}

.report-content {
  margin: 0;
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfdff;
  color: var(--text);
  font-family: var(--font-cjk);
  line-height: 1.65;
}

code {
  width: fit-content;
  max-width: 100%;
  border-radius: 4px;
  padding: 3px 6px;
  background: #e9eef6;
  color: #334155;
  overflow-wrap: anywhere;
}

.hidden {
  display: none;
}

.decision-modal { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(18, 48, 74, .48); }
.decision-modal.hidden { display: none; }
.decision-dialog { width: min(600px, 100%); padding: 30px; border-radius: 16px; background: #fff; box-shadow: 0 24px 70px rgba(15, 35, 54, .28); }
.decision-dialog h2 { margin: 6px 0 12px; color: var(--navy); font-size: 25px; }
.decision-dialog > p:not(.eyebrow) { margin: 0; color: #53687a; line-height: 1.7; }
.decision-url-list { max-height: 160px; margin: 18px 0; padding: 12px 14px 12px 32px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; background: #f8fbfc; color: #45606a; font-size: 13px; line-height: 1.65; }
.decision-url-list li { overflow-wrap: anywhere; }
.decision-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.decision-actions button { min-height: 70px; line-height: 1.35; }
.decision-actions button small { display: block; margin-top: 4px; font-size: 11px; font-weight: 400; opacity: .85; }
.secondary-button { color: var(--primary); border: 1px solid var(--primary); background: #fff; }
.secondary-button:hover:not(:disabled) { color: #fff; background: var(--primary); }

@media (max-width: 680px) {
  .shell {
    margin: 24px auto;
  }

  .panel,
  .result-section {
    padding: 20px;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .share-row,
  .email-row { grid-template-columns: 1fr; }

  button {
    width: 100%;
  }

  .score-section { grid-template-columns: 1fr; }
  .score-hero { min-height: auto; padding: 22px; gap: 18px; }
  .score-ring { width: 112px; height: 112px; flex-basis: 112px; }
  .score-ring strong { font-size: 35px; }
  .score-copy h3 { font-size: 20px; }
  .dimension-grid { grid-template-columns: 1fr; }
  .decision-actions { grid-template-columns: 1fr; }
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  html,
  body {
    background: #fff;
    font-family: "PingFang TC", "Heiti TC", "Microsoft JhengHei", "Noto Sans CJK TC", "Noto Sans TC", "Arial Unicode MS", sans-serif !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .report-header,
  .report-table,
  .report-table th,
  .report-table td {
    font-family: inherit !important;
  }

  .panel,
  #debugSection,
  #reportSection,
  .report-actions .print-button {
    display: none !important;
  }

  .shell {
    width: 100%;
    margin: 0;
  }

  .result-section {
    margin: 0;
    padding: 18mm 14mm;
    border: 0;
    box-shadow: none;
  }

  .report-header {
    margin-bottom: 12mm;
    padding-bottom: 8mm;
  }

  .report-header h2 {
    font-size: 24px;
  }

  .report-header p {
    font-size: 11px;
  }

  .section-heading {
    display: block;
    margin-bottom: 6mm;
  }

  .table-wrap {
    overflow: visible;
  }

  .report-table {
    font-size: 11px;
  }

  .report-table th,
  .report-table td {
    padding: 7px;
  }
}
