:root {
  --bg: #f7f8f5;
  --paper: #ffffff;
  --paper-2: #f0f4f1;
  --ink: #18211f;
  --muted: #68736f;
  --line: #dce2df;
  --teal: #0f766e;
  --teal-weak: #d8f0eb;
  --coral: #b94b35;
  --gold: #a66a00;
  --green: #3f7b43;
  --shadow: 0 16px 38px rgba(24, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(340px, 430px) minmax(0, 1fr);
  height: 100vh;
  min-height: 680px;
  overflow: hidden;
}

.sidebar,
.results-pane,
.detail-pane {
  min-width: 0;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 20px 18px;
  background: #fbfcfa;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid #a4c7bf;
  border-radius: 8px;
  background: var(--teal-weak);
  color: #07564f;
  font-weight: 800;
}

.brand h1,
.results-header h2,
.detail-header h2 {
  margin: 0;
  line-height: 1.15;
}

.brand h1 {
  font-size: 20px;
}

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.brand p {
  margin: 4px 0 0;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field span,
.panel-title {
  color: #44504c;
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.topic-panel {
  margin-top: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.ghost-button {
  border: 0;
  background: transparent;
  color: var(--teal);
  padding: 4px 0;
  font-size: 12px;
}

.topic-chips,
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.topic-chip,
.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: #34413d;
  padding: 5px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.topic-chip.active {
  border-color: var(--teal);
  background: var(--teal-weak);
  color: #064f49;
}

.results-pane {
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-right: 1px solid var(--line);
  background: #fdfefd;
}

.results-header,
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.results-header h2,
.detail-header h2 {
  font-size: 22px;
}

.count-pill {
  min-width: 46px;
  height: 30px;
  border-radius: 999px;
  background: #e9efe9;
  color: #33423d;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}

.results-list {
  overflow: auto;
}

.paper-row {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 15px 18px;
  color: inherit;
  text-align: left;
}

.paper-row:hover,
.paper-row.active {
  background: #f0f6f3;
}

.paper-row.active {
  box-shadow: inset 3px 0 0 var(--teal);
}

.paper-title {
  font-size: 15px;
  font-weight: 750;
  line-height: 1.35;
}

.paper-meta,
.paper-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.mini-badge {
  border-radius: 4px;
  background: #edf0ec;
  padding: 3px 6px;
}

.load-more {
  height: 44px;
  border: 0;
  border-top: 1px solid var(--line);
  background: #f7faf7;
  color: var(--teal);
  font-weight: 750;
}

.detail-pane {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  background: var(--bg);
  overflow: hidden;
}

.detail-header {
  background: var(--paper);
}

.detail-header h2 {
  max-width: 920px;
  font-size: 24px;
}

.link-button {
  display: grid;
  min-width: 72px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--teal);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.detail-tags {
  padding: 12px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.tag.score {
  border-color: #e7c98d;
  background: #fff6df;
  color: #704a00;
}

.action-bar,
.model-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.tool-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  color: #22302d;
  padding: 0 12px;
  font-weight: 750;
}

.tool-button.primary {
  border-color: #0f766e;
  background: #0f766e;
  color: #fff;
}

.tool-button.caution {
  border-color: #d9b169;
  background: #fff8e8;
  color: #6b4500;
}

.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.model-strip {
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.split-content {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(360px, 1fr);
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.preview-panel,
.ai-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto 1fr;
}

.preview-panel h3 {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}

.markdown-preview,
.tab-view {
  overflow: auto;
  padding: 16px;
}

.markdown-preview {
  line-height: 1.55;
  font-size: 14px;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin: 16px 0 8px;
  line-height: 1.25;
}

.markdown-preview h1 {
  font-size: 21px;
}

.markdown-preview h2 {
  font-size: 17px;
}

.markdown-preview h3 {
  font-size: 15px;
}

.markdown-preview p,
.tab-view p {
  margin: 0 0 10px;
}

.markdown-preview ul {
  margin: 8px 0 14px;
  padding-left: 20px;
}

.markdown-preview code,
.tab-view code {
  border-radius: 4px;
  background: #eef2ef;
  padding: 1px 4px;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
}

.tab {
  height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  color: #4d5c57;
  padding: 0 18px;
  font-weight: 800;
}

.tab.active {
  background: var(--paper);
  color: var(--teal);
  box-shadow: inset 0 -3px 0 var(--teal);
}

.tab-view {
  display: none;
  max-height: calc(100vh - 266px);
  line-height: 1.6;
  font-size: 14px;
}

.tab-view.active {
  display: block;
}

.ai-output {
  white-space: pre-wrap;
}

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 240px minmax(320px, 390px) minmax(0, 1fr);
  }

  .split-content {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .tab-view {
    max-height: none;
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar,
  .results-pane,
  .detail-pane {
    border-right: 0;
  }

  .results-list,
  .split-content {
    max-height: none;
    overflow: visible;
  }
}
