:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f0f4f7;
  --line: #dde3ea;
  --text: #17202a;
  --muted: #667485;
  --teal: #0f766e;
  --teal-soft: #dff5f1;
  --amber: #b76e00;
  --amber-soft: #fff1d6;
  --rose: #b42318;
  --rose-soft: #fee4e2;
  --blue: #2563eb;
  --shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 18px;
  min-width: 0;
  overflow: hidden;
}

.brand-row,
.panel-heading,
.url-form,
.status-strip,
.conversation-item,
.metric-row {
  display: flex;
  align-items: center;
}

.brand-row {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  font-size: 18px;
  font-weight: 760;
}

.subtle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.icon-button,
.primary-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-size: 22px;
  line-height: 1;
}

.conversation-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.conversation-item {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 10px;
  text-align: left;
  gap: 10px;
}

.conversation-item:hover,
.conversation-item.active {
  border-color: var(--line);
  background: var(--surface);
}

.conversation-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 99px;
  background: var(--teal);
}

.conversation-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 5px;
  object-fit: contain;
  background: #fff;
}

.conversation-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 650;
}

.conversation-url {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--teal);
  font-size: 12px;
  margin-top: 3px;
}

.conversation-body {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.conversation-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.conversation-item:hover .conversation-actions,
.conversation-item.active .conversation-actions {
  opacity: 1;
}

.conversation-item.active .conversation-actions {
  position: static;
}

.small-action {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.small-action:hover {
  color: var(--text);
  background: var(--line);
}

.small-action.danger:hover {
  color: var(--rose);
  background: var(--rose-soft);
}

.conversation-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.workspace {
  min-width: 0;
  padding: 20px;
  overflow: hidden;
}

.topbar {
  margin-bottom: 14px;
}

.url-form {
  gap: 10px;
}

#urlInput {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

#urlInput:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.toggle {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 12px;
  color: var(--muted);
  white-space: nowrap;
}

.primary-button {
  min-width: 96px;
  min-height: 44px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 720;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.78;
}

.spinner {
  width: 15px;
  height: 15px;
  display: none;
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.is-loading .spinner {
  display: inline-block;
}

.status-strip {
  gap: 8px;
  margin-bottom: 18px;
}

.status-chip {
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.status-chip.active {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-chip.done {
  background: var(--teal-soft);
  color: var(--teal);
}

.status-chip.error {
  background: var(--rose-soft);
  color: var(--rose);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-heading {
  min-height: 54px;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
}

.text-button {
  background: transparent;
  color: var(--blue);
  font-weight: 650;
}

.timeline {
  min-height: 420px;
  max-height: calc(100vh - 180px);
  overflow: auto;
  padding: 14px 16px 18px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #eef2f5;
}

.timeline-item:last-child {
  border-bottom: 0;
}

.phase {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.timeline-message {
  font-size: 14px;
  line-height: 1.5;
}

.timeline-data {
  margin-top: 4px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.result-panel {
  min-height: 520px;
}

.result-state {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  min-height: 460px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.empty-title {
  font-size: 15px;
}

.result-content {
  padding: 16px;
}

.summary-band {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.summary-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.summary-copy {
  min-width: 0;
  flex: 1;
}

.site-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
  padding: 6px;
}

.site-icon.is-hidden,
.conversation-icon.is-hidden {
  display: none;
}

.company-name {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.18;
}

.summary-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.metric-row {
  gap: 10px;
  margin-top: 14px;
}

.score {
  min-width: 76px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 18px;
  font-weight: 800;
}

.confidence {
  color: var(--muted);
  font-size: 13px;
}

.section-title {
  margin: 18px 0 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfd;
  padding: 7px 10px;
  font-size: 13px;
}

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

.social-link {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
}

.social-link:hover {
  border-color: rgba(15, 118, 110, 0.38);
  background: var(--teal-soft);
}

.social-platform {
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

.social-url {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.kv-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
}

.kv-key {
  color: var(--muted);
  font-weight: 700;
}

.screenshot {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  object-position: top;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.error-box {
  margin: 16px;
  border: 1px solid #f5b5b0;
  border-radius: 8px;
  background: var(--rose-soft);
  color: var(--rose);
  padding: 12px;
  line-height: 1.55;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .conversation-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(180px, 240px);
    overflow-x: auto;
    overflow-y: hidden;
  }

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

@media (max-width: 640px) {
  .workspace {
    padding: 14px;
  }

  .url-form {
    flex-wrap: wrap;
  }

  #urlInput {
    flex-basis: 100%;
  }

  .primary-button {
    flex: 1;
  }

  .timeline-item,
  .kv-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
