/* ════════════════════════════════════════════════════════════════════
   LexFlow — public site stylesheet (built on top of shadcn.css)
   ════════════════════════════════════════════════════════════════════ */

@import url('shadcn.css');

/* ─── App shell ───────────────────────────────────────────────── */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.app-main { flex: 1; }

/* ─── Header / topbar ─────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center;
  gap: 1rem;
  padding-inline: 1rem;
  height: var(--header-height);
  background: hsl(var(--background) / 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid hsl(var(--border));
}
@media (min-width: 1024px) { .topbar { padding-inline: 2rem; } }
.topbar-inner {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.125rem;
  color: hsl(var(--foreground));
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem; height: 2rem;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-radius: calc(var(--radius) - 2px);
  font-size: 1rem;
}
.topbar-search {
  flex: 1;
  max-width: 28rem;
  position: relative;
}
.topbar-search input {
  height: 2.25rem;
  padding-left: 1rem;
  padding-right: 2.5rem;
  background: hsl(var(--muted) / 0.5);
  border: 1px solid transparent;
  border-radius: 999px;
}
/* Hide WebKit's native × clear button on type="search" so it doesn't
 * overlap with our right-positioned submit button. */
.topbar-search input::-webkit-search-decoration,
.topbar-search input::-webkit-search-cancel-button,
.topbar-search input::-webkit-search-results-button,
.topbar-search input::-webkit-search-results-decoration { display: none; }
.topbar-search input:focus {
  background: hsl(var(--background));
  border-color: hsl(var(--input));
}
.topbar-search-btn {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: hsl(var(--muted-foreground));
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.topbar-search-btn:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
.topbar-search-btn:focus-visible {
  outline: 2px solid hsl(var(--ring) / 0.5);
  outline-offset: 1px;
}

/* Header search autocomplete dropdown. */
.topbar-suggest {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  z-index: 60;
  background: hsl(var(--popover, var(--background)));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.10);
  max-height: 22rem;
  overflow-y: auto;
  padding: 0.25rem;
}
.topbar-suggest[hidden] { display: none; }
.topbar-suggest-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4375rem 0.625rem;
  border-radius: calc(var(--radius) - 4px);
  text-decoration: none;
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  cursor: pointer;
}
.topbar-suggest-item:hover,
.topbar-suggest-item.is-active {
  background: hsl(var(--muted) / 0.7);
}
.topbar-suggest-tag {
  flex-shrink: 0;
  padding: 0.0625rem 0.4375rem;
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  min-width: 2.75rem;
  text-align: center;
}
.topbar-suggest-tag.case { background: hsl(38 92% 95%); color: hsl(38 92% 30%); }
.topbar-suggest-tag.router { background: hsl(160 55% 92%); color: hsl(160 55% 28%); }
.topbar-suggest-tag.glossary { background: hsl(280 60% 95%); color: hsl(280 60% 35%); }
.topbar-suggest-tag.tool { background: hsl(220 70% 95%); color: hsl(220 70% 35%); }
.topbar-suggest-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Scope chips above the suggest panel — only visible while the dropdown is open */
.topbar-suggest-chips {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0; right: 0;
  z-index: 61;
  display: none;
  flex-wrap: wrap; gap: 0.25rem;
  padding: 0.4375rem 0.5rem 0.0625rem;
  pointer-events: none;
}
form[data-search-suggest].is-suggest-open .topbar-suggest-chips {
  display: flex;
}
.topbar-suggest-chips ~ .topbar-suggest:not([hidden]) {
  top: calc(100% + 2.25rem);
}
.topbar-suggest-chip {
  pointer-events: auto;
  padding: 0.1875rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: background-color .12s, color .12s, border-color .12s;
}
.topbar-suggest-chip:hover { border-color: hsl(var(--primary) / 0.4); }
.topbar-suggest-chip.is-on {
  background: hsl(var(--primary) / 0.10);
  color: hsl(var(--primary));
  border-color: hsl(var(--primary) / 0.5);
}
.topbar-suggest-note {
  padding: 0.25rem 0.625rem;
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  border-bottom: 1px dashed hsl(var(--border));
  margin-bottom: 0.25rem;
}

.topbar-nav { display: flex; gap: 0.25rem; }
.topbar-nav a {
  padding: 0.375rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}
.topbar-nav a:hover { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }
.topbar-nav a.active { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }

.topbar-right {
  display: flex; align-items: center; gap: 0.5rem;
  margin-left: auto;
}
.topbar-right > a {
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--muted-foreground));
}
.topbar-right > a:hover { color: hsl(var(--foreground)); background: hsl(var(--secondary)); }
.topbar-right .btn-primary { font-size: 0.875rem; height: 2rem; padding-inline: 0.875rem; }

.user-link { font-weight: 500; color: hsl(var(--foreground)) !important; }
.admin-link {
  background: hsl(var(--accent) / 0.12);
  color: hsl(var(--accent-foreground)) !important;
  padding: 0.25rem 0.625rem !important;
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.75rem !important;
  font-weight: 600;
  border: 1px solid hsl(var(--accent) / 0.3);
}
.link-btn {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  padding: 0.375rem 0.625rem;
}
.link-btn:hover { color: hsl(var(--foreground)); }

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  width: 2.25rem; height: 2.25rem;
  align-items: center; justify-content: center;
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--foreground));
}
.menu-toggle:hover { background: hsl(var(--secondary)); }

@media (max-width: 767px) {
  .topbar-nav,
  .topbar-search,
  .topbar-right > a:not(.btn-primary):not(.user-link):not(.admin-link),
  .topbar-right form { display: none !important; }
  .menu-toggle { display: inline-flex; }
}

/* Mobile drawer */
.mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}
.mobile-drawer[data-open="true"] { display: block; }
.mobile-drawer-backdrop {
  position: absolute; inset: 0;
  background: rgb(0 0 0 / 0.4);
  animation: fade-in .2s ease;
}
.mobile-drawer-panel {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: min(20rem, 80vw);
  background: hsl(var(--background));
  border-right: 1px solid hsl(var(--border));
  padding: 1rem;
  overflow-y: auto;
  animation: slide-in .25s ease;
}
.mobile-drawer-panel nav { display: flex; flex-direction: column; gap: 0.125rem; margin-top: 1rem; }
.mobile-drawer-panel nav a {
  padding: 0.625rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.9375rem;
  color: hsl(var(--foreground));
}
.mobile-drawer-panel nav a:hover { background: hsl(var(--secondary)); }
.mobile-drawer-panel .group-label {
  margin-top: 1rem;
  padding: 0 0.75rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mobile-drawer-close {
  position: absolute; top: 0.75rem; right: 0.75rem;
  width: 2rem; height: 2rem; border-radius: calc(var(--radius) - 2px);
  display: inline-flex; align-items: center; justify-content: center;
  color: hsl(var(--muted-foreground));
}
.mobile-drawer-close:hover { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }

@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(-100%); } }

/* ─── Pinned posts banner (above hero) ─────────────────────────── */
.pinned-banner {
  display: flex; flex-direction: column; gap: .375rem;
  margin: 1rem auto 0; max-width: 56rem;
  padding: 0 1rem;
}
.pinned-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .625rem .875rem;
  background: hsl(var(--primary) / 0.06);
  border: 1px solid hsl(var(--primary) / 0.2);
  border-radius: var(--radius);
  text-decoration: none;
  color: hsl(var(--foreground));
  font-size: .875rem;
  transition: background .15s, border-color .15s;
}
.pinned-item:hover {
  background: hsl(var(--primary) / 0.1);
  border-color: hsl(var(--primary) / 0.35);
}
.pinned-icon { flex-shrink: 0; }
.pinned-cat {
  font-size: .6875rem; font-weight: 600; letter-spacing: .02em;
  padding: .125rem .5rem;
  background: hsl(var(--primary) / 0.15);
  color: hsl(var(--primary));
  border-radius: 999px;
  flex-shrink: 0;
}
.pinned-title {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500;
}
.pinned-date {
  font-family: var(--font-mono); font-size: .75rem;
  color: hsl(var(--muted-foreground));
  flex-shrink: 0;
}

/* ─── Hero ─────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 4rem 1rem 2.5rem;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, hsl(var(--ring) / 0.08), transparent),
    hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
}
.hero-logo { font-size: 3rem; line-height: 1; margin-bottom: 0.5rem; }
.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -0.025em;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
}
.hero-tagline { color: hsl(var(--muted-foreground)); font-size: 1rem; margin-bottom: 1.75rem; }
.hero-search {
  max-width: 36rem; margin: 0 auto 1rem;
  display: flex; padding: 0 1rem;
  position: relative;
}
.hero-search input {
  flex: 1;
  height: 3rem;
  padding: 0 6rem 0 1.25rem;
  font-size: 0.9375rem;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--background));
  transition: border-color .15s, box-shadow .15s;
}
.hero-search input:focus {
  outline: none;
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.12);
}
.hero-search .btn-primary {
  position: absolute;
  right: 1.375rem;
  top: 50%;
  transform: translateY(-50%);
  height: 2.375rem;
  padding-inline: 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 999px;
  display: inline-flex; align-items: center; gap: .375rem;
}
.hero-stats { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); }
@media (max-width: 540px) {
  .hero-search input { padding-right: 5rem; }
  .hero-search .btn-primary { right: 1.375rem; }
}

/* ─── Sections (public site) ──────────────────────────────────── */
.section {
  margin-top: 2.5rem;
  padding-inline: 1rem;
  max-width: var(--content-max);
  margin-inline: auto;
}
@media (min-width: 1024px) { .section { padding-inline: 2rem; } }
.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
}

.cat-grid, .quick-grid {
  display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.cat-card, .quick-card {
  display: block;
  padding: 1.125rem 1.25rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  color: hsl(var(--foreground));
  transition: all .15s;
}
.cat-card:hover, .quick-card:hover {
  border-color: hsl(var(--primary) / 0.3);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.06);
  transform: translateY(-1px);
}
.cat-label { font-weight: 600; font-size: 1rem; margin-bottom: 0.25rem; }
.cat-desc { color: hsl(var(--muted-foreground)); font-size: 0.8125rem; }

/* ─── Auth card ────────────────────────────────────────────────── */
.auth-card {
  width: 100%;
  max-width: 26rem;
  margin: 3rem auto;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 4px 20px rgb(0 0 0 / 0.04);
}
.auth-card h1 { font-size: 1.5rem; text-align: center; margin-bottom: 0.375rem; }
.auth-card .sub { color: hsl(var(--muted-foreground)); text-align: center; margin-bottom: 1.5rem; font-size: 0.875rem; }
.auth-links {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid hsl(var(--border));
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
}
.auth-links a { color: hsl(var(--foreground)); font-weight: 500; }
.auth-links a:hover { text-decoration: underline; }

/* ─── Form primitives (used by auth + simple public forms) ────── */
.form-group {
  display: flex; flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1rem;
}
.form-group label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="tel"],
.form-group input[type="url"],
.form-group input[type="search"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.875rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: inherit;
  font-size: 0.9375rem;
  transition: border-color .15s, box-shadow .15s;
}
.form-group textarea {
  height: auto;
  min-height: 6rem;
  padding: 0.625rem 0.875rem;
  line-height: 1.5;
  resize: vertical;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.12);
}
.form-group .help {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.125rem;
}

.form-actions {
  display: flex; gap: 0.5rem;
  margin-top: 1.25rem;
}
.form-actions button[type="submit"],
.form-actions .btn-primary {
  flex: 1;
  height: 2.625rem;
  font-weight: 600;
}
.form-actions button[type="submit"]:not(.btn-primary):not(.ghost) {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s;
}
.form-actions button[type="submit"]:not(.btn-primary):not(.ghost):hover {
  background: hsl(var(--primary) / 0.92);
}

/* ─── Footer ───────────────────────────────────────────────────── */
.foot {
  border-top: 1px solid hsl(var(--border));
  padding: 2rem 1rem 1.25rem;
  margin-top: 4rem;
  background: hsl(var(--muted) / 0.3);
}
.foot-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}
.foot-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 1rem 1.5rem;
  padding-bottom: 1.25rem;
}
.foot-col-title {
  font-size: .75rem;
  font-weight: 700;
  margin: 0 0 .5rem;
  color: hsl(var(--foreground));
  letter-spacing: .04em;
}
.foot-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.foot-col a {
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  font-size: .75rem;
}
.foot-col a:hover { color: hsl(var(--primary)); }
.foot-bar {
  border-top: 1px solid hsl(var(--border));
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .6875rem;
  color: hsl(var(--muted-foreground));
}
.foot-credit { font-weight: 500; }
.foot-disclaimer { line-height: 1.6; }
.foot a { color: hsl(var(--foreground)); }
.foot a:hover { text-decoration: underline; }

/* ─── Prose (Markdown-rendered content) ──────────────────────────
   Used by both admin post pages and public /posts/{slug}.
   Designed to feel like the rest of the shadcn shell. */
.prose {
  font-size: 0.9375rem;
  line-height: 1.75;
  color: hsl(var(--foreground));
}
.prose > :first-child { margin-top: 0; }
.prose > :last-child  { margin-bottom: 0; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: -0.015em;
  color: hsl(var(--foreground));
  margin: 1.5em 0 0.5em;
  line-height: 1.3;
}
.prose h1 { font-size: 1.625rem; }
.prose h2 { font-size: 1.375rem; }
.prose h3 { font-size: 1.125rem; }
.prose h4, .prose h5, .prose h6 { font-size: 1rem; }
.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.5em; }
.prose li { margin: 0.25em 0; }
.prose blockquote {
  margin: 0 0 1em;
  padding: 0.5em 1em;
  border-left: 3px solid hsl(var(--primary));
  background: hsl(var(--muted) / 0.4);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.125em 0.375em;
  background: hsl(var(--muted) / 0.7);
  border-radius: 4px;
}
.prose pre {
  margin: 0 0 1em;
  padding: 0.875rem 1rem;
  background: hsl(222 47% 8%);
  color: hsl(0 0% 92%);
  border-radius: calc(var(--radius) - 2px);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.55;
}
.prose pre code { background: transparent; padding: 0; color: inherit; font-size: 1em; }
.prose a {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.prose a:hover { text-decoration-thickness: 2px; }
.prose hr { border: 0; height: 1px; background: hsl(var(--border)); margin: 1.5em 0; }
.prose strong { font-weight: 700; color: hsl(var(--foreground)); }
.prose em { font-style: italic; }

/* ─── Public-page badges ────────────────────────────────────────
   Mirror the admin-pane variants in admin.css. These are used on
   meta rows in /caselaw/{type}/{id}, /admrul/{id}, /treaty/{id},
   /ftc/{id} etc. */
.badge {
  display: inline-flex; align-items: center;
  padding: .125rem .5rem;
  border-radius: 999px;
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid transparent;
  line-height: 1.4;
}
.badge.info    { background: hsl(217 91% 60% / 0.12); color: hsl(217 91% 35%); }
.badge.neutral { background: hsl(var(--muted) / 0.6); color: hsl(var(--muted-foreground)); }
.badge.accent  { background: hsl(38 92% 95%);         color: hsl(38 92% 30%); }
.badge.success { background: hsl(142 71% 45% / 0.1); color: hsl(142 71% 30%); }
.badge.warn    { background: hsl(38 92% 95%);         color: hsl(38 92% 30%); }
.badge.danger  { background: hsl(0 84% 60% / 0.1);   color: hsl(0 70% 40%); }

/* Private note panel (article-anchored notes). */
.note-panel {
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  background: hsl(45 100% 97%);
  border: 1px solid hsl(45 80% 80%);
  border-left: 3px solid hsl(45 90% 55%);
  border-radius: var(--radius);
}
.note-panel-title {
  display: flex; align-items: center; gap: .375rem;
  font-size: .875rem;
  font-weight: 700;
  margin: 0 0 .625rem;
  color: hsl(45 70% 30%);
  letter-spacing: .01em;
}
.note-panel-count {
  margin-left: .375rem;
  padding: 0 .4375rem;
  background: hsl(45 90% 55%);
  color: white;
  border-radius: 999px;
  font-size: .6875rem;
  font-weight: 700;
}
.note-panel-empty {
  margin: 0;
  font-size: .8125rem;
  color: hsl(var(--muted-foreground));
}
.note-panel-empty a {
  color: hsl(var(--primary));
  font-weight: 600;
  text-decoration: none;
}
.note-panel-empty a:hover { text-decoration: underline; }
.note-panel-list {
  list-style: none; padding: 0; margin: 0 0 .75rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.note-panel-item {
  background: hsl(0 0% 100%);
  border: 1px solid hsl(45 60% 85%);
  border-radius: calc(var(--radius) - 2px);
  padding: .625rem .875rem;
}
.note-panel-body {
  font-size: .875rem;
  line-height: 1.6;
  color: hsl(var(--foreground));
  white-space: pre-wrap;
  word-break: keep-all;
}
.note-panel-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: .5rem;
  font-size: .6875rem;
  color: hsl(var(--muted-foreground));
}
.note-panel-meta time { font-family: var(--font-mono); }
.note-panel-del { display: inline-flex; }
.note-panel-del .link-btn {
  background: none; border: 0; padding: 0;
  color: hsl(var(--muted-foreground));
  font-size: .6875rem;
  cursor: pointer;
  text-decoration: underline;
}
.note-panel-del .link-btn:hover { color: hsl(0 70% 45%); }
.note-panel-form textarea {
  width: 100%;
  padding: .5rem .75rem;
  background: hsl(0 0% 100%);
  border: 1px solid hsl(45 60% 80%);
  border-radius: calc(var(--radius) - 2px);
  font-size: .875rem;
  font-family: inherit;
  resize: vertical;
}
.note-panel-form textarea:focus {
  outline: 0;
  border-color: hsl(45 90% 50%);
  box-shadow: 0 0 0 3px hsl(45 90% 55% / 0.15);
}
.note-panel-actions {
  display: flex; justify-content: flex-end;
  margin-top: .375rem;
}

/* Unified visual breadcrumb (companion to JSON-LD BreadcrumbList). */
.breadcrumb-row {
  font-size: .8125rem;
  color: hsl(var(--muted-foreground));
  padding-top: 1rem;
  margin-top: 0;
  display: flex; flex-wrap: wrap; align-items: center;
}
.breadcrumb-row a { color: inherit; text-decoration: none; }
.breadcrumb-row a:hover { color: hsl(var(--primary)); }
.breadcrumb-sep { margin: 0 .375rem; opacity: .6; }
.breadcrumb-current { color: hsl(var(--foreground)); font-weight: 500; }

/* Inline bookmark control on /law/{family} and /caselaw/{type}/{id} hero. */
.bookmark-form { display: inline-flex; }
.bookmark-btn {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .375rem .875rem;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  font-size: .8125rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s, border-color .12s;
}
.bookmark-btn:hover {
  background: hsl(var(--primary) / 0.08);
  border-color: hsl(var(--primary) / 0.4);
  color: hsl(var(--primary));
}
.bookmark-btn.is-active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
  cursor: default;
}
.bookmark-btn.is-active:hover { background: hsl(var(--primary)); }
.bookmark-btn.ghost {
  border-style: dashed;
  color: hsl(var(--muted-foreground));
}
.law-hero-row, .caselaw-title-row {
  display: flex; align-items: flex-start; gap: 1rem;
  flex-wrap: wrap;
}
.law-hero-row > .law-title,
.caselaw-title-row > .caselaw-title { flex: 1; min-width: 0; margin-bottom: 0; }

/* Print styles — clean reference output for legal pros. */
@media print {
  .topbar, .foot, .mobile-drawer, .breadcrumbs,
  .topbar-search, .topbar-suggest, .menu-toggle,
  .bookmark-btn, .bookmark-form,
  .law-graph-link, .law-article-cases,
  .caselaw-cite-row, .caselaw-citations,
  .caselaw-cited-articles,
  .post-comments, .comments-list, .comments-form, .note-panel,
  nav[aria-label], details, footer,
  .recent-feed, .recent-pager,
  .filter-pills, .quick-card,
  button, .btn-primary, .btn-sm { display: none !important; }
  body { background: white; color: black; font-size: 11pt; line-height: 1.6; }
  .section { padding-inline: 0; max-width: none; margin: 0 0 1rem; }
  .law-title, .caselaw-title { font-size: 1.5rem; }
  .law-article, .caselaw-section, .law-art-show { break-inside: avoid; }
  .law-ref { color: black !important; border-bottom: 0; }
  a { color: black; text-decoration: none; }
  a[href^="/law/"]::after { content: " ("attr(href)")"; font-size: 9pt; opacity: .6; }
}

/* "관련 법령" footer chips on /tools/* pages. */
.tools-related {
  display: flex; flex-wrap: wrap; align-items: center; gap: .375rem;
  margin-top: .875rem;
  padding-top: .75rem;
  border-top: 1px dashed hsl(var(--border));
}
.tools-related-label {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: hsl(var(--muted-foreground));
  margin-right: .25rem;
}
.tools-related a {
  display: inline-flex; align-items: center;
  padding: .1875rem .625rem;
  background: hsl(var(--primary) / 0.08);
  color: hsl(var(--primary));
  border-radius: 999px;
  font-size: .75rem;
  text-decoration: none;
  font-weight: 500;
  transition: background-color .12s;
}
.tools-related a:hover { background: hsl(var(--primary) / 0.15); }

/* Auto-linkified law-article references inside case bodies. */
.law-ref {
  color: hsl(var(--primary));
  text-decoration: none;
  border-bottom: 1px dotted hsl(var(--primary) / 0.5);
  transition: border-color .12s, background-color .12s;
}
.law-ref:hover {
  background: hsl(var(--primary) / 0.06);
  border-bottom-color: hsl(var(--primary));
}
.glossary-ref {
  color: hsl(280 60% 35%);
  text-decoration: none;
  border-bottom: 1px dotted hsl(280 60% 50% / 0.5);
  cursor: help;
  transition: border-color .12s, background-color .12s;
}
.glossary-ref:hover {
  background: hsl(280 60% 95%);
  border-bottom-color: hsl(280 60% 50%);
}

/* Matter quick-add dropdown */
.matter-add { position: relative; display: inline-block; }
.matter-add-pop {
  position: absolute;
  top: calc(100% + .25rem); right: 0;
  z-index: 50;
  min-width: 18rem;
  max-height: 24rem;
  overflow-y: auto;
  background: hsl(var(--popover, var(--background)));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.10);
  padding: .25rem;
}
.matter-add-pop[hidden] { display: none; }
.matter-add-head, .matter-add-foot {
  font-size: .6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: hsl(var(--muted-foreground));
  padding: .375rem .5rem;
}
.matter-add-foot {
  border-top: 1px dashed hsl(var(--border));
  margin-top: .25rem;
  display: flex; justify-content: space-between;
}
.matter-add-foot a {
  color: hsl(var(--primary));
  text-decoration: none;
  font-size: .75rem;
}
.matter-add-foot a:hover { text-decoration: underline; }
.matter-add-form-row { margin: 0; }
.matter-add-opt {
  width: 100%;
  display: flex; flex-direction: column; gap: .125rem;
  align-items: flex-start;
  padding: .5rem .625rem;
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius) - 4px);
  text-align: left;
  cursor: pointer;
  color: hsl(var(--foreground));
}
.matter-add-opt:hover { background: hsl(var(--muted) / 0.6); }
.matter-add-opt strong { font-size: .8125rem; font-weight: 600; }
.matter-add-opt small { font-size: .6875rem; color: hsl(var(--muted-foreground)); }
.matter-add-empty {
  padding: 1rem;
  font-size: .8125rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
}
.matter-add-empty a { color: hsl(var(--primary)); text-decoration: none; }

/* ─── Command palette (public, Cmd-K) — mirror of admin.css block ─ */
.cmdk-trigger {
  display: inline-flex; align-items: center; gap: 0.5rem;
  height: 2rem; padding: 0 0.625rem;
  background: hsl(var(--muted) / 0.5);
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.cmdk-trigger:hover {
  background: hsl(var(--muted));
  border-color: hsl(var(--primary) / 0.3);
}
.cmdk-trigger kbd {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: 0.0625rem 0.375rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 4px;
}
@media (max-width: 900px) {
  .cmdk-trigger span, .cmdk-trigger kbd { display: none; }
}

.cmdk-overlay {
  position: fixed; inset: 0;
  z-index: 1000;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 8vh;
}
.cmdk-overlay[hidden] { display: none; }
.cmdk-backdrop {
  position: absolute; inset: 0;
  background: hsl(0 0% 0% / 0.5);
  backdrop-filter: blur(2px);
}
.cmdk-panel {
  position: relative;
  width: min(36rem, 92vw);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 24px 48px hsl(0 0% 0% / 0.25);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: 70vh;
}
.cmdk-input-wrap {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
}
.cmdk-input {
  flex: 1; border: 0; outline: 0; background: transparent;
  color: hsl(var(--foreground));
  font: inherit; font-size: 0.9375rem;
}
.cmdk-input-wrap kbd {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  background: hsl(var(--muted) / 0.6);
  border: 1px solid hsl(var(--border));
  border-radius: 4px;
}
.cmdk-list {
  list-style: none; margin: 0; padding: 0.375rem;
  overflow-y: auto; flex: 1;
}
.cmdk-item {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  align-items: center; gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer; font-size: 0.875rem;
}
.cmdk-item.active { background: hsl(var(--primary) / 0.08); }
.cmdk-icon { color: hsl(var(--muted-foreground)); display: flex; align-items: center; justify-content: center; }
.cmdk-item.active .cmdk-icon { color: hsl(var(--primary)); }
.cmdk-text { display: flex; flex-direction: column; min-width: 0; }
.cmdk-title { color: hsl(var(--foreground)); font-weight: 500; }
.cmdk-group {
  color: hsl(var(--muted-foreground));
  font-size: 0.6875rem;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.cmdk-path {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
}
.cmdk-empty {
  padding: 2rem 1rem; text-align: center;
  color: hsl(var(--muted-foreground)); font-size: 0.875rem;
}
.cmdk-foot {
  display: flex; gap: 1rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.4);
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
}
.cmdk-foot kbd {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  padding: 0.0625rem 0.3125rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 3px;
  margin-right: 0.25rem;
}

.me-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0 1rem;
  margin: 1.25rem auto 0;
  max-width: var(--content-max);
  border-bottom: 1px solid hsl(var(--border));
  font-size: .875rem;
  overflow-x: auto;
}
@media (min-width: 1024px) { .me-nav { padding: 0 2rem; } }
.me-nav-item {
  display: inline-flex;
  align-items: center;
  padding: .625rem .875rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.me-nav-item:hover {
  color: hsl(var(--foreground));
}
.me-nav-item.is-active {
  color: hsl(var(--primary));
  border-bottom-color: hsl(var(--primary));
}
@media (max-width: 540px) {
  .me-nav { font-size: .8125rem; }
  .me-nav-item { padding: .5rem .625rem; }
}

/* Search results grouping toggle (?group=flat|law) and grouped-by-law view.
   Added tick 243 per 변호사님 ultraplan request — flat default, law toggle
   collapses N articles from the same family into a single header + chips. */
.search-group-toggle {
  display: inline-flex; gap: .25rem;
  margin: .75rem 0 1rem;
  padding: 2px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  background: hsl(var(--muted) / 0.4);
}
.search-group-toggle a {
  padding: .35rem .85rem;
  font-size: .8125rem; font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-decoration: none; border-radius: 999px;
  transition: background-color .15s, color .15s;
}
.search-group-toggle a:hover { color: hsl(var(--foreground)); }
.search-group-toggle a.active {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgb(0 0 0 / .04);
}

.search-group {
  margin: .75rem 0;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--card));
  overflow: hidden;
}
.search-group-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .65rem .875rem;
  text-decoration: none; color: hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.4);
  transition: background-color .15s;
}
.search-group-head:hover { background: hsl(var(--muted) / 0.8); }
.search-group-pill {
  font-size: .75rem; font-weight: 600;
  padding: 1px 7px; border-radius: 999px;
  background: hsl(var(--primary) / 0.15);
  color: hsl(var(--primary));
  min-width: 22px; text-align: center;
}
.search-group-name { font-weight: 600; font-size: .9375rem; flex: 1; }
.search-group-arrow { color: hsl(var(--muted-foreground)); font-size: .875rem; }
.search-group-chips {
  display: flex; flex-wrap: wrap; gap: .375rem;
  padding: .625rem .875rem;
}
.search-group-chip {
  font-size: .8125rem; font-weight: 500;
  padding: .25rem .625rem; border-radius: 6px;
  text-decoration: none;
  color: hsl(var(--foreground));
  background: hsl(var(--muted) / 0.5);
  transition: background-color .15s, color .15s;
}
.search-group-chip:hover {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}
.search-group-more {
  font-size: .8125rem; font-weight: 500;
  padding: .25rem .625rem; border-radius: 6px;
  text-decoration: none;
  color: hsl(var(--muted-foreground));
  background: transparent; border: 1px dashed hsl(var(--border));
}
.search-group-more:hover {
  color: hsl(var(--foreground));
  border-color: hsl(var(--muted-foreground));
}

/* Auto-suggest banner — appears when flat-mode results have ≥5 hits in
   the same law family, nudging the user to switch to grouped view. */
.search-suggest-banner {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem .875rem;
  margin-bottom: .5rem;
  border: 1px solid hsl(var(--primary) / 0.25);
  border-radius: var(--radius);
  background: hsl(var(--primary) / 0.06);
  font-size: .8125rem;
}
.search-suggest-banner span {
  flex: 1; color: hsl(var(--foreground));
}
.search-suggest-banner a {
  color: hsl(var(--primary)); font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.search-suggest-banner a:hover { text-decoration: underline; }
