:root {
  --bg: #f4efe5;
  --ink: #18211c;
  --muted: #5f6b63;
  --panel: rgba(255, 252, 247, 0.92);
  --line: rgba(24, 33, 28, 0.12);
  --accent: #17594a;
  --accent-soft: rgba(23, 89, 74, 0.12);
  --heat-1: #e6f2ee;
  --heat-2: #b7d7cb;
  --heat-3: #6ea88f;
  --heat-4: #17594a;
  --shadow: 0 20px 40px rgba(24, 33, 28, 0.08);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(23, 89, 74, 0.12), transparent 32%),
    radial-gradient(circle at top right, rgba(185, 141, 61, 0.15), transparent 28%),
    var(--bg);
}

.app-shell { max-width: 1500px; margin: 0 auto; padding: 28px; }
.hero, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  margin-bottom: 24px;
}
.hero h1 { margin: 8px 0 12px; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1; max-width: 12ch; }
.hero-copy { margin: 0; max-width: 60ch; color: var(--muted); }
.hero-links { display: flex; flex-direction: column; gap: 12px; align-self: flex-start; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.72rem; color: var(--muted); }
.layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(360px, 0.95fr); gap: 24px; }
.sidebar { display: grid; gap: 24px; }
.panel { padding: 22px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.panel-head.compact { margin-bottom: 12px; }
.panel h2 { margin: 8px 0 0; font-size: 1.25rem; }
.controls { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
label { display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; color: var(--muted); }
select {
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 12px 18px;
  text-decoration: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 600;
}
.button.ghost {
  color: var(--accent);
  background: white;
}
.button.small {
  padding: 8px 14px;
  font-size: 0.9rem;
}
.matrix-host { overflow: auto; }
.matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 6px;
}
.matrix th, .matrix td {
  border-radius: 16px;
  padding: 14px;
  text-align: left;
}
.matrix th {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}
.matrix td {
  background: var(--heat-1);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.matrix td:hover { transform: translateY(-2px); box-shadow: 0 12px 18px rgba(24, 33, 28, 0.08); }
.heat-1 { background: var(--heat-1); }
.heat-2 { background: var(--heat-2); }
.heat-3 { background: var(--heat-3); color: white; }
.heat-4 { background: var(--heat-4); color: white; }
.cell-total { display: block; font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }
.cell-label { display: block; font-size: 0.8rem; opacity: 0.88; }
.detail-list, .object-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 180px;
}
.detail-list.empty, .object-card.empty { color: var(--muted); }
.detail-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: white;
}
.detail-item h3, .object-card h3 { margin: 0 0 8px; font-size: 1rem; }
.detail-meta, .object-meta { color: var(--muted); font-size: 0.86rem; }
.detail-actions, .object-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  margin-right: 6px;
}
.code-box {
  background: #151d18;
  color: #f7f5ef;
  padding: 14px;
  border-radius: 16px;
  overflow: auto;
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.83rem;
}
.hidden { display: none !important; }
.modal-shell.hidden { display: none; }
.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 20, 0.58);
  backdrop-filter: blur(5px);
}
.modal-panel {
  position: relative;
  width: min(1180px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  margin: 14px auto;
  background: rgba(255, 251, 245, 0.98);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(11, 18, 14, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(23, 89, 74, 0.08), rgba(185, 141, 61, 0.1)),
    rgba(255, 252, 247, 0.96);
}
.modal-head h2 {
  margin: 8px 0 0;
  max-width: 20ch;
  font-size: clamp(1.5rem, 2.6vw, 2.25rem);
  line-height: 1.04;
}
.modal-body {
  overflow: auto;
  padding: 24px;
  display: grid;
  gap: 18px;
}
.help-section {
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
}
.help-section h3 {
  margin: 0 0 10px;
  font-size: 1.12rem;
}
.help-section h4 {
  margin: 0 0 8px;
  font-size: 0.96rem;
}
.help-section p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.5;
}
.help-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.help-card {
  background: linear-gradient(180deg, rgba(23, 89, 74, 0.05), rgba(255, 255, 255, 0.94));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}
.help-card p {
  margin: 0;
}
.help-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
}
.help-list li {
  margin: 0 0 10px;
  line-height: 1.5;
}
.prompt-box {
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-radius: 18px;
  background: #141b17;
  color: #eff6f1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
}
.embeddings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.embeddings-form label {
  min-width: 0;
}
.embeddings-form input,
.embeddings-form select {
  width: 100%;
}
.embeddings-form .detail-actions {
  grid-column: 1 / -1;
}
.field-hint {
  font-size: 0.8rem;
  color: var(--muted);
}
.status-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: white;
}
.status-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.1rem;
}
.status-card .detail-meta {
  margin-top: 6px;
}
.profile-card-active {
  border-color: rgba(23, 89, 74, 0.35);
  box-shadow: inset 0 0 0 1px rgba(23, 89, 74, 0.16);
}
.warning-box {
  border: 1px solid rgba(185, 141, 61, 0.45);
  background: rgba(185, 141, 61, 0.1);
  color: #6d5121;
  border-radius: 14px;
  padding: 12px 14px;
}

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .hero { flex-direction: column; }
  .hero h1 { max-width: none; }
  .help-grid { grid-template-columns: 1fr; }
  .embeddings-form { grid-template-columns: 1fr; }
  .modal-panel {
    width: calc(100vw - 12px);
    max-height: calc(100vh - 12px);
    margin: 6px;
    border-radius: 22px;
  }
  .modal-head,
  .modal-body { padding: 18px; }
}

@media (max-width: 720px) {
  .hero-links {
    width: 100%;
  }
  .hero-links .button {
    width: 100%;
  }
  .modal-head {
    flex-direction: column;
  }
  .modal-head h2 {
    max-width: none;
  }
}
