@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600;700;800&family=Inter:wght@400;500;600;700&family=Noto+Sans+TC:wght@400;500;700&display=swap');

:root {
  --color-primary:       #5333A6;
  --color-primary-dark:  #452A93;
  --color-primary-light: #7A52C5;
  --color-accent:        #B47EDB;
  --color-electric:      #6843BB;

  --color-bg:             #FFFFFF;
  --color-bg-soft:        #F7F3FC;
  --color-surface:        #FFFFFF;
  --color-surface-purple: #F0E8FA;
  --color-border:         #E6DEF2;
  --color-hover:          #F4EDFB;

  --color-text-main:      #1F1744;
  --color-text-secondary: #5F567A;
  --color-text-muted:     #8B82A8;
  --color-text-purple:    #5333A6;

  --gradient-primary: linear-gradient(135deg, #5333A6 0%, #7A52C5 55%, #B47EDB 100%);
  --gradient-soft:    linear-gradient(135deg, #F7F3FC 0%, #EFE5FA 45%, #FFFFFF 100%);
  --gradient-dark:    linear-gradient(135deg, #452A93 0%, #5333A6 45%, #7A52C5 100%);

  --shadow-purple: 0 16px 40px rgba(83, 51, 166, 0.14);
  --shadow-soft:   0 8px 24px rgba(69, 42, 147, 0.10);

  --radius-card:   24px;
  --radius-button: 16px;

  --red: #c2413b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 8%,  rgba(180,126,219,.20) 0%, transparent 35%),
    radial-gradient(circle at 85% 5%,  rgba(180,126,219,.12) 0%, transparent 30%),
    linear-gradient(180deg, #FFFFFF 0%, #F7F3FC 100%);
  color: var(--color-text-main);
  font-family: 'Inter', 'Noto Sans TC', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

/* ── layout ── */

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 32px auto;
  display: grid;
  grid-template-columns: minmax(320px, 460px) 1fr;
  gap: 20px;
}

.shell:has(.result-panel #result[hidden]) {
  grid-template-columns: minmax(320px, 460px);
  justify-content: center;
}

.panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 28px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.result-panel:has(#result[hidden]) {
  display: none;
}

/* ── brand ── */

.brand,
.score-row,
.dim-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo-img {
  height: 52px;
  width: auto;
  display: block;
  margin-bottom: 12px;
}

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

h1, h2 {
  margin: 0;
}

h1 {
  font-family: 'Poppins', 'Noto Sans TC', sans-serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-main);
}

.lede {
  max-width: 320px;
  margin: 10px 0 0;
  color: var(--color-text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-main);
}

.badge,
.risk {
  background: var(--color-surface-purple);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 7px 14px;
  color: var(--color-text-purple);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.risk--high {
  background: #fff1f1;
  border-color: #f87171;
  color: #c00;
  font-size: 14px;
}

.risk--medium {
  background: #fff7ed;
  border-color: #fb923c;
  color: #c2550a;
  font-size: 14px;
}

.risk--low {
  background: #f0fdf4;
  border-color: #4ade80;
  color: #16a34a;
  font-size: 14px;
}

/* ── form ── */

form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 700;
}

label span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

label small {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 400;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 11px 14px;
  color: var(--color-text-main);
  font: inherit;
  background: var(--color-bg-soft);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

input:focus,
textarea:focus {
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(83, 51, 166, 0.10);
  background: #fff;
}

textarea {
  resize: vertical;
}

.combo-list {
  position: absolute;
  top: calc(100% - 6px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 100;
  -webkit-overflow-scrolling: touch;
}

.combo-list li {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--color-text-main);
  cursor: pointer;
}

.combo-list li:hover,
.combo-list li.combo-active {
  background: var(--color-bg-soft);
  color: var(--color-primary);
}

.hint {
  margin: -2px 0 0;
  color: var(--color-text-muted);
  font-size: 13px;
}

button {
  height: 48px;
  border: 0;
  border-radius: var(--radius-button);
  background: var(--gradient-primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(83, 51, 166, 0.22);
  transition: opacity 0.15s, transform 0.15s;
}

button:hover:not(:disabled) {
  opacity: .90;
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  opacity: .60;
  cursor: wait;
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.penalty-banner {
  background: #fff4f4;
  border: 1.5px solid #f5a9a9;
  border-left: 5px solid #c2413b;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13.5px;
  color: #7a1a1a;
  line-height: 1.6;
}
.penalty-banner strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
  color: #c2413b;
}

.empty {
  min-height: 520px;
  display: grid;
  place-items: center;
  color: var(--color-text-muted);
  text-align: center;
}

/* ── score ── */

.score {
  font-family: 'Poppins', sans-serif;
  font-size: 54px;
  font-weight: 800;
  line-height: 1;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score small {
  font-family: 'Inter', sans-serif;
  font-size: 20px;
  font-weight: 500;
  -webkit-text-fill-color: var(--color-text-muted);
}

/* ── radar ── */

.radar-card {
  margin: 22px 0 18px;
  padding: 20px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background:
    radial-gradient(circle at top right, rgba(180,126,219,.14), transparent 50%),
    var(--color-bg-soft);
}

.radar-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.radar-title span {
  color: var(--color-text-muted);
  font-size: 12px;
}

.radar-chart {
  width: min(100%, 460px);
  margin: 0 auto;
  aspect-ratio: 1;
}

.radar-chart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.radar-grid {
  fill: none;
  stroke: #D8C8F0;
  stroke-width: 1;
}

.radar-grid-outer {
  stroke: #C4ACE8;
  stroke-width: 1.5;
}

.radar-axis {
  stroke: #E2D4F5;
  stroke-width: 1;
}

.radar-score {
  fill: rgba(83, 51, 166, 0.16);
  stroke: var(--color-primary);
  stroke-width: 2.5;
}

.radar-dot {
  fill: var(--color-accent);
  stroke: #fff;
  stroke-width: 2;
}

.radar-label text:first-child {
  fill: var(--color-text-main);
  font-size: 13px;
  font-weight: 800;
}

.radar-label text:nth-child(2) {
  fill: var(--color-text-secondary);
  font-size: 10px;
  font-weight: 600;
}

.radar-label text:last-child {
  fill: var(--color-text-muted);
  font-size: 11px;
  font-weight: 700;
}

/* ── dimensions ── */

.dimensions {
  display: grid;
  gap: 12px;
  margin: 22px 0;
}

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

.dim-top {
  font-size: 14px;
  font-weight: 600;
}

.dim-top span {
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 500;
}

.bar {
  height: 9px;
  overflow: hidden;
  background: var(--color-surface-purple);
  border-radius: 999px;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--gradient-primary);
  border-radius: inherit;
}

.dim-problems {
  margin: 4px 0 0;
  padding-left: 18px;
  list-style: disc;
  display: grid;
  gap: 3px;
}

.dim-problems li {
  font-size: 12px;
  color: var(--color-text-secondary);
  line-height: 1.55;
  margin: 0;
}

.dim-ok {
  margin: 4px 0 0;
  font-size: 12px;
  color: #4a8c5c;
  font-weight: 500;
}

/* ── sections ── */

.section {
  border-top: 1px solid var(--color-border);
  padding-top: 18px;
  margin-top: 18px;
}

ol {
  margin: 12px 0 0;
  padding-left: 22px;
  color: var(--color-text-secondary);
  line-height: 1.7;
}

li + li {
  margin-top: 8px;
}

pre {
  overflow: auto;
  margin: 12px 0 0;
  padding: 14px;
  background: #1F1744;
  color: #E6DEF2;
  border-radius: 14px;
  font-size: 12px;
}

/* ── keyword chips ── */

.kw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.kw-overall {
  background: var(--color-surface-purple);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px 12px;
  color: var(--color-text-purple);
  font-size: 12px;
  font-weight: 700;
}

.kw-categories {
  display: grid;
  gap: 14px;
}

.kw-cat {
  display: grid;
  gap: 7px;
}

.kw-cat-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kw-cat-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-secondary);
}

.kw-cat-count {
  font-size: 12px;
  color: var(--color-text-muted);
}

.kw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.kw-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.kw-hit {
  background: rgba(83, 51, 166, 0.12);
  color: var(--color-primary);
  border: 1.5px solid rgba(122, 82, 197, 0.40);
  box-shadow: 0 2px 8px rgba(83, 51, 166, 0.09);
}

.kw-miss {
  background: var(--color-bg-soft);
  color: var(--color-text-muted);
  border: 1.5px solid var(--color-border);
  opacity: 0.55;
}

/* ── responsive ── */

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }
}
