/* ==========================================================================
   『タリーヒ・カシュガル（チンギズナマ）』タシケント写本（C576）
   古典チャガタイ語批判校訂版 学術Webポータル スタイルシート
   ========================================================================== */

:root {
  /* Theme: Academic Light (羊皮紙・古文書調) */
  --bg-primary: #fcfbf7;
  --bg-secondary: #f4f0e6;
  --bg-card: #ffffff;
  --bg-card-hover: #faf7ee;
  --border-color: #e4ddcf;
  --border-subtle: #eee9dc;
  
  --text-main: #2b2520;
  --text-muted: #6e6459;
  --text-dim: #998e82;
  
  --accent-gold: #c29b38;
  --accent-gold-hover: #aa852b;
  --accent-gold-light: rgba(194, 155, 56, 0.12);
  --accent-burgundy: #801824;
  --accent-burgundy-light: rgba(128, 24, 36, 0.08);
  --accent-teal: #1f6868;
  --accent-teal-light: rgba(31, 104, 104, 0.1);
  
  --shadow-sm: 0 1px 3px rgba(43, 37, 32, 0.06);
  --shadow-md: 0 4px 12px rgba(43, 37, 32, 0.08);
  --shadow-lg: 0 12px 28px rgba(43, 37, 32, 0.12);
  
  --font-arabic: 'Scheherazade New', 'Amiri', 'Noto Naskh Arabic', serif;
  --font-body: 'Noto Serif JP', 'Inter', -apple-system, sans-serif;
  --font-title: 'Cinzel', 'Noto Serif JP', serif;
  
  --header-height: 86px;
  --transition-fast: 0.18s ease;
  --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="academic-dark"] {
  /* Theme: Academic Dark (深夜書斎・漆黒古写本調) */
  --bg-primary: #121316;
  --bg-secondary: #1a1c22;
  --bg-card: #20232b;
  --bg-card-hover: #262a34;
  --border-color: #313642;
  --border-subtle: #272c36;
  
  --text-main: #f0ede6;
  --text-muted: #a8a398;
  --text-dim: #6d7280;
  
  --accent-gold: #d8af47;
  --accent-gold-hover: #e6be55;
  --accent-gold-light: rgba(216, 175, 71, 0.15);
  --accent-burgundy: #a83242;
  --accent-burgundy-light: rgba(168, 50, 66, 0.18);
  --accent-teal: #3ba2a2;
  --accent-teal-light: rgba(59, 162, 162, 0.16);
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.7);
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 100;
  flex-shrink: 0;
}

.header-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex-shrink: 1;
}

.title-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.subtitle-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-burgundy);
  background: var(--accent-burgundy-light);
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
}

.arabic-sub {
  font-family: var(--font-arabic);
  font-size: 0.95rem;
  font-weight: normal;
  color: var(--accent-gold);
  direction: rtl;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
}

.title-bottom-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.main-title {
  font-family: var(--font-title);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
  margin: 0;
  flex-shrink: 0;
}

.meta-tagline {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1480px) {
  .meta-tagline {
    display: none;
  }
}

@media (max-width: 1200px) {
  .arabic-sub {
    font-size: 0.88rem;
  }
  .main-title {
    font-size: 0.96rem;
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.control-group {
  display: flex;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.control-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.control-btn:hover {
  color: var(--text-main);
  background: var(--accent-gold-light);
}

.control-btn.active {
  background: var(--accent-gold);
  color: #ffffff;
  font-weight: 600;
}

.control-btn.outline {
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.control-btn.outline:hover {
  border-color: var(--accent-gold);
}

.control-btn.icon-only {
  padding: 5px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
}

/* Sub-Navigation */
.sub-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 20px;
  background: var(--bg-primary);
  gap: 14px;
  overflow-x: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.nav-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

.chapter-dropdown {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 3px 10px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
}

.chapter-dropdown:focus {
  border-color: var(--accent-gold);
}

.folio-pill-container {
  display: flex;
  gap: 4px;
  align-items: center;
}

.folio-pill {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.folio-pill:hover {
  color: var(--text-main);
  border-color: var(--accent-gold);
}

.folio-pill.active {
  background: var(--accent-gold);
  color: #ffffff;
  border-color: var(--accent-gold);
}

.display-toggles-wrap {
  display: flex;
  gap: 12px;
}

.toggle-checkbox {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.toggle-checkbox input {
  accent-color: var(--accent-gold);
  cursor: pointer;
}

.toggle-checkbox:hover {
  color: var(--text-main);
}

/* ==========================================================================
   Main Workspace Layout & View Modes
   ========================================================================== */
.main-workspace {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  flex: 1;
  height: calc(100vh - var(--header-height) - 32px);
  overflow: hidden;
  background: var(--bg-primary);
}

/* View Mode State Controls */
.mode-split .facsimile-pane {
  display: flex;
}
.mode-split .text-pane {
  display: flex;
}
.mode-split .main-workspace {
  grid-template-columns: 1fr 1.15fr;
}

/* Default / Text Only Mode (Safe & Clean Academic Reading) */
.mode-text-only .facsimile-pane {
  display: none !important;
}
.mode-text-only .text-pane {
  display: flex;
  width: 100%;
}
.mode-text-only .main-workspace {
  grid-template-columns: 1fr;
}
.mode-text-only .pane-header {
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}
.mode-text-only .edition-content {
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
  padding-left: 28px;
  padding-right: 28px;
}

/* Facsimile Only Mode */
.mode-facsimile-only .text-pane {
  display: none !important;
}
.mode-facsimile-only .facsimile-pane {
  display: flex;
  width: 100%;
}
.mode-facsimile-only .main-workspace {
  grid-template-columns: 1fr;
}

/* Pane Styles */
.pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
  font-weight: 600;
  flex-shrink: 0;
}

.pane-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  background: var(--accent-gold);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--accent-gold-light);
  display: inline-block;
}

/* Left Pane: Facsimile Viewer */
.facsimile-pane {
  border-right: 1px solid var(--border-color);
  background: #17181c; /* 暗色背景で写本の視認性を最大化 */
}

.image-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-close-facsimile {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 6px;
  transition: all var(--transition-fast);
}

.btn-close-facsimile:hover {
  color: var(--accent-burgundy);
  border-color: var(--accent-burgundy);
  background: var(--accent-burgundy-light);
}

.tool-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 7px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: all var(--transition-fast);
}

.tool-btn:hover {
  background: var(--accent-gold);
  color: #ffffff;
  border-color: var(--accent-gold);
}

.facsimile-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  background: radial-gradient(circle at center, #23252c 0%, #111215 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.facsimile-viewport:active {
  cursor: grabbing;
}

.image-stage {
  position: relative;
  display: inline-block;
  transform-origin: center center;
  transition: transform 0.05s linear;
}

.image-stage img {
  display: block;
  max-height: 82vh;
  width: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  border-radius: 3px;
  pointer-events: none;
}

.line-highlight-box {
  position: absolute;
  pointer-events: none;
  box-sizing: border-box;
  border: 2.5px solid var(--accent-gold);
  background: rgba(216, 175, 71, 0.16);
  box-shadow: 0 0 14px rgba(216, 175, 71, 0.5), inset 0 0 8px rgba(216, 175, 71, 0.25);
  border-radius: 4px;
  z-index: 10;
  transition: top 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), left 0.3s ease, width 0.3s ease;
  animation: pulseLineBox 2.4s infinite ease-in-out;
}

@keyframes pulseLineBox {
  0%, 100% {
    box-shadow: 0 0 10px rgba(216, 175, 71, 0.4), inset 0 0 6px rgba(216, 175, 71, 0.2);
    border-color: rgba(216, 175, 71, 0.9);
  }
  50% {
    box-shadow: 0 0 20px rgba(216, 175, 71, 0.7), inset 0 0 12px rgba(216, 175, 71, 0.35);
    border-color: rgba(240, 205, 100, 1);
  }
}

.viewport-hints {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  color: #d1ceca;
  font-size: 0.72rem;
  padding: 4px 12px;
  border-radius: 12px;
  pointer-events: none;
  letter-spacing: 0.04em;
}

/* Right Pane: Critical Edition Text */
.text-pane {
  background: var(--bg-primary);
}

.chagatai-tag {
  background: var(--accent-gold-light);
  color: var(--accent-gold-hover);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 700;
}

.text-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.edition-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px 60px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Edition Entry Card */
.entry-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
  transition: all var(--transition-fast);
  position: relative;
  border-left: 4px solid var(--border-color);
}

.entry-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-gold);
  border-left-color: var(--accent-gold);
  box-shadow: var(--shadow-md);
}

.entry-card.active-target {
  border-color: var(--accent-gold);
  border-left-color: var(--accent-burgundy);
  background: var(--accent-gold-light);
}

.card-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
}

.folio-locator {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.folio-locator:hover {
  text-decoration: underline;
}

.meta-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-open-facsimile {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-gold);
  background: var(--accent-gold-light);
  border: 1px solid rgba(179, 139, 44, 0.35);
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-open-facsimile:hover {
  background: var(--accent-gold);
  color: #ffffff;
}

.critical-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  background: var(--accent-burgundy-light);
  color: var(--accent-burgundy);
  border: 1px solid rgba(128, 24, 36, 0.2);
}

/* Classical Chagatai Typography */
.layer-classical {
  margin-bottom: 12px;
}

.classical-text {
  font-family: var(--font-arabic);
  font-size: 1.65rem;
  line-height: 2.1;
  color: var(--text-main);
  direction: rtl;
  text-align: right;
  word-spacing: 0.05em;
}

.mishra-sep {
  color: var(--accent-gold);
  margin: 0 8px;
  font-size: 1.3rem;
  vertical-align: middle;
}

/* 1986 Uyghur Script Comparison */
.layer-uyghur {
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: 5px;
  border-right: 3px solid var(--accent-teal);
}

.layer-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.uyghur-text {
  font-family: var(--font-arabic);
  font-size: 1.25rem;
  line-height: 1.8;
  color: var(--text-muted);
  direction: rtl;
  text-align: right;
}

/* Japanese Academic Translation */
.layer-japanese {
  margin-bottom: 8px;
  padding-left: 2px;
}

.japanese-text {
  font-size: 0.94rem;
  line-height: 1.75;
  color: var(--text-main);
  font-family: var(--font-body);
}

/* Apparatus Criticus (校合注) */
.layer-notes {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--accent-gold-light);
  border-left: 3px solid var(--accent-gold);
  border-radius: 0 4px 4px 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.layer-notes strong {
  color: var(--accent-burgundy);
}

/* Layout Modes */
.mode-text-only .facsimile-pane {
  display: none;
}
.mode-text-only .main-workspace {
  grid-template-columns: 1fr;
}
.mode-text-only .edition-content {
  max-width: 900px;
  margin: 0 auto;
}

.mode-facsimile-only .text-pane {
  display: none;
}
.mode-facsimile-only .main-workspace {
  grid-template-columns: 1fr;
}

/* ==========================================================================
   Academic Guide Modal
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  max-width: 760px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.modal-header h2 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  color: var(--text-main);
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-size: 0.9rem;
  line-height: 1.7;
}

.modal-sec h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-burgundy);
  margin-bottom: 8px;
  border-left: 3px solid var(--accent-gold);
  padding-left: 8px;
}

.highlight-list {
  padding-left: 20px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-sec code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-arabic);
  font-size: 1.1rem;
}

.modal-sec ol {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  height: 32px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.footer-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-footer a {
  color: var(--accent-gold);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Loading & Empty */
.loading-state {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold);
}

/* ==========================================================================
   Omni-Search Trigger & Modal
   ========================================================================== */
.search-trigger-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-trigger-btn:hover {
  border-color: var(--accent-gold);
  color: var(--text-main);
  box-shadow: 0 0 0 2px var(--accent-gold-light);
}

.search-btn-text {
  font-weight: 500;
}

.search-kbd {
  font-size: 0.68rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-dim);
  font-family: inherit;
}

/* Search Modal Specifics */
.modal-search-card {
  max-width: 760px;
  height: 80vh;
  display: flex;
  flex-direction: column;
}

.search-header-input-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  position: relative;
  margin-right: 12px;
}

.search-modal-icon {
  position: absolute;
  left: 12px;
  color: var(--accent-gold);
  pointer-events: none;
}

.search-modal-input {
  width: 100%;
  padding: 10px 36px 10px 40px;
  font-size: 1.05rem;
  font-family: var(--font-body);
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-main);
  transition: border-color var(--transition-fast);
}

.search-modal-input:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-light);
}

.btn-clear-search {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 6px;
  display: none;
}

.btn-clear-search:hover {
  color: var(--text-main);
}

.search-helpers {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  font-size: 0.8rem;
}

.helper-pill {
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all var(--transition-fast);
}

.helper-pill:hover,
.helper-pill.active {
  background: var(--accent-gold);
  color: #ffffff;
  border-color: var(--accent-gold);
}

.search-count-info {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 0.75rem;
}

.search-results-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-result-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-result-item:hover {
  border-color: var(--accent-gold);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  background: var(--bg-card-hover);
}

.search-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.result-location {
  font-weight: 700;
  color: var(--accent-gold-hover);
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-chapter-badge {
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.search-result-snippet {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-snippet.rtl-snippet {
  font-family: var(--font-arabic);
  font-size: 1.15rem;
  direction: rtl;
}

.search-result-snippet mark {
  background: rgba(216, 175, 71, 0.35);
  color: var(--accent-burgundy);
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 2px;
}

.search-empty-state {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-dim);
}

.search-hint-box {
  text-align: left;
  max-width: 540px;
  margin: 0 auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
}

.search-hint-box h4 {
  color: var(--text-main);
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.search-hint-box ul {
  padding-left: 20px;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
}

/* ==========================================================================
   Current Folio & Line Indicator in Facsimile Pane Header
   ========================================================================== */
.current-line-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-gold);
  margin-left: 6px;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Glossary Modal
   ========================================================================== */
.modal-glossary-card {
  max-width: 900px;
  height: 85vh;
  display: flex;
  flex-direction: column;
}

.glossary-header-titles h2 {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.glossary-controls {
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.glossary-search-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-main);
}

.glossary-category-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cat-pill {
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cat-pill:hover,
.cat-pill.active {
  background: var(--accent-teal);
  color: #ffffff;
  border-color: var(--accent-teal);
}

.glossary-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.glossary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.glossary-card:hover {
  border-color: var(--accent-gold);
  box-shadow: var(--shadow-md);
}

.glossary-term-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px dashed var(--border-subtle);
  padding-bottom: 8px;
}

.term-arabic {
  font-family: var(--font-arabic);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--accent-burgundy);
  line-height: 1.2;
}

[data-theme="academic-dark"] .term-arabic {
  color: #ff9da8;
}

.term-meta-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.term-lat {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-main);
}

.term-jp {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.term-origin-tag {
  align-self: flex-start;
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-dim);
}

.term-def {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-main);
  flex: 1;
}

.term-chapters-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.btn-chapter-jump {
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--accent-teal);
  cursor: pointer;
  text-decoration: none;
  font-size: 0.68rem;
}

.btn-chapter-jump:hover {
  background: var(--accent-teal);
  color: #ffffff;
}

/* ==========================================================================
   Concordance Modal (史料対照)
   ========================================================================== */
.modal-concordance-card {
  max-width: 900px;
  height: 85vh;
  display: flex;
  flex-direction: column;
}

.concordance-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.concordance-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}

.concordance-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1.5px solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.concordance-chapter-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-gold-hover);
}

.concordance-folio-tag {
  font-size: 0.75rem;
  color: var(--text-dim);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 4px;
}

.concordance-topic {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-main);
}

.parallel-sources-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.parallel-source-item {
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent-gold);
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
}

.parallel-source-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.parallel-work-title {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent-burgundy);
}

[data-theme="academic-dark"] .parallel-work-title {
  color: #ff9da8;
}

.parallel-section {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.parallel-note {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-main);
}

/* Entry Card Additions */
.concordance-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-teal-light);
  color: var(--accent-teal);
  border: 1px solid rgba(31, 104, 104, 0.2);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.concordance-badge:hover {
  background: var(--accent-teal);
  color: #ffffff;
}

.btn-diff-view {
  background: transparent;
  border: 1px dashed var(--accent-burgundy);
  color: var(--accent-burgundy);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.68rem;
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn-diff-view:hover {
  background: var(--accent-burgundy);
  color: #ffffff;
}

/* ==========================================================================
   Apparatus Popover (Floating Panel)
   ========================================================================== */
.apparatus-popover {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--accent-gold);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  overflow: hidden;
  animation: popoverSlideUp 0.22s ease-out;
}

@keyframes popoverSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.popover-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-gold-hover);
}

.popover-close-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-dim);
  cursor: pointer;
}

.popover-close-btn:hover {
  color: var(--text-main);
}

.popover-body {
  padding: 12px 14px;
  font-size: 0.8rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popover-diff-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-secondary);
  padding: 8px 10px;
  border-radius: 4px;
}

.popover-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.popover-val-orig {
  font-family: var(--font-arabic);
  font-size: 1.25rem;
  direction: rtl;
  color: #1f6868;
  font-weight: 700;
}

[data-theme="academic-dark"] .popover-val-orig {
  color: #5dd4d4;
}

.popover-val-1986 {
  font-family: var(--font-arabic);
  font-size: 1.2rem;
  direction: rtl;
  color: #a83242;
  text-decoration: line-through;
}

[data-theme="academic-dark"] .popover-val-1986 {
  color: #ff9da8;
}

/* ==========================================================================
   Apparatus Criticus Filter Toolbar
   ========================================================================== */
.pane-title-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.apparatus-filter-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.apparatus-filter-toolbar .filter-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
}

.app-filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.app-filter-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-gold);
  color: var(--text-main);
}

.app-filter-btn.active {
  background: var(--accent-gold);
  border-color: var(--accent-gold-hover);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(194, 155, 56, 0.35);
}

.app-filter-btn.filter-recovery.active {
  background: var(--accent-burgundy);
  border-color: #5c0f18;
  color: #ffffff;
}

.app-filter-btn.filter-proper.active {
  background: var(--accent-teal);
  border-color: #154c4c;
  color: #ffffff;
}

.app-filter-btn.filter-lexical.active {
  background: #475569;
  border-color: #334155;
  color: #ffffff;
}

/* Entry Card Filtering */
.entry-card.filtered-out {
  display: none !important;
}

/* Shortcut Tip & Badge */
.shortcut-tip {
  font-size: 0.72rem;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.shortcut-tip kbd {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.68rem;
  font-family: inherit;
  color: var(--text-muted);
  box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}

.count-divider {
  color: var(--border-color);
  margin: 0 4px;
}

/* Citation Button */
.btn-cite-item {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
}

.btn-cite-item:hover {
  background: var(--accent-gold-light);
  border-color: var(--accent-gold);
  color: var(--accent-gold-hover);
}

/* Target Hash Animation */
.entry-card:target,
.entry-card.target-highlight {
  border-color: var(--accent-gold) !important;
  box-shadow: 0 0 0 2px var(--accent-gold), 0 4px 16px rgba(194, 155, 56, 0.25) !important;
  animation: pulseTarget 1.8s ease-in-out;
}

@keyframes pulseTarget {
  0% { transform: scale(1.01); box-shadow: 0 0 0 4px var(--accent-gold); }
  50% { transform: scale(1.0); box-shadow: 0 0 0 1px var(--accent-gold); }
  100% { transform: scale(1.0); box-shadow: 0 0 0 2px var(--accent-gold); }
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(32, 35, 43, 0.95);
  color: #ffffff;
  padding: 12px 22px;
  border-radius: 30px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 9999;
  font-size: 0.85rem;
  font-weight: 500;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  pointer-events: none;
}

.toast-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast-icon {
  color: #4ade80;
  display: flex;
  align-items: center;
}

/* Shortcut Modal Table */
.shortcut-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.shortcut-table th,
.shortcut-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  text-align: left;
}

.shortcut-table th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-muted);
}

.shortcut-table kbd {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 0.8rem;
  box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}

/* ==========================================================================
   Sync Scroll & Text Actions Bar
   ========================================================================== */
#btnToggleSyncScroll {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 4px;
}

#btnToggleSyncScroll.active {
  background: var(--accent-gold-light);
  border-color: var(--accent-gold);
  color: var(--accent-gold-hover);
  font-weight: 600;
}

.text-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.text-actions-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.text-action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
}

.text-action-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-gold);
  color: var(--text-main);
}

.stats-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Inline Search Hit Highlight */
mark.search-hit-inline {
  background: rgba(234, 179, 8, 0.45);
  color: inherit;
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(234, 179, 8, 0.6);
  animation: hitPulse 2.5s ease-out;
}

@keyframes hitPulse {
  0% { background: rgba(234, 179, 8, 0.85); box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.8); }
  100% { background: rgba(234, 179, 8, 0.35); box-shadow: 0 0 0 1px rgba(234, 179, 8, 0.4); }
}

/* Search result snippet notes badge */
.snippet-notes-tag {
  display: inline-block;
  background: var(--accent-burgundy-light);
  color: var(--accent-burgundy);
  border: 1px solid var(--accent-burgundy);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
}

/* ==========================================================================
   Print Stylesheet (@media print)
   伝統的な東洋学術書籍・校訂本としての美しいA4組版
   ========================================================================== */
@media print {
  /* Hide non-content UI elements */
  .site-header,
  .facsimile-pane,
  .apparatus-filter-toolbar,
  .text-actions-bar,
  .meta-actions,
  .shortcut-tip,
  .count-divider,
  .modal-overlay,
  .toast-notification,
  .apparatus-popover,
  .close-btn,
  .viewport-hints {
    display: none !important;
  }

  html, body {
    height: auto !important;
    background: #ffffff !important;
    color: #111111 !important;
    font-size: 11pt !important;
  }

  .app-container {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .main-workspace {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .text-pane {
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  .pane-header {
    border-bottom: 2px solid #333333 !important;
    padding-bottom: 12px !important;
    margin-bottom: 16px !important;
  }

  .pane-title #currentChapterHeading {
    font-size: 16pt !important;
    font-weight: 700 !important;
    color: #000000 !important;
  }

  .edition-content {
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  .entry-card {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    margin-bottom: 14pt !important;
    padding: 10pt 12pt !important;
    background: #ffffff !important;
  }

  .card-meta-bar {
    border-bottom: 1px solid #eeeeee !important;
    padding-bottom: 4pt !important;
    margin-bottom: 6pt !important;
    font-size: 9pt !important;
    color: #555555 !important;
  }

  .classical-text {
    font-size: 16pt !important;
    line-height: 1.8 !important;
    color: #000000 !important;
  }

  .layer-uyghur {
    font-size: 11pt !important;
    color: #333333 !important;
    border-top: 1px dashed #dddddd !important;
    padding-top: 6pt !important;
    margin-top: 6pt !important;
  }

  .layer-japanese {
    font-size: 10.5pt !important;
    line-height: 1.7 !important;
    color: #111111 !important;
    border-top: 1px solid #eeeeee !important;
    padding-top: 6pt !important;
    margin-top: 6pt !important;
  }

  .layer-notes {
    font-size: 9pt !important;
    line-height: 1.5 !important;
    color: #444444 !important;
    background: #f9f9f9 !important;
    border: 1px solid #e0e0e0 !important;
    padding: 6pt 8pt !important;
    margin-top: 6pt !important;
    border-radius: 2pt !important;
  }
}

