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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #0a0a0f;
  color: #e4e4e7;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: #93c5fd;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: #111118;
  border-bottom: 1px solid #1e1e2e;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #f4f4f5;
}

.header nav {
  display: flex;
  gap: 0.25rem;
}

.header nav button {
  background: none;
  border: none;
  color: #71717a;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.header nav button:hover {
  color: #e4e4e7;
  background: #1e1e2e;
}

.header nav button.active {
  color: #93c5fd;
  background: #1e1e2e;
  border-bottom: 2px solid #93c5fd;
}

/* Queue container */
.queue-container {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  transition: all 0.3s ease;
  overflow: hidden;
}

.queue-container .queue {
  flex: 1;
  min-width: 0;
  transition: all 0.3s ease;
  overflow-y: auto;
}

.queue-container.panel-open .queue {
  flex: 0 0 55%;
  opacity: 0.7;
}

/* Queue header */
.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
}

.queue-count {
  font-size: 0.875rem;
  color: #71717a;
}

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

.hint-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #71717a;
  background: #1e1e2e;
  border: 1px solid #2e2e3e;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}

.hint-toggle:hover,
.hint-toggle.active {
  color: #93c5fd;
  border-color: #93c5fd;
  background: #1e293b;
}

/* Cards */
.card {
  border: 1px solid #1e1e2e;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 0 1.5rem 0.75rem;
  background: #111118;
  transition: border-color 0.15s;
}

.card:hover {
  border-color: #2e2e3e;
}

.card.focused {
  border-color: #93c5fd;
  box-shadow: 0 0 0 1px #93c5fd33;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #71717a;
}

.card-meta span + span::before {
  content: "\00b7";
  margin-right: 0.5rem;
}

.card-source {
  font-weight: 500;
  color: #a1a1aa;
}

.card-score {
  font-size: 0.8rem;
  font-weight: 600;
  color: #93c5fd;
  background: #1e293b;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.card-title a {
  color: #f4f4f5;
}
.card-title a:hover {
  color: #93c5fd;
}

.card-summary {
  font-size: 0.875rem;
  color: #a1a1aa;
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.tag {
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  border-radius: 12px;
  font-weight: 500;
}

.tag-purpose {
  background: #312e81;
  color: #a5b4fc;
}

.tag-general {
  background: #27272a;
  color: #a1a1aa;
}

.card-reasoning {
  font-size: 0.8rem;
  color: #71717a;
  font-style: italic;
  margin-bottom: 0.5rem;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* Buttons */
.btn {
  padding: 0.4rem 0.9rem;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:hover {
  opacity: 0.85;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-bad {
  background: #dc2626;
  color: #fff;
}

.btn-skip {
  background: #3f3f46;
  color: #d4d4d8;
}

.btn-star {
  background: #2563eb;
  color: #fff;
}

.btn-awesome {
  background: #16a34a;
  color: #fff;
}

.btn-refresh {
  background: #27272a;
  color: #d4d4d8;
}

.btn-cancel {
  background: #27272a;
  color: #d4d4d8;
}

/* Keyboard hint badges */
kbd {
  display: inline-block;
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  padding: 0 0.3rem;
  line-height: 1.4;
  vertical-align: middle;
  margin-right: 0.15rem;
}

/* Feedback panel */
.feedback-panel {
  flex: 0 0 45%;
  min-width: 0;
  background: #131320;
  border-left: 1px solid #1e1e2e;
  padding: 1.5rem;
  height: calc(100vh - 57px);
  position: fixed;
  top: 57px;
  right: 0;
  width: 45%;
  max-width: 540px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  z-index: 50;
}

.panel-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #f4f4f5;
  margin-bottom: 0.5rem;
}

.panel-article-title {
  display: block;
  font-size: 0.9rem;
  color: #a1a1aa;
  margin-bottom: 0.25rem;
}

.panel-article-source {
  display: block;
  font-size: 0.8rem;
  color: #71717a;
}

.taste-hint {
  font-size: 0.75rem;
  color: #52525b;
  font-style: italic;
  margin-top: -0.25rem;
}

.panel-dimensions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dim-btn {
  background: #1e1e2e;
  border: 1px solid #2e2e3e;
  color: #d4d4d8;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.dim-btn:hover {
  border-color: #4e4e5e;
  background: #252535;
}

.dim-btn.active {
  border-color: #93c5fd;
  background: #1e293b;
  color: #93c5fd;
}

.panel-freeform {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.panel-freeform label {
  font-size: 0.8rem;
  color: #71717a;
  font-weight: 500;
}

.panel-freeform input {
  background: #1e1e2e;
  border: 1px solid #2e2e3e;
  color: #e4e4e7;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.panel-freeform input:focus {
  border-color: #93c5fd;
}

.panel-freeform input::placeholder {
  color: #52525b;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: auto;
}

/* Empty state */
.empty {
  text-align: center;
  color: #71717a;
  padding: 3rem 1rem;
  font-size: 0.95rem;
}

/* Dashboard */
.dashboard {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

.dashboard section {
  margin-top: 2rem;
}

.dashboard section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #a1a1aa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

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

.stat-card {
  border: 1px solid #1e1e2e;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  background: #111118;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #f4f4f5;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: #71717a;
  margin-top: 0.25rem;
}

/* Score distribution histogram */
.chart-histogram {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0.25rem;
  height: 200px;
  padding: 0.5rem 0;
  border-bottom: 1px solid #1e1e2e;
}

.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
}

.bar {
  background: #4f46e5;
  min-width: 20px;
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  transition: background 0.15s;
}

.bar:hover {
  background: #6366f1;
}

.bar-count {
  font-size: 0.65rem;
  color: #c7d2fe;
  padding-top: 2px;
  line-height: 1;
}

.bar-label {
  font-size: 0.65rem;
  color: #71717a;
  margin-top: 0.25rem;
  white-space: nowrap;
}

/* Rejections table */
.rejections-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.rejections-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: #71717a;
  font-weight: 500;
  border-bottom: 1px solid #1e1e2e;
}

.rejections-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #111118;
  color: #d4d4d8;
}

.rejections-table tr:hover td {
  background: #111118;
}

.rejections-table td:last-child {
  color: #a1a1aa;
  text-align: right;
  width: 4rem;
}

/* Responsive */
@media (max-width: 768px) {
  .queue-container {
    flex-direction: column;
  }

  .queue-container.panel-open .queue {
    flex: 1;
    opacity: 0.3;
    pointer-events: none;
  }

  .feedback-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100vh;
    z-index: 200;
  }

  .card {
    margin: 0 0.75rem 0.75rem;
  }

  .queue-header {
    padding: 1rem 0.75rem;
  }
}

/* Settings */
.settings {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

.settings-section {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #1e1e2e;
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #a1a1aa;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

/* Threshold control */
.threshold-control {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.threshold-control input[type="range"] {
  width: 200px;
  accent-color: #4f46e5;
}

.threshold-control .threshold-value,
.threshold-value {
  font-family: monospace;
  min-width: 3rem;
  text-align: right;
  color: #a1a1aa;
  font-size: 0.875rem;
}

/* Config table (rules, interests) */
.config-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.config-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: #71717a;
  font-weight: 500;
  border-bottom: 1px solid #1e1e2e;
}

.config-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #111118;
  color: #d4d4d8;
}

.config-table tr:hover td {
  background: #111118;
}

.config-table .btn-delete {
  background: #7f1d1d;
  color: #fca5a5;
  border: none;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.config-table .btn-delete:hover {
  opacity: 0.8;
}

/* Rule type badge */
.rule-type-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
}

.rule-type-badge.badge-solid {
  background: #27272a;
  color: #a1a1aa;
}

.rule-type-badge.badge-topic {
  background: transparent;
  border: 1px solid #71717a;
  color: #71717a;
}

/* Add form */
.add-form {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  margin-top: 1rem;
  align-items: flex-end;
}

.add-form input,
.add-form select {
  background: #1e1e2e;
  border: 1px solid #2e2e3e;
  color: #e4e4e7;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}

.add-form input:focus,
.add-form select:focus {
  border-color: #93c5fd;
}

.add-form input::placeholder {
  color: #52525b;
}

.add-form .btn-add {
  background: #4f46e5;
  color: #fff;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.add-form .btn-add:hover {
  opacity: 0.85;
}

/* Weight slider */
.weight-slider {
  width: 80px;
  accent-color: #4f46e5;
  vertical-align: middle;
}

/* Taste signals */
.taste-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.taste-column h4 {
  font-size: 0.9rem;
  color: #a1a1aa;
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.taste-list {
  display: flex;
  flex-direction: column;
}

.taste-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid #1e1e2e;
  font-size: 0.875rem;
  color: #d4d4d8;
}

.taste-entry .btn-delete {
  background: #7f1d1d;
  color: #fca5a5;
  border: none;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.taste-entry .btn-delete:hover {
  opacity: 0.8;
}

/* Responsive: taste columns */
@media (max-width: 768px) {
  .taste-columns {
    grid-template-columns: 1fr;
  }
}

/* Queue threshold slider */
.queue-threshold {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #71717a;
}

.queue-threshold label {
  white-space: nowrap;
}

.queue-threshold input[type="range"] {
  width: 120px;
  accent-color: #4f46e5;
}

.threshold-value {
  font-family: monospace;
  font-size: 0.8rem;
  color: #a1a1aa;
  min-width: 2.5rem;
  text-align: right;
}
