*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1117;
  --bg-surface: #1a1d27;
  --bg-surface-2: #222535;
  --bg-surface-3: #2a2e42;
  --border: #2e3248;
  --text: #e2e4ed;
  --text-muted: #8a8fa8;
  --text-dim: #5a5f77;
  --accent: #6366f1;
  --accent-hover: #4f52d9;
  --accent-dim: rgba(99, 102, 241, 0.15);
  --green: #22c55e;
  --blue: #3b82f6;
  --yellow: #eab308;
  --red: #ef4444;
  --radius: 8px;
  --radius-sm: 4px;
  --sidebar-width: 260px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

html,
body,
#app {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* ── Layout ────────────────────────────────────────────── */

.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

/* ── Sidebar ────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.btn-new {
  margin: 12px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}

.btn-new:hover {
  background: var(--accent-hover);
}

.sidebar-section-label {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sidebar-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 4px 8px 8px;
}

.sidebar-empty {
  padding: 8px;
  color: var(--text-dim);
  font-size: 13px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: background 0.1s, color 0.1s;
  user-select: none;
}

.sidebar-item:hover {
  background: var(--bg-surface-2);
  color: var(--text);
}

.sidebar-item.selected {
  background: var(--accent-dim);
  color: var(--text);
}

.sidebar-icon {
  font-size: 12px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.status-done {
  color: var(--green);
}

.status-error {
  color: var(--red);
}

.status-running {
  color: var(--accent);
}

.status-pending {
  color: var(--text-dim);
}

.sidebar-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Main content areas ─────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.content-area {
  max-width: 860px;
  margin: 0 auto;
}

.rec-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}

.error-state {
  color: var(--text-muted);
}

.error-state h2 {
  color: var(--red);
  margin-bottom: 8px;
}

.error-state p {
  margin-bottom: 16px;
}

/* ── Pipeline Progress ──────────────────────────────────── */

.pipeline-progress {
  padding: 40px 0;
}

.pipeline-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 24px;
}

.pipeline-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

.pipeline-step--running {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.pipeline-step--done {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.05);
}

.pipeline-step--error {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
}

.stage-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.stage-done {
  color: var(--green);
}

.stage-error {
  color: var(--red);
}

.stage-running {
  color: var(--accent);
}

.stage-pending {
  color: var(--text-dim);
}

.spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.pipeline-step-label {
  font-weight: 500;
}

/* ── Cards ─────────────────────────────────────────────── */

.cards-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.15s;
}

.card:hover {
  border-color: var(--bg-surface-3);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.badge-green {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.badge-blue {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.badge-yellow {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
}

.badge-red {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.card-explanation {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.card-feedback {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.star-rating {
  display: flex;
  align-items: center;
  gap: 2px;
}

.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-dim);
  padding: 0 2px;
  transition: color 0.1s, transform 0.1s;
}

.star-btn:hover,
.star-btn.star-active {
  color: var(--yellow);
}

.star-btn:hover {
  transform: scale(1.1);
}

.feedback-saved {
  margin-left: 8px;
  font-size: 12px;
  color: var(--green);
  font-weight: 500;
}

.comment-area {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comment-input {
  font-size: 13px;
  resize: vertical;
}

/* ── Rerank Button ──────────────────────────────────────── */

.rerank-section {
  padding: 16px 0 32px;
  display: flex;
  justify-content: center;
}

.btn-rerank {
  padding: 12px 28px;
  background: var(--bg-surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-rerank:hover:not(:disabled) {
  background: var(--bg-surface-3);
  border-color: var(--accent);
  color: var(--accent);
}

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

/* ── Buttons ────────────────────────────────────────────── */

.btn-primary {
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

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

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

.btn-primary.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-secondary {
  padding: 10px 20px;
  background: var(--bg-surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-surface-3);
}

/* ── Modal ──────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 540px;
  max-width: 96vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

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

.modal-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-input,
.form-textarea {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  width: 100%;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--accent);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

/* ── Landing page ───────────────────────────────────────── */

.landing-layout {
  display: flex;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

.landing-bg {
  position: absolute;
  inset: -6px;
  /* overflow slightly to hide blur edges */
  background: url('/wallpaper.png') center / cover no-repeat;
  filter: blur(3px) brightness(0.35);
  z-index: 0;
}

.landing-layout .sidebar {
  position: relative;
  z-index: 1;
  background: rgba(26, 29, 39, 0.85);
  backdrop-filter: blur(8px);
}

.landing-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  text-align: center;
  position: relative;
  z-index: 1;
  padding: 40px;
}

.landing-title {
  font-size: 5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -2px;
  line-height: 1;
}

.landing-tagline {
  font-size: 1.4rem;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 400;
}

.btn-gradient {
  padding: 18px 52px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, #e040fb, #7c4dff, #2979ff, #00b0ff, #e040fb);
  background-size: 300% 300%;
  animation: gradient-flow 5s ease infinite;
  box-shadow: 0 4px 32px rgba(99, 102, 241, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  letter-spacing: 0.02em;
}

.btn-gradient:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 40px rgba(99, 102, 241, 0.55);
}

@keyframes gradient-flow {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

/* ── Recom page ─────────────────────────────────────────── */

.recom-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.recom-nav {
  flex-shrink: 0;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.recom-back {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s;
}

.recom-back:hover {
  color: var(--text);
}

.recom-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}