:root {
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #6c706f;
  --line: #dcded8;
  --green: #2f8f5b;
  --red: #c84646;
  --yellow: #b98214;
  --blue: #4267b2;
  --purple: #7b4aa8;
}

* {
  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;
}

body.modal-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.site-logo {
  display: block;
  width: 46px;
  height: 46px;
  object-fit: contain;
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 720;
}

h2 {
  font-size: 15px;
  font-weight: 720;
}

.user-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 33, 36, 0.34);
}

.user-modal.opaque-backdrop {
  background: var(--bg);
}

.user-modal[hidden] {
  display: none;
}

.user-dialog {
  display: grid;
  gap: 12px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(32, 33, 36, 0.2);
}

.user-dialog label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.user-dialog input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
}

.form-error {
  color: var(--red);
  font-size: 13px;
  line-height: 1.35;
}

.project-dialog {
  width: min(640px, 100%);
}

.project-model-options {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.project-model-option {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.project-model-option input {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  accent-color: var(--ink);
}

.project-model-option:has(input:disabled) {
  color: var(--muted);
}

.confirm-dialog {
  width: min(420px, 100%);
}

.artifact-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  width: 90vw;
  height: 90vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(32, 33, 36, 0.2);
}

.artifact-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.artifact-content {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  overflow: auto;
  background: #fbfbf8;
  color: var(--ink);
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.confirm-text {
  color: var(--muted);
  line-height: 1.4;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.session {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.session-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.llm-row {
  justify-content: end;
}

.session-row select {
  min-height: 30px;
  max-width: min(320px, 48vw);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 0 8px;
}

#llm-variant {
  width: 148px;
  max-width: 148px;
}

.llm-cost-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

#llm-status {
  cursor: pointer;
}

.llm-cost-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 4;
  display: none;
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(32, 33, 36, 0.16);
  color: var(--ink);
  text-align: left;
}

.llm-cost-wrapper:hover .llm-cost-popover,
.llm-cost-wrapper:focus-within .llm-cost-popover {
  display: grid;
  gap: 10px;
}

.llm-cost-row {
  display: grid;
  gap: 3px;
}

.llm-cost-row strong {
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.llm-cost-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.download-link[aria-disabled="true"],
.download-link:disabled {
  background: #fff;
  color: var(--muted);
  pointer-events: none;
  cursor: not-allowed;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  max-width: 1480px;
  margin: 0 auto;
}

section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}

.summary-section,
.questions-section,
.downloads-section,
.feedback-section {
  padding: 18px;
}

.summary-section {
  grid-column: 1 / -1;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
}

.section-title h2 {
  color: var(--ink);
}

#goal-summary {
  font-size: 18px;
  line-height: 1.45;
  max-width: 110ch;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e7f0eb;
  color: var(--green);
  font-size: 13px;
  font-weight: 680;
}

.status-pill.warning {
  background: #f5e8d0;
  color: var(--yellow);
}

.user-pill {
  border: 0;
  cursor: pointer;
}

.user-pill:disabled {
  background: #e7f0eb;
  color: var(--green);
  cursor: not-allowed;
  opacity: 0.65;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--red);
}

.graph-section {
  position: relative;
  overflow: hidden;
  padding: 0;
  background: #fbfbf8;
}

#graph {
  display: block;
  height: clamp(520px, 62vh, 760px);
  width: 100%;
}

.node {
  cursor: pointer;
  outline: none;
}

.node:focus,
.node:focus-visible {
  outline: none;
}

.node text {
  pointer-events: none;
  fill: var(--ink);
  font-size: 12px;
  font-weight: 660;
}

.edge {
  stroke: #aeb4af;
  stroke-width: 1.5;
}

.edge-label {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.node.selected circle {
  stroke: var(--blue);
  stroke-width: 4;
}

.node-popover {
  position: absolute;
  z-index: 2;
  width: min(320px, calc(100% - 24px));
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(32, 33, 36, 0.16);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.node-popover[hidden] {
  display: none;
}

.node-popover strong {
  display: block;
  color: var(--ink);
  margin-bottom: 6px;
}

.answer-form {
  display: grid;
  gap: 10px;
}

.answer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.enter-to-send {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  user-select: none;
}

.enter-to-send input {
  width: 16px;
  height: 16px;
  accent-color: var(--ink);
}

.answer-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

#answer-state-text {
  overflow-wrap: anywhere;
}

.answer-state.error {
  color: var(--red);
}

.answer-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  flex: 0 0 auto;
}

.answer-state.thinking .answer-spinner {
  display: inline-block;
  animation: spin 0.75s linear infinite;
}

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

#active-question {
  font-size: 16px;
  line-height: 1.4;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}

button {
  justify-self: start;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-weight: 720;
  cursor: pointer;
}

.secondary-button {
  min-height: 30px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
}

.icon-button::before {
  display: block;
  width: 18px;
  height: 18px;
  background: currentColor;
  content: "";
}

.trash-button::before {
  -webkit-mask: url("/assets/trash-can-solid-full.svg") center / contain no-repeat;
  mask: url("/assets/trash-can-solid-full.svg") center / contain no-repeat;
}

.icon-button:hover {
  color: var(--red);
}

.icon-button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.danger-button {
  background: var(--red);
  color: #fff;
}

button:disabled {
  background: #a5aaa6;
  cursor: not-allowed;
}

.icon-button:disabled {
  background: transparent;
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.45;
}

.download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.feedback-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.feedback-list li {
  border-left: 3px solid var(--line);
  padding-left: 10px;
  color: var(--ink);
  line-height: 1.4;
}

.feedback-list strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
  text-transform: uppercase;
}

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

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .session,
  .session-row {
    justify-items: stretch;
    justify-content: flex-start;
    width: 100%;
  }

  .llm-cost-popover {
    left: 0;
    right: auto;
    max-width: calc(100vw - 32px);
  }

  .artifact-dialog {
    width: 92vw;
    height: 92vh;
    padding: 12px;
  }

  .artifact-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  #graph {
    height: clamp(440px, 58vh, 620px);
  }

  .layout {
    padding: 12px;
  }
}
