/* Juriscore — research workspace tokens */
:root {
  --ink: #14213d;
  --ink-soft: #2c3a5a;
  --paper: #fafaf8;
  --card: #ffffff;
  --rule: #e2e5eb;
  --muted: #6b7280;
  --accent: #00327d;
  --accent-soft: #e8eef8;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --green: #047857;
  --green-soft: #d1fae5;
  --error: #b91c1c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 33, 61, 0.04), 0 8px 24px rgba(20, 33, 61, 0.06);
  --font-display: Georgia, "Times New Roman", Times, serif;
  --font-body: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", Consolas, "SF Mono", monospace;
  --max: 920px;
  --nav-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  border-radius: 0 0 8px 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }
.brand-mark img,
.brand-mark-svg {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: block;
}

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--nav-w);
  background: var(--card);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 20px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 16px;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--ink-soft);
  text-align: left; width: 100%;
  transition: background 0.15s ease;
}
.nav-item:hover { background: var(--accent-soft); text-decoration: none; }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }

.sidebar-foot { border-top: 1px solid var(--rule); padding-top: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  width: 100%; text-align: left;
}
.user-chip:hover { background: var(--accent-soft); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-mail { font-size: 11px; color: var(--muted); }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 28px;
  background: rgba(250, 250, 248, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.content { max-width: var(--max); margin: 0 auto; padding: 28px 28px 80px; }

/* Mobile nav */
.menu-btn { display: none; width: 40px; height: 40px; border-radius: 8px; align-items: center; justify-content: center; }
.menu-btn:hover { background: var(--accent-soft); }
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: 8px 0 24px rgba(20,33,61,0.08);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .backdrop {
    display: none; position: fixed; inset: 0; background: rgba(20,33,61,0.35); z-index: 30;
  }
  .backdrop.show { display: block; }
  .content { padding: 20px 16px 96px; }
  .topbar { padding: 12px 16px; }
}

/* Views */
.view { display: none; }
.view.active { display: block; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Search hero */
.hero { padding: 12px 0 28px; }
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 8px;
}
.hero p { color: var(--muted); font-size: 15px; max-width: 48ch; }
.search-box {
  margin-top: 22px;
  display: flex; align-items: center; gap: 0;
  background: var(--card);
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box input {
  flex: 1; border: none; outline: none;
  padding: 16px 18px; font-size: 16px; background: transparent;
}
.search-box input::placeholder { color: var(--muted); }
.search-box button {
  padding: 14px 22px; margin: 4px;
  background: var(--accent); color: #fff;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
}
.search-box button:hover { background: #002560; }
.search-box button:disabled { opacity: 0.55; cursor: wait; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--card);
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
}
.chip:hover, .chip.active {
  border-color: var(--accent); background: var(--accent-soft); color: var(--accent);
}

/* Cards & lists */
.section-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin: 28px 0 12px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.tile {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px; background: var(--card);
  border: 1px solid var(--rule); border-radius: var(--radius);
  text-align: left; transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 88px;
}
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; }
.tile-title { font-weight: 700; font-size: 14px; }
.tile-sub { font-size: 12px; color: var(--muted); line-height: 1.4; }

.result {
  background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 10px;
  text-align: left; width: 100%; display: block;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.result:hover { border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.result-meta {
  display: flex; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted);
}
.result-meta .court { color: var(--accent); }
.result-title {
  font-family: var(--font-display); font-size: 17px; font-weight: 700;
  line-height: 1.35; margin-bottom: 6px; color: var(--ink);
}
.result-cite { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); margin-bottom: 8px; }
.result-excerpt { font-size: 13px; color: var(--muted); line-height: 1.5; }
.result-actions { display: flex; gap: 8px; margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--rule); background: var(--card); color: var(--ink);
  min-height: 36px;
}
.btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #002560; color: #fff; }
.btn-danger { color: var(--error); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; color: var(--error); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Detail */
.detail-head { margin-bottom: 20px; }
.detail-kicker {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 8px;
}
.detail-title {
  font-family: var(--font-display); font-size: clamp(22px, 3vw, 28px);
  font-weight: 700; line-height: 1.25; letter-spacing: -0.01em;
}
.detail-cite { font-family: var(--font-mono); font-size: 13px; color: var(--ink-soft); margin-top: 8px; }
.detail-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.brief {
  background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 0; overflow: hidden; margin-bottom: 16px;
}
.brief-row { display: grid; grid-template-columns: 110px 1fr; border-bottom: 1px solid var(--rule); }
.brief-row:last-child { border-bottom: none; }
.brief-label {
  padding: 14px 16px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  background: var(--paper); border-right: 1px solid var(--rule);
}
.brief-body { padding: 14px 16px; font-size: 14px; line-height: 1.6; }
@media (max-width: 520px) {
  .brief-row { grid-template-columns: 1fr; }
  .brief-label { border-right: none; border-bottom: 1px solid var(--rule); padding-bottom: 6px; }
}

.prose { font-size: 15px; line-height: 1.7; }
.prose h3 { font-family: var(--font-display); font-size: 18px; margin: 18px 0 8px; }
.prose p { margin-bottom: 12px; }
.prose ul { margin: 0 0 12px 18px; }
.prose li { margin-bottom: 6px; }

/* States */
.state {
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.state-title { font-weight: 700; color: var(--ink); font-size: 16px; margin-bottom: 6px; }
.state-text { font-size: 14px; max-width: 36ch; margin: 0 auto; line-height: 1.5; }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--rule);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 100;
  background: var(--ink); color: #fff; padding: 12px 16px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); transform: translateY(12px); opacity: 0;
  pointer-events: none; transition: all 0.2s ease;
}
.toast.show { transform: none; opacity: 1; }

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 6px;
}
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--rule); background: var(--card);
  font-size: 14px;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { min-height: 100px; resize: vertical; }

.card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hstack { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.empty {
  border: 1.5px dashed var(--rule); border-radius: var(--radius);
  padding: 36px 20px; text-align: center; color: var(--muted);
}

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    linear-gradient(180deg, rgba(0,50,125,0.04), transparent 40%),
    var(--paper);
}
.login-card {
  width: 100%; max-width: 420px; background: var(--card);
  border: 1px solid var(--rule); border-radius: 16px;
  padding: 32px 28px; box-shadow: var(--shadow);
}
.login-card h1 { font-family: var(--font-display); font-size: 26px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.tabs { display: flex; gap: 4px; background: var(--paper); padding: 4px; border-radius: 10px; margin-bottom: 18px; }
.tabs button {
  flex: 1; padding: 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted);
}
.tabs button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.error-banner {
  background: #fef2f2; color: var(--error); border: 1px solid #fecaca;
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px;
}

.flashcard-face {
  min-height: 200px; display: flex; flex-direction: column; justify-content: center;
  padding: 28px; background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--radius); margin-bottom: 12px;
}
.flashcard-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
.flashcard-text { font-family: var(--font-display); font-size: 20px; line-height: 1.4; }

@media print {
  .sidebar, .topbar, .result-actions { display: none !important; }
  .main { margin: 0; }
}
