:root {
  color-scheme: light;
  --bg: #f4ecde;
  --bg-accent: radial-gradient(circle at top left, rgba(193, 122, 29, 0.18), transparent 30%),
    linear-gradient(180deg, #f8f2e8 0%, #f1e7d7 100%);
  --panel: rgba(255, 250, 241, 0.96);
  --panel-border: #dec8a6;
  --text: #2f2417;
  --muted: #6f604f;
  --accent: #8f4c09;
  --accent-strong: #b55e0f;
  --accent-soft: #f0dcc0;
  --shadow: 0 18px 60px rgba(76, 44, 12, 0.12);
  --snippet: #fff7ec;
  --snippet-border: #e9d5b8;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #15120f;
  --bg-accent: radial-gradient(circle at top left, rgba(230, 151, 71, 0.2), transparent 28%),
    linear-gradient(180deg, #1f1913 0%, #120f0c 100%);
  --panel: rgba(31, 24, 18, 0.96);
  --panel-border: #4e3a24;
  --text: #f4ead9;
  --muted: #c0ae95;
  --accent: #efaa57;
  --accent-strong: #ffbf73;
  --accent-soft: #3a2a18;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --snippet: #241b13;
  --snippet-border: #4d3822;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: var(--bg-accent);
  color: var(--text);
}

.page-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero,
.layout {
  display: grid;
  gap: 20px;
}

.hero {
  grid-template-columns: 1.5fr 0.9fr;
  margin-bottom: 20px;
}

.hero-copy,
.hero-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 28px;
}

.hero-copy h1 {
  margin: 10px 0 12px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.95;
  max-width: 10ch;
}

.hero-copy p {
  max-width: 58ch;
  color: var(--muted);
  line-height: 1.6;
}

.eyebrow {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.hero-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-card-label,
.panel-meta,
.status-detail,
.hint-box p {
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 700;
  margin: 0 0 10px;
}

.status-waiting {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-ready {
  background: #d9f2df;
  color: #23633b;
}

body.theme-dark .status-ready {
  background: #1f3d2c;
  color: #8ed8a6;
}

.status-error {
  background: #f9d7d7;
  color: #8a2222;
}

body.theme-dark .status-error {
  background: #442020;
  color: #ffaaaa;
}

.layout {
  grid-template-columns: minmax(290px, 360px) 1fr;
  align-items: start;
}

.panel {
  padding: 24px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.panel-header h2,
.empty-state h3,
.result-title {
  margin: 0;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  font-weight: 700;
}

.field-inline {
  grid-template-columns: 1fr 120px;
  align-items: center;
}

select,
textarea,
input,
button,
a {
  font: inherit;
}

select,
textarea,
input {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--text);
}

body.theme-dark select,
body.theme-dark textarea,
body.theme-dark input {
  background: rgba(0, 0, 0, 0.18);
}

textarea {
  resize: vertical;
  min-height: 132px;
}

.actions-row {
  display: flex;
  gap: 12px;
  margin: 18px 0 14px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.result-link {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.result-link:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: white;
  font-weight: 700;
}

.secondary-btn,
.ghost-btn,
.result-link {
  background: var(--accent-soft);
  color: var(--accent);
}

.hint-box,
.empty-state,
.result-card,
.fragment-item {
  border: 1px solid var(--panel-border);
  border-radius: 18px;
}

.hint-box {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.4);
}

.empty-state {
  padding: 28px;
  background: rgba(255, 255, 255, 0.3);
}

.results-list {
  display: grid;
  gap: 16px;
}

.result-card {
  padding: 18px;
  background: rgba(255, 255, 255, 0.26);
}

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

.result-badge {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.result-score {
  margin: 0;
  color: var(--muted);
  white-space: nowrap;
}

.result-snippet {
  margin: 14px 0;
  line-height: 1.7;
}

.result-fragments {
  display: grid;
  gap: 10px;
}

.fragment-item {
  padding: 12px 14px;
  background: var(--snippet);
  border-color: var(--snippet-border);
}

.fragment-item strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
}

.result-actions {
  margin-top: 14px;
}

code {
  padding: 0.15rem 0.4rem;
  border-radius: 8px;
  background: var(--accent-soft);
}

mark {
  background: #ffe28a;
  color: #221709;
  padding: 0 0.15em;
  border-radius: 4px;
}

body.theme-dark mark {
  background: #b87b1e;
  color: #fff9ef;
}

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

  .actions-row,
  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .field-inline {
    grid-template-columns: 1fr;
  }
}
