/* ── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  /* Light — from DDoS Alert Analysis Report */
  --bg-page: #f5f7fa;
  --bg-card: #ffffff;
  --bg-surface: #f7fafc;
  --bg-hover: #f7fafc;
  --tx-primary: #2d3748;
  --tx-secondary: #4a5568;
  --tx-muted: #718096;
  --border: #e2e8f0;
  --border-light: #e2e8f0;

  --accent-tb: #667eea;
  --accent-tb-soft: #ebf8ff;
  --accent-tb2: #48bb78;
  --accent-tb2-soft: #c6f6d5;

  --diff-bg: #fffaf0;
  --diff-mark: #f6ad55;
  --identical-bg: #c6f6d5;
  --missing-bg: #fff5f5;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 12px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);

  --font-ui:
    "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-read: "Source Serif 4", Georgia, serif;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  /* Dark — from DDoS Alert Analysis Report */
  --bg-page: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-surface: #252536;
  --bg-hover: #252536;
  --tx-primary: #e2e8f0;
  --tx-secondary: #a0aec0;
  --tx-muted: #718096;
  --border: #2d3748;
  --border-light: #2d3748;

  --accent-tb: #667eea;
  --accent-tb-soft: rgba(102, 126, 234, 0.15);
  --accent-tb2: #68d391;
  --accent-tb2-soft: rgba(104, 211, 145, 0.12);

  --diff-bg: #2d2a1f;
  --diff-mark: #f6ad55;
  --identical-bg: rgba(104, 211, 145, 0.1);
  --missing-bg: #2d1f1f;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.3);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-page);
  color: var(--tx-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition:
    background 0.35s var(--ease),
    color 0.35s var(--ease);
}

/* ── Layout Shell ──────────────────────────────────────────────────────── */
.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2.5rem);
}

/* ── Header ────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: clamp(1.25rem, 3vw, 2rem) clamp(1.25rem, 4vw, 2.5rem);
  margin-bottom: clamp(1rem, 2vw, 1.5rem);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  transition:
    background 0.35s var(--ease),
    border-color 0.35s var(--ease);
}

.site-title {
  font-family: var(--font-read);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--tx-primary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.site-title svg {
  color: var(--accent-tb);
  flex-shrink: 0;
}

.site-logo {
  width: clamp(40px, 8vw, 56px);
  height: clamp(40px, 8vw, 56px);
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.site-subtitle {
  font-size: 0.82rem;
  color: var(--tx-secondary);
  margin-top: 0.15rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Theme Toggle */
.theme-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-surface);
  color: var(--tx-secondary);
  border: 1px solid var(--border);
  transition: all 0.25s var(--ease);
  flex-shrink: 0;
}
.theme-btn:hover {
  background: var(--bg-hover);
  color: var(--tx-primary);
}
.theme-btn:focus-visible {
  outline: 2px solid var(--accent-tb);
  outline-offset: 2px;
}
.theme-btn svg {
  width: 20px;
  height: 20px;
  transition: transform 0.35s var(--ease);
}
.theme-btn:hover svg {
  transform: rotate(15deg);
}

/* ── Selector Card ─────────────────────────────────────────────────────── */
.selector-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: clamp(1.25rem, 3vw, 2rem);
  margin-bottom: clamp(1rem, 2vw, 1.5rem);
  box-shadow: var(--shadow-sm);
  transition:
    background 0.35s var(--ease),
    border-color 0.35s var(--ease);
}

.selector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1rem;
  align-items: end;
  max-width: 820px;
  margin: 0 auto;
}

label.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tx-secondary);
  margin-bottom: 0.4rem;
}

select.field-select {
  appearance: none;
  width: 100%;
  padding: 0.7rem 2.5rem 0.7rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  color: var(--tx-primary);
  background: var(--bg-surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23718096' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right 1rem center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.2s var(--ease);
  cursor: pointer;
}
select.field-select:hover {
  border-color: var(--accent-tb);
}
select.field-select:focus {
  outline: none;
  border-color: var(--accent-tb);
  box-shadow: 0 0 0 3px rgba(74, 127, 173, 0.15);
}

[data-theme="dark"] select.field-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a0aec0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.go-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 0.7rem 1.6rem;
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--radius-md);
  transition: all 0.2s var(--ease);
  white-space: nowrap;
  min-height: 44px;
}
.go-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.go-btn:active {
  transform: translateY(0);
}
.go-btn:focus-visible {
  outline: 2px solid var(--accent-tb);
  outline-offset: 2px;
}

.selector-meta {
  text-align: center;
  font-size: 0.78rem;
  color: var(--tx-muted);
  margin-top: 0.75rem;
}

/* ── Chapter Nav ───────────────────────────────────────────────────────── */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: clamp(1rem, 2vw, 1.5rem);
  gap: 0.75rem;
}
.chapter-nav-label {
  font-family: var(--font-read);
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  font-weight: 600;
  color: var(--tx-primary);
  text-align: center;
  flex: 1;
}
.nav-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--tx-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.2s var(--ease);
  text-decoration: none;
  min-height: 44px;
}
.nav-btn:hover {
  background: var(--bg-hover);
  color: var(--tx-primary);
}
.nav-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ── Stats Bar ─────────────────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: clamp(1rem, 2vw, 1.5rem);
}
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  letter-spacing: 0.01em;
}
.stat-chip.identical {
  background: var(--identical-bg);
  color: var(--accent-tb2);
}
.stat-chip.different {
  background: var(--diff-bg);
  color: #9a7b2e;
}
[data-theme="dark"] .stat-chip.different {
  color: #fbd38d;
}
.stat-chip.total {
  background: var(--bg-surface);
  color: var(--tx-secondary);
}
.stat-chip.missing {
  background: var(--missing-bg);
  color: #b05a57;
}
[data-theme="dark"] .stat-chip.missing {
  color: #feb2b2;
}

/* ── Comparison Grid ───────────────────────────────────────────────────── */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1rem, 2vw, 1.5rem);
  margin-bottom: 1.5rem;
}

.version-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition:
    background 0.35s var(--ease),
    border-color 0.35s var(--ease);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border-light);
}
.panel-header.tb {
  background: var(--accent-tb-soft);
  color: var(--accent-tb);
}
.panel-header.tb2 {
  background: var(--accent-tb2-soft);
  color: var(--accent-tb2);
}

.panel-body {
  padding: clamp(0.75rem, 2vw, 1.25rem);
}

/* ── OT Single Panel ──────────────────────────────────────────────────── */
.ot-panel {
  width: 100%;
  margin-bottom: 1.5rem;
}

/* ── Verse Items ───────────────────────────────────────────────────────── */
.verse {
  display: flex;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.35rem;
  transition: background 0.15s var(--ease);
  align-items: baseline;
}
.verse:hover {
  background: var(--bg-hover);
}
.verse.identical {
  background: var(--identical-bg);
}
.verse.different {
  background: var(--diff-bg);
}
.verse.missing {
  background: var(--missing-bg);
}

.vn {
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--tx-muted);
  padding-top: 0.15rem;
  user-select: none;
}

.vt {
  font-family: var(--font-read);
  font-size: clamp(0.92rem, 1.8vw, 1.05rem);
  line-height: 1.75;
  color: var(--tx-primary);
}
.vt em {
  color: var(--tx-muted);
  font-style: italic;
  font-family: var(--font-ui);
  font-size: 0.85rem;
}

mark {
  background: var(--diff-mark);
  color: var(--tx-primary);
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  font-weight: 500;
}

/* ── Copy Button ───────────────────────────────────────────────────────── */
.copy-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  color: inherit;
  opacity: 0.6;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  transition: all 0.2s var(--ease);
}
.copy-btn:hover {
  opacity: 1;
}
.copy-btn.copied {
  opacity: 1;
  border-color: var(--accent-tb2);
  color: var(--accent-tb2);
}

/* ── Info/Alert Boxes ──────────────────────────────────────────────────── */
.info-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  text-align: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  transition:
    background 0.35s var(--ease),
    border-color 0.35s var(--ease);
}
.info-box h2 {
  font-family: var(--font-read);
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.info-box p {
  color: var(--tx-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

.ot-notice {
  background: var(--accent-tb-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  font-size: 0.85rem;
  color: var(--accent-tb);
  margin-bottom: 1rem;
}

.error-box {
  background: var(--missing-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  color: #b05a57;
  margin-bottom: 1rem;
}

/* ── Footer ────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
  font-size: 0.75rem;
  color: var(--tx-muted);
}

/* ── Legend ─────────────────────────────────────────────────────────────── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.78rem;
  color: var(--tx-secondary);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── Dark Theme Enhancements ───────────────────────────────────────── */
[data-theme="dark"] .site-header {
  border-color: #2d3748;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .site-title svg {
  color: #667eea;
}

[data-theme="dark"] .version-panel {
  border-color: #2d3748;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .version-panel:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .panel-header.tb {
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.15) 0%,
    rgba(102, 126, 234, 0.08) 100%
  );
  border-bottom-color: #2d3748;
}
[data-theme="dark"] .panel-header.tb2 {
  background: linear-gradient(
    135deg,
    rgba(104, 211, 145, 0.15) 0%,
    rgba(104, 211, 145, 0.08) 100%
  );
  border-bottom-color: #2d3748;
}

[data-theme="dark"] .go-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
[data-theme="dark"] .go-btn:hover {
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] select.field-select:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

[data-theme="dark"] .nav-btn:hover {
  border-color: #667eea;
  background: #252536;
  color: #667eea;
}

[data-theme="dark"] mark {
  background: #f6ad55;
  color: #1a1a2e;
}

[data-theme="dark"] .vn {
  color: #718096;
}

[data-theme="dark"] .info-box {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .selector-card {
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
}

[data-theme="dark"] .site-footer {
  color: #4a5568;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .selector-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .go-btn {
    width: 100%;
  }
  .compare-grid {
    grid-template-columns: 1fr;
  }
  .site-header {
    flex-direction: column;
    text-align: center;
  }
  .header-actions {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .shell {
    padding: 0.75rem;
  }
  .chapter-nav-label {
    font-size: 0.9rem;
  }
}

/* ── Print ─────────────────────────────────────────────────────────────── */
@media print {
  body {
    background: #fff;
    color: #000;
  }
  .theme-btn,
  .copy-btn,
  .go-btn,
  .nav-btn,
  .selector-card {
    display: none !important;
  }
  .compare-grid {
    grid-template-columns: 1fr 1fr;
  }
  .version-panel {
    break-inside: avoid;
  }
}

/* ── Focus-visible ─────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-tb);
  outline-offset: 2px;
}

/* ── Reduced motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}

/* ── Search Input Styles ──────────────────────────────────────────────────── */
.panel-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 260px;
}

.panel-search {
  width: 100%;
  padding: 0.35rem 2rem 0.35rem 2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 0.8rem;
  font-family: "DM Sans", sans-serif;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.panel-search::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.panel-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}

.panel-search-icon {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--muted);
  display: flex;
  align-items: center;
}

.panel-search-clear {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 0;
  transition:
    color 0.15s,
    background 0.15s;
}

.panel-search-clear:hover {
  color: var(--fg);
  background: var(--border);
}

.panel-search-clear.visible {
  display: flex;
}

/* Search highlight (distinct from diff <mark>) */
.search-hl {
  background: #ffe066;
  color: #1a1a1a;
  border-radius: 2px;
  padding: 0 1px;
  box-shadow: 0 0 0 1px rgba(255, 200, 0, 0.4);
}

[data-theme="dark"] .search-hl {
  background: #b8860b;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(184, 134, 11, 0.5);
}

/* Verse hidden by search filter */
.verse.search-hidden {
  display: none;
}

/* Search match count badge */
.search-count {
  font-size: 0.7rem;
  color: var(--muted);
  margin-left: 0.25rem;
  white-space: nowrap;
}

/* Adjust panel-header layout to accommodate search */
.panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.panel-header > span:first-child {
  white-space: nowrap;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex: 1;
  justify-content: flex-end;
}
