/**
 * TMGS4 Proofreader
 * Extends the existing warm orange/cream design system
 */

/* ══════════════════════════════════════════════════════
   FONTS
   ══════════════════════════════════════════════════════ */

@font-face {
  font-family: 'FutoMaruGothic';
  src: url('/fonts/DF-FutoMaruGothic-W9-CAB-18277f51d7ae7c3bd42f53247de2bb48--4329643920678357007.ttf') format('truetype');
  font-display: swap;
}

@font-face {
  font-family: 'HeiSeiMaruGothic';
  src: url('/fonts/DF-HeiSeiMaruGothic-W4-CAB-18277f51d7ae7c3bd42f53247de2bb48-2057771419379400601.ttf') format('truetype');
  font-display: swap;
}

/* ══════════════════════════════════════════════════════
   EXTENDED VARIABLES
   ══════════════════════════════════════════════════════ */

:root {
  /* Category Colors - warm, earthy tones that complement the existing palette */
  --cat-story: #E8792B;
  --cat-dating: #F4A0B0;
  --cat-skinship: #E88BC0;
  --cat-communication: #6CB4D6;
  --cat-school: #A388D4;
  --cat-seasonal: #7DC37D;
  --cat-daily: #F5C16C;
  --cat-misc: #B0A090;
}

/* ══════════════════════════════════════════════════════
   PROGRESS STATS BAR
   ══════════════════════════════════════════════════════ */

.progress-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 20px;
  padding: 16px 24px;
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.progress-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.progress-stat .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.progress-stat .stat-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.progress-stat-wide {
  min-width: 180px;
}

/* Overall progress bar */
.overall-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
  min-width: 100px;
}

.overall-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #F5C16C, var(--primary), var(--accent-pink));
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* Scenario list mini progress bar */
.scenario-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 80px;
}

.progress-bar-mini {
  width: 50px;
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.scenario-item.complete .progress-bar-fill {
  background: linear-gradient(90deg, #7DC37D, #B8D430);
}

.scenario-item.inprogress .progress-bar-fill {
  background: linear-gradient(90deg, #F5A623, #F5C16C);
}

.progress-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 28px;
  text-align: right;
}

.scenario-item.complete .progress-pct {
  color: var(--proofread-text);
}

/* Proofread toggle button active state */
.btn.proofread-active {
  background: var(--proofread-bg);
  color: var(--proofread-text);
  border-color: var(--proofread-border);
}

/* ══════════════════════════════════════════════════════
   MODE SWITCHER
   ══════════════════════════════════════════════════════ */

.mode-switcher {
  display: flex;
  gap: 4px;
  margin: 24px 0;
  padding: 4px;
  background: var(--surface);
  border-radius: 24px;
  width: fit-content;
  box-shadow: var(--inset-shadow);
}

.mode-tab {
  padding: 10px 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 20px;
  transition: all 0.25s ease;
}

.mode-tab:hover {
  color: var(--primary);
  background: rgba(255, 255, 255, 0.5);
}

.mode-tab.active {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* Mode Panels */
.mode-panel {
  display: none;
}

.mode-panel.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* ══════════════════════════════════════════════════════
   FILTER BAR
   ══════════════════════════════════════════════════════ */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-end;
  margin-top: 16px;
  padding: 18px 22px;
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 140px;
  max-width: 280px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-select {
  padding: 10px 32px 10px 14px;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235C4033' d='M2 4l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 12px center;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
}

[data-theme="dark"] .filter-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23A08878' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
}

.filter-select:hover {
  border-color: var(--primary-light);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-shadow);
}

.btn.small {
  padding: 10px 16px;
  font-size: 13px;
  font-family: inherit;
}

/* Ensure buttons inherit body font */
.btn,
.btn.secondary,
.btn.primary {
  font-family: inherit;
}

/* Active Filters Display */
.active-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card-bg);
  border-radius: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--border-subtle);
}

.active-filters.hidden {
  display: none;
}

.filters-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

#filter-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 12px;
  background: var(--card-bg);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.filter-tag button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.filter-tag button:hover {
  background: var(--primary);
  color: white;
}

/* ══════════════════════════════════════════════════════
   ENHANCED RESULTS
   ══════════════════════════════════════════════════════ */

.results-meta {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.result-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Category badges */
.badge-story {
  background: rgba(232, 121, 43, 0.12);
  color: #C05A10;
}

.badge-dating {
  background: rgba(244, 160, 176, 0.25);
  color: #B85A6F;
}

.badge-skinship {
  background: rgba(232, 139, 192, 0.2);
  color: #9A4A7A;
}

.badge-communication {
  background: rgba(108, 180, 214, 0.2);
  color: var(--openpr-text);
}

.badge-school {
  background: rgba(163, 136, 212, 0.2);
  color: #6B4FA0;
}

.badge-seasonal {
  background: var(--proofread-bg);
  color: var(--proofread-text);
}

.badge-daily {
  background: rgba(245, 193, 108, 0.2);
  color: #8A5A10;
}

.badge-misc {
  background: rgba(176, 160, 144, 0.2);
  color: #6A5A4A;
}

.badge-folder {
  background: var(--surface);
  color: var(--text-secondary);
}

.badge-count {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid currentColor;
  opacity: 0.7;
}

.badge-reviewed {
  background: var(--proofread-bg);
  color: var(--proofread-text);
  font-size: 10px;
}

.preview {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

.preview-speaker {
  font-weight: 600;
  color: var(--primary);
}

/* Expandable Search Results */
.result-item {
  cursor: default;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.expand-icon {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.result-item.expanded .expand-icon {
  transform: translateY(-50%) rotate(180deg);
}

.result-preview {
  margin-top: 8px;
}

.result-more {
  margin-top: 8px;
}

.btn-show-more {
  padding: 6px 12px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--primary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
}

.btn-show-more:hover {
  background: var(--hover-bg-strong);
  border-color: var(--primary);
}

.result-item.expanded .btn-show-more {
  display: none;
}

.result-expanded {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.result-item.expanded .result-expanded {
  display: block;
  animation: slideDown 0.2s ease;
}

.result-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.result-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 10px;
  transition: all 0.15s ease;
}

.result-line:hover {
  background: var(--hover-bg);
  box-shadow: var(--shadow-sm);
}

.line-num {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 32px;
}

.line-content {
  flex: 1;
  font-size: 14px;
  min-width: 0;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.line-content:hover {
  background: var(--hover-bg);
}

.line-dialogue {
  color: var(--text);
  white-space: pre-wrap;
}

/* Result line editing state */
.result-line.editing {
  background: var(--hover-bg-strong);
}

.result-line.editing .line-content {
  cursor: default;
}

.result-line.corrected {
  border-left: 3px solid var(--proofread-border);
  margin-left: -3px;
}

.result-line .corrected-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  background: var(--proofread-bg);
  color: var(--proofread-text);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Inline correction form in search results */
.search-correction-form {
  margin: 8px 0 12px;
}

.btn-open-reader {
  padding: 6px 10px;
  border: none;
  background: var(--primary);
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.15s ease;
}

.result-line:hover .btn-open-reader {
  opacity: 1;
}

.btn-open-reader:hover {
  background: var(--primary-dark);
  transform: translateX(2px);
}

.view-full-file {
  width: 100%;
}

/* ══════════════════════════════════════════════════════
   BROWSE MODE LAYOUT
   ══════════════════════════════════════════════════════ */

.browse-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  min-height: 500px;
}

@media (max-width: 900px) {
  .browse-layout {
    grid-template-columns: 1fr;
  }
}

/* Sidebar */
.browse-sidebar {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  height: fit-content;
  position: sticky;
  top: 24px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
}

.browse-sidebar h3 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Category Groups */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.category-group {
  border-radius: 8px;
  overflow: hidden;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease;
  list-style: none;
}

.category-header::-webkit-details-marker {
  display: none;
}

.category-header:hover {
  background: var(--hover-bg);
}

.category-group[open] > .category-header {
  background: var(--hover-bg);
}

/* Category Indicators */
.cat-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-indicator.story { background: var(--cat-story); }
.cat-indicator.dating { background: var(--cat-dating); }
.cat-indicator.skinship { background: var(--cat-skinship); }
.cat-indicator.communication { background: var(--cat-communication); }
.cat-indicator.school { background: var(--cat-school); }
.cat-indicator.seasonal { background: var(--cat-seasonal); }
.cat-indicator.daily { background: var(--cat-daily); }
.cat-indicator.misc { background: var(--cat-misc); }

.cat-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.cat-count {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Folder Links */
.folder-list {
  padding: 4px 0 4px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.folder-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  transition: all 0.15s ease;
}

.folder-link:hover {
  background: var(--hover-bg-strong);
  color: var(--primary);
}

.folder-link.active {
  background: var(--primary);
  color: white;
}

.folder-link code {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 11px;
  opacity: 0.6;
}

.folder-link.active code {
  opacity: 0.8;
}

/* Main Content Area */
.browse-main {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
}

.browse-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.breadcrumb strong {
  color: var(--text);
}

.breadcrumb code {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 12px;
  padding: 2px 6px;
  background: var(--surface);
  border-radius: 4px;
  margin-left: 4px;
}

.breadcrumb .sep {
  opacity: 0.4;
}

.browse-filter input {
  padding: 8px 14px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  width: 220px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s ease;
}

.browse-filter input:focus {
  outline: none;
  border-color: var(--primary);
}

.folder-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--surface);
}

/* File Cards */
.file-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.file-card {
  padding: 14px;
  background: var(--bg);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.file-card:hover {
  background: var(--card-bg);
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.file-name {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.speaker-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--hover-bg-strong);
  color: var(--primary);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.speaker-tag.protag {
  background: rgba(244, 160, 176, 0.2);
  color: #B85A6F;
}

.speaker-tag.narrator {
  background: rgba(163, 136, 212, 0.15);
  color: #6B4FA0;
}

.file-card.more {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 2px dashed var(--border-strong);
  color: var(--text-secondary);
  font-size: 14px;
}

.file-card.more:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--hover-bg);
}

/* ══════════════════════════════════════════════════════
   PROPOSAL NOTICE
   ══════════════════════════════════════════════════════ */

.proposal-notice {
  position: fixed;
  bottom: 16px;
  right: 16px;
  padding: 10px 18px;
  background: var(--text);
  color: var(--bg);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 1000;
}

/* ══════════════════════════════════════════════════════
   READER MODE STYLES
   ══════════════════════════════════════════════════════ */

/* Reader Filters */
.reader-filters {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.filter-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-results {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.match-count {
  font-size: 14px;
  color: var(--text-secondary);
}

.match-count strong {
  color: var(--primary);
  font-weight: 600;
}

.progress-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.progress-dot.complete {
  background: #7DC37D;
}

.progress-dot.inprogress {
  background: #F5C16C;
}

.progress-dot.unreviewed {
  background: #D0D0D0;
}

/* Scenario List */
.scenario-list {
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.scenario-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.15s ease;
}

.scenario-item:last-of-type {
  border-bottom: none;
}

.scenario-item:hover {
  background: rgba(244, 160, 176, 0.06);
}

.scenario-item.active {
  background: var(--hover-bg);
  border-left: 3px solid var(--primary);
}

.status-indicator {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.scenario-item.complete .status-indicator {
  color: #7CB342;
}

.scenario-item.inprogress .status-indicator {
  color: #F5A623;
}

.scenario-item.unreviewed .status-indicator {
  color: #BDBDBD;
}

.scenario-info {
  flex: 1;
  min-width: 0;
}

.scenario-title {
  display: block;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.scenario-preview {
  display: inline;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}

.scenario-preview:hover {
  text-decoration: underline;
}

a.file-path {
  color: var(--primary);
  text-decoration: none;
}

a.file-path:hover {
  text-decoration: underline;
}

.scenario-more {
  padding: 16px 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  background: var(--surface);
}

.browse-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border-color);
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-num {
  min-width: 36px;
  padding: 4px 8px !important;
}

.pagination-current {
  min-width: 36px;
  padding: 4px 8px;
  text-align: center;
  font-weight: 600;
  color: var(--card-bg);
  background: var(--primary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
}

.pagination-current:hover {
  opacity: 0.85;
}

.pagination-jump {
  width: 48px;
  padding: 4px 6px;
  text-align: center;
  font-size: 14px;
  border: 2px solid var(--primary);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  outline: none;
}

.pagination-jump::-webkit-inner-spin-button,
.pagination-jump::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pagination-ellipsis {
  color: var(--text-secondary);
  padding: 0 4px;
}

/* Reading Mode */
.reading-mode {
  display: none;
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.reading-mode.active {
  display: block;
}

.reader-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
}

.btn-icon {
  padding: 8px 12px;
  border: none;
  background: var(--card-bg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: var(--primary);
  color: white;
}

.reader-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reader-title .scene-type {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  align-self: flex-start;
}

.reader-title .scene-type:hover {
  text-decoration: underline;
}

.reader-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reader-title .reader-progress {
  font-size: 13px;
  color: var(--text-secondary);
}

.btn-jp {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-decoration: none;
  letter-spacing: 0.3px;
  transition: all 0.15s ease;
}

.btn-jp:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--hover-bg);
}

#mark-file-proofread {
  padding: 6px 12px;
  font-size: 12px;
}

#mark-file-proofread.reviewed {
  background: var(--proofread-bg);
  color: var(--proofread-text);
  border-color: var(--proofread-border);
}

.reader-content {
  padding: 32px;
  max-height: 50vh;
  overflow-y: auto;
}

.dialogue-container {
  max-width: 640px;
  margin: 0 auto;
}

.dialogue-line {
  margin-bottom: 20px;
}

.dialogue-line .line-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.dialogue-line .speaker {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Line status badges */
.line-status-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
}

.line-status-badge.proofread {
  background: var(--proofread-bg);
  color: var(--proofread-text);
}

.line-status-badge.open-pr {
  background: var(--openpr-bg);
  color: var(--openpr-text);
}

.line-status-badge.open-pr:hover {
  background: rgba(108, 180, 214, 0.4);
  text-decoration: underline;
}

/* Line status visual indicators */
.dialogue-line.line-proofread {
  border-left: 3px solid var(--proofread-border);
  padding-left: 12px;
  background: rgba(125, 195, 125, 0.05);
}

.dialogue-line.line-open-pr {
  border-left: 3px solid #6CB4D6;
  padding-left: 12px;
  background: rgba(108, 180, 214, 0.05);
}

.speaker.kazama {
  background: var(--openpr-bg);
  color: var(--openpr-text);
}

.speaker.protag {
  background: rgba(244, 160, 176, 0.2);
  color: #B85A6F;
}

.speaker.narration {
  background: rgba(176, 160, 144, 0.2);
  color: #6A5A4A;
}

[data-theme="dark"] .speaker.narration {
  background: rgba(176, 160, 144, 0.12);
  color: #A09080;
}

.line-text {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

/* From Search Indicator */
.from-search-badge {
  display: inline-block;
  padding: 3px 8px;
  background: var(--openpr-bg);
  color: var(--openpr-text);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

/* Search Result Highlighting in Reader */
.dialogue-line.search-highlight {
  background: rgba(108, 180, 214, 0.3) !important;
  animation: searchPulse 0.5s ease 3;
}

.dialogue-line.search-target {
  border-left: 3px solid #6CB4D6;
  padding-left: 9px;
}

@keyframes searchPulse {
  0%, 100% { background: rgba(108, 180, 214, 0.3); }
  50% { background: rgba(108, 180, 214, 0.5); }
}

/* Click-to-Edit Correction Form */
.dialogue-line {
  cursor: pointer;
  padding: 8px 12px;
  margin: -8px -12px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.dialogue-line:hover {
  background: var(--hover-bg);
}

.dialogue-line.editing {
  background: var(--hover-bg-strong);
  cursor: default;
}

.dialogue-line.corrected {
  border-left: 3px solid var(--proofread-border);
  padding-left: 9px;
}

.dialogue-line.corrected::after {
  content: 'Corrected';
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  background: var(--proofread-bg);
  color: var(--proofread-text);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  vertical-align: middle;
}

.correction-form {
  background: var(--bg-light);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0 20px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  animation: slideDown 0.2s ease;
}

/* Line warning messages */
.line-warning {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.line-warning.open-pr-warning {
  background: var(--openpr-bg);
  border: 1px solid rgba(108, 180, 214, 0.3);
  color: var(--openpr-text);
}

.line-warning.open-pr-warning a {
  color: var(--openpr-text);
  font-weight: 600;
}

.line-warning.proofread-warning {
  background: var(--proofread-bg);
  border: 1px solid rgba(125, 195, 125, 0.3);
  color: var(--proofread-text);
}

.line-warning .undo-proofread-btn {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 11px;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.correction-original {
  margin-bottom: 12px;
}

.correction-original label,
.correction-input label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.correction-original p {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
}

.correction-input {
  margin-bottom: 12px;
}

.correction-input textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--card-bg);
  resize: vertical;
  transition: border-color 0.15s ease;
  field-sizing: content;
  min-height: 2.5em;
  box-sizing: border-box;
}

.correction-input textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-shadow);
}

.correction-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.correction-success {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--proofread-bg);
  border-radius: 6px;
  color: var(--proofread-text);
  font-weight: 500;
}

.correction-success .success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #7DC37D;
  color: white;
  border-radius: 50%;
  font-size: 14px;
}

.correction-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: rgba(220, 80, 80, 0.15);
  border-radius: 6px;
  color: #8B3A3A;
  font-weight: 500;
}

[data-theme="dark"] .correction-error {
  color: #E08080;
}

.correction-error .error-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #DC5050;
  color: white;
  border-radius: 50%;
  font-size: 14px;
}

.reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border-subtle);
}

.footer-hint {
  font-size: 13px;
  color: var(--text-secondary);
}

.keyboard-hint {
  text-align: center;
  padding: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--hover-bg);
}

/* Button disabled states */
.btn:disabled,
.btn.secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Smooth transitions for reading mode */
.scenario-list {
  transition: opacity 0.2s ease;
}

.reading-mode {
  animation: readerFadeIn 0.15s ease;
}

@keyframes readerFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Clickable scenario items */
.scenario-item {
  cursor: pointer;
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
   ══════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
  }

  .result-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .browse-sidebar {
    position: static;
  }

  .browse-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .browse-filter input {
    width: 100%;
  }

  /* Reader Mode responsive */
  .filter-row {
    flex-direction: column;
  }

  .filter-results {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .reader-header {
    flex-wrap: wrap;
  }

  .reader-footer {
    flex-wrap: wrap;
    justify-content: center;
  }

  .reader-content {
    padding: 20px;
  }
}

/* ══════════════════════════════════════════════════════
   LOADING & EMPTY STATES
   ══════════════════════════════════════════════════════ */

.loading,
.scenario-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-style: italic;
}

/* Skeleton loader */
.skeleton-line {
  pointer-events: none;
}

.skeleton-block {
  display: block;
  height: 1em;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--bg-light) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-line .line-header .skeleton-block {
  height: 0.8em;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.no-results,
.no-dialogue,
.error {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  background: var(--surface);
  border-radius: 12px;
  margin: 16px 0;
}

.error {
  color: var(--error);
  border: 1px solid rgba(204, 51, 51, 0.2);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state .hint {
  font-size: 14px;
  margin-top: 8px;
  opacity: 0.8;
}

.hidden {
  display: none !important;
}

.scenario-more {
  text-align: center;
  padding: 16px;
  color: var(--text-secondary);
  font-size: 14px;
  border-top: 1px solid var(--border-subtle);
}

/* ══════════════════════════════════════════════════════
   IN-GAME PREVIEW
   ══════════════════════════════════════════════════════ */

.game-preview {
  display: flex;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #f5d6c6 0%, #fce5d8 50%, #fff0e6 100%);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.game-box {
  border-image-source: url('/msg_window.png');
  border-image-slice: 143 120 89 381;
  border-image-width: 50px 50px 40px 125px;
  border-style: solid;
  padding: 37px 15px 16px 11px;
  font-family: 'HeiSeiMaruGothic', sans-serif;
  font-size: 11.5pt;
  width: fit-content;
  position: relative;
}

.game-speaker {
  position: absolute;
  font-family: 'HeiSeiMaruGothic', sans-serif;
  top: 17px;
  left: 20px;
  color: #000000b3;
  font-size: 11.5pt;
}

.game-contents {
  text-overflow: clip;
  white-space: nowrap;
  background-color: #FFFFFF;
  border-radius: 11px;
  padding-top: 0.2em;
  padding-bottom: 0.3em;
  padding-left: 1em;
  line-height: 1.4em;
  width: fit-content;
  padding-right: 1em;
  color: #000000b3;
  box-shadow: inset 0 0 10px #00000030;
  overflow: hidden;
}

.game-text {
  padding-left: 0.25em;
  padding-right: 0.25em;
  padding-bottom: 3px;
  width: 22.3em;
  overflow: hidden;
}

.game-line {
  border-bottom: 2px solid #0000003d;
  padding-top: 3px;
  min-height: 1.3em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-line:last-child {
  border-bottom: none;
}

.preview-hint {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 8px 0 12px;
}

/* Y files use larger font */
.game-box.y-file {
  font-size: 13pt;
}

.game-box.y-file .game-speaker {
  font-size: 13pt;
}

.game-box.y-file .game-contents {
  overflow: visible;
}

.game-box.y-file .game-text {
  overflow: visible;
}

.game-box.y-file .game-line {
  overflow: visible;
  text-overflow: clip;
}

/* Game preview dark mode */
[data-theme="dark"] .game-preview {
  background: linear-gradient(135deg, #2A1E16 0%, #1E1612 50%, #1A1410 100%);
}

/* Line overflow / line-count warnings */
.dialogue-line.has-warning {
  border-left: 3px solid #e8972b;
}

.line-warnings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.line-warning {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--warning-badge-text);
  background: var(--warning-badge-bg);
  border: 1px solid var(--warning-badge-border);
  border-radius: 4px;
  padding: 2px 8px;
  line-height: 1.4;
}

/* PR Attribution fields */
.correction-field {
  margin-bottom: 12px;
}

.correction-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.correction-field input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.correction-field input:focus {
  outline: none;
  border-color: var(--primary);
}
