/* ============================================================
   LawNode — layout.css  (Complete — single source of truth)
   Sections: topbar → hero → seo → suggest → search →
             law-detail → modal → cmd-palette → footer
   ============================================================ */

/* ══════════════════════════════════════════════════════════
   TOPBAR
══════════════════════════════════════════════════════════ */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: 56px; display: flex; align-items: center;
  background: var(--bg); border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.topbar.scrolled { background: var(--bg-1); }
.topbar-inner {
  display: flex; align-items: center;
  width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 24px; gap: 4px;
}

/* ── Logo (text) ── */
.logo {
  display: flex; align-items: center;
  margin-right: 20px; flex-shrink: 0; text-decoration: none; gap: 0;
}
.logo-word {
  font-family: var(--mono); font-size: 14px; font-weight: 700;
  color: var(--navy); letter-spacing: -.01em;
}
.logo-dot-circle {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal); margin: 0 2px 4px; flex-shrink: 0;
}

/* ── Nav buttons ── */
.topbar-nav { display: flex; align-items: stretch; gap: 0; flex-shrink: 0; height: 56px; }
.nav-btn {
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
  padding: 0 12px; border-radius: 0;
  cursor: pointer; border: none; border-bottom: 2px solid transparent;
  background: transparent; font-family: var(--font); white-space: nowrap;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; gap: 5px; height: 100%;
}
.nav-btn:hover { color: var(--text); background: var(--bg-2); }
.nav-btn.active { color: var(--text); border-bottom-color: var(--navy); }
[data-theme="dark"] .nav-btn.active { border-bottom-color: var(--navy); }
.nav-btn:disabled, .nav-btn[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ── "เพิ่มเติม" dropdown ── */
.nav-more { position: relative; display: flex; align-items: stretch; }
.nav-more-btn { border-radius: 0; }
.nav-more-arrow { transition: transform .15s; flex-shrink: 0; }
.nav-more-btn[aria-expanded="true"] .nav-more-arrow { transform: rotate(180deg); }

.nav-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 6px;
  min-width: 220px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 200;
}
[data-theme="dark"] .nav-dropdown { box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.nav-dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  font-size: 13.5px; color: var(--text-2);
  cursor: pointer; transition: background var(--transition), color var(--transition);
  user-select: none;
}
.nav-dd-item:hover { background: var(--bg-2); color: var(--text); }
.nav-dd-item--dim { opacity: 0.5; cursor: default; pointer-events: none; }
.nav-dd-item--dim:hover { background: transparent; }
.nav-dd-icon { color: var(--text-3); flex-shrink: 0; display: flex; align-items: center; }
.nav-dd-label { flex: 1; }
.nav-dd-soon {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--text-3); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; letter-spacing: .01em;
}
.nav-dd-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Topbar search bar (hidden on home) ── */
.topbar-search-wrap {
  flex: 1; display: flex; justify-content: center; align-items: center;
  padding: 0 16px; min-width: 0;
}
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  width: 100%; max-width: 440px;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 99px; padding: 7px 14px;
  cursor: pointer; font-family: var(--font);
  transition: border-color var(--transition), background var(--transition);
  -webkit-appearance: none; appearance: none;
}
.topbar-search:hover { border-color: var(--text-3); background: var(--bg-2); }
.topbar-search-icon { color: var(--text-3); flex-shrink: 0; }
.topbar-search-ph {
  flex: 1; font-size: 13px; color: var(--text-3); text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-search-kbd {
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; flex-shrink: 0;
}

/* ── Right section ── */
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ── Theme icon button ── */
.theme-icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-1);
  cursor: pointer; color: var(--text-2);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  -webkit-appearance: none; appearance: none; flex-shrink: 0;
}
.theme-icon-btn:hover { background: var(--bg-2); color: var(--text); }
/* In light mode show moon, in dark mode show sun */
[data-theme="light"] .ti-sun { display: none; }
[data-theme="dark"]  .ti-moon { display: none; }
/* Drawer theme label: show current mode */
.ti-label-dark  { font-size: 12px; font-family: var(--mono); color: var(--text-2); }
.ti-label-light { font-size: 12px; font-family: var(--mono); color: var(--text-2); }
[data-theme="light"] .ti-label-dark  { display: none; }
[data-theme="dark"]  .ti-label-light { display: none; }

/* ── Auth buttons ── */
.nav-auth-plain {
  font-size: 13px; font-weight: 500; color: var(--text-2);
  padding: 6px 12px; border-radius: var(--radius);
  cursor: pointer; border: none; background: transparent;
  font-family: var(--font); transition: color var(--transition);
  -webkit-appearance: none; appearance: none;
}
.nav-auth-plain:hover { color: var(--text); }
.nav-auth-cta {
  font-size: 13px; font-weight: 600; color: #fff;
  padding: 6px 14px; border-radius: var(--radius);
  cursor: pointer; border: none; background: var(--navy);
  font-family: var(--font); transition: opacity var(--transition);
  -webkit-appearance: none; appearance: none;
  letter-spacing: -.01em;
}
.nav-auth-cta:hover { opacity: 0.85; }
[data-theme="dark"] .nav-auth-cta {
  background: #FFFFFF;
  color: #0F0E0C;
}

/* ── Mobile hamburger ── */

/* ══════════════════════════════════════════════════════════
   PAGE SHELL & SHARED
══════════════════════════════════════════════════════════ */
#page { min-height: calc(100vh - 56px); }
.page-shell { max-width: 1024px; margin: 0 auto; padding: 40px 24px 80px; }
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 48px; color: var(--text-3); font-size: 14px;
}
.loading::after {
  content: ''; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--acc2);
  border-radius: 50%; animation: spin 0.7s linear infinite; margin-left: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { padding: 32px 0; text-align: center; font-size: 13px; color: var(--text-3); }

/* ══════════════════════════════════════════════════════════
   HERO  (home.js)
══════════════════════════════════════════════════════════ */
.hero {
  position: relative; overflow: clip; overflow-clip-margin: 20px;
  min-height: calc(100vh - 56px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
#plexus-canvas {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  pointer-events: none; z-index: -1;
}
.hero-content {
  position: relative; z-index: 1; text-align: center;
  padding: 64px 24px; max-width: 760px; width: 100%;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  color: var(--acc2); letter-spacing: .01em; text-transform: none;
  background: var(--acc-dim); border: 1px solid var(--acc-border);
  border-radius: 99px; padding: 4px 16px; margin-bottom: 32px;
}
.hero-badge-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--acc2); animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:.4; transform:scale(.7); }
}
.hero-title {
  font-size: clamp(1.8rem, 4.5vw, 3rem); font-weight: 600;
  overflow-wrap: break-word;
  line-height: 1.9; letter-spacing: -.025em;
  color: var(--text); margin-bottom: 20px; word-break: keep-all;
}
.hero-title em {
  font-style: normal;
  background: var(--acc-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  font-size: 16px; color: var(--text-2);
  line-height: 1.65; margin-bottom: 40px;
}
.hero-search-wrap {
  position: relative; width: 100%;
  max-width: 680px; margin: 0 auto 14px;
}
.hero-search {
  display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); height: 52px; overflow: hidden;
  transition: border-color var(--transition);
}
.hero-search:focus-within { border-color: var(--acc2); }
[data-theme="light"] .hero-search { background: #fff; border-color: rgba(0,0,0,.15); }
[data-theme="light"] .hero-search:focus-within { border-color: var(--acc1); }
.hero-search input {
  flex: 1; height: 100%; background: transparent;
  border: none; outline: none;
  padding: 0 18px; font-family: var(--font);
  font-size: 15px; color: var(--text); min-width: 0;
}
.hero-search input::placeholder { color: var(--text-3); }
.hero-search-btn {
  height: 100%; background: var(--acc-grad); color: #fff;
  border: none; padding: 0 24px; font-family: var(--font);
  font-size: 14px; font-weight: 600; cursor: pointer; flex-shrink: 0;
  transition: opacity var(--transition);
  -webkit-appearance: none; appearance: none;
}
.hero-search-btn:hover { opacity: .88; }
.hero-hint {
  font-size: 12px; color: var(--text-3);
  margin-bottom: 28px; font-family: var(--mono);
}
.hero-quicklinks {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
  max-width: 680px; margin: 0 auto 40px;
}
.qlink {
  font-size: 13px; color: var(--text-2); cursor: pointer;
  padding: 5px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 99px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.qlink:hover { color: var(--acc2); border-color: var(--acc-border); }
[data-theme="light"] .qlink:hover { color: var(--acc1); }
.qlink-sep { display: none; }
.hero-stats {
  display: grid; grid-template-columns: repeat(3,1fr);
  width: 100%; max-width: 680px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.stat-item {
  padding: 20px 16px; text-align: center;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: center;
}
.stat-item:last-child { border-right: none; }
.stat-num {
  font-family: var(--mono); font-size: 1.6rem; font-weight: 600;
  color: var(--acc2); line-height: 1.1;
}
[data-theme="light"] .stat-num { color: var(--acc1); }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 5px; }
@media (max-width: 640px) {
  .hero-stats { grid-template-columns: 1fr; }
  .stat-item { border-right: none; border-bottom: 1px solid var(--border); }
  .stat-item:last-child { border-bottom: none; }
}

/* ══════════════════════════════════════════════════════════
   SEO SECTION  (home.js)
══════════════════════════════════════════════════════════ */
#seo-section {
  background: var(--bg-1); border-top: 1px solid var(--border);
  padding: 80px 24px;
}
.seo-inner  { max-width: 1024px; margin: 0 auto; }
.seo-top    { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; margin-bottom: 64px; }
@media (max-width: 768px) { .seo-top { grid-template-columns: 1fr; gap: 40px; } }
.seo-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px;
  color: var(--acc2); letter-spacing: .01em; text-transform: none;
  margin-bottom: 16px;
}
.seo-label-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--acc2); display: inline-block; }
.seo-h2    { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-bottom: 16px; }
.seo-h2-sm { font-size: 18px; font-weight: 600; letter-spacing: -.015em; margin-bottom: 16px; }
.seo-desc  { font-size: 15px; color: var(--text-2); line-height: 1.75; margin-bottom: 32px; }
.seo-stats-row {
  display: flex; gap: 28px; flex-wrap: wrap;
  padding: 20px 24px; margin-bottom: 16px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.seo-stat   { display: flex; flex-direction: column; }
.seo-stat-n { font-family: var(--mono); font-size: 1.4rem; font-weight: 600; color: var(--acc2); line-height: 1.1; }
[data-theme="light"] .seo-stat-n { color: var(--acc1); }
.seo-stat-l { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.seo-methods { display: flex; flex-direction: column; gap: 16px; padding: 20px 24px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.seo-method { display: flex; align-items: flex-start; gap: 12px; }
.seo-m-icon { color: var(--acc2); flex-shrink: 0; margin-top: 2px; }
[data-theme="light"] .seo-m-icon { color: var(--acc1); }
.seo-m-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.seo-m-eg   { font-size: 12px; color: var(--text-3); }
.seo-cards  { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 12px; }
.seo-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px;
  transition: border-color var(--transition);
}
.seo-card:hover { border-color: var(--acc-border); }
[data-theme="light"] .seo-card { background: #fff; }
.seo-card-icon  { font-size: 18px; margin-bottom: 10px; }
.seo-card-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.seo-card-list  { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.seo-card-h3    { font-size: 13px; color: var(--text-2); font-weight: 400; }

/* ══════════════════════════════════════════════════════════
   SUGGEST BOX  (home.js / search.js)
══════════════════════════════════════════════════════════ */
.suggest-box {
  display: none; position: absolute; top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: clip; z-index: 200;
}
.suggest-box.open { display: block; }
[data-theme="light"] .suggest-box { background: #fff; }
.suggest-chips-bar {
  display: flex; gap: 6px; padding: 10px 12px;
  border-bottom: 1px solid var(--border-dim);
}
.sug-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 99px; padding: 2px 10px; cursor: pointer;
  transition: all var(--transition);
  -webkit-appearance: none; appearance: none;
}
.sug-chip.active { color: var(--acc2); border-color: var(--acc-border); background: var(--acc-dim); }
.sug-chip-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--acc2); flex-shrink: 0; }
.sug-chip-n { font-size: 12px; opacity: .7; }
.suggest-list {
  overflow-y: auto;
  overscroll-behavior: contain;
}
.suggest-section { }
.suggest-section-label {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--text-3); letter-spacing: .02em; text-transform: none;
  padding: 8px 16px 4px;
}
.suggest-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border-dim);
  transition: background var(--transition);
}
.suggest-row:last-child { border-bottom: none; }
.suggest-row:hover, .suggest-row.active { background: var(--bg-2); }
.suggest-icon  { color: var(--text-3); flex-shrink: 0; }
.suggest-main  { flex: 1; min-width: 0; }
.suggest-title {
  font-size: 14px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.suggest-title mark { background: var(--acc-dim); color: var(--acc2); border-radius: 2px; padding: 0 2px; }
.suggest-sub   { font-size: 12px; color: var(--text-3); font-family: var(--mono); }
.suggest-badge {
  font-family: var(--mono); font-size: 12px;
  padding: 1px 8px; border-radius: 99px;
  border: 1px solid var(--border); color: var(--text-3); flex-shrink: 0;
}
.suggest-badge--law     { border-color: var(--acc-border); color: var(--acc2); background: var(--acc-dim); }
.suggest-badge--section { border-color: rgba(34,197,94,.25); color: #22c55e; background: rgba(34,197,94,.06); }
.suggest-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; border-top: 1px solid var(--border-dim);
  font-size: 12px;
}
.suggest-footer-keys { color: var(--text-3); font-family: var(--mono); }
.suggest-footer-keys kbd {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1px 5px; font-size: 12px;
}
.suggest-footer-all { color: var(--acc2); cursor: pointer; font-family: var(--mono); font-size: 12px; }
.suggest-footer-all:hover { text-decoration: underline; }
.suggest-empty { padding: 16px; text-align: center; font-size: 13px; color: var(--text-3); }

/* ══════════════════════════════════════════════════════════
   SEARCH RESULTS PAGE  (search.js)
══════════════════════════════════════════════════════════ */
.s-page   { padding: 40px 24px 80px; max-width: 1024px; margin: 0 auto; }
.s-header { margin-bottom: 28px; }
.s-title  { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.s-sub    { font-size: 13px; color: var(--text-3); font-family: var(--mono); }
.s-chips  { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.s-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-2);
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 99px; padding: 5px 14px; cursor: pointer;
  transition: all var(--transition);
}
.s-chip:hover { color: var(--text); border-color: var(--text-3); }
.s-chip.active { background: var(--acc-dim); border-color: var(--acc-border); color: var(--acc2); }
.s-chip-dot   { width: 5px; height: 5px; border-radius: 50%; background: var(--acc2); flex-shrink: 0; }
.s-chip-count {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg-3); border-radius: 99px; padding: 1px 7px; color: var(--text-3);
}
.s-chip.active .s-chip-count { background: var(--acc-dim); color: var(--acc2); }
.search-group {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 12px;
}
.search-group-header {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.search-group-count { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.search-result-item {
  padding: 14px 16px; border-bottom: 1px solid var(--border-dim);
  cursor: pointer; transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-2); }
.search-page { max-width: 860px; margin: 0 auto; padding: 48px 48px 80px; }
@media (max-width: 640px) { .search-page { padding: 32px 20px 80px; } }
.search-header {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 24px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.search-header-top { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.search-filter-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.search-query { font-size: 20px; font-weight: 600; color: var(--text); }
.search-count { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.search-result {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: padding var(--transition), background var(--transition);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg-2); padding-left: 12px; margin-left: -12px; border-radius: var(--radius); }
.sr-law     { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.sr-title   { font-size: 14px; font-weight: 600; color: var(--acc2); }
[data-theme="light"] .sr-title { color: var(--acc1); }
.sr-excerpt { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.sri-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.sri-law     { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.sri-section { font-family: var(--mono); font-size: 12px; color: var(--acc2); font-weight: 600; }
.sri-badge   { font-family: var(--mono); font-size: 12px; padding: 1px 8px; border-radius: 99px; }
.sri-badge--law { border: 1px solid var(--acc-border); color: var(--acc2); background: var(--acc-dim); }
.sri-title   { font-size: 14px; color: var(--text); font-weight: 600; margin-bottom: 4px; line-height: 1.45; }
.sri-title mark, .sri-excerpt mark { background: var(--acc-dim); color: var(--acc2); border-radius: 2px; padding: 0 2px; }
.sri-excerpt { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.search-show-more {
  padding: 10px 16px; text-align: center; font-size: 13px;
  color: var(--acc2); cursor: pointer;
  border-top: 1px solid var(--border-dim);
  transition: background var(--transition);
}
.search-show-more:hover { background: var(--bg-2); }

/* ══════════════════════════════════════════════════════════
   LAW DETAIL PAGE  (law-detail.js — ld-* classes)
══════════════════════════════════════════════════════════ */
.ld-page { max-width: 1440px; margin: 0 auto; padding: 0 0 80px; }

/* Header */
.ld-header { padding: 32px 48px 24px; border-bottom: 1px solid var(--border); }
@media (max-width: 768px) { .ld-header { padding: 24px 20px 20px; } }
.law-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  margin-bottom: 14px;
}
.law-breadcrumb a { color: var(--text-3); cursor: pointer; transition: color var(--transition); }
.law-breadcrumb a:hover { color: var(--text); text-decoration: underline; }
.crumb-sep { color: var(--border); }
.ld-header-main {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.ld-header-left { flex: 1; min-width: 0; }
.ld-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.ld-law-name {
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--text); margin-bottom: 12px; line-height: 1.3;
}
.ld-law-sub { font-size: 12px; color: var(--text-3); margin-top: 6px; font-family: var(--mono); }
.ld-meta-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
}
.ld-meta-badge { padding: 2px 10px; border-radius: 99px; border: 1px solid var(--border); color: var(--text-2); }
.ld-meta-text  { color: var(--text-3); }
.ld-status-badge {
  font-family: var(--mono); font-size: 12px;
  padding: 2px 10px; border-radius: 99px; border: 1px solid currentColor;
}
.ld-status-badge.active   { color: #22c55e; }
.ld-status-badge.repealed { color: var(--text-3); }
.ld-status-badge.amended  { color: #f59e0b; }
.ld-flag-badge {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px; letter-spacing: .01em;
}
.ld-flag-badge.consolidated { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.25); }
.ld-flag-badge.enabling     { background: rgba(168,85,247,0.12); color: #c084fc; border: 1px solid rgba(168,85,247,0.25); }
.section-version-badge {
  font-family: var(--mono); font-size: 12px;
  padding: 1px 7px; border-radius: 99px;
  background: rgba(245,158,11,0.12); color: #f59e0b;
  border: 1px solid rgba(245,158,11,0.25);
}

/* Preamble (native <details>) */
details.preamble-box { margin: 0 48px; border-bottom: 1px solid var(--border); }
@media (max-width: 768px) { details.preamble-box { margin: 0 20px; } }
.preamble-summary {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0; cursor: pointer; list-style: none;
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  letter-spacing: .01em; text-transform: none;
  user-select: none; transition: color var(--transition);
}
.preamble-summary::-webkit-details-marker { display: none; }
.preamble-summary::before { content: '▶'; font-size: 12px; transition: transform 0.2s; display: inline-block; }
details.preamble-box[open] .preamble-summary::before { transform: rotate(90deg); }
.preamble-summary:hover { color: var(--text); }
.preamble-body { padding: 4px 0 16px 16px; font-size: 14px; color: var(--text-2); line-height: 1.85; }

/* 3-Column Layout */
.ld-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-areas: "toc content";
  align-items: start;
  transition: grid-template-columns 0.25s ease;
}
.ld-layout.panel-open {
  grid-template-columns: 220px 1fr 300px;
  grid-template-areas: "toc content panel";
}
@media (max-width: 1200px) { .ld-layout.panel-open { grid-template-columns: 200px 1fr 260px; } }
@media (max-width: 960px) {
  .ld-layout, .ld-layout.panel-open {
    grid-template-columns: 1fr;
    grid-template-areas: "content";
  }
  .ld-toc, .ld-panel { display: none; }
}

/* TOC Column */
.ld-toc {
  grid-area: toc;
  position: sticky; top: 56px;
  max-height: calc(100vh - 72px);
  overflow-y: auto; overflow-x: hidden;
  border-right: 1px solid var(--border);
  padding: 20px 0;
}
.ld-toc::-webkit-scrollbar { width: 4px; }
.ld-toc::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.toc-header {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--text-3); letter-spacing: .01em; text-transform: none;
  padding: 0 16px 10px;
}
.toc-scroll { overflow-y: auto; }
.toc-group > .toc-items { display: none; }
.toc-group.open > .toc-items { display: block; }
.toc-group-btn {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 6px 16px; background: transparent; border: none;
  text-align: left; cursor: pointer; color: var(--text-2);
  font-size: 12px; font-family: var(--font);
  transition: background var(--transition), color var(--transition);
}
.toc-group-btn:hover { background: var(--bg-2); color: var(--text); }
.toc-arrow { font-size: 12px; color: var(--text-3); flex-shrink: 0; transition: transform 0.15s; }
.toc-group.open .toc-arrow { transform: rotate(90deg); }
.toc-group-label { flex: 1; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc-count { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.toc-item {
  display: block; padding: 5px 16px 5px 28px;
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  cursor: pointer; transition: all var(--transition);
  border-left: 2px solid transparent;
}
.toc-item:hover { color: var(--text); background: var(--bg-2); }
.toc-item.active { color: var(--acc2); border-left-color: var(--acc2); background: var(--acc-dim); font-weight: 500; }
[data-theme="light"] .toc-item.active { color: var(--acc1); border-left-color: var(--acc1); }

/* Content Column */
.ld-content { grid-area: content; min-width: 0; }
.sections-col { padding: 32px 48px; max-width: 860px; }
@media (max-width: 768px) { .sections-col { padding: 24px 20px; } }

/* Section Card */
.section-card { padding: 32px 0 0; border-bottom: 1px solid var(--border); }
.section-card:last-child { border-bottom: none; }
.section-card.highlighted {
  background: var(--acc-dim); border-radius: var(--radius);
  padding-left: 16px; padding-right: 16px;
  margin-left: -16px; margin-right: -16px;
}
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head-spacer { flex: 1; }
.section-num { font-size: 13px; font-weight: 700; color: var(--acc2); font-family: var(--mono); margin: 0; letter-spacing: 0.02em; }
[data-theme="light"] .section-num { color: var(--acc1); }
.section-status {
  font-family: var(--mono); font-size: 12px;
  padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor;
}
.section-status.active   { color: #22c55e; }
.section-status.repealed { color: var(--text-3); }
.section-status.amended  { color: #f59e0b; }
.section-detail-link {
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 3px 10px;
  cursor: pointer; transition: all var(--transition);
  -webkit-appearance: none; appearance: none;
}
.section-detail-link:hover { color: var(--acc2); border-color: var(--acc-border); }
[data-theme="light"] .section-detail-link:hover { color: var(--acc1); }

/* Tags */
.section-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tag-pill {
  font-size: 12px; color: var(--text-3); background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 99px; padding: 2px 10px;
  cursor: pointer; transition: all var(--transition);
}
.tag-pill:hover { color: var(--text); border-color: var(--text-3); }

/* Paragraphs */
.section-paras { margin-bottom: 4px; }
.para-block {
  border-left: 2px solid var(--border);
  padding: 4px 0 4px 18px; margin-bottom: 10px;
}
.para-block.is-sub { border-left-color: var(--acc-border); margin-left: 20px; }
.para-text { font-size: 15px; line-height: 2; color: var(--text); margin: 0; }
.para-text .law-ref {
  color: var(--acc2); cursor: pointer;
  border-bottom: 1px dashed var(--acc-border);
  transition: border-color var(--transition);
}
.para-text .law-ref:hover { border-bottom-color: var(--acc2); }
[data-theme="light"] .para-text .law-ref { color: var(--acc1); }

/* Note box */
.note-box {
  font-size: 13px; color: var(--text-3);
  border-left: 2px solid var(--border);
  padding: 8px 12px; margin-bottom: 10px;
  font-family: var(--mono); background: var(--bg-1);
}

/* Section toolbar */
.section-toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 0 24px; flex-wrap: wrap;
  border-top: 1px solid var(--border-dim); margin-top: 12px;
}
.stb-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 5px 12px;
  cursor: pointer; transition: all var(--transition);
  -webkit-appearance: none; appearance: none; white-space: nowrap;
}
.stb-btn:hover  { color: var(--text); border-color: var(--text-3); background: var(--bg-2); }
.stb-btn.active { color: var(--acc2); border-color: var(--acc-border); background: var(--acc-dim); }
[data-theme="light"] .stb-btn.active { color: var(--acc1); }
.stb-btn--detail:hover { color: var(--acc2); }
[data-theme="light"] .stb-btn--detail:hover { color: var(--acc1); }

/* Detail Panel (col 3) */
.ld-panel {
  grid-area: panel;
  position: sticky; top: 56px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--bg-1);
}
.ld-panel[hidden] { display: none; }
.ld-panel::-webkit-scrollbar { width: 4px; }
.ld-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.ld-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 12px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-1); z-index: 2;
}
.ld-panel-title { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--text-2); }
.ld-panel-close {
  font-size: 13px; color: var(--text-3); background: transparent;
  border: none; cursor: pointer; padding: 3px 6px; line-height: 1;
  transition: color var(--transition); border-radius: var(--radius);
}
.ld-panel-close:hover { color: var(--text); background: var(--bg-2); }
.ld-panel-body { padding: 16px 20px 32px; }
.panel-section-label {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--text-3); letter-spacing: .01em; text-transform: none;
  margin-bottom: 8px;
}

/* Connection rows */
.conn-list { display: flex; flex-direction: column; gap: 1px; }
.conn-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px; padding: 9px 8px; border-radius: var(--radius);
  cursor: pointer; transition: background var(--transition);
}
.conn-row:hover { background: var(--bg-2); }
.conn-row-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.conn-num { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--acc2); white-space: nowrap; }
[data-theme="light"] .conn-num { color: var(--acc1); }
.conn-meta { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-badges { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }
.conn-type { font-family: var(--mono); font-size: 12px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--border); white-space: nowrap; }
.conn-type.explicit { border-color: var(--acc-border); color: var(--acc2); }
[data-theme="light"] .conn-type.explicit { color: var(--acc1); }
.conn-type.semantic { border-color: rgba(34,197,94,.3); color: #22c55e; }

/* Inline link list */
.link-entry {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border-dim);
  cursor: pointer; transition: color var(--transition);
}
.link-entry:last-child { border-bottom: none; }
.link-entry:hover .link-num { color: var(--acc2); }
.link-num { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); }
.link-meta { font-family: var(--mono); font-size: 12px; color: var(--text-3); }

/* AI placeholder */
.ai-placeholder { padding: 32px 16px; text-align: center; font-size: 13px; color: var(--text-2); line-height: 1.7; }

/* Version timeline */
.version-timeline { display: flex; flex-direction: column; gap: 0; }
.version-row { display: flex; align-items: flex-start; gap: 10px; padding: 0 0 16px; }
.version-spine { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; padding-top: 4px; }
.version-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border); background: var(--bg); flex-shrink: 0; z-index: 1; }
.version-dot--active { border-color: var(--acc2); background: var(--acc2); }
[data-theme="light"] .version-dot--active { border-color: var(--acc1); background: var(--acc1); }
.version-line { width: 2px; flex: 1; min-height: 24px; background: var(--border); margin-top: 4px; }
.version-content { flex: 1; min-width: 0; }
.version-year { font-family: var(--mono); font-size: 12px; color: var(--text-3); margin-bottom: 3px; }
.version-title { font-size: 13px; color: var(--text); line-height: 1.4; font-weight: 500; margin-bottom: 3px; }
.version-title--link { color: var(--acc2); cursor: pointer; }
.version-title--link:hover { text-decoration: underline; }
[data-theme="light"] .version-title--link { color: var(--acc1); }
.version-action { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.version-row--current .version-title { font-weight: 600; }

/* Enabling act panel */
.enabling-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 16px; }
.enabling-label { font-family: var(--mono); font-size: 12px; color: var(--text-3); letter-spacing: .01em; text-transform: none; margin-bottom: 8px; }
.enabling-name { font-size: 14px; font-weight: 600; color: var(--acc2); line-height: 1.4; margin-bottom: 10px; cursor: pointer; }
.enabling-name:hover { text-decoration: underline; }
[data-theme="light"] .enabling-name { color: var(--acc1); }
.enabling-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.enabling-explain { font-size: 12px; color: var(--text-3); line-height: 1.65; padding: 12px 14px; background: var(--bg-2); border-radius: var(--radius); border-left: 2px solid var(--border); }

/* Section detail page */
.det-body { padding: 32px 48px; max-width: 860px; }
@media (max-width: 768px) { .det-body { padding: 24px 20px; } }
.tree-para {
  padding: 12px 0; border-left: 2px solid var(--border);
  padding-left: 20px; margin-bottom: 10px; position: relative;
}
.tree-para::before { content: ''; position: absolute; left: -1px; top: 18px; width: 10px; height: 2px; background: var(--border); }
.tree-para.is-sub { border-left-color: var(--acc-border); margin-left: 24px; }
.tree-para.is-sub::before { background: var(--acc-border); }
.tree-text { font-size: 15px; line-height: 2; color: var(--text); margin: 0; }
.tree-chips { margin-top: 10px; display: flex; flex-direction: column; gap: 3px; }
.chip-summary {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  cursor: pointer; list-style: none; padding: 3px 0;
  transition: color var(--transition); user-select: none;
}
.chip-summary::-webkit-details-marker { display: none; }
.chip-summary::before { content: '›'; font-size: 13px; transition: transform 0.15s; display: inline-block; }
details.chip-details[open] .chip-summary::before { transform: rotate(90deg); }
.chip-summary:hover { color: var(--text); }
.chip-panel { padding: 6px 0 4px 10px; display: flex; flex-wrap: wrap; gap: 5px; }
.chip-panel--list { flex-direction: column; gap: 0; }
.tree-related-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; cursor: pointer; border-radius: var(--radius); transition: color var(--transition); }
.tree-related-row:hover { color: var(--acc2); }
[data-theme="light"] .tree-related-row:hover { color: var(--acc1); }
.tree-related-num { font-family: var(--mono); font-size: 12px; color: var(--acc2); font-weight: 600; }
[data-theme="light"] .tree-related-num { color: var(--acc1); }
.tree-related-meta { font-size: 12px; color: var(--text-3); }
.connections-section { margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--border); }
.connections-title { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--text-3); letter-spacing: .01em; text-transform: none; margin-bottom: 14px; }

/* Preamble box (also used in old-style JS) */
.preamble-box {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px; margin-bottom: 28px;
}
.preamble-title {
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  letter-spacing: .01em; text-transform: none; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.preamble-body { font-size: 14px; color: var(--text-2); line-height: 1.8; }
.preamble-body.hidden { display: none; }
.collapse-btn {
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  background: transparent; border: none; cursor: pointer;
  transition: color var(--transition);
}
.collapse-btn:hover { color: var(--text); }

/* ══════════════════════════════════════════════════════════
   NATIVE <dialog> MODAL
══════════════════════════════════════════════════════════ */
.section-modal {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); padding: 0;
  max-width: 560px; width: 90vw; color: var(--text); box-shadow: none;
}
.section-modal::backdrop { background: rgba(0,0,0,0.48); backdrop-filter: blur(2px); }
[data-theme="light"] .section-modal::backdrop { background: rgba(0,0,0,0.28); }
.section-modal-box { display: flex; flex-direction: column; }
.section-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px 14px; border-bottom: 1px solid var(--border);
}
.section-modal-num { font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--acc2); }
[data-theme="light"] .section-modal-num { color: var(--acc1); }
.section-modal-close {
  font-size: 16px; color: var(--text-3); background: transparent;
  border: none; cursor: pointer; padding: 2px 6px; line-height: 1;
  transition: color var(--transition);
}
.section-modal-close:hover { color: var(--text); }
.section-modal-body { padding: 20px 22px; max-height: 58vh; overflow-y: auto; }
.modal-para { font-size: 14px; line-height: 1.85; color: var(--text); margin-bottom: 12px; }
.modal-para:last-child { margin-bottom: 0; }
.section-modal-foot { padding: 12px 22px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

/* Legacy modal overlay */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 300;
  align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 600px;
  max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-3); font-size: 20px; line-height: 1; padding: 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

/* ══════════════════════════════════════════════════════════
   COMMAND PALETTE
══════════════════════════════════════════════════════════ */
.cmd-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 400;
  align-items: flex-start; justify-content: center;
  padding: 80px 24px 24px;
}
.cmd-overlay.show { display: flex; }
.cmd-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 560px; overflow: hidden;
}
.cmd-input-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text-3);
}
.cmd-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: var(--font); font-size: 15px; color: var(--text); min-width: 0;
}
.cmd-input::placeholder { color: var(--text-3); }
.cmd-esc {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2px 6px; color: var(--text-3);
}
.cmd-results { max-height: 360px; overflow-y: auto; }
.cmd-section-label {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--text-3); letter-spacing: .01em; text-transform: none;
  padding: 10px 16px 4px;
}
.cmd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer; transition: background var(--transition);
}
.cmd-item:hover, .cmd-item.selected { background: var(--bg-2); }
.cmd-item-icon {
  width: 30px; height: 30px; border-radius: var(--radius);
  background: var(--bg-3); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  color: var(--acc2); flex-shrink: 0;
}
[data-theme="light"] .cmd-item-icon { color: var(--acc1); }
.cmd-item-text { flex: 1; min-width: 0; }
.cmd-item-title { font-size: 14px; color: var(--text); font-weight: 500; }
.cmd-item-sub   { font-size: 12px; color: var(--text-3); font-family: var(--mono); }
.cmd-empty { padding: 24px; text-align: center; font-size: 13px; color: var(--text-3); }

/* ══════════════════════════════════════════════════════════
   SITE FOOTER
══════════════════════════════════════════════════════════ */
.site-footer { background: var(--bg-1); border-top: 1px solid var(--border); padding: 48px 24px 32px; }
.site-footer-inner { max-width: 1024px; margin: 0 auto; }
.site-footer-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 32px; margin-bottom: 40px; }
@media (max-width: 640px) { .site-footer-grid { grid-template-columns: 1fr; gap: 24px; } }
.footer-col-label {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--text-3); letter-spacing: .01em; text-transform: none; margin-bottom: 12px;
}
.footer-links { display: flex; flex-direction: column; gap: 8px; }
.footer-link { font-size: 13px; color: var(--text-2); text-decoration: none; transition: color var(--transition); }
.footer-link:hover { color: var(--acc2); text-decoration: none; }
[data-theme="light"] .footer-link:hover { color: var(--acc1); }
.site-footer-bottom {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 24px; border-top: 1px solid var(--border);
}
.footer-copyright { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.footer-logo-img  { height: 14px; opacity: 0.5; }

/* ══════════════════════════════════════════════════════════
   CORS WARNING
══════════════════════════════════════════════════════════ */
.cors-box {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px;
  font-size: 14px; color: var(--text-2); line-height: 1.7;
  max-width: 600px; margin: 40px auto;
}
.cors-box h3 { margin-bottom: 12px; font-size: 16px; color: var(--text); }
.cors-box code { font-family: var(--mono); font-size: 12px; background: var(--bg-2); padding: 1px 5px; border-radius: var(--radius); }

/* ============================================================
   layout-additions.css — Patch สำหรับ v4
   วาง <link> นี้ หลัง layout.css ใน index.html
   เพิ่ม: law-info-details, para-text ไม่มี border, section improvements
   ============================================================ */

/* ── Law Info Details (Native <details>) ─────────────────── */
.law-info-details {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-1);
}
.law-info-summary {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px; cursor: pointer; list-style: none;
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  letter-spacing: .01em; user-select: none;
  transition: color var(--transition);
}
.law-info-summary::-webkit-details-marker { display: none; }
.law-info-summary::after {
  content: '▾'; margin-left: auto; font-size: 12px;
  transition: transform 0.2s; display: inline-block;
}
.law-info-details[open] .law-info-summary::after { transform: rotate(-180deg); }
.law-info-summary:hover { color: var(--text); }
.law-info-body {
  padding: 0 12px 10px;
  display: flex; flex-direction: column; gap: 0;
}
.law-info-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 5px 0; border-bottom: 1px solid var(--border-dim);
}
.law-info-row:last-child { border-bottom: none; }
.law-info-label {
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  min-width: 90px; flex-shrink: 0;
}
.law-info-val {
  font-size: 13px; color: var(--text-2); line-height: 1.5;
}
.law-info-link {
  font-size: 13px; color: var(--acc2); text-decoration: none;
  transition: color var(--transition);
}
.law-info-link:hover { color: var(--acc2); text-decoration: underline; }
[data-theme="light"] .law-info-link { color: var(--acc1); }

/* ── Para text — ไม่มี border-left แล้ว อ่านลื่นกว่า ─────── */
/* Override .para-block ที่มี border-left เดิม */
.para-block {
  border-left: none !important;
  padding-left: 0 !important;
  margin-bottom: 8px;
}
.para-block.is-sub {
  border-left: none !important;
  margin-left: 24px;
  padding-left: 0 !important;
}

/* para-text สำหรับใช้ใน v4 (ไม่ผ่าน para-block) */
.para-text {
  font-size: 15px; line-height: 2; color: var(--text);
  margin: 0 0 8px 0;
}
.para-text.para-sub {
  margin-left: 24px;
  color: var(--text-2);
}
.para-text .law-ref {
  color: var(--acc2); cursor: pointer;
  border-bottom: 1px dashed var(--acc-border);
  transition: border-color var(--transition);
}
.para-text .law-ref:hover { border-bottom-color: var(--acc2); }
[data-theme="light"] .para-text .law-ref { color: var(--acc1); }

/* para-label (เลข/อักษรย่อหน้า เช่น "(1)" "(ก)") */
.para-label {
  font-family: var(--mono); font-size: 13px; color: var(--text-3);
  margin-right: 6px;
}

/* ── Section card improvements ───────────────────────────── */
/* เพิ่ม spacing ด้านบน ให้หน้าดูโปร่ง */
.section-card {
  padding: 28px 0 0;
}

/* ซ่อน status badge ถ้า active — ไม่ต้องแสดง "ใช้บังคับ" ทุกมาตรา */
.section-card .section-status.active { display: none; }

/* section title (ชื่อหมวด/ส่วน) */
.section-title-line {
  font-size: 13px; color: var(--text-3); margin-bottom: 10px;
  font-style: italic;
}

/* section ที่ไม่ active */
.section-card--inactive { opacity: 0.6; }

/* ── det-body: ลด tree-para border ─────────────────────────
   (section detail page — ยังคง structure เดิม แต่ไม่มีเส้น)  */
.tree-para {
  border-left: none !important;
  padding-left: 0 !important;
}
.tree-para::before { display: none !important; }
.tree-para.is-sub {
  border-left: none !important;
  margin-left: 20px;
  padding-left: 0 !important;
}

/* ── Version / enabling card ─────────────────────────────── */
.enabling-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 16px;
}
.enabling-name {
  font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 8px;
  line-height: 1.4;
}
[data-theme="light"] .enabling-name { color: var(--acc1); }
.enabling-explain {
  font-size: 12px; color: var(--text-3); line-height: 1.65;
  padding: 10px 14px; background: var(--bg-2);
  border-radius: var(--radius); border-left: 2px solid var(--border);
}

/* ── AI placeholder ──────────────────────────────────────── */
.ai-placeholder {
  text-align: center; padding: 32px 16px;
  font-size: 13px; color: var(--text-3); line-height: 1.7;
}

/* ── Version timeline ────────────────────────────────────── */
.version-origin { display: flex; flex-direction: column; gap: 0; }
.version-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border-dim);
}
.version-row:last-child { border-bottom: none; }
.version-row--current { background: var(--acc-dim); border-radius: var(--radius); padding: 10px 10px; margin: -2px; }
.version-dot {
  width: 8px; height: 8px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--bg-2);
  flex-shrink: 0; margin-top: 5px;
}
.version-dot--active { background: #22c55e; border-color: #22c55e; }
.version-dot--child  { background: var(--acc2); border-color: var(--acc2); }
[data-theme="light"] .version-dot--child { background: var(--acc1); border-color: var(--acc1); }
.version-content { flex: 1; min-width: 0; }
.version-title { font-size: 13px; color: var(--text); font-weight: 500; line-height: 1.4; margin-bottom: 3px; }
.version-meta  { font-family: var(--mono); font-size: 12px; color: var(--text-3); }

/* ── Preamble box override (Native <details> style) ──────── */
details.preamble-box {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0 48px;
  margin-bottom: 0;
}
@media (max-width: 768px) {
  details.preamble-box { padding: 0 20px; }
}
.preamble-summary {
  padding: 12px 0;
}
.preamble-body {
  padding: 0 0 16px 0;
  font-size: 14px; color: var(--text-2); line-height: 1.85;
}

/* ── v5: topbar stats, AI search shell, search results, law detail polish ─ */
.nav-stat {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  margin-left: 4px;
  white-space: nowrap;
}
.nav-stat--muted { opacity: 0.75; }
@media (max-width: 1100px) {
  .nav-stat { display: none; }
}

.hero--minimal { min-height: calc(100vh - 56px); }
.hero-content--wide { max-width: 820px; }
.hero-title--compact { margin-bottom: 12px; }
.hero-sub--compact { margin-bottom: 28px; }

.hero-search-ai {
  position: relative;
  width: 100%;
  max-width: 820px;
  margin: 0 auto 12px;
  padding: 2px;
  border-radius: 999px;
  background: linear-gradient(120deg, #a855f7, #f97316, #eab308);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0 12px 40px rgba(168,85,247,0.15);
}
[data-theme="light"] .hero-search-ai {
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06), 0 10px 32px rgba(249,115,22,0.12);
}
.hero-search-ai-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 6px 4px 14px;
  min-height: 54px;
}
.hero-search-ai-spark {
  font-size: 14px;
  color: #a855f7;
  flex-shrink: 0;
  line-height: 1;
}
.hero-search-ai-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  padding: 8px 4px;
}
.hero-search-ai-input::placeholder { color: var(--text-3); }
.hero-search-ai-clear {
  border: none;
  background: var(--bg-2);
  color: var(--text-3);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}
.hero-search-ai-clear:hover { color: var(--text); }
.hero-search-ai-submit {
  border: none;
  border-radius: 999px;
  padding: 0 22px;
  height: 44px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--acc-grad);
  cursor: pointer;
  flex-shrink: 0;
}
.hero-search-ai-submit:hover { opacity: 0.9; }

.search-page--centered {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}
.search-inline-form { margin-bottom: 24px; }
.search-inline-ai {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px 3px 12px;
  border-radius: 999px;
  background: linear-gradient(120deg, #a855f7, #f97316, #eab308);
}
.search-inline-ai .hero-search-ai-spark { margin-left: 4px; }
.search-inline-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: var(--surface);
  border-radius: 999px;
  padding: 12px 16px;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
}
.search-inline-submit {
  border: none;
  border-radius: 999px;
  padding: 0 20px;
  height: 44px;
  font-weight: 600;
  color: #fff;
  background: var(--acc-grad);
  cursor: pointer;
  flex-shrink: 0;
}

.suggest-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.suggest-link-btn {
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--acc2);
  cursor: pointer;
  padding: 2px 4px;
}
[data-theme="light"] .suggest-link-btn { color: var(--acc1); }
.suggest-row--hist { position: relative; }
.suggest-hist-x {
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-3);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
}
.suggest-hist-x:hover { color: var(--text); }
.suggest-pop-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.suggest-pop-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--acc2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: var(--font);
}
[data-theme="light"] .suggest-pop-pill { color: var(--acc1); }
.suggest-pop-pill:hover, .suggest-pop-pill.active {
  border-color: var(--acc-border);
  background: var(--acc-dim);
}
.suggest-pop-arrow { font-size: 12px; opacity: 0.7; }
.suggest-section--popfoot { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border-dim); }

.section-foot-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0 28px;
  margin-top: 4px;
  border-top: 1px solid var(--border-dim);
}
.section-foot-sep { color: var(--text-3); user-select: none; }
.section-micro-link {
  border: none;
  background: none;
  padding: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.section-micro-link:hover { color: var(--acc2); }
[data-theme="light"] .section-micro-link:hover { color: var(--acc1); }

.panel-loading, .panel-empty {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.6;
  padding: 8px 0;
}
.ai-placeholder-sub {
  display: block;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
}

.ld-panel {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.ld-panel-head .ld-panel-title { flex: 1; min-width: 0; }

.sections-col { max-width: 720px; margin: 0 auto; }
.ld-page { padding-left: 0; padding-right: 0; }
