/* ===== PANEL DESIGN SYSTEM ===== */
:root {
  --panel-width: 340px;
  --panel-header-height: 60px;
  /* Flat design adjustments aligned with admin styles */
  --radius-sm: 0;
  --radius-md: 0;
  --radius-xl: 0;
  --radius-full: 0;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
  --shadow-xl: none;
  --shadow-inner: none;
}

/* ===== CARDS ===== */
.card {
  background-color: var(--bg-primary);
  border-radius: 0;
  box-shadow: none;
  border: 1px solid var(--border-light);
  overflow: hidden;
  transition: all var(--transition-normal);
  backdrop-filter: blur(10px);
}

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

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--panel-header-height);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  background-color: var(--primary-light);
  border-radius: var(--radius-sm);
}

.meta-item svg {
  width: 16px;
  height: 16px;
  stroke: var(--primary);
}

.preview-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ===== SEARCH PANEL ===== */
#search-panel {
  position: absolute;
  background-color: var(--bg-primary);
  backdrop-filter: blur(20px);
  box-shadow: none;
  z-index: 100;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-light);
  overflow: hidden;
  border-radius: 0;
}

#search-panel:not(.mobile) {
  top: 0;
  right: calc(-1 * var(--panel-width));
  width: var(--panel-width);
  height: 100%;
  opacity: 0;
  visibility: hidden;
}

#search-panel:not(.mobile).open {
  right: 0;
  opacity: 1;
  visibility: visible;
}

#search-panel.hidden {
  display: none;
}

#search-panel.mobile {
  position: fixed;
  top: auto;
  bottom: 0;
  transform: translateY(100%);
  right: 0;
  left: 0;
  width: 100%;
  height: 75vh;
  max-height: 90vh;
  border-radius: 0;
  border: 1px solid var(--border-light);
  border-bottom: none;
  box-shadow: var(--shadow-md);
}

#search-panel.mobile.open {
  transform: translateY(0);
}

#search-panel.mobile::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  background-color: var(--border-medium);
  border-radius: 2px;
  opacity: 0.6;
  cursor: grab;
}

.search-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--gradient-light);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: var(--panel-header-height);
}

#search-panel.mobile .search-header {
  padding-top: 1.75rem;
}

.search-header h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ===== TABLE OF CONTENTS PANEL ===== */
#toc-panel {
  position: absolute;
  background-color: var(--bg-primary);
  backdrop-filter: blur(20px);
  box-shadow: none;
  z-index: 100;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-light);
  overflow: hidden;
  border-radius: 0;
}

#toc-panel:not(.mobile) {
  top: 0;
  right: calc(-1 * var(--panel-width));
  width: var(--panel-width);
  height: 100%;
  opacity: 0;
  visibility: hidden;
}

#toc-panel:not(.mobile).open {
  right: 0;
  opacity: 1;
  visibility: visible;
}

#toc-panel.mobile {
  position: fixed;
  top: auto;
  bottom: 0;
  transform: translateY(100%);
  right: 0;
  left: 0;
  width: 100%;
  height: 75vh;
  max-height: 90vh;
  border-radius: 0;
  border: 1px solid var(--border-light);
  border-bottom: none;
  box-shadow: var(--shadow-md);
}

#toc-panel.mobile.open {
  transform: translateY(0);
}

#toc-panel.mobile::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  background-color: var(--border-medium);
  border-radius: 2px;
  opacity: 0.6;
  cursor: grab;
}

.toc-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-elevated);
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    min-height: var(--panel-header-height);

}

#toc-panel.mobile .toc-header {
  padding-top: 1.75rem;
}

.toc-header h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.toc-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    flex: 1;
    min-height: 0;
    background-color: var(--bg-secondary);
    padding-bottom: env(safe-area-inset-bottom);

}

.toc-status {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.toc-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-right: 0.25rem;
}

.toc-list:empty::after {
  content: 'No sections available yet.';
  font-size: 0.9rem;
  color: var(--text-tertiary);
}

.toc-card {
  --toc-indent: calc(var(--toc-level, 0) * 0.75rem);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  padding-left: calc(1.25rem + var(--toc-indent));
  min-height: 0;
  max-height: 200px;
  border: 1px solid var(--border-light);
  border-radius: 0;
  box-shadow: none;
  background: var(--bg-primary);
  overflow: hidden;
  transform: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.toc-card::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--toc-indent);
    width: 100%;
    background: rgba(55, 66, 82, 0.25);
    transition: background-color var(--transition-fast);

}

.toc-card:hover {
  background: var(--bg-secondary);
  border-color: var(--primary-light);
  box-shadow: none;
  transform: none;
}

.toc-card:hover::before {
    background: rgba(99, 102, 241, 0.33);

}

.toc-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.toc-card .article-card-header {
    align-items: flex-start;
    z-index: 102;

}

.toc-card .article-card-heading {
    gap: 0.35rem;
    width: 100%;

}

.toc-card .article-card-heading .article-title {
  font-size: 1rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-card .article-card-subtitle {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-card-page {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.toc-card.disabled {
  cursor: default;
  opacity: 0.6;
}

.toc-card.disabled::before {
  background: var(--border-light);
}

.toc-card.disabled:hover {
  background: var(--bg-primary);
  border-color: var(--border-light);
}

.toc-empty-message,
.toc-error-message {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}

.toc-error-message {
  color: var(--danger);
}

.search-header h3::before {
  content: "\f002";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 1.25rem;
}

.search-input-wrapper {
  position: relative;
  margin: 0.25rem 1rem;
  margin: 18px;
}

#page-selection-controls-section {
  border-bottom: 1px solid var(--border-light);
  background-color: var(--bg-secondary);
  display: flex;
  gap: 1.5rem;
  font-size: 0.875rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.panel-input-wrapper {
  position: relative;
  margin: 0.25rem 1rem;
  margin: 18px;
}

#search-input, #page-selection-input {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-inner);
}

#search-input:focus, #page-selection-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light), var(--shadow-inner);
  background-color: var(--bg-primary);
}

.panel-input-wrapper:before {
  content: '';
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.5;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

#search-input:focus + .panel-input-wrapper::before {
  opacity: 0.8;
}

.search-buttons-row {
  display: flex;
  gap: 0.75rem;
  margin: 0.5rem 1rem 1rem;
}

.page-selection-label{
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1rem;
}

.article-action-buttons {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1rem;
}

#search-execute,
#search-reset, 
#analyze-pages-btn, 
#clear-cache-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9375rem;
  transition: all var(--transition-fast);
  cursor: pointer;
}

#search-execute {
  background: var(--gradient-primary);
  color: var(--text-light);
  border: none;
  box-shadow: var(--shadow-sm);
}

#analyze-pages-btn {
  background: var(--gradient-primary);
  color: var(--text-light);
  border: none;
  box-shadow: var(--shadow-sm);
}

#search-execute:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

#analyze-pages-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

#search-reset {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}

#search-reset:hover,
#clear-cache-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--accent);
  transform: translateY(-1px);
  border-color: var(--accent);
}

#search-reset svg,
#search-execute svg,
#analyze-pages-btn svg,
#clear-cache-btn svg {
  width: 16px;
  height: 16px;
}

#search-reset svg,
#clear-cache-btn svg {
  transition: transform var(--transition-normal);
}

#analyze-pages-btn svg {
  transition: transform var(--transition-normal);
}

#search-reset:hover svg, 
#analyze-pages-btn:hover svg {
  transform: rotate(-90deg);
}

#close-search {
    position: absolute;
    top: 15px;
    right: 20px;
    /* transform: translateY(-50%); */
    width: 32px;
    height: 32px;
    /* border-radius: var(--radius-full); */
    background: transparent;
    /* border: none; */
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;

}

#search-panel.mobile #close-search {
  top: calc(1.75rem + 1.125rem / 2);
}

#close-search:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent);
    /* transform: translateY(-50%) scale(1.1); */

}

#close-search svg {
  width: 20px;
  height: 20px;
}

.search-options {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background-color: var(--bg-secondary);
  display: flex;
  /*! gap: 1.5rem; */
  font-size: 0.875rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.search-options label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.search-options label:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

.search-options input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-medium);
  border-radius: 4px;
  background-color: var(--bg-primary);
  position: relative;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.search-options input[type="checkbox"]:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.search-options input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid var(--text-light);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.search-results {
    flex: 1;
    overflow-y: auto;
    background-color: var(--bg-secondary);
    padding-bottom: env(safe-area-inset-bottom);

}

.search-results::-webkit-scrollbar {
  width: 6px;
}

.search-results::-webkit-scrollbar-track {
  background: transparent;
}

.search-results::-webkit-scrollbar-thumb {
  background-color: var(--border-medium);
  border-radius: 3px;
}

.search-status {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  background-color: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-shrink: 0;
}

.search-navigation {
  display: flex;
  gap: 0.5rem;
}

.search-navigation button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

.search-navigation button:hover:not([disabled]) {
  background-color: var(--primary);
  color: var(--text-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.search-navigation button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#search-results-list {
  padding: 1rem 1.5rem;
}

.search-result-item {
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-normal);
  background-color: var(--bg-primary);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.search-result-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.search-result-item.active {
  background-color: var(--primary-light);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.search-result-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 4px;
  background-color: var(--primary);
}

.result-page {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--primary);
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background-color: var(--primary-light);
  border-radius: var(--radius-full);
}

.result-context {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.result-context .highlight {
  background-color: var(--warning-light);
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 600;
  color: var(--warning);
}

.result-meta {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
}

.result-match-count {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  background-color: var(--bg-tertiary);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-full);
  font-weight: 500;
}

.no-results,
.search-error {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.no-results::before {
  content: "\f002";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 2.5rem;
  opacity: 0.5;
}

.search-error {
  color: var(--error);
}

.search-error::before {
  content: "\f071";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 2.5rem;
}



/* ===== DARK MODE STYLES ===== */
.dark-mode #search-panel{
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-light);
  background: var(--dark-bg-elevated);
}

.dark-mode .search-header {
    background: var(--dark-bg-elevated);
    border-bottom-color: var(--border-light);

}

.dark-mode .search-header h3 {
  color: var(--text-primary);
}

.dark-mode .search-result-item {
  background-color: var(--dark-bg-secondary);
  border-color: var(--dark-border-color);
}

.dark-mode .search-result-item:hover {
  border-color: var(--primary);
}

.dark-mode .article-card.clickable-article-card:hover {
  border-left-color: var(--primary);
}

.dark-mode .article-card h4 {
  color: var(--text-primary);
}

.dark-mode .article-card p {
  color: var(--text-secondary);
}

.dark-mode .tag {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
}

.dark-mode .page-tag {
  background: var(--gradient-primary) !important;
  color: var(--text-light) !important;
}

.dark-mode .click-hint {
  background-color: var(--primary);
}

.dark-mode #article-close,
.dark-mode #close-search {
    color: var(--text-primary);

}

.dark-mode #article-close:hover,
.dark-mode #close-search:hover {
    background-color: var(--bg-tertiary);
    /* color: var(--accent); */

}

.dark-mode .analyze-articles-btn {
  background: var(--gradient-primary);
}

.dark-mode .analyze-articles-btn:hover {
  background: var(--gradient-primary);
}

.dark-mode .article-count {
  background-color: var(--error);
  border-color: var(--bg-primary);
  color: var(--text-light);
}

.dark-mode #article-view {
  background: rgba(0, 0, 0, 0.9);
}

.dark-mode .article-modal-content {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-light);
}

.dark-mode .article-meta-item,
.dark-mode .confidence-badge,
.dark-mode .word-count,
.dark-mode .feature-tag {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
}

.dark-mode .article-meta-item.page {
  background-color: var(--primary-light);
  color: var(--primary);
}

.dark-mode .article-meta-item.layout {
  background-color: var(--accent-light);
  color: var(--accent);
}

.dark-mode .confidence-badge.high {
  background-color: var(--success-light);
  color: var(--success);
}

.dark-mode .confidence-badge.medium {
  background-color: var(--warning-light);
  color: var(--warning);
}

.dark-mode .confidence-badge.low {
  background-color: var(--error-light);
  color: var(--error);
}

.dark-mode .feature-tag {
  background-color: var(--primary-light);
  color: var(--primary);
}

/* ===== RESPONSIVE STYLES ===== */
@media (max-width: 768px) {
  :root {
    --panel-width: 100vw;
  }

  .flipbook-area.pushed {
    margin-right: 0;
  }

  .btn-next.shifted {
    right: 1.5rem;
  }

  .article-meta {
    gap: 0.25rem;
  }

  .article-stats {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .content-features {
    margin-left: 0;
    margin-top: 0.25rem;
  }
}

@media (max-width: 600px) {
  .search-options {
    flex-direction: column;
    gap: 0.75rem;
  }

  .preview-meta,
  .preview-actions {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }

  .article-card {
    padding: 1rem;
  }

  .article-card h4 {
    font-size: 0.9375rem;
  }
}

@media (max-width: 480px) {
  .search-header {
    padding: 1rem;
  }

  .panel-input-wrapper {
    margin-left: 1rem;
    margin-right: 1rem;
  }

  #search-results-list,
  .article-list {
    padding: 1rem;
  }

  .article-meta-item,
  .confidence-badge,
  .word-count,
  .feature-tag {
    font-size: 0.6875rem;
    padding: 0.1875rem 0.375rem;
  }
}

@media (max-width: 400px) {
  .preview-meta,
  .preview-actions {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }

  .preview-actions .btn {
    width: 100%;
  }

  .article-card {
    padding: 0.875rem;
  }

  .article-stats {
    gap: 0.375rem;
  }
}

@media print {
  .structure-info {
    background: #f8f9fa;
    border-left: 2px solid #6c757d;
    margin: 8pt 0;
    padding: 6pt 8pt;
  }
}

.clear-cache-btn {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.clear-cache-btn:hover {
    background: linear-gradient(135deg, #c82333, #bd2130);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.clear-cache-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.summary-keypoints {
    margin: 0.75rem 0 0 0;
    padding-left: 1.2rem;
    color: var(--text-secondary, #475569);
    font-size: 0.85rem;
}

.summary-keypoints li {
    margin-bottom: 0.35rem;
}


.summary-structure-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary, #475569);
}

.summary-structure-row .label {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    color: var(--text-tertiary, #94a3b8);
}

.summary-structure-row .value {
    text-align: right;
    flex: 1;
}

.summary-structure-row .value.muted {
    color: var(--text-tertiary, #94a3b8);
    font-style: italic;
}

.visual-content-indicators {
    display: flex;
    gap: 1em;
    align-items: center;
    margin-top: 0.5em;
}

.visual-item {
    display: flex;
    align-items: center;
    gap: 0.3em;
    background: #f8f9fa;
    padding: 0.3em 0.7em;
    border-radius: 8px;
    margin: 2px 0;
    color: initial;
}

.visual-icon {
    width: 18px;
    height: 18px;
    color: #3498db;
}

.visual-count {
    font-size: 0.95em;
    font-weight: 500;
    color: #2c3e50;
}

.grouping-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    background: #e8f4fc;
    color: #2980b9;
    padding: 0.3em 0.7em;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 500;
    margin-left: 0.5em;
}

/* ===== Article card visual refresh ===== */
.article-list {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    /* display: grid; */
    gap: 1.25rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    padding: 1rem 1.5rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    align-content: start;
    min-height: 0;
    max-height: 100%;
    scrollbar-gutter: stable both-edges;
    overscroll-behavior: contain;

}

.article-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    min-height: 10rem;
    margin: 0;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    animation: fadeInSlide 0.5s ease-out;
    transition: background-color var(--transition-fast), border-color var(--transition-fast),
transform var(--transition-fast), box-shadow var(--transition-fast);

}

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

.article-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.article-card-heading {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.article-card-heading .article-title {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.05rem;
  line-height: 1.4;
}

.article-card-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.35;
}

.article-card-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.article-card .article-summary-snippet {
  display: none;
}

.article-meta-grid {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.meta-icon {
  width: 16px;
  height: 16px;
  color: currentColor;
  flex-shrink: 0;
  fill: currentColor;
  stroke: currentColor;
}

.meta-icon path {
  fill: currentColor;
  stroke: currentColor;
}

.article-card-structure {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.structure-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.structure-block.full-width {
  grid-column: 1 / -1;
}

.structure-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.structure-value {
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.structure-value.muted {
  color: var(--text-tertiary);
  font-style: italic;
}

.structure-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.structure-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
}

.structure-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.structure-list li {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.structure-list-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.structure-list-preview {
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.structure-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
}

.structure-tag.continuation {
  background: var(--warning-soft, #fef3c7);
  color: var(--warning-strong, #b45309);
}

.structure-tag.contained {
  background: var(--success-soft, #dcfce7);
  color: var(--success-strong, #047857);
}

.structure-tag.highlight {
  background: var(--danger-soft, #fef2f2);
  color: var(--danger-strong, #b91c1c);
}

.structure-text {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.article-card-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.article-card-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn.btn-xs {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm, 6px);
}

.btn.btn-xs.btn-outline {
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-secondary);
}

.visual-content-indicators {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.visual-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.visual-icon {
  width: 18px;
  height: 18px;
  color: currentColor;
}

.visual-icon path {
  fill: currentColor;
}

.visual-count {
  font-size: 0.85rem;
  font-weight: 500;
}

.summary-takeaways {
    margin-top: 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
}

.summary-takeaways h4 {
    margin: 0 0 0.35rem 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary, #94a3b8);
}

.summary-keypoints {
    margin: 0.75rem 0 0 0;
    padding-left: 1.2rem;
    color: var(--text-secondary, #475569);
    font-size: 0.85rem;
}

.summary-keypoints li {
    margin-bottom: 0.35rem;
}

.article-summary-structure {
    border-top: 1px solid #e2e8f0;
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.summary-structure-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary, #475569);
}

.summary-structure-row .label {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    color: var(--text-tertiary, #94a3b8);
}

.dark-mode .article-card:hover {
  background: var(--dark-bg-elevated);
  border-color: var(--primary);
}

.dark-mode .article-meta-grid,
.dark-mode .article-card-structure {
  background: var(--dark-bg-elevated);
  border-color: var(--dark-border-color);
}

.dark-mode .structure-tag {
  background: var(--dark-bg-secondary);
  color: var(--text-secondary);
}

.dark-mode .visual-item {
  background: var(--dark-bg-elevated);
  color: var(--text-secondary);
}

.dark-mode .grouping-badge {
  background: var(--accent);
  color: var(--text-light, #fff);
}
