/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.header-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  min-height: 44px;
}

.header-brand:hover {
  text-decoration: none;
  color: var(--accent-text);
}

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

/* Breadcrumbs */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.breadcrumb a {
  color: var(--text-muted);
  padding: 0.25rem 0;
}

.breadcrumb a:hover {
  color: var(--accent-text);
}

.breadcrumb-sep {
  opacity: 0.6;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.btn:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: var(--border-strong);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-sm {
  min-height: 36px;
  padding: 0.35rem 0.7rem;
  font-size: 0.825rem;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: transparent;
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--badge-bg);
  color: var(--badge-text);
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}

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

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

/* Cards & Grids */
.section-block {
  margin-top: 1.75rem;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.card-interactive {
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.card-muted {
  opacity: 0.85;
  background: var(--surface-subtle);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.25rem;
}

/* Stats bar */
.stats-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
  .stats-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
}

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

/* Toolbar & Filters */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toolbar-row {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

@media (min-width: 640px) {
  .toolbar-row {
    flex-direction: row;
    align-items: center;
  }
}

.input,
.select {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}

.input::placeholder {
  color: var(--text-muted);
}

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

.pill-btn {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: capitalize;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.pill-btn:hover {
  background: var(--surface-subtle);
}

.pill-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

/* Notes: Term Cards & Table */
.term-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.term-card.is-studied {
  border-left: 4px solid var(--success-text);
}

.term-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.term-example {
  background: var(--surface-subtle);
  border-left: 3px solid var(--accent);
  padding: 0.55rem 0.75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.92rem;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  background: var(--surface-subtle);
  font-weight: 600;
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Detail Dialog / Panel */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 1.5rem;
  }
}

.modal-panel {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

@media (min-width: 640px) {
  .modal-panel {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
  }
}

.detail-kv {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0;
}

@media (min-width: 640px) {
  .detail-row {
    flex-direction: row;
    gap: 1rem;
  }
  .detail-label {
    min-width: 130px;
    flex-shrink: 0;
  }
}

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

/* Quiz UI */
.quiz-shell {
  max-width: 680px;
  margin: 0 auto;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--surface-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width var(--transition-fast);
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.option-btn {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  padding: 0.75rem 1rem;
  min-height: 48px;
  font-weight: 500;
  line-height: 1.4;
}

.option-btn.is-correct {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.option-btn.is-wrong {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.feedback-banner {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-top: 0.75rem;
}

.feedback-banner.is-correct {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.feedback-banner.is-wrong {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.empty-state {
  text-align: center;
  padding: 2.25rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}
