:root {
  --bg: #161a24;
  --bgEl: #1c2130;
  --bgHover: #262c3d;
  --border: #2b3142;
  --text: #e8eaf0;
  --muted: #8b90a3;
  --accent: #8b8cf5;
  --accent2: #f5a76c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  display: flex;
  flex-direction: column;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.topbar {
  height: 56px; min-height: 56px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--bgEl);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); display: inline-block; }
.search-wrap { position: relative; flex: 1; max-width: 480px; }
.search-wrap input {
  width: 100%; height: 36px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); padding: 0 12px; font-size: 13px;
  font-family: inherit; outline: none;
}
.search-panel {
  position: absolute; top: 42px; left: 0; right: 0; max-height: 420px; overflow: auto;
  background: var(--bgEl); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35); z-index: 40;
}
.search-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.search-item:hover { background: var(--bgHover); }
.search-item .breadcrumb { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-bottom: 2px; }
.search-item .title { font-size: 13px; font-weight: 600; }
.search-item .snippet { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  height: 32px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bgHover); }
.btn.primary { background: var(--accent); color: #10121a; border-color: var(--accent); }
.btn.small { height: 26px; padding: 0 8px; font-size: 11px; }
.btn.danger { color: #ff8a80; }

.body { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 300px; min-width: 300px; border-right: 1px solid var(--border); background: var(--bgEl); display: flex; flex-direction: column; min-height: 0; }
.cat-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 14px 10px 14px; border-bottom: 1px solid var(--border); }
.cat-tab {
  padding: 6px 10px; border-radius: 7px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer;
}
.cat-tab.active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }

.law-tree { flex: 1; overflow: auto; padding: 8px; }
.law-node { margin-bottom: 4px; }
.law-header { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.law-header:hover { background: var(--bgHover); }
.law-header .caret { font-size: 10px; color: var(--muted); width: 10px; display: inline-block; transition: transform 0.15s ease; }
.law-header.expanded .caret { transform: rotate(90deg); }
.law-header .title { font-size: 13px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.law-actions { display: none; gap: 4px; }
.law-header:hover .law-actions { display: flex; }
.icon-btn { width: 22px; height: 22px; border-radius: 5px; border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.icon-btn:hover { background: var(--border); color: var(--text); }

.art-list { padding-left: 18px; margin-top: 2px; }
.art-row { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.art-row:hover { background: var(--bgHover); }
.art-row .no { font-size: 11px; font-family: 'JetBrains Mono', monospace; color: var(--muted); white-space: nowrap; }
.art-row .title { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.art-row .star { font-size: 11px; color: var(--accent); }

.sidebar-empty { padding: 24px 12px; text-align: center; font-size: 12.5px; color: var(--muted); }

.main { flex: 1; overflow: auto; min-height: 0; }
.content { max-width: 780px; margin: 0 auto; padding: 32px 40px 120px 40px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-bottom: 18px; }

.law-card { border: 1px solid var(--border); background: var(--bgEl); border-radius: 12px; padding: 20px 22px; margin-bottom: 24px; }
.law-card .name { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.law-card .meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.revisions { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.revision-row { display: flex; gap: 10px; font-size: 12px; }

.article-block { padding: 22px 0; border-bottom: 1px solid var(--border); }
.article-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.article-head .left { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.article-head .no { font-family: 'JetBrains Mono', monospace; font-size: 14px; color: var(--accent); font-weight: 600; }
.article-head .title { font-size: 17px; font-weight: 700; }
.article-actions { display: flex; gap: 6px; flex-shrink: 0; }
.para { font-size: 14.5px; line-height: 1.75; color: var(--text); margin-bottom: 8px; white-space: pre-wrap; }

.empty { padding: 80px 20px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 32px; margin-bottom: 12px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bgEl); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 9px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); z-index: 60;
}

.sync-status { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; transition: background 0.2s ease; }
.sync-dot.ok { background: #6fcf6f; }
.sync-dot.error { background: #ff8a80; }
.sync-dot.running { background: var(--accent2); animation: syncPulse 1s ease-in-out infinite; }
@keyframes syncPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
