:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #5d6972;
  --line: #d7dde2;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warn: #995b00;
  --draft: #315c94;
  --published: #26734d;
  --shadow: 0 16px 40px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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,
textarea {
  font: inherit;
}

button,
a.button,
.topbar a,
#export-link {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 10px 14px;
  text-decoration: none;
  font-weight: 700;
}

button:hover,
#export-link:hover {
  background: var(--accent-strong);
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.topbar p {
  color: var(--muted);
  margin-top: 8px;
}

.api-key {
  display: grid;
  grid-template-columns: auto minmax(180px, 260px) auto;
  align-items: end;
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: white;
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  padding: 22px clamp(18px, 4vw, 48px) 48px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
}

.wide-panel,
.search-panel {
  grid-column: 1 / -1;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: #e9f0f2;
  color: var(--muted);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wide {
  grid-column: 1 / -1;
}

.results,
.review-list,
.compact-list,
.audit-list {
  display: grid;
  gap: 10px;
}

.results {
  margin-top: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.record {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
  background: #fff;
}

.record header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.record p,
.meta,
.empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  border-radius: 5px;
  background: #eef3f4;
  color: #33434c;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 800;
}

.tag.published {
  background: #e4f5eb;
  color: var(--published);
}

.tag.draft {
  background: #e7eef8;
  color: var(--draft);
}

.tag.warn {
  background: #fff2d9;
  color: var(--warn);
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.review-actions button {
  padding: 8px 10px;
}

.link-list a {
  color: var(--accent-strong);
  font-weight: 700;
  word-break: break-word;
}

.audit-item {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.audit-item:last-child {
  border-bottom: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: #172026;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 20;
}

@media (max-width: 860px) {
  .topbar {
    display: grid;
    align-items: stretch;
  }

  .api-key,
  .layout,
  .grid-form,
  .results {
    grid-template-columns: 1fr;
  }

  .wide-panel,
  .search-panel,
  .wide {
    grid-column: auto;
  }

  .audit-item {
    grid-template-columns: 1fr;
  }
}
