/* Legal AI Report v1.0.0 */
:root {
  /* Colors — Light */
  --bg-primary: #f8f9fb;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f2f5;
  --bg-accent: #e8f0fe;
  --text-primary: #1a1d23;
  --text-secondary: #4a5068;
  --text-muted: #8690a6;
  --border: #dde1e8;
  --border-light: #eceef2;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #dbeafe;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #ca8a04;
  --warning-bg: #fef9c3;
  --error: #dc2626;
  --error-bg: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  /* Typography */
  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --fs-xs: .75rem;
  --fs-sm: .875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 2rem;
  --lh-tight: 1.3;
  --lh-normal: 1.6;
}

/* Dark mode */
[data-theme="dark"] {
  --bg-primary: #0b0d14;
  --bg-secondary: #151823;
  --bg-tertiary: #1e2233;
  --bg-accent: #1a2540;
  --text-primary: #eceef4;
  --text-secondary: #a8b0c8;
  --text-muted: #6b7394;
  --border: #252a3e;
  --border-light: #1e2236;
  --accent: #4f8fff;
  --accent-hover: #70a5ff;
  --accent-light: #1a2e52;
  --success-bg: #14532d;
  --warning-bg: #422006;
  --error-bg: #450a0a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
}
[data-theme="dark"] .search-card,
[data-theme="dark"] .api-dashboard,
[data-theme="dark"] .report-block {
  border-color: var(--border);
  box-shadow: 0 0 0 1px var(--border), var(--shadow-sm);
}
[data-theme="dark"] .api-card {
  background: var(--bg-tertiary);
  border-color: var(--border);
}
[data-theme="dark"] .search-card:hover {
  border-color: var(--accent-light);
  box-shadow: 0 0 20px rgba(79, 143, 255, .08);
}
[data-theme="dark"] .btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 24px rgba(79, 143, 255, .3);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: var(--lh-normal);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header */
.app-header {
  background: color-mix(in srgb, var(--bg-secondary) 85%, transparent);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: .625rem;
}

.app-header__logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: var(--fs-sm);
  transition: transform .2s;
}
.app-header__logo:hover {
  transform: rotate(15deg) scale(1.1);
}

.app-header__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -.02em;
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* Icon button */
.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .15s;
  font-size: var(--fs-lg);
}
.icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* Main content */
.app-main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ===== Entrance Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.92); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ===== Hero Section ===== */
.hero-section {
  text-align: center;
  margin-bottom: 2rem;
  animation: fadeInUp .6s ease both;
  position: relative;
  padding: 2.5rem 0 1rem;
}
.hero-section::before {
  content: "";
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: min(600px, 120vw);
  height: min(600px, 120vw);
  background: radial-gradient(circle, rgba(37,99,235,.12) 0%, rgba(124,58,237,.08) 30%, rgba(236,72,153,.04) 55%, transparent 70%);
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}
[data-theme="dark"] .hero-section::before {
  background: radial-gradient(circle, rgba(79,143,255,.14) 0%, rgba(124,58,237,.1) 30%, rgba(236,72,153,.05) 55%, transparent 70%);
}
/* Hero badge */
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .3rem .875rem;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent);
  margin-bottom: .75rem;
  animation: fadeIn .6s ease both;
  box-shadow: 0 1px 4px rgba(37, 99, 235, .1);
}
.hero-badge__dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s ease infinite;
}

.hero-title, .search-section__heading {
  font-size: var(--fs-3xl);
  font-weight: 800;
  letter-spacing: -.03em;
  margin-bottom: .5rem;
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 40%, #ec4899 70%, var(--accent) 100%);
  background-size: 300% 300%;
  animation: gradientShift 6s ease infinite;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 8px rgba(37, 99, 235, .15));
}
.hero-subtitle, .search-section__sub {
  color: var(--text-secondary);
  font-size: var(--fs-lg);
  margin-bottom: 1.5rem;
  max-width: 540px;
  margin-left: auto;
  margin-right: auto;
  line-height: var(--lh-normal);
}
/* ===== API Dashboard ===== */
.api-dashboard {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  animation: scaleIn .5s ease both;
}
.api-dashboard__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.api-dashboard__title {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.api-dashboard__refresh {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  font-size: var(--fs-xs);
  color: var(--accent);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: .25rem .75rem;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.api-dashboard__refresh:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}
.api-dashboard__refresh.spinning svg {
  animation: spin .8s linear infinite;
}
.api-dashboard__cards {
  display: flex;
  gap: .75rem;
}
.api-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  transition: border-color .2s, box-shadow .2s;
}
.api-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.api-card__indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.api-card__indicator--online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.api-card__indicator--error { background: var(--error); box-shadow: 0 0 6px var(--error); }
.api-card__indicator--rate_limited { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.api-card__indicator--loading { background: var(--text-muted); animation: pulse 1.5s infinite; }
.api-card__indicator--info { background: var(--accent); }
.api-card__info { flex: 1; min-width: 0; }
.api-card__name { font-size: var(--fs-xs); font-weight: 600; color: var(--text-primary); }
.api-card__detail { font-size: .6875rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.api-card__latency { font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); white-space: nowrap; }

/* Template button */
.btn-template {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: .375rem .75rem;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
}
.btn-template:hover {
  background: color-mix(in srgb, var(--accent-light) 70%, var(--accent));
  border-color: var(--accent);
  transform: translateY(-1px);
}
.search-header__right {
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ===== Search Section ===== */
.search-section {
  text-align: center;
  margin-bottom: 2rem;
  animation: fadeInUp .6s ease .1s both;
}
.search-label {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-primary);
}
.search-hint {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.search-card__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: .75rem;
}
.search-input-wrapper {
  position: relative;
}
.search-textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  resize: vertical;
  line-height: var(--lh-normal);
  transition: border-color .15s;
}
.search-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light), 0 0 20px rgba(37, 99, 235, .08);
}
[data-theme="dark"] .search-textarea:focus {
  box-shadow: 0 0 0 3px var(--accent-light), 0 0 24px rgba(79, 143, 255, .12);
}
.search-textarea::placeholder {
  color: var(--text-muted);
}
.char-count {
  text-align: right;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: .375rem;
}

/* Search card */
.search-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  animation: fadeInUp .6s ease .15s both;
}
.search-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #7c3aed, #ec4899, var(--accent));
  background-size: 300% 100%;
  animation: gradientShift 4s ease infinite;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.search-card__textarea {
  width: 100%;
  min-height: 100px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  resize: vertical;
  line-height: var(--lh-normal);
  transition: border-color .15s;
}
.search-card__textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.search-card__textarea::placeholder {
  color: var(--text-muted);
}

.search-card__footer, .search-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
}
.search-card__hint {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.search-shortcuts {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: .25rem;
}
.search-shortcuts kbd {
  display: inline-block;
  padding: .125rem .5rem;
  font-family: var(--font-sans);
  font-size: .75rem;
  font-weight: 500;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.textarea-counter {
  text-align: right;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: .25rem;
}

/* Primary button */
@keyframes subtlePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, .3); }
  50% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 2rem;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  animation: subtlePulse 3s ease-in-out infinite;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .2);
}
.btn-primary:disabled {
  animation: none;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px rgba(37, 99, 235, .35);
  transform: translateY(-2px);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}
.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1rem;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn-secondary:hover {
  background: var(--bg-accent);
  border-color: var(--accent);
}

/* Validation error */
.validation-error {
  color: var(--error);
  font-size: var(--fs-sm);
  margin-top: .5rem;
  display: none;
}
.validation-error.visible {
  display: block;
}

/* ===== Progress Tracker ===== */
.progress-section {
  display: none;
  margin-bottom: 2rem;
}
.progress-section.visible {
  display: block;
  animation: fadeInUp .4s ease both;
}

.progress-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.progress-card__title, .progress-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.progress-overall {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.progress-bar {
  width: 120px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #7c3aed, #ec4899);
  background-size: 200% 100%;
  animation: gradientShift 3s ease infinite;
  border-radius: var(--radius-full);
  transition: width .3s ease;
  position: relative;
  overflow: hidden;
}
.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.3), transparent);
  animation: shimmer 1.5s infinite;
}
.progress-text {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  min-width: 2rem;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem 0;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  transition: color .2s;
}
.progress-step.active { color: var(--accent); font-weight: 600; }
.progress-step.done { color: var(--success); }
.progress-step.error { color: var(--error); }

.progress-step__icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  flex-shrink: 0;
}
.progress-step.pending .progress-step__icon {
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
}
.progress-step.active .progress-step__icon {
  background: var(--accent-light);
  border: 2px solid var(--accent);
  animation: pulse 1.5s infinite;
}
.progress-step.done .progress-step__icon {
  background: var(--success-bg);
  color: var(--success);
}
.progress-step.error .progress-step__icon {
  background: var(--error-bg);
  color: var(--error);
}

.progress-step__content {
  flex: 1;
}
.step-label {
  font-weight: 500;
}
.step-detail {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: .125rem;
}
.progress-step__count, .step-count {
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: .125rem .5rem;
  border-radius: var(--radius-full);
}
.step-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: none;
}
.step-check {
  display: none;
  color: var(--success);
}
.progress-step.active .step-spinner { display: block; }
.progress-step.done .step-check { display: block; }
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* ===== Report ===== */
.report-section {
  display: none;
}
.report-section.visible {
  display: block;
  animation: fadeInUp .5s ease both;
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.report-title-group {
  flex: 1;
}
.report-title, .report-header__title {
  font-size: var(--fs-2xl);
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.report-metadata {
  display: flex;
  gap: .75rem;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: .25rem;
}
.report-actions, .report-header__actions {
  display: flex;
  gap: .5rem;
}

/* Report card / accordion */
.report-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  overflow: hidden;
  transition: box-shadow .2s, border-color .2s, transform .2s;
  position: relative;
}
.report-block::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  background: var(--border);
  transition: background .2s;
}
.report-block.summary-block::before { background: var(--accent); }
.report-block.laws-block::before { background: #7c3aed; }
.report-block.precedents-block::before { background: #059669; }
.report-block.interpretations-block::before { background: #d97706; }
.report-block.news-block::before { background: #0891b2; }
.report-block.analysis-block::before { background: #4f46e5; }
.report-block.conclusion-block::before { background: #16a34a; }
.report-block:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-light);
  transform: translateX(2px);
}

.report-block__header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.report-block__header:hover {
  background: var(--bg-tertiary);
}

.report-block__icon, .block-icon {
  font-size: var(--fs-xl);
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: #fff;
}
.summary-icon { background: var(--accent); }
.laws-icon { background: #7c3aed; }
.precedents-icon { background: #059669; }
.interpretations-icon { background: #d97706; }
.news-icon { background: #0891b2; }
.analysis-icon { background: #4f46e5; }
.conclusion-icon { background: #16a34a; }

.report-block__label, .block-label {
  font-weight: 600;
  font-size: var(--fs-base);
  flex: 1;
}

.report-block__count, .block-count {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: .125rem .5rem;
  border-radius: var(--radius-full);
}

.report-block__chevron, .block-chevron {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform .2s;
  position: relative;
}
.block-chevron::after {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin: 4px auto;
}
.report-block.open .report-block__chevron,
.report-block.open .block-chevron {
  transform: rotate(180deg);
}

.report-block__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}
.report-block.open .report-block__body {
  max-height: 2000px;
}

.report-block__content {
  padding: 1rem 1.25rem 1.25rem;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: var(--lh-normal);
}

/* Law / Prec / Interp card items */
.ref-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: .875rem 1rem;
  margin-bottom: .5rem;
  transition: border-color .15s, box-shadow .15s;
}
.ref-item:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-light);
}

.ref-item__title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: .25rem;
}

.ref-item__meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-bottom: .375rem;
}

.ref-item__text {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-bottom: .375rem;
}

.ref-item__link {
  font-size: var(--fs-xs);
  color: var(--accent);
  text-decoration: none;
}
.ref-item__link:hover { text-decoration: underline; }

/* Summary box */
.summary-box {
  background: var(--bg-accent);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.25rem;
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text-primary);
}

/* Analysis text */
.analysis-text {
  white-space: pre-wrap;
  font-size: var(--fs-sm);
  line-height: 1.8;
}

/* Skeleton loading */
.skeleton-text {
  height: .875rem;
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border-light) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  margin-bottom: .5rem;
}
.skeleton-text.short { width: 60%; }
.skeleton-cards { display: flex; flex-direction: column; gap: .5rem; }
.skeleton-card {
  height: 4rem;
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border-light) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Summary / Analysis / Conclusion content */
.summary-content, .analysis-content, .conclusion-content {
  font-size: var(--fs-sm);
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
  padding: 1rem 1.25rem 1.25rem;
}
.summary-content {
  background: var(--bg-accent);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.25rem;
  color: var(--text-primary);
}

/* Disclaimer */
.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: linear-gradient(135deg, var(--warning-bg), color-mix(in srgb, var(--warning-bg) 60%, var(--bg-secondary)));
  border: 1px solid var(--warning);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-top: 1.5rem;
  margin-bottom: 2rem;
}
.disclaimer-icon {
  flex-shrink: 0;
  font-size: var(--fs-lg);
}
.disclaimer-text {
  line-height: 1.5;
}

/* Report bottom actions */
.report-bottom-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0 1.5rem;
}

/* ===== Markdown Preview Modal ===== */
/* ===== Markdown Editor + Preview Modal ===== */
.md-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.md-modal-overlay.visible {
  display: flex;
  animation: fadeIn .2s ease;
}
.md-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 1200px;
  height: 88vh;
  display: flex;
  flex-direction: column;
  animation: scaleIn .25s ease;
}
.md-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.md-modal__title {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.md-modal__header-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.md-modal__view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.view-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  background: var(--bg-primary);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.view-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}
.view-toggle-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}
.view-toggle-btn.active {
  background: var(--accent);
  color: #fff;
}
.btn-sm {
  padding: .375rem .875rem;
  font-size: var(--fs-xs);
}
.md-modal__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.md-modal__close:hover {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error);
}

/* Split body */
.md-modal__body--split {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}
.md-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.md-pane__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-tertiary);
  flex-shrink: 0;
}
.md-pane__divider {
  width: 1px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  transition: background .15s;
}
.md-pane__divider::after {
  content: "";
  position: absolute;
  inset: 0 -3px;
}
.md-pane__divider:hover,
.md-pane__divider.dragging {
  background: var(--accent);
}

/* Editor */
.md-editor {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  tab-size: 2;
}
.md-editor::placeholder {
  color: var(--text-muted);
}

/* Preview */
.md-preview {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  font-size: var(--fs-sm);
  line-height: 1.8;
  color: var(--text-primary);
}
.md-preview h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--accent);
}
.md-preview h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 1.5rem 0 .75rem;
  padding-bottom: .375rem;
  border-bottom: 1px solid var(--border-light);
}
.md-preview h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 1rem 0 .5rem;
}
.md-preview p {
  margin: 0 0 .75rem;
}
.md-preview blockquote {
  margin: 0 0 1rem;
  padding: .75rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}
.md-preview blockquote p {
  margin: 0;
}
.md-preview ul, .md-preview ol {
  margin: 0 0 .75rem;
  padding-left: 1.5rem;
}
.md-preview li {
  margin-bottom: .25rem;
}
.md-preview strong {
  font-weight: 700;
  color: var(--text-primary);
}
.md-preview em {
  color: var(--text-secondary);
}
.md-preview a {
  color: var(--accent);
  text-decoration: none;
}
.md-preview a:hover {
  text-decoration: underline;
}
.md-preview hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}
.md-preview code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--bg-tertiary);
  padding: .125rem .375rem;
  border-radius: var(--radius-sm);
}
.md-preview .ref-item {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin-bottom: .25rem;
}

/* View modes */
.md-modal__body--editor-only .md-pane--preview,
.md-modal__body--editor-only .md-pane__divider {
  display: none;
}
.md-modal__body--preview-only .md-pane--editor,
.md-modal__body--preview-only .md-pane__divider {
  display: none;
}

@media (max-width: 768px) {
  .md-modal { height: 95vh; border-radius: var(--radius-md); }
  .md-modal__header { padding: .625rem .75rem; }
  .md-modal__title { font-size: var(--fs-sm); }
  .md-modal__body--split { flex-direction: column; }
  .md-pane__divider { width: auto; height: 1px; cursor: row-resize; }
  .md-modal__view-toggle { display: none; }
  .md-editor { font-size: var(--fs-xs); }
  .md-preview { font-size: var(--fs-xs); padding: 1rem; }
  .report-bottom-actions { flex-direction: column; }
  .report-bottom-actions .btn-primary,
  .report-bottom-actions .btn-secondary { width: 100%; justify-content: center; }
}

/* Error retry */
.error-retry-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: var(--radius-sm);
  padding: .75rem 1.25rem;
  margin-top: 1rem;
}
.error-retry-msg {
  flex: 1;
  font-size: var(--fs-sm);
  color: var(--error);
  margin: 0;
}
.error-retry-btn {
  flex-shrink: 0;
  padding: .5rem 1rem;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: #fff;
  background: var(--error);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity .2s;
}
.error-retry-btn:hover { opacity: .85; }

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
  position: relative;
}
.app-footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-light), transparent);
}
.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: .375rem;
  font-weight: 500;
}
.footer-logo {
  display: flex;
  color: var(--accent);
}
.footer-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ===== Error toast ===== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--error);
  color: #fff;
  padding: .75rem 1.5rem;
  border-radius: var(--radius-full);
  font-size: var(--fs-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transition: all .3s;
  pointer-events: none;
}
.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ===== Responsive ===== */

/* Tablet */
@media (max-width: 768px) {
  .app-main { padding: 1.5rem 1rem 3rem; }
  .hero-title { font-size: var(--fs-2xl); }
  .search-section__heading { font-size: var(--fs-2xl); }
  .api-dashboard__cards { gap: .5rem; }
  .api-card { padding: .5rem .625rem; }
  .api-card__name { font-size: .6875rem; }
  .stat-number { font-size: var(--fs-xl); }
  .report-header { flex-direction: column; align-items: flex-start; gap: .75rem; }
}

/* References / Citations */
.references-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: .75rem;
  position: relative;
  overflow: hidden;
}
.references-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #7c3aed, #059669);
}
.references-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .75rem;
}
.ref-citation {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  padding: .375rem 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}
.ref-citation:last-child { border-bottom: none; }
.ref-citation a {
  color: var(--accent);
  text-decoration: none;
}
.ref-citation a:hover { text-decoration: underline; }
.ref-citation__type {
  display: inline-block;
  font-size: .6875rem;
  background: var(--bg-primary);
  color: var(--text-muted);
  padding: .125rem .375rem;
  border-radius: var(--radius-sm);
  margin-left: .375rem;
}

/* Mobile */
@media (max-width: 480px) {
  .app-header { padding: .625rem 1rem; }
  .app-header__title { font-size: var(--fs-base); }
  .app-main { padding: 1rem .75rem 2rem; }
  .hero-title { font-size: var(--fs-xl); }
  .hero-subtitle { font-size: var(--fs-base); }
  .api-dashboard__cards { flex-direction: column; gap: .5rem; }
  .api-card { padding: .5rem .75rem; }
  .search-header__right { flex-direction: column; align-items: flex-end; gap: .25rem; }
  .search-hint { font-size: var(--fs-xs); }
  .search-card { padding: 1rem; }
  .search-actions { flex-direction: column; gap: .75rem; }
  .btn-primary { width: 100%; justify-content: center; }
  .report-actions { width: 100%; }
  .report-actions .btn-secondary { flex: 1; justify-content: center; }
  .app-footer { padding: 1.5rem 1rem 2rem; }
  .question-input::placeholder { font-size: var(--fs-sm); }
}
