:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --ink: #202421;
  --muted: #66706a;
  --line: #d8ded9;
  --line-strong: #b9c3bd;
  --accent: #9d392c;
  --accent-soft: #f7e7e3;
  --gold-soft: #fff3d6;
  --green-soft: #e4f3ee;
  --blue-soft: #e9eef5;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

.app-shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

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

.brand {
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: 0;
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.official-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.official-link {
  padding: 0 14px;
}

.compliance-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}

.compliance-notice strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}

.compliance-notice p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.compliance-notice a {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.source-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.source-status strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}

.source-status p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.source-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.category-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.panel-label {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.filter-button {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name count"
    "note count";
  align-items: center;
  gap: 2px 8px;
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.filter-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.filter-name {
  grid-area: name;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.filter-note {
  grid-area: note;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.filter-count {
  grid-area: count;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.rule-text {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: right;
}

.summary-band {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 10px;
}

.result-label,
.updated-at,
.item-type,
.card-meta,
.section-title {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-band h2 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.updated-at {
  text-align: right;
}

.ranking-panel {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.ranking-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.ranking-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: right;
}

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

.ranking-card {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.ranking-rank {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.ranking-content {
  min-width: 0;
}

.ranking-content h3 {
  margin: 0 0 7px;
  font-size: 15px;
  line-height: 1.3;
  letter-spacing: 0;
}

.ranking-meta {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.ranking-content p {
  margin: 0;
  color: #2d3430;
  font-size: 13px;
  line-height: 1.5;
}

.insight-grid {
  display: grid;
  gap: 10px;
}

.insight-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card-head {
  display: grid;
  gap: 4px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.item-type {
  color: var(--accent);
}

.card-head h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: 0;
}

.card-body {
  display: grid;
  gap: 12px;
  padding: 12px 14px;
}

.price-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.price-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: #33475f;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.price-badge.divine {
  background: var(--gold-soft);
  color: #6d4a08;
}

.price-badge.exalted {
  background: var(--green-soft);
  color: #155747;
}

.price-badge.chaos {
  background: var(--blue-soft);
  color: #33475f;
}

.mod-list,
.reason-list {
  display: grid;
  gap: 6px;
  margin: 7px 0 0;
  padding-left: 18px;
  color: #2d3430;
  font-size: 14px;
  line-height: 1.55;
}

.mod-list {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f9faf8;
  list-style: none;
}

.mod-list li {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  align-items: start;
}

.mod-list span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.empty-state {
  margin-top: 12px;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.legal-page {
  display: grid;
  gap: 12px;
}

.legal-section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.legal-section h2 {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: 0;
}

.legal-section p {
  margin: 0 0 10px;
  color: #2d3430;
  font-size: 14px;
  line-height: 1.7;
}

.legal-section ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
  color: #2d3430;
  font-size: 14px;
  line-height: 1.6;
}

.legal-section a {
  color: var(--accent);
  font-weight: 700;
}

.legal-lead {
  border-left: 4px solid var(--accent);
}

.legal-updated {
  color: var(--muted);
  font-size: 12px;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

.footer p {
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 12px;
  font-weight: 700;
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 16px;
  }

  .topbar,
  .compliance-notice,
  .source-status,
  .panel-head,
  .ranking-head,
  .summary-band,
  .footer {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rule-text,
  .ranking-note,
  .source-meta {
    text-align: left;
  }

  .source-meta {
    white-space: normal;
  }

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

  .official-link {
    width: 100%;
  }

  .updated-at {
    text-align: left;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 22px;
  }

  .category-panel {
    padding: 12px;
  }

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