:root {
  color-scheme: light;
  --bg: #f4f3ee;
  --bg-alt: #f0e9de;
  --ink: #1f2424;
  --muted: #576064;
  --accent: #f27d52;
  --accent-strong: #e8603a;
  --accent-cool: #2b8a78;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(31, 36, 36, 0.12);
  --panel-shadow: 0 22px 45px rgba(24, 28, 28, 0.16);
  --chip: rgba(242, 125, 82, 0.12);
  --chip-text: #9a3d22;
  --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: #101b2f;
  --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 28px 60px rgba(0, 0, 0, 0.6);
  --chip: rgba(69, 243, 255, 0.18);
  --chip-text: #9ff2ff;
  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%);
}

.bg-grid,
.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
}

.bg-grid {
  background-image:
    linear-gradient(120deg, rgba(31, 36, 36, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 36, 36, 0.03) 1px, transparent 1px);
  background-size: 72px 72px;
  opacity: 0.55;
}

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;
}

.bg-glow {
  width: 720px;
  height: 720px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 125, 82, 0.2), transparent 70%);
  top: -260px;
  right: -220px;
  animation: floatGlow 12s ease-in-out infinite;
}

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

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

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

body.embed .hero {
  padding: 24px 4vw 12px;
}

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

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

.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.1rem, 3vw, 3rem);
  margin: 0 0 12px;
}

.hero p {
  max-width: 740px;
  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(31, 36, 36, 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);
}

.search-meta {
  margin-top: 6px;
  font-size: 0.73rem;
  line-height: 1.35;
  color: var(--muted);
}

.search-meta.is-active {
  color: var(--accent-cool);
}

.search-meta.is-error {
  color: #b42318;
}

body.theme-console .search-meta.is-error {
  color: #ff9191;
}

.toolbar-control--search {
  min-width: 280px;
  flex: 1 1 280px;
}

.toolbar-control--view {
  min-width: 160px;
}

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

.btn {
  border: none;
  background: var(--accent);
  color: #ffffff;
  padding: 10px 16px;
  min-height: 42px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 12px 24px rgba(242, 125, 82, 0.2);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(242, 125, 82, 0.26);
}

.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;
}

.mobile-only {
  display: none;
}

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

.stats--inline {
  align-items: stretch;
}

.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-card {
  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-card {
  background: rgba(15, 23, 38, 0.9);
}

.source-title {
  font-weight: 600;
}

.source-path {
  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;
}

.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);
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.filter-list select {
  width: 100%;
}

.content {
  min-width: 0;
}

.session-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 360px);
  gap: 20px;
}

.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(31, 36, 36, 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__action-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
}

.list__action-toggle input {
  margin: 0;
}

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

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

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

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

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

.list__row {
  border: none;
  border-bottom: 1px solid rgba(31, 36, 36, 0.08);
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition);
  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:hover,
.list__row.is-selected {
  background: rgba(242, 125, 82, 0.08);
}

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

.list__row.is-active {
  box-shadow: inset 4px 0 0 var(--accent);
}

body.theme-console .list__row.is-active {
  box-shadow: inset 4px 0 0 var(--accent-strong);
}

.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(31, 36, 36, 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);
}

.session-title {
  font-weight: 600;
}

.session-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

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

.session-snippet {
  margin-top: 6px;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  word-break: break-word;
}

.row-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.row-badge--session {
  background: rgba(43, 138, 120, 0.14);
  color: #1d675a;
}

.row-badge--summary {
  background: rgba(242, 125, 82, 0.16);
  color: #9a3d22;
}

.row-badge--linked {
  background: rgba(31, 36, 36, 0.08);
  color: var(--muted);
}

.row-badge--score {
  background: rgba(43, 138, 120, 0.16);
  color: #1d675a;
  font-family: "JetBrains Mono", monospace;
  text-transform: none;
  letter-spacing: 0;
}

body.theme-console .row-badge--session {
  background: rgba(109, 255, 136, 0.16);
  color: #9dffbc;
}

body.theme-console .row-badge--summary {
  background: rgba(69, 243, 255, 0.18);
  color: #9ff2ff;
}

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

body.theme-console .row-badge--score {
  background: rgba(109, 255, 136, 0.2);
  color: #b8ffd0;
}

mark.search-mark {
  background: rgba(242, 125, 82, 0.22);
  color: inherit;
  border-radius: 4px;
  padding: 0 2px;
}

body.theme-console mark.search-mark {
  background: rgba(69, 243, 255, 0.22);
}

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

.session-detail {
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

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

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

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 16px;
}

.meta-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.meta-value {
  font-size: 0.92rem;
  word-break: break-word;
}

.meta-tags {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-tags__items {
  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--ghost {
  background: rgba(31, 36, 36, 0.08);
  color: var(--muted);
}

body.theme-console .tag--ghost {
  background: rgba(69, 243, 255, 0.12);
}

.detail-preview {
  background: rgba(31, 36, 36, 0.04);
  border-radius: var(--radius-md);
  border: 1px solid var(--panel-border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body.theme-console .detail-preview {
  background: rgba(10, 16, 27, 0.6);
}

.detail-preview__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-content {
  margin: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 380px;
  overflow: auto;
}

.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);
}

.detail-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  border: none;
  background: var(--accent);
  color: #ffffff;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 14px 30px rgba(24, 28, 28, 0.24);
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  z-index: 24;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 24, 0.5);
  backdrop-filter: blur(2px);
  z-index: 33;
}

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

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

@media (max-width: 1000px) {
  .hero {
    padding: 30px 4vw 18px;
  }

  .hero p {
    font-size: 0.96rem;
    margin-bottom: 18px;
  }

  .hero__bar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: stretch;
  }

  .toolbar-control {
    min-width: 0;
    width: 100%;
    box-shadow: none;
    padding: 11px 12px;
  }

  .toolbar-control--search,
  .toolbar-control--view {
    min-width: 0;
    flex: 0 0 auto;
  }

  .stats--inline {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat {
    min-width: 0;
    padding: 10px 12px;
    box-shadow: none;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 0 4vw 34px;
  }

  .sidebar {
    position: static;
    order: 2;
  }

  .content {
    order: 1;
  }

  .panel {
    padding: 14px;
    border-radius: 18px;
  }

  .source-actions .btn {
    flex: 1 1 150px;
  }
}

@media (max-width: 900px) {
  .mobile-only {
    display: inline-flex;
  }

  body.mobile-sheet-open {
    overflow: hidden;
  }

  .detail-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.mobile-sheet-mode .content {
    padding-bottom: 92px;
  }

  .list__head {
    display: none;
  }

  .list {
    overflow: visible;
  }

  .list__toolbar {
    position: sticky;
    top: 0;
    z-index: 6;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    backdrop-filter: blur(6px);
    padding: 10px 12px;
  }

  .list__row {
    grid-template-columns: 1fr;
    gap: 7px;
    margin: 0;
    padding: 11px 12px;
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.58);
  }

  body.theme-console .list__row {
    background: rgba(13, 22, 35, 0.86);
  }

  .list__body {
    gap: 10px;
    padding: 10px;
  }

  .list__cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 26px;
  }

  .list__cell[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.66rem;
    font-family: "JetBrains Mono", monospace;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
  }

  .list__cell--session {
    display: block;
  }

  .list__cell--model,
  .list__cell--workspace,
  .list__cell--date,
  .list__cell--duration,
  .list__cell--relevance {
    text-align: right;
    word-break: break-word;
  }

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

  .list__selection,
  .list__actions {
    width: 100%;
  }

  .list__actions .btn,
  .list__selection .btn {
    flex: 1 1 0;
  }

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

  .session-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .row-badges {
    width: 100%;
  }

  body.mobile-sheet-mode .session-detail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 34;
    max-height: min(86vh, 720px);
    border-radius: 18px 18px 0 0;
    margin: 0;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
    gap: 12px;
    transform: translateY(102%);
    transition: transform 0.24s ease;
    box-shadow: 0 -18px 44px rgba(15, 20, 25, 0.34);
  }

  body.mobile-sheet-mode.mobile-sheet-open .session-detail {
    transform: translateY(0);
  }

  body.mobile-sheet-mode:not(.mobile-sheet-open) .session-detail {
    pointer-events: none;
  }

  body.mobile-sheet-mode .session-detail::before {
    content: "";
    align-self: center;
    width: 46px;
    height: 4px;
    border-radius: 999px;
    background: rgba(31, 36, 36, 0.22);
    margin-bottom: 2px;
  }

  body.theme-console.mobile-sheet-mode .session-detail::before {
    background: rgba(69, 243, 255, 0.35);
  }

  .detail-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .detail-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .detail-actions #mobileSheetClose {
    grid-column: 1 / -1;
  }

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

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

  .detail-content {
    max-height: 48vh;
    font-size: 0.74rem;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 24px 4vw 14px;
  }

  h1 {
    font-size: clamp(1.65rem, 9vw, 2.2rem);
  }

  .pill {
    font-size: 0.68rem;
    padding: 5px 10px;
  }

  .detail-actions {
    grid-template-columns: 1fr;
  }

  .detail-fab {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    text-align: center;
  }
}
