:root {
  color-scheme: light;
  --bg: #f6f3ea;
  --bg-alt: #e2f0ee;
  --ink: #1c2422;
  --muted: #5b6a66;
  --accent: #e07a5f;
  --accent-strong: #c85f45;
  --accent-cool: #2f7a70;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-border: rgba(28, 36, 34, 0.08);
  --panel-shadow: 0 18px 50px rgba(28, 36, 34, 0.12);
  --chip: rgba(47, 122, 112, 0.12);
  --chip-text: #1e4f48;
  --star-off: rgba(28, 36, 34, 0.16);
  --star-on: #e07a5f;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --transition: 0.2s ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Karla", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #ffffff, var(--bg));
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body.theme-console {
  color-scheme: dark;
  --bg: #0a101b;
  --bg-alt: #0f1726;
  --ink: #e8f0ff;
  --muted: #8aa3c4;
  --accent: #45f3ff;
  --accent-strong: #6dff88;
  --accent-cool: #45f3ff;
  --panel: rgba(15, 23, 38, 0.92);
  --panel-border: rgba(69, 243, 255, 0.2);
  --panel-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  --chip: rgba(69, 243, 255, 0.16);
  --chip-text: #6dff88;
  --star-off: rgba(232, 240, 255, 0.28);
  --star-on: #ff8f1f;
  background:
    radial-gradient(900px circle at 12% -10%, rgba(69, 243, 255, 0.18) 0%, transparent 55%),
    radial-gradient(900px circle at 90% 10%, rgba(109, 255, 136, 0.14) 0%, transparent 55%),
    linear-gradient(160deg, #0b131f 0%, #0a101b 100%);
}

body.theme-console .bg-grid {
  background-image:
    linear-gradient(120deg, rgba(69, 243, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(69, 243, 255, 0.06) 1px, transparent 1px);
  opacity: 0.35;
}

body.theme-console .bg-glow {
  background: radial-gradient(circle, rgba(69, 243, 255, 0.22), transparent 70%);
  opacity: 0.7;
}

body.embed .bg-grid,
body.embed .bg-glow {
  display: none;
}

body.embed .hero {
  padding: 28px 4vw 16px;
}

body.embed .hero h1 {
  font-size: clamp(1.6rem, 3.6vw, 2.4rem);
}

body.embed .hero p {
  display: none;
}

body.embed .hero__top {
  display: none;
}

body.embed .layout {
  padding: 0 4vw 32px;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(120deg, rgba(28, 36, 34, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 36, 34, 0.03) 1px, transparent 1px);
  background-size: 72px 72px;
  opacity: 0.6;
  pointer-events: none;
  z-index: -2;
}

.bg-glow {
  position: fixed;
  width: 700px;
  height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(224, 122, 95, 0.18), transparent 70%);
  top: -280px;
  right: -200px;
  pointer-events: none;
  z-index: -1;
  animation: floatGlow 12s ease-in-out infinite;
}

@keyframes floatGlow {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(30px);
  }
}

.hero {
  padding: 48px 6vw 28px;
  position: relative;
}

.hero__top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

h1 {
  font-family: "Sora", sans-serif;
  font-size: clamp(2.2rem, 3vw, 3rem);
  margin: 0 0 12px;
}

.hero p {
  max-width: 720px;
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0 0 24px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-cool);
  color: #ffffff;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pill--ghost {
  background: rgba(28, 36, 34, 0.08);
  color: var(--ink);
}

body.theme-console .pill--ghost {
  background: rgba(69, 243, 255, 0.12);
  color: var(--ink);
}

.hero__bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.toolbar-control {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  min-width: 220px;
  box-shadow: var(--panel-shadow);
}

.toolbar-control label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.toolbar-control input,
.toolbar-control select {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 1rem;
  margin-top: 6px;
  outline: none;
  color: var(--ink);
}

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

.btn {
  border: none;
  background: var(--accent);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 10px 20px rgba(224, 122, 95, 0.2);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(224, 122, 95, 0.28);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--panel-border);
  box-shadow: none;
}

.btn--outline {
  background: transparent;
  border: 1px dashed var(--accent-cool);
  color: var(--accent-cool);
  box-shadow: none;
}

.stats {
  display: flex;
  gap: 18px;
}

.stat {
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
  min-width: 120px;
}

.stat__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat__value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 6px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 24px;
  padding: 0 6vw 64px;
}

.layout.is-collapsed {
  grid-template-columns: 1fr;
}

.layout.is-collapsed .sidebar {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 20px;
  align-self: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--panel-shadow);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel__head h2 {
  font-family: "Sora", sans-serif;
  font-size: 1.1rem;
  margin: 0;
}

.panel__actions {
  display: flex;
  gap: 8px;
}

.sources {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.source-row {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body.theme-console .source-row {
  background: rgba(15, 23, 38, 0.9);
}

.source-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.source-label {
  font-weight: 600;
  border: none;
  background: transparent;
  font-size: 1rem;
  outline: none;
}

.source-hint {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  color: var(--muted);
  word-break: break-all;
}

.source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.source-toggle input {
  accent-color: var(--accent-cool);
}

.source-status {
  font-size: 0.78rem;
  color: var(--muted);
}

.hint {
  display: block;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--muted);
}

.filter-block {
  margin-bottom: 16px;
}

.filter-block summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 8px;
}

.filter-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
}

.filter-item input {
  margin-right: 8px;
}

.filter-item__count {
  font-family: "JetBrains Mono", monospace;
  color: var(--muted);
}

.rating-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rating-filter select {
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  border: 1px solid var(--panel-border);
}

.content {
  min-width: 0;
}

.list {
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
}

.list__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(28, 36, 34, 0.03);
}

body.theme-console .list__toolbar {
  background: rgba(14, 22, 36, 0.9);
}

.list__selection,
.list__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.list__count {
  font-size: 0.85rem;
  color: var(--muted);
}

.list__head,
.list__row {
  display: grid;
  grid-template-columns: 52px minmax(220px, 1.4fr) 140px minmax(160px, 1fr) 140px 160px;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
}

.list__head {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--panel-border);
  background: rgba(28, 36, 34, 0.04);
}

body.theme-console .list__head {
  background: rgba(14, 22, 36, 0.9);
}

.list__body {
  display: flex;
  flex-direction: column;
}

.list__row {
  border-bottom: 1px solid rgba(28, 36, 34, 0.08);
  animation: fadeUp 0.35s ease both;
  animation-delay: var(--delay, 0ms);
}

body.theme-console .list__row {
  border-bottom: 1px solid rgba(69, 243, 255, 0.12);
}

.list__row.is-selected {
  background: rgba(224, 122, 95, 0.08);
}

body.theme-console .list__row.is-selected {
  background: rgba(69, 243, 255, 0.12);
}

.list__cell--select {
  display: flex;
  align-items: center;
  justify-content: center;
}

.select-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.select-toggle input {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(28, 36, 34, 0.25);
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  place-content: center;
  margin: 0;
  transition: background var(--transition), border-color var(--transition);
}

.select-toggle input::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: rotate(-45deg) scale(0);
  transition: transform var(--transition);
}

.select-toggle input:checked {
  background: var(--accent);
  border-color: transparent;
}

.select-toggle input:checked::after {
  transform: rotate(-45deg) scale(1);
}

body.theme-console .select-toggle input {
  border-color: rgba(69, 243, 255, 0.4);
  background: rgba(15, 23, 38, 0.85);
}

.list__row:last-child {
  border-bottom: none;
}

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

.file-name {
  font-weight: 600;
}

.file-path {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  margin-top: 4px;
  word-break: break-all;
}

.file-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  border-radius: 6px;
  padding: 4px 6px;
  margin-right: 10px;
  background: rgba(47, 122, 112, 0.16);
  color: var(--accent-cool);
  font-weight: 600;
  min-width: 32px;
}

body.theme-console .file-badge {
  background: rgba(69, 243, 255, 0.18);
}

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

.tag {
  background: var(--chip);
  color: var(--chip-text);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tag--empty {
  background: rgba(28, 36, 34, 0.06);
  color: var(--muted);
}

body.theme-console .tag--empty {
  background: rgba(69, 243, 255, 0.12);
  color: var(--muted);
}

.tag-action {
  border: 1px dashed rgba(47, 122, 112, 0.4);
  color: var(--accent-cool);
  background: transparent;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.7rem;
  cursor: pointer;
}

body.theme-console .tag-action {
  border-color: rgba(69, 243, 255, 0.4);
  color: var(--accent);
}

.list__cell--rating {
  display: flex;
  align-items: center;
}

.stars {
  display: inline-flex;
  gap: 4px;
}

.star {
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  color: var(--star-off);
  transition: color var(--transition), transform var(--transition);
}

.star.is-active {
  color: var(--star-on);
}

.star:hover {
  transform: scale(1.05);
}

.empty {
  text-align: center;
  padding: 32px;
  color: var(--muted);
}

.dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(420px, 90vw);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--panel-shadow);
}

.dialog::backdrop {
  background: rgba(28, 36, 34, 0.4);
}

body.theme-console .dialog::backdrop {
  background: rgba(5, 8, 14, 0.65);
}

.dialog__target {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
  color: var(--muted);
}

.dialog input {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  font-size: 0.95rem;
  background: transparent;
  color: var(--ink);
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: var(--panel-shadow);
  z-index: 10;
}

body.theme-console .toast {
  background: #0f1726;
  color: var(--ink);
}

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

  .sidebar {
    position: static;
  }
}

@media (max-width: 900px) {
  .list__head {
    display: none;
  }

  .list__row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

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

  .list__cell--select {
    justify-content: flex-start;
  }

  .list__cell--tags,
  .list__cell--rating,
  .list__cell--updated,
  .list__cell--source {
    justify-self: start;
  }
}
