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

:root {
  --color-primary: #0F172A;
  --color-secondary: #1E293B;
  --color-cta: #22C55E;
  --color-cta-soft: rgba(34,197,94,0.12);
  --color-background: #020617;
  --color-text: #F8FAFC;
  --color-muted: #94A3B8;
  --color-border: #1E293B;
  --color-card: #0B1220;
  --color-card-hover: #0f1a2e;
  --color-danger: #F87171;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --radius: 14px;
  --shadow-md: 0 8px 24px rgba(0,0,0,0.28);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.35);
  --max: 1120px;
  --reader-max: 42rem;
  --header-h: 3.6rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(34,197,94,0.08), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(56,189,248,0.05), transparent 50%),
    var(--color-background);
  color: var(--color-text);
  font-family: "Noto Sans SC", system-ui, sans-serif;
  line-height: 1.65;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; cursor: pointer; }
a:hover { color: var(--color-cta); }
button, .btn {
  cursor: pointer;
  font: inherit;
  border: 0;
  border-radius: 10px;
  transition: transform 160ms ease, filter 160ms ease, background 160ms ease, border-color 160ms ease;
}
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--color-cta);
  outline-offset: 2px;
}
.container {
  width: min(100% - 2rem, var(--max));
  margin: 0 auto;
}
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(14px) saturate(1.2);
  background: rgba(2,6,23,0.82);
  border-bottom: 1px solid rgba(30,41,59,0.95);
}
.site-header .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-height: var(--header-h);
  padding: 0.75rem 0;
}
.brand {
  font-family: "Noto Serif SC", serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.brand span { color: var(--color-cta); }
.nav {
  display: flex;
  gap: 0.55rem 0.85rem;
  align-items: center;
  color: var(--color-muted);
  font-size: 0.92rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nav a {
  padding: 0.28rem 0.45rem;
  border-radius: 8px;
}
.nav a:hover {
  background: rgba(148,163,184,0.08);
  color: var(--color-text);
}
.hero {
  padding: clamp(1.4rem, 3vw, 2.4rem) 0 1.1rem;
}
.hero h1 {
  font-family: "Noto Serif SC", serif;
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  margin: 0 0 0.45rem;
  letter-spacing: 0.01em;
}
.hero p {
  color: var(--color-muted);
  margin: 0;
  max-width: 42rem;
  font-size: 0.98rem;
}
.search-bar {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  max-width: 42rem;
  flex-wrap: wrap;
}
.search-bar input[type="search"],
input[type="search"] {
  flex: 1 1 16rem;
  min-width: 0;
  padding: 0.82rem 0.95rem;
  border-radius: 12px;
  border: 1px solid #334155;
  background: rgba(2,6,23,0.9);
  color: var(--color-text);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.search-bar input[type="search"]:focus,
input[type="search"]:focus {
  border-color: rgba(34,197,94,0.55);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
}
.reader-controls {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}
.rules-content h1, .rules-content h2, .rules-content h3 {
  font-family: "Noto Serif SC", serif;
}
.rules-content pre {
  background: #020617;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 0.95rem;
  overflow-x: auto;
  line-height: 1.55;
}
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-md);
  padding-bottom: calc(var(--space-2xl) + var(--safe-bottom));
}
.section-title {
  grid-column: 1 / -1;
  font-family: "Noto Serif SC", serif;
  font-size: 1.12rem;
  margin: var(--space-lg) 0 var(--space-sm);
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, #1e293b, transparent);
  transform: translateY(-0.15rem);
}
.card {
  grid-column: span 6;
  background: linear-gradient(180deg, rgba(15,23,42,0.55), rgba(11,18,32,0.95));
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow-md);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease;
  min-height: 8.5rem;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: #334155;
  background: var(--color-card-hover);
}
.card h3 {
  font-family: "Noto Serif SC", serif;
  font-size: 1.08rem;
  margin: 0 0 0.5rem;
  line-height: 1.35;
}
.card h3 a:hover { color: var(--color-cta); }
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: #111827;
  border: 1px solid #243044;
  color: var(--color-muted);
  font-size: 0.76rem;
  line-height: 1.2;
}
.tag.accent {
  color: #86efac;
  border-color: rgba(34,197,94,0.35);
  background: var(--color-cta-soft);
}
a.tag:hover {
  color: #bbf7d0;
  border-color: rgba(34,197,94,0.5);
}
.summary {
  color: var(--color-muted);
  font-size: 0.92rem;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(100%, 430px);
  background: rgba(11,18,32,0.96);
  border: 1px solid var(--color-border);
  border-radius: 18px;
  padding: 1.7rem;
  box-shadow: var(--shadow-lg);
}
.login-card h1 {
  font-family: "Noto Serif SC", serif;
  font-size: 1.5rem;
  margin: 0 0 0.35rem;
}
.login-card .sub {
  color: var(--color-muted);
  margin: 0 0 1.2rem;
  font-size: 0.92rem;
}
label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 0.82rem 0.95rem;
  border-radius: 12px;
  border: 1px solid #334155;
  background: #020617;
  color: var(--color-text);
}
.btn-primary {
  width: 100%;
  margin-top: 1.1rem;
  padding: 0.88rem 1rem;
  background: var(--color-cta);
  color: #052e16;
  font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--color-muted);
  border: 1px solid #334155;
  padding: 0.42rem 0.8rem;
  border-radius: 10px;
}
.btn-ghost:hover {
  color: var(--color-text);
  border-color: #475569;
  background: rgba(148,163,184,0.06);
}
.error {
  color: var(--color-danger);
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.25);
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.reader-shell {
  width: min(100% - 2rem, calc(var(--reader-max) + 15rem));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 14rem 1fr;
  gap: 1.25rem;
  padding: 1.25rem 0 calc(3rem + var(--safe-bottom));
}
.toc {
  position: sticky;
  top: 4.6rem;
  align-self: start;
  background: rgba(11,18,32,0.95);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.95rem;
  max-height: calc(100vh - 6rem);
  overflow: auto;
}
.toc h2 {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin: 0 0 0.6rem;
  font-weight: 500;
}
.toc a {
  display: block;
  padding: 0.4rem 0.45rem;
  border-radius: 8px;
  color: var(--color-muted);
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}
.toc a.active, .toc a:hover {
  background: #111827;
  color: var(--color-text);
}
.reader {
  background: rgba(11,18,32,0.96);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 2rem);
  box-shadow: var(--shadow-md);
}
.reader header h1 {
  font-family: "Noto Serif SC", serif;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  margin: 0 0 0.5rem;
}
.reader .content {
  font-size: clamp(1.04rem, 0.98rem + 0.4vw, 1.15rem);
  line-height: 1.98;
  max-width: var(--reader-max);
  word-break: break-word;
  overflow-wrap: anywhere;
  letter-spacing: 0.012em;
}
.reader .content p {
  margin: 0 0 1.08em;
  text-align: justify;
  text-justify: inter-ideograph;
}
.reader .content p:last-child { margin-bottom: 0; }
.reader .content h1, .reader .content h2, .reader .content h3 {
  font-family: "Noto Serif SC", serif;
  line-height: 1.35;
  margin: 1.4em 0 0.7em;
}
.reader .content blockquote {
  margin: 1em 0;
  padding: 0.25em 0 0.25em 0.95em;
  border-left: 3px solid rgba(34,197,94,0.45);
  color: #cbd5e1;
}
.reader .content pre, .reader .content code {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
}
.back-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.95rem;
  align-items: center;
}
.empty {
  grid-column: 1 / -1;
  color: var(--color-muted);
  padding: 1rem 0 2rem;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--color-muted);
  font-size: 0.86rem;
}
@media (max-width: 860px) {
  .card { grid-column: span 12; }
  .reader-shell {
    width: min(100% - 1rem, calc(var(--reader-max) + 14rem));
    grid-template-columns: 1fr;
    gap: 0.85rem;
    padding: 0.85rem 0 calc(2.2rem + var(--safe-bottom));
  }
  .toc {
    position: relative;
    top: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    max-height: none;
    overflow: visible;
  }
  .toc h2 {
    width: 100%;
    margin-bottom: 0.2rem;
  }
  .toc a {
    display: inline-block;
    padding: 0.35rem 0.55rem;
    background: #111827;
    margin-bottom: 0;
  }
  .reader {
    padding: 1rem 0.95rem 1.35rem;
    border-radius: 12px;
  }
  .reader header h1 { font-size: 1.35rem; }
  .reader .content {
    font-size: 1.06rem;
    line-height: 1.98;
  }
  .site-header .inner { padding: 0.7rem 0; }
  .hero { padding: 1.25rem 0 0.9rem; }
  .nav { gap: 0.35rem 0.55rem; font-size: 0.86rem; }
}
@media (max-width: 480px) {
  .container { width: min(100% - 1rem, var(--max)); }
  .reader .content {
    font-size: 1.05rem;
    line-height: 2.0;
  }
  .tag { font-size: 0.72rem; }
  .brand { font-size: 0.98rem; }
  .card { padding: 1rem; min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
@media (hover: none) {
  .card:hover { transform: none; }
}
