.leyes-layout {
  display: flex;
  height: calc(100vh - var(--topbar-h));
  margin-top: var(--topbar-h);
  overflow: hidden;
}

/* ── Panel izquierdo ─── */
.leyes-sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.leyes-sidebar-header {
  padding: 1rem 1.1rem .8rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.leyes-sidebar-header h2 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .5rem;
}
.leyes-search {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .35rem .7rem;
  gap: .5rem;
}
.leyes-search i { color: var(--text-muted); font-size: .85rem; }
.leyes-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: .85rem;
  width: 100%;
}
.leyes-search input::placeholder { color: var(--text-muted); }

.leyes-list {
  overflow-y: auto;
  flex: 1;
  padding: .5rem 0;
}

.ley-grupo-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  padding: .7rem 1.1rem .3rem;
}
.ley-item {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .6rem 1.1rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .12s, border-color .12s;
}
.ley-item:hover { background: var(--bg-hover); }
.ley-item.active {
  background: var(--bg-hover);
  border-left-color: var(--accent);
}
.ley-item.hidden { display: none; }
.ley-nombre {
  font-size: .87rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.ley-subtitulo {
  font-size: .75rem;
  color: var(--text-muted);
}
.ley-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 4px;
  background: rgba(0,122,204,.15);
  color: var(--accent);
  margin-top: .1rem;
  width: fit-content;
}

/* ── Panel derecho ─── */
.leyes-viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.leyes-viewer-header {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .75rem 1.2rem;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.leyes-viewer-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.leyes-viewer-actions {
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}
.leyes-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  font-weight: 600;
  padding: .35rem .8rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.leyes-btn:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent-2); }
.leyes-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.leyes-btn.primary:hover { background: #0090e8; }

.leyes-viewer iframe {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
  filter: invert(1) hue-rotate(180deg);
}

/* ── Visor Markdown ─── */
#md-frame {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.5rem;
  color: var(--text);
  font-size: .95rem;
  line-height: 1.75;
}
#md-frame h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 1.2rem; color: var(--accent-2); border-bottom: 2px solid var(--border); padding-bottom: .5rem; }
#md-frame h2 { font-size: 1.2rem; font-weight: 700; margin: 2rem 0 .7rem; color: var(--accent-2); border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
#md-frame h3 { font-size: 1.05rem; font-weight: 600; margin: 1.5rem 0 .5rem; color: var(--text); }
#md-frame h4 { font-size: .97rem; font-weight: 600; margin: 1.2rem 0 .4rem; color: var(--text); }
#md-frame h5 { font-size: .92rem; font-weight: 600; margin: 1rem 0 .3rem; color: var(--text-muted); }
#md-frame p { margin: 0 0 .8rem; }
#md-frame ul, #md-frame ol { margin: .4rem 0 .8rem 1.5rem; }
#md-frame li { margin-bottom: .3rem; }
#md-frame strong { color: var(--accent-2); }
#md-frame hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
#md-frame blockquote { border-left: 3px solid var(--accent); background: var(--bg-alt); margin: .8rem 0; padding: .5rem 1rem; border-radius: 0 6px 6px 0; color: var(--text-muted); }
#md-frame code { background: var(--bg-alt); padding: .1rem .4rem; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: .88rem; }

.leyes-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
}
.leyes-placeholder i { font-size: 3rem; opacity: .3; }
.leyes-placeholder p { font-size: .95rem; }

/* ── Responsive ─── */
@media (max-width: 700px) {
  .leyes-layout { flex-direction: column; height: auto; overflow: auto; }
  .leyes-sidebar { width: 100%; height: 260px; border-right: none; border-bottom: 1px solid var(--border); }
  .leyes-viewer { height: calc(100vh - var(--topbar-h) - 260px); min-height: 400px; }
}
