:root {
  --bg: #f3efe7;
  --panel: rgba(255, 252, 245, 0.86);
  --panel-strong: #fffaf0;
  --line: rgba(45, 31, 22, 0.12);
  --text: #261a12;
  --muted: #76665b;
  --accent: #b6572e;
  --accent-soft: rgba(182, 87, 46, 0.12);
  --shadow: 0 24px 80px rgba(70, 37, 18, 0.08);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 999px;
  --max-width: 1380px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Iowan Old Style", "Palatino Linotype", "Noto Serif SC", serif;
  background:
    radial-gradient(circle at top left, rgba(182, 87, 46, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(33, 90, 120, 0.12), transparent 24%),
    linear-gradient(180deg, #f7f1e6 0%, #f3efe7 100%);
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(calc(100% - 32px), var(--max-width));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.control-panel,
.content-panel,
.detail-drawer {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.control-panel,
.content-panel {
  border-radius: var(--radius-lg);
}

.metric-card {
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 250, 240, 0.86);
  border: 1px solid rgba(38, 26, 18, 0.08);
}

.metric-card strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 8px;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
}

.control-panel,
.content-panel {
  padding: 24px;
}

.control-panel {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 22px;
  overflow: hidden;
}

.panel-block {
  display: grid;
  gap: 12px;
}

.panel-filter {
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
}

.filter-scroll {
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  padding-right: 8px;
}

.panel-note ol {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.field-label,
.eyebrow {
  margin: 0;
  font-family: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.search-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  padding: 14px 18px;
  outline: none;
  transition: border-color 180ms ease, transform 180ms ease;
}

.search-input:focus {
  border-color: rgba(182, 87, 46, 0.48);
  transform: translateY(-1px);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: start;
}

.chip {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  padding: 9px 14px;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    color 180ms ease,
    border-color 180ms ease;
}

.chip:hover,
.chip.is-active {
  transform: translateY(-1px);
  background: var(--accent);
  border-color: var(--accent);
  color: #fff7ef;
}

.content-panel {
  min-height: 70vh;
}

.list-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

.list-header h2 {
  margin: 10px 0 0;
  font-size: 2rem;
}

.result-count {
  margin: 0;
  color: var(--muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.root-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 250, 240, 0.74);
  cursor: pointer;
  transition:
    transform 220ms ease,
    box-shadow 220ms ease,
    border-color 220ms ease;
}

.root-card:hover {
  transform: translateY(-4px);
  border-color: rgba(182, 87, 46, 0.4);
  box-shadow: 0 18px 44px rgba(105, 56, 29, 0.12);
}

.root-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.root-card h3 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1;
}

.trend-link {
  color: inherit;
  text-decoration: none;
}

.trend-link:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

.root-card p {
  margin: 0;
}

.root-card-tag,
.root-card-volume {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.8rem;
  font-family: "IBM Plex Sans", "Helvetica Neue", sans-serif;
}

.root-card-tag {
  background: var(--accent-soft);
  color: var(--accent);
}

.root-card-volume {
  background: rgba(38, 26, 18, 0.06);
  color: var(--muted);
}

.root-card-intent {
  color: var(--muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.root-card-combos {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(33, 90, 120, 0.08);
  color: #214d5b;
  font-size: 0.82rem;
}

.trend-link-pill {
  text-decoration: none;
}

.trend-link-pill:hover {
  background: rgba(33, 90, 120, 0.16);
  color: #173842;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

.detail-drawer {
  position: fixed;
  inset: 20px 20px 20px auto;
  width: min(480px, calc(100vw - 40px));
  border-radius: var(--radius-lg);
  padding: 24px 24px 28px;
  transform: translateX(calc(100% + 24px));
  transition: transform 260ms ease;
  z-index: 20;
}

.detail-drawer.is-open {
  transform: translateX(0);
}

.drawer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(38, 26, 18, 0.08);
  color: var(--text);
  cursor: pointer;
}

.drawer-content {
  display: grid;
  gap: 18px;
}

.drawer-header h3 {
  margin: 8px 0 0;
  font-size: 2.4rem;
  line-height: 0.95;
}

.drawer-section {
  display: grid;
  gap: 10px;
}

.drawer-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
  white-space: pre-wrap;
}

.drawer-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

  .control-panel {
    position: static;
    max-height: none;
    grid-template-rows: auto auto auto;
    overflow: visible;
  }

  .panel-filter,
  .filter-scroll {
    min-height: auto;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(calc(100% - 20px), var(--max-width));
    padding-top: 16px;
  }

  .hero-copy,
  .control-panel,
  .content-panel {
    padding: 18px;
  }

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

  .detail-drawer {
    inset: auto 10px 10px 10px;
    width: auto;
    max-height: calc(100vh - 20px);
    overflow: auto;
    transform: translateY(calc(100% + 24px));
  }

  .detail-drawer.is-open {
    transform: translateY(0);
  }
}
