:root {
  --bg: #f6f3ee;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: #ffffff;
  --line: rgba(28, 28, 28, 0.08);
  --line-strong: rgba(28, 28, 28, 0.14);
  --text: #171717;
  --muted: #707070;
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.1);
  --shadow: 0 18px 48px rgba(23, 23, 23, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "SF Pro Display", "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.06), transparent 24%),
    linear-gradient(180deg, #fbfaf7 0%, var(--bg) 100%);
}

.app-shell {
  width: min(1180px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 140px;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  box-shadow: 0 0 0 6px rgba(15, 118, 110, 0.12);
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tabbar {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tab.is-active {
  background: var(--panel-strong);
  color: var(--text);
  box-shadow: 0 6px 16px rgba(23, 23, 23, 0.08);
}

.topbar-status,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 700;
}

.chip.muted {
  background: rgba(23, 23, 23, 0.06);
  color: var(--muted);
}

.view {
  display: none;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 28px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.section-kicker,
.message-role {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.section-head h1,
.finder-head h2 {
  margin: 0;
  font-size: clamp(1.6rem, 2vw, 2.2rem);
  letter-spacing: -0.03em;
}

.capture-form,
.chat-form {
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: 0.85fr 1.35fr 0.8fr;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
textarea,
.results {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  padding: 15px 16px;
  font: inherit;
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.34);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.1);
}

.finder {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.68);
}

.finder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.results {
  min-height: 76px;
  padding: 10px;
}

.results.empty {
  color: var(--muted);
}

.result-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.96);
  text-align: left;
  cursor: pointer;
}

.result-item + .result-item {
  margin-top: 10px;
}

.result-item strong {
  font-size: 0.95rem;
}

.result-item small {
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.button {
  appearance: none;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}

.button.primary {
  background: linear-gradient(135deg, #0f766e, #115e59);
  color: white;
}

.button.secondary {
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--line-strong);
  color: var(--text);
}

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

.insight-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.chat-log {
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 243, 238, 0.88));
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 14px;
  margin-bottom: 18px;
}

.message {
  max-width: 78%;
  border-radius: 20px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 24px rgba(23, 23, 23, 0.05);
}

.message-system {
  justify-self: flex-start;
}

.message-user {
  justify-self: flex-end;
  background: linear-gradient(135deg, #0f766e, #115e59);
  color: white;
  border-color: rgba(15, 118, 110, 0.45);
}

.message-user .message-role {
  color: rgba(255, 255, 255, 0.74);
}

.message-text,
.message p:last-child {
  margin: 0;
  line-height: 1.65;
}

.message-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.65;
}

@media (max-width: 960px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 18px;
  }

  .topbar,
  .section-head,
  .finder-head {
    flex-direction: column;
    align-items: stretch;
  }

  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .insight-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions {
    justify-content: stretch;
  }

  .button {
    width: 100%;
  }

  .message {
    max-width: 100%;
  }
}
