:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --ink: #202018;
  --muted: #67635d;
  --line: #d7d3c8;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --hit: #fff0a8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-weight: 700;
}

.text-button {
  padding: 0;
  text-align: left;
}

.topbar-title {
  display: grid;
  gap: 4px;
}

.library-back {
  width: fit-content;
  min-height: 30px;
  padding: 0 10px;
  border-color: #a9cfc9;
  background: #e7f3f1;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 760;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: #fffdfa;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 760;
}

h2 {
  font-size: 20px;
  font-weight: 720;
}

.topbar p,
#sessionStats,
.muted {
  color: var(--muted);
  margin-top: 4px;
}

.library {
  padding: 22px 24px 34px;
}

.library-head {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(280px, 420px);
  gap: 20px;
  align-items: end;
  margin-bottom: 18px;
}

.library-head p {
  color: var(--muted);
  margin-top: 4px;
}

.library-search {
  display: grid;
  gap: 6px;
}

.library-search label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.library-search input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
  background: var(--panel);
}

.global-transcript-search {
  display: grid;
  grid-template-columns: minmax(280px, 640px) minmax(160px, 1fr);
  gap: 10px 16px;
  align-items: end;
  margin: 0 0 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
}

.global-transcript-results {
  grid-column: 1 / -1;
  min-height: 0;
  max-height: 360px;
}

.facet-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.facets {
  display: grid;
  gap: 18px;
}

.active-filters {
  display: grid;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.filter-pill {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: #e7f3f1;
}

.facet-group {
  display: grid;
  gap: 6px;
  padding-top: 4px;
}

.facet-group h3 {
  margin: 0 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
  text-transform: uppercase;
}

.facet-link {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 6px 0;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  text-align: left;
}

.facet-link:hover,
.facet-link.active {
  border-bottom-color: var(--accent);
  color: var(--accent-dark);
}

.event-results {
  display: grid;
  gap: 10px;
}

.event-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.event-main h3 {
  margin: 0;
  font-size: 17px;
}

.event-open {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--ink);
  font-weight: 760;
  text-align: left;
}

.event-open:hover {
  color: var(--accent-dark);
}

.event-main p,
.event-meta {
  color: var(--muted);
}

.event-main p {
  margin-top: 3px;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 9px;
  font-size: 13px;
}

.event-action {
  min-height: 34px;
  padding: 0 13px;
}

.conference-search {
  display: grid;
  grid-template-columns: minmax(280px, 640px) minmax(150px, 1fr);
  gap: 10px 16px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: #fdfcf8;
}

.searchbox {
  display: grid;
  grid-template-columns: max-content minmax(180px, 1fr) 36px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.searchbox label {
  padding: 0 12px;
  color: var(--accent-dark);
  font-weight: 720;
  white-space: nowrap;
}

.searchbox input {
  border: 0;
  border-left: 1px solid var(--line);
  min-width: 0;
  padding: 12px;
  outline: none;
}

.searchbox button {
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  font-size: 22px;
  line-height: 1;
}

.search-status {
  color: var(--muted);
  font-size: 13px;
}

.search-results {
  grid-column: 1 / -1;
  min-height: 0;
  max-height: 300px;
}

.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: calc(100vh - 167px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfaf7;
  min-width: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.sidebar-head button,
.view-toggle button,
.insight-controls button {
  min-height: 34px;
  padding: 0 12px;
}

.session-list {
  max-height: calc(100vh - 138px);
  overflow: auto;
}

.session-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 16px;
  background: transparent;
}

.session-item.active {
  background: #e7f3f1;
  box-shadow: inset 4px 0 0 var(--accent);
}

.session-title {
  display: block;
  font-weight: 680;
}

.session-detail {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.reader {
  min-width: 0;
  padding: 20px 24px 32px;
}

.reader-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.audio-bar {
  margin-bottom: 16px;
}

.audio-bar audio {
  display: block;
  width: 100%;
  height: 38px;
}

.view-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f0eee8;
}

.view-toggle button {
  border: 0;
  background: transparent;
}

.view-toggle button.active {
  background: var(--panel);
  color: var(--accent-dark);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 520px;
  max-height: calc(100vh - 170px);
  overflow: auto;
}

.hidden {
  display: none;
}

.chunk,
.result {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.timestamp {
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  white-space: nowrap;
}

button.timestamp {
  width: fit-content;
  padding: 0;
  border: 0;
  background: transparent;
}

a.timestamp,
.insight-time,
.word-time {
  text-decoration: none;
}

a.timestamp:hover,
.insight-time:hover,
.word-time:hover,
.word-time:focus {
  text-decoration: underline;
}

.word-time {
  color: inherit;
  border-radius: 3px;
}

.word-time:hover,
.word-time:focus {
  color: var(--accent-dark);
  background: #eef7f5;
  outline: none;
}

.word-time.playing-window {
  background: #fff3c4;
  box-shadow: 0 0 0 2px #fff3c4;
}

.word-time.playing-center {
  background: #ffd966;
  box-shadow: 0 0 0 2px #ffd966;
  color: var(--ink);
}

.chunk-text,
.result-text {
  max-width: 920px;
}

mark {
  background: var(--hit);
  padding: 0 2px;
}

.result-title {
  margin-bottom: 4px;
  font-weight: 700;
}

.empty {
  padding: 28px;
  color: var(--muted);
}

.insight-controls {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-chip {
  min-height: 34px;
  padding: 0 12px;
  color: var(--accent-dark);
}

.prompt-chip.active {
  background: #dff1ee;
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 700;
}

.focus-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px 120px;
  gap: 10px;
}

.insight-controls input,
.insight-controls select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.insight-controls button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.insight-output {
  padding: 18px;
  max-width: 980px;
}

.cache-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.insight-output h2,
.insight-output h3,
.insight-output h4 {
  margin: 18px 0 8px;
  line-height: 1.25;
}

.insight-output h2:first-child,
.insight-output h3:first-child,
.insight-output h4:first-child {
  margin-top: 0;
}

.insight-output p {
  margin: 0 0 12px;
}

.insight-output ul,
.insight-output ol {
  margin: 0 0 14px 22px;
  padding: 0;
}

.insight-output li {
  margin: 5px 0;
}

.insight-output blockquote {
  margin: 0 0 14px;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: #f4faf8;
  color: var(--ink);
}

.insight-output code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #efeee9;
}

@media (max-width: 860px) {
  .topbar,
  .library-head,
  .global-transcript-search,
  .facet-layout,
  .conference-search,
  .layout,
  .reader-head,
  .focus-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .layout {
    display: block;
  }

  .library {
    padding: 18px 16px 28px;
  }

  .event-card {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .session-list {
    max-height: 220px;
  }

  .reader-head {
    display: grid;
  }

  .searchbox {
    grid-template-columns: 1fr 36px;
  }

  .searchbox label {
    grid-column: 1 / -1;
    padding: 9px 12px 0;
  }

  .searchbox input {
    border-left: 0;
  }

  .chunk,
  .result {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
