@layer reset, tokens, base, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { -webkit-text-size-adjust: 100%; }
  body { line-height: 1.6; -webkit-font-smoothing: antialiased; }
  img, svg { display: block; max-width: 100%; }
  table { border-collapse: collapse; width: 100%; }
  h1, h2, h3, h4 { line-height: 1.25; }
  a { color: inherit; }
}

@layer tokens {
  :root {
    color-scheme: light;
    --bg: #fafaf9;
    --surface: #ffffff;
    --surface-muted: #f5f5f4;
    --border: #e7e5e4;
    --border-strong: #d6d3d1;
    --fg: #1c1917;
    --fg-muted: #57534e;
    --fg-subtle: #78716c;
    --accent: #0f766e;
    --accent-soft: #ccfbf1;
    --warn: #b45309;
    --warn-soft: #fef3c7;
    --bad: #b91c1c;
    --bad-soft: #fee2e2;
    --good: #15803d;
    --good-soft: #dcfce7;
    --gold: #ca8a04;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
    --maxw: 1080px;
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Pretendard", system-ui, sans-serif;
  }
}

@layer base {
  body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    font-size: 15px;
  }
  main {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 32px 24px 80px;
  }
  h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
  h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.005em; margin: 36px 0 14px; }
  h3 { font-size: 16px; font-weight: 650; margin: 18px 0 8px; }
  p { margin: 0 0 10px; color: var(--fg-muted); }
  ul, ol { margin: 6px 0 10px; padding-left: 22px; color: var(--fg-muted); }
  li { margin: 3px 0; }
  strong { color: var(--fg); font-weight: 600; }
  code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.92em; background: var(--surface-muted); padding: 1px 5px; border-radius: 4px; }
}

@layer components {
  header.hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 26px;
    box-shadow: var(--shadow);
  }
  header.hero .eyebrow {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 3px 10px;
    border-radius: 999px;
    letter-spacing: 0.02em;
  }
  header.hero h1 { margin: 10px 0 8px; }
  header.hero .meta {
    color: var(--fg-subtle);
    font-size: 13px;
    margin-top: 6px;
  }
  header.hero .meta span + span::before { content: " · "; }

  .summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin: 18px 0 0;
  }
  .summary .card {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
  }
  .summary .card .label {
    font-size: 11px;
    color: var(--fg-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .summary .card .value {
    font-size: 15px;
    font-weight: 600;
    color: var(--fg);
    margin-top: 2px;
  }

  section.block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 26px;
    margin-top: 18px;
    box-shadow: var(--shadow);
  }

  table {
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
  }
  thead {
    background: var(--surface-muted);
  }
  th, td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
  }
  tbody tr:last-child td { border-bottom: none; }
  td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
  td.score { font-weight: 600; }

  .rank {
    display: inline-block;
    min-width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--fg-muted);
  }
  .rank.rank-1 { background: #fef3c7; color: var(--gold); }
  .rank.rank-2 { background: #e5e7eb; color: #525252; }
  .rank.rank-3 { background: #fde68a; color: #92400e; }

  .badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--fg-muted);
  }
  .badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
  .badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
  .badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

  .grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  @container (max-width: 640px) {
    .grid-2 { grid-template-columns: 1fr; }
  }

  .option {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    background: var(--surface);
  }
  .option header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
  }
  .option header h3 { margin: 0; }
  .option header .score-tag {
    font-size: 12px;
    color: var(--fg-subtle);
    font-variant-numeric: tabular-nums;
  }
  .option .pro-con {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
  }
  .option .pro-con > div h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-subtle);
    margin: 4px 0 4px;
    font-weight: 600;
  }
  .option .pro-con ul { padding-left: 18px; font-size: 13px; }

  details {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-top: 8px;
    background: var(--surface-muted);
  }
  details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--fg);
  }
  details summary::-webkit-details-marker { color: var(--fg-subtle); }
  details > *:not(summary) { margin-top: 8px; }

  .recommend {
    background: linear-gradient(180deg, var(--accent-soft) 0%, #fff 70%);
    border: 1px solid #99f6e4;
  }
  .recommend h2 { color: var(--accent); }

  .note-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 14px;
    padding: 8px 0;
    border-top: 1px dashed var(--border);
    font-size: 14px;
  }
  .note-row:first-of-type { border-top: none; }
  .note-row .label { color: var(--fg-subtle); font-weight: 600; }

  footer.sources {
    margin-top: 28px;
    font-size: 12px;
    color: var(--fg-subtle);
  }
  footer.sources ol { padding-left: 18px; }
  footer.sources a { color: var(--accent); text-decoration: none; }
  footer.sources a:hover { text-decoration: underline; }
}

@layer utilities {
  .muted { color: var(--fg-subtle); }
  .small { font-size: 12px; }
  .mt-0 { margin-top: 0 !important; }
}
