@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;600;700&family=Playfair+Display:wght@400;600;700;800&family=Source+Sans+3:wght@300;400;500;600;700&display=swap");

:root {
  color-scheme: light;

  --color-bg: #FAFAF8;
  --color-bg-soft: #F5F2EC;
  --color-surface: #FCFBF9;
  --color-surface-raised: #FFFFFF;
  --color-border: #EBE6DF;
  --color-border-strong: #D8D1C7;
  --color-accent: #B8860B;
  --color-accent-strong: #8B6508;
  --color-text: #1A1A1A;
  --color-text-soft: #2A2A2A;
  --color-muted: #6B6B6B;
  --color-dim: #8A8785;

  --layer-1: oklch(52% 0.20 68);
  --layer-2: oklch(44% 0.22 255);
  --layer-3: oklch(42% 0.20 155);
  --layer-4: oklch(48% 0.25 315);
  --layer-5: oklch(50% 0.22 35);

  --radius-sm: 3px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(26, 26, 26, 0.025);
  --shadow-md:
    0 1px 2px rgba(26, 26, 26, 0.025),
    0 12px 32px -22px rgba(26, 26, 26, 0.20);

  --font-sans: "Source Sans 3", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Heiti SC", system-ui, sans-serif;
  --font-serif: "Playfair Display", "Songti SC", "Noto Serif SC", "SimSun", Georgia, serif;
  --font-mono: "IBM Plex Mono", Menlo, Monaco, Consolas, monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  --page-x: clamp(16px, 4vw, 32px);
  --content-max: 1180px;

  --bg: var(--color-bg);
  --paper: var(--color-surface);
  --surface: var(--color-surface-raised);
  --surface2: var(--color-bg-soft);
  --surface3: #EEEAE3;
  --border: var(--color-border);
  --border-hair: var(--color-border);
  --border-ink: var(--color-border-strong);
  --ink: var(--color-text);
  --text: var(--color-text);
  --text-muted: var(--color-muted);
  --text-dim: var(--color-dim);
  --text-faint: #B8B5B0;
  --accent: var(--color-accent);
  --font: var(--font-sans);
  --display: var(--font-serif);
  --mono: var(--font-mono);
  --font-body: var(--font-sans);
  --font-display: var(--font-serif);
  --radius: var(--radius-sm);
  --max-w: 880px;
  --l1: var(--layer-1);
  --l2: var(--layer-2);
  --l3: var(--layer-3);
  --l4: var(--layer-4);
  --l5: var(--layer-5);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--color-bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(14px, 1.6vw, 16px);
  line-height: 1.65;
  color: var(--color-text);
  background:
    radial-gradient(var(--color-border) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

button,
a,
[role="button"],
summary {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #B8B5B0;
  border-radius: var(--radius-pill);
}

.page-shell {
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

.page-container {
  width: min(100%, var(--content-max));
  margin-inline: auto;
  padding-inline: var(--page-x);
}

.nav-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 56px;
  padding: 10px var(--page-x);
  background: rgba(250, 250, 248, 0.94);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

.mr-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--color-text);
  text-decoration: none;
  flex: 0 0 auto;
}

.brand-mark,
.mr-logo {
  width: 28px;
  height: 28px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  flex: 0 0 auto;
}

.brand-mark span,
.mr-logo span {
  display: block;
  border-radius: 2px;
  background: var(--layer-1);
}

.brand-mark span:nth-child(2),
.mr-logo span:nth-child(2) {
  background: var(--color-accent);
}

.brand-mark span:nth-child(3),
.mr-logo span:nth-child(3) {
  background: var(--layer-3);
}

.brand-mark span:nth-child(4),
.mr-logo span:nth-child(4) {
  background: var(--layer-4);
}

.brand-mark span:nth-child(5),
.mr-logo span:nth-child(5) {
  background: var(--layer-5);
}

.mr-brand-copy {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.mr-brand-text {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: var(--color-text);
  white-space: nowrap;
}

.mr-brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-dim);
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  color: var(--color-muted);
  transition:
    color 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.nav-link:hover {
  color: var(--color-text);
  background: var(--color-surface);
  border-color: var(--color-border);
}

.nav-link:active {
  transform: translateY(1px);
}

.nav-link.active,
.nav-link[aria-current="page"] {
  color: var(--color-accent-strong);
  background: rgba(184, 134, 11, 0.08);
  border-color: rgba(184, 134, 11, 0.22);
}

.card {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.tag,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
}

.tag {
  padding: 4px 7px;
  border-radius: var(--radius-sm);
}

.pill {
  padding: 6px 10px;
  border-radius: var(--radius-pill);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.btn:hover {
  border-color: var(--color-border-strong);
  background: var(--color-bg-soft);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--color-text);
  border-color: var(--color-text);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--color-accent-strong);
  border-color: var(--color-accent-strong);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-3);
}

.report-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.report-item,
.report-list button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted);
  text-align: left;
}

.report-item:hover,
.report-list button:hover,
.report-list button.active {
  background: var(--color-surface);
  border-color: var(--color-border);
}

.report-list button.active {
  border-color: rgba(184, 134, 11, 0.45);
  color: var(--color-text);
}

.report-card {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.report-card:hover,
.report-card.active {
  background: var(--color-surface);
  border-color: var(--color-border);
}

.report-card.active {
  border-color: rgba(184, 134, 11, 0.45);
}

.report-card button {
  border-color: transparent;
  background: transparent;
}

.report-card button:hover,
.report-card button.active {
  border-color: transparent;
  background: transparent;
}

.report-export-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 12px 10px;
  color: var(--color-dim);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
}

.report-export-links a {
  color: var(--color-muted);
  text-decoration: none;
}

.report-export-links a:hover {
  color: var(--color-accent-strong);
}

.report-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.download-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: 2px;
}

.download-btn {
  white-space: nowrap;
}

.footer-watermark {
  color: var(--color-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.03em;
}

.mr-watermark {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 14px var(--page-x) calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--color-border);
  color: var(--color-dim);
  background: rgba(250, 250, 248, 0.82);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  opacity: 0.45;
}

.desktop-only {
  display: initial;
}

.mobile-only {
  display: none;
}

@media (max-width: 1024px) {
  .nav-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .nav {
    margin-left: 0;
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  :root {
    --page-x: 16px;
  }

  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: initial;
  }

  .nav-header {
    gap: 8px 12px;
    min-height: 0;
    padding-block: 9px;
  }

  .mr-brand {
    width: 100%;
  }

  .mr-brand-copy {
    flex-wrap: wrap;
    gap: 4px 8px;
  }

  .mr-brand-text {
    font-size: 17px;
  }

  .mr-brand-sub {
    font-size: 9px;
  }

  .nav {
    width: 100%;
    gap: 4px;
  }

  .nav-link {
    min-height: 32px;
    padding: 7px 8px;
    font-size: 10px;
  }

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

  .report-header-top {
    flex-direction: column;
  }

  .download-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 420px) {
  .nav-link {
    flex: 1 1 auto;
    min-width: calc(20% - 4px);
    padding-inline: 5px;
  }

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