:root {
  --bg: #f5f1e8;
  --bg-soft: #fbf8f1;
  --panel: rgba(255, 252, 245, 0.9);
  --panel-strong: #fffdf8;
  --text: #1f1a17;
  --muted: #6f655d;
  --line: rgba(57, 42, 27, 0.12);
  --accent: #b34f2e;
  --accent-strong: #8f3519;
  --accent-soft: rgba(179, 79, 46, 0.12);
  --shadow: 0 16px 40px rgba(80, 58, 37, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-main: "Avenir Next", "Segoe UI", sans-serif;
  --font-display: "Georgia", "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(179, 79, 46, 0.1), transparent 28%),
    radial-gradient(circle at right 10% top 20%, rgba(113, 131, 93, 0.12), transparent 22%),
    linear-gradient(180deg, var(--bg-soft), var(--bg));
  color: var(--text);
  font-family: var(--font-main);
}

.page {
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 12px 0 56px;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 92px;
  align-self: start;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
}

.results-column {
  min-width: 0;
}

.sidebar-scroll {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar::-webkit-scrollbar {
  width: 10px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(111, 101, 93, 0.28);
  border-radius: 999px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.hero {
  position: sticky;
  top: 0;
  z-index: 9;
  padding: 12px 18px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 248, 238, 0.96)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hero-title-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
}

h1 {
  font-size: clamp(26px, 4vw, 38px);
  line-height: 0.95;
  max-width: none;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.meta-pill,
.tag,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.meta-pill {
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
  font-size: 12px;
  min-height: 30px;
  padding: 6px 10px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.filters,
.quick-tags,
.recommender,
.side-note,
.empty-state {
  padding: 20px;
}

.filters {
  backdrop-filter: blur(12px);
}

.filters .search-wrap label {
  font-size: 15px;
  color: #5a4c42;
}

.search-wrap label,
.filter-grid span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-strong);
  color: var(--text);
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(179, 79, 46, 0.25);
  outline-offset: 1px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 16px;
}

.filter-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  margin-top: 14px;
}

button {
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fffaf6;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

.results-meta,
.panel-head p,
.card-copy,
.meta-row,
.sub-meta,
.stack-line,
.source-line,
.card-links,
.side-note li {
  color: var(--muted);
}

.quick-tags {
  margin-top: 20px;
}

.recommender {
  margin-top: 20px;
  background:
    linear-gradient(180deg, rgba(255, 247, 237, 0.9), rgba(255, 252, 247, 0.92));
}

.recommend-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.recommend-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}

.recommend-card {
  padding: 14px;
  border: 1px solid rgba(57, 42, 27, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.recommend-card h3 {
  font-size: 20px;
  line-height: 1.15;
}

.recommend-rank {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(179, 79, 46, 0.12);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.recommend-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.recommend-link {
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  color: var(--accent-strong);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.recommend-link:hover {
  text-decoration: underline;
}

.guide-copy {
  color: var(--muted);
  line-height: 1.5;
}

.guide-copy a {
  color: var(--accent-strong);
  text-decoration: none;
}

.guide-copy a:hover {
  text-decoration: underline;
}

.sidebar-section {
  overflow: hidden;
}

.sidebar-subsection {
  margin-top: 16px;
  border-top: 1px solid rgba(57, 42, 27, 0.08);
  padding-top: 10px;
}

.sidebar-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  position: relative;
  padding-right: 48px;
}

.sidebar-summary::-webkit-details-marker {
  display: none;
}

.sidebar-summary::after {
  content: "▾";
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-main);
  font-size: 16px;
  color: var(--accent-strong);
  transition: transform 160ms ease;
}

details:not([open]) > .sidebar-summary::after {
  transform: translateY(-50%) rotate(-90deg);
}

.summary-note {
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.sidebar-section-body {
  padding: 0 20px 20px;
}

.sidebar-section-body-compact {
  padding: 0 0 0;
}

.sidebar-section[open] .sidebar-summary {
  border-bottom: 1px solid rgba(57, 42, 27, 0.08);
  margin-bottom: 16px;
}

.sidebar-summary-compact {
  padding: 8px 28px 8px 0;
  font-size: 18px;
  font-family: var(--font-main);
  font-weight: 800;
}

.sidebar-summary-compact::after {
  right: 0;
}

.sidebar-subsection[open] > .sidebar-summary-compact {
  margin-bottom: 14px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-head p {
  margin: 0;
  font-size: 14px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tag {
  background: #fff8ee;
  color: #4d433d;
  border-color: rgba(57, 42, 27, 0.18);
  cursor: pointer;
}

.tag:hover {
  background: #f6e4d7;
}

.side-note h2 + ul {
  margin-top: 10px;
}

.side-note ul {
  padding-left: 18px;
  line-height: 1.45;
}

.compact-list {
  list-style: none;
  padding: 0;
}

.compact-list li + li {
  margin-top: 10px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 250, 243, 0.94));
  box-shadow: var(--shadow);
  scroll-margin-top: 140px;
  transition: box-shadow 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.card-targeted {
  border-color: rgba(179, 79, 46, 0.45);
  box-shadow: 0 18px 44px rgba(179, 79, 46, 0.16);
  transform: translateY(-2px);
}

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

.card h3 {
  font-size: 28px;
  line-height: 1.08;
  max-width: 18ch;
}

.card-copy {
  margin: 0;
  line-height: 1.65;
  font-size: 17px;
}

.sub-meta {
  font-size: 14px;
  line-height: 1.5;
}

.info-block {
  padding: 12px 14px;
  border: 1px solid rgba(57, 42, 27, 0.1);
  border-radius: 14px;
  background: rgba(255, 247, 237, 0.66);
}

.info-title {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #6a5241;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.info-main {
  display: block;
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

.stack-line {
  margin-top: 6px;
  font-size: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 14px;
}

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

.chip {
  background: #fffaf3;
  border-color: rgba(57, 42, 27, 0.15);
  font-size: 13px;
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 14px;
}

.card-links a,
.compact-list a {
  color: var(--accent-strong);
  text-decoration: none;
}

.card-links a:hover,
.compact-list a:hover {
  text-decoration: underline;
}

.empty-state {
  margin-top: 16px;
}

@media (max-width: 1120px) {
  .workspace,
  .cards {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

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

  .hero-meta {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .page {
    width: min(100vw - 20px, 1320px);
    padding-top: 10px;
    padding-bottom: 36px;
  }

  .hero,
  .filters,
  .quick-tags,
  .side-note,
  .card,
  .empty-state {
    padding: 16px;
  }

  .hero-copy {
    font-size: 16px;
  }

  .panel-head {
    flex-direction: column;
  }

  .filter-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
