:root {
  --font-sans: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #15233d;
  --muted: #60708a;
  --line: #d7e0ec;
  --brand: #155fa8;
  --brand-strong: #114d87;
  --shadow: 0 10px 24px rgba(16, 37, 68, 0.06);
  --radius: 14px;
}

:root[data-theme="dark"] {
  --bg: #0c1422;
  --panel: #111c2f;
  --text: #eef4ff;
  --muted: #96a8c5;
  --line: #243651;
  --brand: #78b3ff;
  --brand-strong: #9dc9ff;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

.topbar,
.page-shell,
.footer {
  width: min(1180px, calc(100vw - 28px));
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand-text {
  display: grid;
  gap: 1px;
}

.brand-text strong {
  font-size: 14px;
}

.brand-text small,
.subtle,
.meta-line,
.footer {
  color: var(--muted);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}

.topnav a:hover,
.text-link:hover {
  color: var(--brand);
}

.page-shell {
  padding-bottom: 18px;
}

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

.panel {
  padding: 16px;
}

.hero {
  padding: 18px;
}

.hero-compact {
  margin-bottom: 12px;
}

.hero h1,
.section-head h2,
.panel-head h2,
.card h3 {
  margin: 0;
  font-family: var(--font-display);
}

.hero h1 {
  font-size: clamp(1.9rem, 3vw, 2.5rem);
  max-width: 16ch;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand);
}

.subtle {
  margin: 8px 0 0;
  line-height: 1.5;
  font-size: 14px;
}

.search-row,
.action-row,
.chip-row,
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-row {
  margin-top: 14px;
  max-width: 620px;
}

.search-row input,
.field-shell input,
.field-shell textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
}

.search-row input {
  flex: 1;
  min-width: 220px;
}

.field-shell textarea {
  min-height: 90px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.btn-small {
  padding: 8px 10px;
  font-size: 12px;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-strong);
}

.btn-secondary {
  border-color: var(--line);
}

.chip,
.meta-badge,
.filter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 12px;
}

.chip:hover,
.filter-button:hover,
.filter-button.active {
  color: var(--brand);
  border-color: var(--brand);
}

.chip-row,
.stat-row {
  margin-top: 12px;
}

.section {
  margin-top: 14px;
  padding: 16px;
}

.section-head,
.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.catalog-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.active-card {
  border-color: var(--brand);
}

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

.card h3 {
  font-size: 17px;
  line-height: 1.25;
}

.card .subtle {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-line {
  margin: 8px 0 0;
  font-size: 12px;
}

.text-link {
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.crumbs a {
  color: var(--brand);
}

.workspace-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
}

.workspace-main {
  display: grid;
  gap: 12px;
}

.sidebar {
  padding: 14px;
  align-self: start;
  position: sticky;
  top: 10px;
}

.filter-list {
  display: grid;
  gap: 8px;
}

.filter-button {
  justify-content: flex-start;
  width: 100%;
  background: transparent;
  cursor: pointer;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.field-shell {
  display: grid;
  gap: 5px;
  font-size: 13px;
}

.field-shell.is-wide {
  grid-column: 1 / -1;
}

.preview-panel {
  padding: 16px;
}

.preview-frame {
  width: 100%;
  min-height: 440px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.message {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.message.has-text {
  color: var(--brand);
}

.message.is-error {
  color: #c44237;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 20px;
  font-size: 13px;
}

@media (max-width: 920px) {
  .topbar {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .workspace-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .field-shell.is-wide {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .topbar,
  .page-shell,
  .footer {
    width: min(100vw - 20px, 1180px);
  }

  .topnav,
  .footer,
  .panel-head,
  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .preview-frame {
    min-height: 360px;
  }
}
