@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400&display=swap');
:root {
  --pink:     #c9134e;
  --pink-bg:  #f5e0e8;
  --page:     #f0f0f0;
  --surface:  #f8f8f8;
  --topbar:   #1a1a1a;
  --text:       #1a1a1a;
  --text-mid:   #555;
  --text-faint: #888;
  --text-inv:   #f0f0f0;
  --line:      #d8d8d8;
  --line-soft: #e4e4e4;
  --red:      #b02a1f;
  --red-bg:   #fdf0ee;
  --green:    #1a6e42;
  --green-bg: #eaf5ef;
  --kim-bg:    #eef3f8;
  --kim-line:  #a0bcd4;
  --kim-text:  #2a5278;
  --sidebar-w: 268px;
  --bar-h:     54px;
  --font:      'Atkinson Hyperlegible', sans-serif;
  --r:         6px;
  --size:    17px;
  --size-sm: 14px;
  --lh:      1.85;
}
[data-theme="dark"] {
  --pink:     #f0507a;
  --pink-bg:  #2a0f1a;
  --page:     #141414;
  --surface:  #1e1e1e;
  --topbar:   #0e0e0e;
  --text:       #e8e8e8;
  --text-mid:   #aaa;
  --text-faint: #9a9a9a;
  --text-inv:   #e8e8e8;
  --line:      #2e2e2e;
  --line-soft: #262626;
  --red:      #e05a50;
  --red-bg:   #1f0d0b;
  --green:    #4caf7d;
  --green-bg: #0a1f14;
  --kim-bg:   #0e1a24;
  --kim-line: #2a4a62;
  --kim-text: #7aafd4;
}
html[data-fontsize="large"] { --size: 20px; --size-sm: 16px; --lh: 1.95; }
html[data-fontsize="small"]  { --size: 15px; --size-sm: 12px; --lh: 1.8; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scrollbar-gutter: stable; }
body {
  font-family: var(--font);
  font-size: var(--size);
  line-height: var(--lh);
  letter-spacing: 0.01em;
  color: var(--text);
  background: var(--page);
  overflow-x: hidden;
  transition: background 0.2s, color 0.2s;
}
a { color: var(--pink); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
p { text-align: left; max-width: 68ch; }
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--bar-h);
  background: var(--topbar);
  color: var(--text-inv);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
  transition: background 0.2s;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.topbar-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-inv);
  font-size: 20px;
  cursor: pointer;
  padding: 5px 7px;
  border-radius: var(--r);
  line-height: 1;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }
.site-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--text-inv);
}
.rules-tagline {
  font-size: 12px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.03em;
  white-space: nowrap;
  position: relative;
  margin-left: 6px;
  padding-left: 10px;
}
.rules-tagline::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  height: 12px; width: 1px;
  background: rgba(255,255,255,0.25);
}
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 400px;
}
#searchInput {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--r);
  background: rgba(255,255,255,0.09);
  color: var(--text-inv);
  font-family: var(--font);
  font-size: var(--size-sm);
  outline: none;
}
#searchInput::placeholder { color: rgba(255,255,255,0.35); }
#searchInput:focus { border-color: var(--pink); background: rgba(255,255,255,0.13); }
.search-results,
.landing-search-wrap .search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  z-index: 200;
  max-height: 420px;
  overflow-y: auto;
  font-size: var(--size-sm);
}
.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--pink-bg); }
.result-id    { font-size: 11px; font-weight: 700; color: var(--pink); }
.result-title { font-weight: 700; color: var(--text); }
.search-empty { padding: 16px 14px; color: var(--text-faint); }
.controls {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.ctrl-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.8);
  border-radius: var(--r);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  width: 34px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.ctrl-btn:hover,
.ctrl-btn.on { background: var(--pink); border-color: var(--pink); color: #fff; }
.sz-sm { font-size: 11px; }
.sz-lg { font-size: 16px; font-weight: 700; }
.theme-btn { font-size: 15px; }
.ctrl-sep { width: 1px; height: 20px; background: rgba(255,255,255,0.18); margin: 0 2px; flex-shrink: 0; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: fixed;
  top: var(--bar-h);
  bottom: 0; left: 0;
  overflow-y: auto;
  padding: 20px 0 48px;
  transition: transform 0.2s, background 0.2s;
  z-index: 50;
}
.sidebar.hidden { transform: translateX(-100%); }
.sidebar-search {
  position: relative;
  padding: 16px 16px 16px;
}
.sidebar-search input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--size-sm);
  outline: none;
}
.sidebar-search input:focus { border-color: var(--pink); }
.sidebar-search input::placeholder { color: var(--text-faint); }
.sidebar-search .search-results {
  position: absolute;
  top: calc(100% - 4px);
  left: 16px; right: 16px;
  z-index: 200;
}
.nav-group { margin-bottom: 28px; }
.nav-group-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 16px 8px;
}
.nav-link {
  display: block;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.45;
  border-left: 3px solid transparent;
  transition: background 0.1s, color 0.1s;
}
.nav-link:hover  { background: var(--pink-bg); color: var(--pink); text-decoration: none; }
.nav-link.active { background: var(--pink-bg); color: var(--pink); border-left-color: var(--pink); font-weight: 700; }
.nav-link.top    { font-weight: 700; color: var(--text); padding-top: 8px; }
.nav-link.sub    { padding-left: 26px; font-size: 12px; }
.landing-footer {
  padding: 20px 0 28px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.8;
  width: 100%;
  border-top: 1px solid var(--line);
  margin-top: 20px;
}
.landing-footer p { max-width: 100%; width: 100%; margin: 0 0 4px; text-align: center; }
.landing-footer p:last-child { margin-bottom: 0; }
.landing-footer a { color: var(--text-faint); text-decoration: underline; }
.landing-footer a:hover { color: var(--pink); }
.layout {
  display: flex;
  margin-top: var(--bar-h);
  min-height: calc(100vh - var(--bar-h));
}
.content {
  min-width: 0;
  padding: 36px 44px 96px;
  width: 820px;
  max-width: 820px;
  margin-left: var(--sidebar-w);
  margin-right: auto;
}
.breadcrumb {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 28px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.breadcrumb a { color: var(--text-faint); }
.breadcrumb a:hover { color: var(--pink); }
.rule-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--line);
}
.rule-num {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--pink);
  padding: 4px 12px;
  border-radius: var(--r);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
h1.rule-name {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.rule-text { margin-bottom: 16px; }
.rule-text p { margin-bottom: 14px; }
.sub-blocks { margin-bottom: 32px; }
.sub-block {
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--r);
  transition: border-left-color 0.15s;
}
.sub-block:hover { border-left-color: var(--pink); }
.sub-block-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.sub-block p { color: var(--text); line-height: 1.65; }
.sub-block-list {
  list-style: decimal;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.6;
}
.sub-block-list li { margin-bottom: 6px; }
.penalty-ref { margin-bottom: 32px; display: flex; flex-wrap: wrap; gap: 10px; }
.penalty-tag {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--red-bg);
  border: 1px solid var(--red);
  border-radius: var(--r);
  padding: 10px 18px;
  text-decoration: none;
  transition: box-shadow 0.15s;
}
.penalty-tag:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); text-decoration: none; }
.penalty-tag .lbl  { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.07em; }
.penalty-tag .code { font-weight: 700; font-size: 18px; color: var(--red); line-height: 1; }
.penalty-tag .name { color: var(--red); font-weight: 700; font-size: var(--size-sm); }
.scenario-list { margin-bottom: 32px; }
.scenario-chips { display: flex; flex-direction: column; gap: 8px; }
.scenario-chip {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.scenario-chip:hover {
  border-color: var(--pink);
  box-shadow: 0 2px 10px rgba(201,19,78,0.1);
  text-decoration: none;
}
.chip-id      { font-size: 12px; font-weight: 700; color: var(--pink); flex-shrink: 0; min-width: 76px; }
.chip-preview { font-size: var(--size-sm); color: var(--text-mid); flex: 1; line-height: 1.5; }
.term-list { margin-bottom: 32px; }
.term-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.term-chip {
  font-size: var(--size-sm);
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--text-mid);
  background: var(--surface);
  transition: border-color 0.15s, color 0.15s;
}
.term-chip:hover { border-color: var(--pink); color: var(--pink); text-decoration: none; }
.glossary-group { margin-bottom: 28px; width: 100%; }
.glossary-letter {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.child-rule-link {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: var(--size-sm);
  color: var(--text);
  transition: border-color 0.15s;
}
.child-rule-link:hover { border-color: var(--pink); text-decoration: none; }
.child-rule-num { font-weight: 700; color: var(--pink); flex-shrink: 0; min-width: 40px; }
.scenario-view .rule-header { flex-direction: column; align-items: flex-start; gap: 8px; }
.scenario-origin { font-size: var(--size-sm); color: var(--text-faint); }
.scenario-origin a { color: var(--pink); }
.scenario-block {
  margin-bottom: 20px;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  line-height: var(--lh);
  transition: background 0.2s;
}
.scenario-block p { max-width: 68ch; }
.block-title {
  font-size: var(--size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.outcome-block     { border-left: 5px solid var(--green); }
.outcome-block.pen { border-left-color: var(--red); }
.outcome-block .block-title     { color: var(--green); }
.outcome-block.pen .block-title { color: var(--red); }
.kim-block { background: var(--kim-bg); border-color: var(--kim-line); }
.kim-block .block-title { color: var(--kim-text); }
.kim-block ul { padding-left: 20px; list-style: none; }
.kim-block li { margin-bottom: 8px; }
.scenario-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: var(--size-sm);
  flex-wrap: wrap;
  gap: 10px;
}
.scenario-nav a { color: var(--pink); }
.nav-back { color: var(--text-faint); }
.nav-back:hover { color: var(--pink); }
.penalty-code-inline {
  display: inline-block;
  font-weight: 700;
  font-size: 20px;
  color: var(--red);
  margin-right: 8px;
  min-width: 20px;
}
.subtype-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--line-soft);
  color: var(--text-mid);
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.penalty-block-body { display: flex; gap: 24px; align-items: flex-start; }
.penalty-block-text { flex: 1; min-width: 0; }
.penalty-block-text p { max-width: none; margin-bottom: 4px; line-height: 1.65; }
.signal-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.signal-text { font-size: var(--size-sm); color: var(--text-mid); font-style: italic; }
.signal-img-wrap { flex-shrink: 0; }
.signal-img {
  width: 220px;
  max-width: 100%;
  max-height: 160px;
  object-fit: contain;
  border-radius: var(--r);
  display: block;
}
.sub-block:has(.signal-img) { padding: 8px 14px; }
.landing-page { min-height: 100vh; display: flex; flex-direction: column; }
.landing-main {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--bar-h) + 32px) 24px 8px;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}
.hero { text-align: center; margin-bottom: 16px; }
.hero-title {
  font-size: clamp(36px, 7vw, 60px);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 6px;
}
.hero-title span { color: var(--pink); }
.hero-sub {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
  text-align: center;
  max-width: none;
  width: 100%;
}
.hero-desc {
  font-size: clamp(15px, 2.5vw, 17px);
  line-height: 1.65;
  color: var(--text-mid);
  max-width: 64ch;
  margin: 0 auto;
  text-align: center;
}
.landing-search-wrap {
  position: relative;
  width: 100%;
  max-width: 680px;
  margin: 0 auto 16px;
}
.landing-search-wrap input {
  width: 100%;
  padding: 14px 22px;
  font-family: var(--font);
  font-size: 16px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 40px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.landing-search-wrap input:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(201,19,78,0.1);
}
.landing-search-wrap input::placeholder { color: var(--text-faint); }
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 1fr;
  gap: 10px;
  width: 100%;
  max-width: 820px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.12s, transform 0.1s;
}
.card:hover {
  border-color: var(--pink);
  box-shadow: 0 3px 14px rgba(0,0,0,0.09);
  transform: translateY(-1px);
  text-decoration: none;
}
.card-header { display: flex; align-items: center; gap: 10px; }
.card-icon  { font-size: 20px; line-height: 1; flex-shrink: 0; }
.card-title { font-size: 15px; font-weight: 700; color: var(--text); }
.card-desc  { font-size: 13px; color: var(--text-mid); line-height: 1.5; }
@media (max-width: 720px) {
  .topbar { padding: 0 10px; gap: 8px; }
  .rules-tagline { display: none; }
  .site-title { font-size: 14px; }
  .search-wrap { max-width: 130px; }
  .controls { gap: 4px; }
  .ctrl-btn { padding: 4px 7px; font-size: 11px; }
  .theme-btn { width: 30px; }
  .ctrl-sep { margin: 0 1px; }
  .sidebar { width: 85vw; max-width: 300px; }
  .content { margin-left: 0 !important; padding: 24px 18px 72px; max-width: 100%; width: 100%; }
  h1.rule-name { font-size: 22px; }
  p { max-width: 100%; }
  .penalty-block-body { flex-direction: column; }
  .signal-img-wrap { display: none; }
  .landing-footer { padding: 16px 20px 24px; font-size: 13px; }
  .cards { grid-template-columns: 1fr; }
  .hero-title { font-size: 38px; }
  .landing-main { padding-top: calc(var(--bar-h) + 24px); }
}
@media (max-width: 480px) {
  .search-wrap { display: none; }
}