:root {
  color-scheme: light;
  --bg: #f4f2ed;
  --ink: #202426;
  --muted: #6c7376;
  --line: #d8d8d1;
  --panel: rgba(255, 255, 255, .86);
  --panel-strong: #ffffff;
  --green: #25735e;
  --green-dark: #195544;
  --red: #bf493f;
  --yellow: #dca641;
  --blue: #2d6b9f;
  --shadow: 0 18px 55px rgba(32, 36, 38, .13);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden !important;
}

body {
  height: 100%;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  margin: 0;
  overflow: hidden !important;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(37, 115, 94, .10), transparent 34%),
    linear-gradient(315deg, rgba(45, 107, 159, .11), transparent 40%),
    var(--bg);
}

button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: 100%;
  max-width: 100vw;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
}

.sidebar,
.companion {
  min-width: 0;
  min-height: calc(100vh - 32px);
  border: 1px solid rgba(32, 36, 38, .10);
  border-radius: 18px;
  background: rgba(246, 246, 242, .82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  animation: dockIn .45s cubic-bezier(.2, .8, .2, 1);
}

.sidebar {
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
}

.companion {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto;
  gap: 12px;
  padding: 12px;
}

.topbar,
.question-row,
.insight-header,
.prompt-toolbar,
.actions,
.history-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar > div,
.question-row > div,
.prompt-toolbar > div,
.insight-header > div {
  min-width: 0;
}

.app-headline,
h1,
h2,
p,
strong,
textarea,
select {
  overflow-wrap: break-word;
}

button {
  white-space: nowrap;
}

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

.brand p,
.brand span,
h1,
h2,
p,
ul {
  margin: 0;
}

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

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #143d35;
}

.mark svg {
  width: 28px;
  height: 28px;
  fill: #f6d17a;
}

.mark-line,
.icon-button path,
.drop-icon path,
.primary-button path,
.secondary-button path,
.side-button path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mark-line {
  color: #143d35;
  stroke-width: 2.4;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, .66);
}

.icon-button:hover,
.ghost-button:hover,
.secondary-button:hover,
.chips button:hover,
.side-button:hover,
.stack-buttons button:hover {
  border-color: rgba(37, 115, 94, .42);
  color: var(--green-dark);
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.step {
  position: relative;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, .64);
  font-size: 12px;
  font-weight: 700;
  transition: .2s ease;
}

.step::before {
  content: attr(data-step-dot);
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #9aa0a1;
  font-size: 10px;
}

.step.is-active {
  border-color: rgba(37, 115, 94, .50);
  color: var(--green-dark);
  background: rgba(37, 115, 94, .10);
}

.step.is-active::before,
.step.is-done::before {
  background: var(--green);
}

.panel {
  min-width: 0;
  border: 1px solid rgba(32, 36, 38, .09);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px;
}

.side-button {
  width: 100%;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, .72);
  font-weight: 800;
}

.side-button svg {
  width: 20px;
  height: 20px;
  color: var(--green);
}

.side-button.quiet {
  margin-top: auto;
  color: var(--muted);
}

.stack-card {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(32, 36, 38, .09);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 255, 255, .78);
}

.stack-card h2 {
  font-size: 15px;
}

.stack-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.stack-buttons button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #343b3e;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.stack-buttons button.is-selected {
  border-color: transparent;
  color: #fff;
  background: var(--green);
}

h1 {
  font-size: 24px;
  line-height: 1.06;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: 0;
}

.app-headline {
  max-width: 940px;
  font-size: clamp(22px, 2.2vw, 34px);
  line-height: 1.08;
  font-weight: 860;
}

.question-row p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.ghost-button,
.secondary-button,
.primary-button {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 0 12px;
  background: var(--panel-strong);
  color: var(--ink);
  font-weight: 760;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-width: 100%;
  overflow: hidden;
  padding: 12px 0 6px;
}

.chips button {
  flex: 0 1 auto;
  max-width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: #fff;
  color: #3d4447;
  font-size: 12px;
  font-weight: 760;
  white-space: normal;
  transition: .18s ease;
}

.chips button.is-selected {
  border-color: transparent;
  color: #fff;
  background: var(--green);
}

.dropzone {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px dashed #aab2ad;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .72);
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}

.dropzone.is-dragging {
  border-color: var(--green);
  background: rgba(37, 115, 94, .10);
  transform: translateY(-1px);
}

#fileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-icon {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--green);
  background: rgba(37, 115, 94, .10);
  pointer-events: none;
}

.drop-icon svg {
  width: 18px;
  height: 18px;
}

textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  line-height: 1.45;
}

#contentInput {
  min-height: clamp(220px, 32vh, 420px);
  padding: 16px 54px 16px 16px;
}

textarea::placeholder {
  color: #8d9496;
}

.eyebrow,
.metric span,
.missing span,
.history-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.score {
  min-width: 50px;
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  background: var(--blue);
  font-weight: 850;
  font-size: 13px;
}

.insight-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.metric {
  min-height: 68px;
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(255, 255, 255, .66);
}

.metric strong {
  font-size: 14px;
  line-height: 1.2;
}

.missing {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.missing ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  list-style: none;
}

.missing li {
  border: 1px solid rgba(191, 73, 63, .22);
  border-radius: 999px;
  padding: 6px 9px;
  color: #8d3028;
  background: rgba(191, 73, 63, .08);
  font-size: 12px;
  font-weight: 740;
}

.prompt-toolbar select {
  max-width: 172px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

#promptOutput {
  min-height: 168px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfbf8;
}

.actions {
  margin-top: 10px;
}

.primary-button,
.secondary-button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-button {
  border-color: transparent;
  color: #fff;
  background: var(--green);
}

.primary-button:hover {
  background: var(--green-dark);
}

.primary-button svg,
.secondary-button svg {
  width: 18px;
  height: 18px;
}

.history-panel {
  min-height: 126px;
  overflow: hidden;
  border-radius: var(--radius);
}

.history-head {
  padding: 0 2px 8px;
}

.history-head strong {
  min-width: 26px;
  min-height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: #343b3e;
  font-size: 12px;
}

.history-list {
  display: grid;
  gap: 7px;
  max-height: 178px;
  overflow: auto;
}

.history-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  text-align: left;
  background: rgba(255, 255, 255, .75);
}

.history-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.history-item span {
  color: var(--muted);
  font-size: 11px;
}

.history-item time {
  color: #778083;
  font-size: 11px;
  white-space: nowrap;
}

.empty-history {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 28px;
  bottom: 26px;
  z-index: 5;
  max-width: 320px;
  transform: translateY(20px);
  opacity: 0;
  border-radius: var(--radius);
  padding: 11px 13px;
  color: #fff;
  background: #202426;
  box-shadow: 0 12px 32px rgba(32, 36, 38, .24);
  pointer-events: none;
  transition: .25s ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 22px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .22s ease;
}

.modal.is-open {
  pointer-events: auto;
  opacity: 1;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(32, 36, 38, .44);
  backdrop-filter: blur(10px);
}

.tutorial {
  position: relative;
  width: min(820px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, .40);
  border-radius: 18px;
  padding: 24px;
  background: #fbfbf8;
  box-shadow: 0 30px 90px rgba(32, 36, 38, .30);
  transform: translateY(18px) scale(.98);
  transition: transform .26s cubic-bezier(.2, .8, .2, 1);
}

.modal.is-open .tutorial {
  transform: translateY(0) scale(1);
}

.tutorial h2 {
  max-width: 640px;
  font-size: 28px;
  line-height: 1.08;
}

.tutorial-lead {
  max-width: 640px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
}

.tutorial-steps {
  display: grid;
  gap: 10px;
}

.tutorial-steps article {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
}

.tutorial-steps strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.tutorial-steps b {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 13px;
}

.tutorial-steps p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

@keyframes dockIn {
  from {
    transform: translateX(18px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@media (max-width: 720px) {
  .shell {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
  }

  .sidebar {
    position: static;
    height: auto;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .companion {
    width: 100%;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

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

  .insight-grid,
  .actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .toast {
    left: 14px;
    right: 14px;
    bottom: 14px;
    max-width: none;
  }

  .tutorial h2 {
    font-size: 22px;
    padding-right: 44px;
  }
}
