:root {
  --ink: #f5f7fb;
  --ink-2: #dce2ec;
  --muted: #9ea8b7;
  --muted-2: #7f8a9c;
  --page: #0e1117;
  --paper: #171c25;
  --paper-2: #131821;
  --paper-3: #1b212c;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #ffbf66;
  --accent-2: #ff9e45;
  --accent-soft: rgba(255, 191, 102, 0.13);
  --mark: rgba(255, 191, 102, 0.24);
  --danger: #ff6b6b;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.26);
  --shadow-soft: 0 12px 28px rgba(0, 0, 0, 0.18);
  --radius: 18px;
  --sidebar: 318px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.light-mode {
  --ink: #151821;
  --ink-2: #252a36;
  --muted: #737b8b;
  --muted-2: #9aa2b2;
  --page: #f3f5f8;
  --paper: #ffffff;
  --paper-2: #f8f9fb;
  --paper-3: #eef2f7;
  --line: rgba(21, 24, 33, 0.10);
  --line-strong: rgba(21, 24, 33, 0.16);
  --accent-soft: rgba(255, 191, 102, 0.18);
  --mark: rgba(255, 191, 102, 0.32);
  --shadow: 0 18px 46px rgba(28, 35, 48, 0.10);
  --shadow-soft: 0 12px 28px rgba(28, 35, 48, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: var(--font);
  line-height: 1.72;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  color-scheme: dark;
}

body.light-mode { color-scheme: light; }
body::selection, *::selection { background: transparent; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }

.read-progress {
  position: fixed;
  inset: 0 auto auto 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 1000;
}

.page-shell {
  width: min(1280px, calc(100% - 44px));
  margin: 34px auto 42px;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 22px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.side-panel,
.document-cover,
.rule-section,
.limit-table-card,
.empty-state {
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-soft);
}

.side-panel {
  border-radius: 16px;
  padding: 17px;
}

.search-card label,
.side-panel h3 {
  display: block;
  margin: 0 0 10px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--paper-2);
}

.search-wrap span { color: var(--muted-2); font-size: 18px; }

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 14px;
}

.search-wrap input::placeholder { color: var(--muted-2); }

#searchMeta {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.controls-panel { display: grid; gap: 10px; }

.ghost-btn,
.ghost-link,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  width: 100%;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-2);
  background: var(--paper-2);
  font-size: 13px;
  font-weight: 800;
  transition: border-color .2s ease, transform .2s ease, background .2s ease;
}

.ghost-btn:hover,
.ghost-link:hover,
.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 158, 69, 0.34);
  background: var(--paper-3);
}

.theme-toggle {
  justify-content: flex-start;
  gap: 10px;
}

.theme-toggle__icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  box-shadow: inset -5px -2px 0 rgba(255, 191, 102, 0.28);
}

body.light-mode .theme-toggle__icon {
  background: var(--accent);
  box-shadow: none;
}

.toc-card ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.toc-link {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
  transition: color .2s ease, background .2s ease;
}

.toc-link .toc-no {
  color: var(--accent);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.toc-link .toc-title {
  color: inherit;
  font-weight: 750;
}

.toc-link:hover,
.toc-link.active {
  color: var(--ink);
  background: var(--paper-3);
}

body:not(.light-mode) .toc-link:hover .toc-title,
body:not(.light-mode) .toc-link.active .toc-title {
  color: #ffffff;
}

.def-item {
  padding: 12px;
  border-radius: 12px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}

.def-item + .def-item { margin-top: 8px; }
.def-item strong { display: block; color: var(--accent); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.def-item p { margin: 5px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }

.content { min-width: 0; display: grid; gap: 18px; }

.document-cover {
  border-radius: 24px;
  padding: clamp(28px, 5vw, 54px);
  overflow: hidden;
}

.document-cover h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(38px, 6vw, 68px);
  line-height: .95;
  letter-spacing: -0.06em;
  font-weight: 900;
}

.document-lead {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 19px);
  font-weight: 600;
}

.document-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 160px));
  gap: 10px;
  margin: 26px 0 0;
}

.document-meta div {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-2);
}

.document-meta dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.document-meta dd {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.rules-root { display: grid; gap: 14px; }

.rule-section {
  border-radius: 20px;
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  cursor: pointer;
  outline: 0;
}

.section-head:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.section-title-wrap { min-width: 0; }
.section-label {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.section-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(22px, 2.6vw, 32px);
  line-height: 1.06;
  letter-spacing: -0.04em;
  font-weight: 900;
}

.section-head h2 span { color: var(--accent); }

.section-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toggle-section {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  line-height: 0;
  transition: background .2s ease, border-color .2s ease;
}

.toggle-section svg {
  width: 17px;
  height: 17px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .2s ease;
}

.section-head:hover .toggle-section {
  border-color: rgba(255, 158, 69, 0.34);
  background: var(--paper-3);
}

.rule-section.collapsed .toggle-section svg { transform: rotate(-90deg); }

.rules-body {
  display: grid;
  gap: 10px;
  padding: 0 16px 18px;
}

.rule-section.collapsed .rules-body { display: none; }

.rule-card {
  position: relative;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 38px;
  gap: 16px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper-2);
}

.rule-no {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}

.rule-text {
  color: var(--ink-2);
  font-size: 14.8px;
  white-space: pre-line;
}

.rule-text a {
  color: var(--accent);
  border-bottom: 1px solid rgba(255, 191, 102, .35);
}

.copy-rule-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #ffffff;
  background: var(--paper-3);
  line-height: 0;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity .18s ease, transform .18s ease, border-color .18s ease, color .18s ease, background .18s ease;
}

.copy-rule-icon {
  width: 17px;
  height: 17px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rule-card:hover .copy-rule-btn {
  opacity: 1;
  transform: translateY(0);
}

.copy-rule-btn:hover {
  color: #ffffff;
  border-color: rgba(255, 158, 69, 0.42);
  background: rgba(255, 158, 69, 0.18);
}

.copy-rule-btn.is-copied {
  color: #ffffff;
  border-color: rgba(255, 158, 69, 0.52);
  background: var(--accent);
}

body.light-mode .copy-rule-btn {
  color: var(--ink);
}

body.light-mode .copy-rule-btn:hover,
body.light-mode .copy-rule-btn.is-copied {
  color: #ffffff;
}

mark {
  color: inherit;
  background: var(--mark);
  border-radius: 4px;
  padding: 0 2px;
}

.limit-table-card {
  margin-top: 8px;
  border-radius: 18px;
  overflow: hidden;
}

.notice-kicker {
  display: inline-flex;
  color: var(--accent);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.limit-table-head {
  padding: 20px 20px 12px;
}

.limit-table-head h3 {
  margin: 8px 0 4px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.limit-table-head p { margin: 0; color: var(--muted); font-size: 13px; }
.table-wrap,
.table-scroll { overflow-x: auto; padding: 0 12px 14px; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  min-width: 720px;
}

th {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-align: left;
  letter-spacing: .08em;
  text-transform: uppercase;
}

td {
  padding: 13px 12px;
  color: var(--ink-2);
  background: var(--paper-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

td:first-child { border-left: 1px solid var(--line); border-radius: 12px 0 0 12px; font-weight: 850; color: var(--ink); }
td:last-child { border-right: 1px solid var(--line); border-radius: 0 12px 12px 0; }

.empty-state {
  padding: 34px;
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  font-weight: 750;
}

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
}

.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  max-width: min(460px, calc(100% - 40px));
  padding: 13px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
  transform: translate(-50%, 18px);
  opacity: 0;
  visibility: hidden;
  z-index: 1200;
  font-size: 13px;
  font-weight: 700;
}

.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

.security-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 10, 14, .72);
  backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  z-index: 1500;
  transition: opacity .18s ease, visibility .18s ease;
}

.security-overlay.visible { opacity: 1; visibility: visible; }

.security-card {
  width: min(440px, 100%);
  padding: 24px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}

.security-card strong { color: var(--ink); font-size: 20px; font-weight: 900; }
.security-card p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

.footer {
  width: min(1280px, calc(100% - 44px));
  margin: 0 auto 34px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 980px) {
  .page-shell { grid-template-columns: 1fr; margin-top: 18px; }
  .sidebar { position: static; max-height: none; order: 2; }
  .content { order: 1; }
  .toc-card { max-height: 320px; overflow: auto; }
}

@media (max-width: 640px) {
  .page-shell,
  .footer { width: min(100% - 28px, 1280px); }
  .document-cover { padding: 26px 20px; border-radius: 20px; }
  .document-meta { grid-template-columns: 1fr; }
  .section-head { padding: 19px 18px; }
  .rules-body { padding: 0 10px 12px; }
  .rule-card { grid-template-columns: 1fr; gap: 6px; padding: 14px; }
  .footer { flex-direction: column; }
}

@media print {
  body { display: none !important; }
}

@media (max-width: 760px) {
  .rule-card {
    grid-template-columns: 52px minmax(0, 1fr) 34px;
    gap: 10px;
  }

  .copy-rule-btn {
    opacity: 1;
    transform: none;
  }
}