:root {
  --paper: #f5efe5;
  --paper-deep: #eadbc5;
  --ink: #1f2630;
  --muted: #66707d;
  --accent: #f1643f;
  --accent-deep: #d34f2c;
  --assistant: #fff9f1;
  --user: #16212e;
  --user-ink: #f7f3ee;
  --card: rgba(255, 255, 255, 0.7);
  --line: rgba(22, 33, 46, 0.12);
  --shadow: 0 18px 42px rgba(67, 42, 28, 0.12);
  --shadow-tight: 0 10px 24px rgba(31, 38, 48, 0.1);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(241, 100, 63, 0.22), transparent 28%),
    radial-gradient(circle at bottom left, rgba(32, 153, 137, 0.12), transparent 22%),
    var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  width: min(100vw, 100%);
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

@supports (height: 100dvh) {
  .app-shell {
    height: 100dvh;
  }
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  padding: calc(18px + var(--safe-top)) 18px 14px;
}

.brand-mark {
  width: 58px;
  height: 52px;
  display: grid;
  place-items: center;
}

.brand-mark img {
  display: block;
  width: 58px;
  height: 52px;
  object-fit: contain;
}

.brand-copy h1 {
  margin: 2px 0 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  min-height: 42px;
}

.chat-stage {
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 18px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.chat-stage.is-busy {
  display: grid;
  grid-template-rows: 1fr;
}

.question-context {
  padding: 0 16px 10px;
  position: relative;
  z-index: 3;
}

.question-pill {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  max-height: 76px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid rgba(22, 33, 46, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 26px rgba(31, 38, 48, 0.09);
  backdrop-filter: blur(12px);
}

.question-context.is-processing .question-pill {
  max-height: none;
  overflow: visible;
}

.question-context.is-complete .question-pill {
  max-height: 76px;
  overflow-y: auto;
}

.question-icon {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(241, 100, 63, 0.16);
  flex: 0 0 auto;
}

.question-icon::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 4px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  border: 2px solid var(--accent-deep);
}

.question-icon::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 5px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent-deep);
  transform: rotate(45deg);
}

.question-label {
  color: var(--accent-deep);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  white-space: nowrap;
}

.question-text {
  min-width: 0;
  color: #33404d;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
}

.welcome-panel {
  display: grid;
  gap: 16px;
  animation: lift-in 380ms ease;
}

.welcome-card {
  padding: 24px 22px;
  border-radius: var(--radius-xl);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.82), rgba(255, 249, 241, 0.92));
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.welcome-kicker {
  margin: 0 0 10px;
  color: var(--accent-deep);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
}

.welcome-card h2 {
  margin: 0 0 10px;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(1.8rem, 6vw, 2.35rem);
  line-height: 0.95;
}

.welcome-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.message-list {
  display: grid;
  gap: 18px;
  padding-top: 10px;
}

.message-list.is-busy {
  height: 100%;
  min-height: 100%;
  padding-top: 0;
  align-content: center;
}

.message {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: start;
  animation: lift-in 260ms ease;
}

.message-column {
  display: grid;
  gap: 8px;
}

.bubble {
  padding: 16px 18px;
  border-radius: 20px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.assistant .bubble {
  background: var(--assistant);
  box-shadow: 0 8px 20px rgba(58, 47, 33, 0.08);
}

.message.assistant .bubble.spinner-only {
  display: grid;
  justify-items: center;
  padding: 10px 0;
  background: transparent;
  box-shadow: none;
}

.spinner-stack {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.spinner-status-text {
  max-width: 280px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
}

.message.assistant .bubble.evaluation-report {
  display: grid;
  gap: 12px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.classification-hero {
  position: relative;
  overflow: hidden;
  display: flow-root;
  min-height: 166px;
  padding: 18px;
  border-radius: 24px;
  color: #fffaf3;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.22), transparent 34%),
    linear-gradient(145deg, #263443, #16212e);
  box-shadow: var(--shadow-tight);
}

.classification-copy {
  position: relative;
  z-index: 1;
}

.classification-hero::after {
  content: "";
  position: absolute;
  right: -34px;
  bottom: -48px;
  width: 128px;
  height: 128px;
  border-radius: 999px;
  border: 22px solid rgba(255, 255, 255, 0.09);
}

.classification-hero.mindful {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.24), transparent 34%),
    linear-gradient(145deg, #148271, #214f47);
}

.classification-hero.singleminded {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.24), transparent 34%),
    linear-gradient(145deg, #d34f2c, #80331f);
}

.classification-hero.simpleminded {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.24), transparent 34%),
    linear-gradient(145deg, #a5761d, #5d4316);
}

.classification-hero.mindless {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.18), transparent 34%),
    linear-gradient(145deg, #4b5563, #202733);
}

.classification-kicker {
  display: block;
  margin-bottom: 6px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.78;
}

.classification-title {
  display: block;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: 1.75rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

.classification-rationale {
  position: relative;
  margin: 10px 0 0;
  color: rgba(255, 250, 243, 0.88);
  line-height: 1.45;
}

.matrix-thumb {
  position: relative;
  z-index: 1;
  float: right;
  display: grid;
  grid-template-columns: 18px 48px 48px;
  grid-template-rows: 13px 36px 36px;
  gap: 4px;
  width: 136px;
  height: 112px;
  margin: -4px 0 10px 10px;
  padding: 7px 5px;
  justify-content: center;
  align-content: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
}

.matrix-axis {
  display: grid;
  place-items: center;
  color: rgba(255, 250, 243, 0.74);
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.matrix-axis-y {
  grid-column: 1;
  grid-row: 2 / 4;
  align-self: center;
  justify-self: center;
  transform: rotate(-90deg);
  transform-origin: center;
  width: 76px;
  text-align: center;
}

.matrix-axis-x {
  grid-column: 2 / 4;
  grid-row: 1;
  transform: none;
  text-align: center;
  align-self: end;
}

.matrix-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 3px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 250, 243, 0.82);
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.matrix-cell.singleminded {
  grid-column: 2;
  grid-row: 2;
}

.matrix-cell.mindful {
  grid-column: 3;
  grid-row: 2;
}

.matrix-cell.mindless {
  grid-column: 2;
  grid-row: 3;
}

.matrix-cell.simpleminded {
  grid-column: 3;
  grid-row: 3;
}

.matrix-cell.active {
  background: #f6d84f;
  border-color: rgba(255, 255, 255, 0.72);
  color: #2c2a18;
  box-shadow:
    0 0 0 2px rgba(246, 216, 79, 0.22),
    0 10px 18px rgba(0, 0, 0, 0.18);
}

.outline-card {
  display: grid;
  gap: 10px;
  padding: 15px;
  border: 1px solid rgba(22, 33, 46, 0.09);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 18px rgba(31, 38, 48, 0.06);
}

.outline-heading {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}

.outline-index {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: rgba(241, 100, 63, 0.14);
  color: var(--accent-deep);
  font-size: 0.72rem;
  font-weight: 900;
}

.outline-title {
  margin: 2px 0 0;
  font-size: 0.92rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.outline-copy,
.ethics-copy {
  margin: 0;
  color: #45505d;
  line-height: 1.52;
}

.cost-footnote {
  margin: 4px 2px 0;
  color: rgba(102, 112, 125, 0.72);
  font-size: 0.68rem;
  line-height: 1.2;
  text-align: right;
}

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

.outline-list li {
  position: relative;
  padding: 10px 12px 10px 34px;
  border-radius: 14px;
  background: rgba(32, 153, 137, 0.09);
  color: #33404d;
  line-height: 1.45;
}

.outline-list li::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 17px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #209989;
}

.ethics-grid {
  display: grid;
  gap: 8px;
}

.ethics-card {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border-radius: 15px;
  background: rgba(22, 33, 46, 0.05);
}

.ethics-label {
  color: var(--accent-deep);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.message-meta {
  display: flex;
  padding: 0 2px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(22, 33, 46, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  box-shadow: 0 7px 16px rgba(31, 38, 48, 0.06);
}

.meta-icon {
  position: relative;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(32, 153, 137, 0.14);
}

.assistant-meta .meta-icon::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 3px;
  width: 6px;
  height: 8px;
  border-right: 2px solid #209989;
  border-bottom: 2px solid #209989;
  transform: rotate(40deg);
}

.user-meta .meta-icon {
  background: rgba(22, 33, 46, 0.12);
}

.user-meta .meta-icon::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 3px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(22, 33, 46, 0.58);
}

.user-meta .meta-icon::after {
  content: "";
  position: absolute;
  left: 3px;
  bottom: 2px;
  width: 9px;
  height: 5px;
  border-radius: 999px 999px 3px 3px;
  background: rgba(22, 33, 46, 0.58);
}

.source-drawer {
  padding: 0 4px;
}

.source-drawer summary {
  cursor: pointer;
  color: var(--accent-deep);
  font-weight: 700;
}

.source-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.source-card {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  padding: 14px;
}

.source-card h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.source-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.source-meta {
  margin-top: 8px;
  font-size: 0.76rem;
}

.composer-shell {
  padding: 10px 14px calc(14px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(245, 239, 229, 0), rgba(245, 239, 229, 0.95) 20%);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 2;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
  padding: 0 8px 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.status-row[hidden] {
  display: none;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #9aa3ad;
  box-shadow: 0 0 0 5px rgba(154, 163, 173, 0.16);
}

.status-dot.ready {
  background: #209989;
  box-shadow: 0 0 0 5px rgba(32, 153, 137, 0.18);
}

.status-dot.busy {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(241, 100, 63, 0.16);
}

.composer-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  border-radius: 24px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.composer-notice {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(241, 100, 63, 0.12);
  color: var(--accent-deep);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.35;
}

.composer-notice.is-ready {
  background: rgba(32, 153, 137, 0.12);
  color: #148271;
}

.composer-notice[hidden] {
  display: none;
}

.composer-input {
  width: 100%;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  min-height: 28px;
  max-height: 140px;
  line-height: 1.45;
  color: var(--ink);
  font-size: 16px;
}

.composer-input::placeholder {
  color: #8d95a0;
}

.send-button {
  min-width: 96px;
  border: 0;
  border-radius: 18px;
  padding: 14px 16px;
  background: linear-gradient(145deg, var(--accent), #ff8a54);
  color: white;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(241, 100, 63, 0.24);
  min-height: 52px;
}

.send-button:disabled,
.download-button:disabled,
.retry-button:disabled {
  cursor: default;
}

.retry-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  padding: 2px 0 4px;
}

.retry-panel[hidden] {
  display: none;
}

.retry-button {
  flex: 1 1 160px;
  border: 0;
  border-radius: 999px;
  padding: 15px 22px;
  min-height: 52px;
  background: linear-gradient(145deg, var(--accent), #ff8a54);
  color: white;
  cursor: pointer;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(241, 100, 63, 0.24);
}

.download-button {
  flex: 1 1 140px;
  border: 1px solid rgba(22, 33, 46, 0.14);
  border-radius: 999px;
  padding: 15px 18px;
  min-height: 52px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  box-shadow: var(--shadow-tight);
}

.send-button:active,
.download-button:active,
.retry-button:active,
.ghost-button:active {
  transform: translateY(1px);
}

.send-button:disabled,
.retry-button:disabled,
.ghost-button:disabled {
  opacity: 0.55;
}

.mindful-spinner {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background:
    radial-gradient(circle, var(--assistant) 0 38%, transparent 39%),
    conic-gradient(from 0deg, #209989, #f1643f, #f4ba4f, #209989);
  animation: mindful-spin 1.2s linear infinite;
  box-shadow: 0 12px 24px rgba(241, 100, 63, 0.18);
}

.mindful-spinner::after {
  content: "";
  position: absolute;
  inset: 9px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fff9f1 url("/mindful-marketing-logo.svg?v=48") center / 21px 19px no-repeat;
  animation: mindful-counter-spin 1.2s linear infinite;
}

.mindful-spinner span {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
}

.mindful-spinner span:nth-child(1) {
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
}

.mindful-spinner span:nth-child(2) {
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
}

.mindful-spinner span:nth-child(3) {
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
}

.mindful-spinner span:nth-child(4) {
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
}

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

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

@keyframes lift-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 640px) {
  .app-shell {
    width: min(100vw, 560px);
    margin: 0 auto;
  }
}

@media (min-width: 380px) and (min-height: 820px) {
  .topbar {
    padding-left: 22px;
    padding-right: 22px;
  }

  .chat-stage {
    padding-left: 20px;
    padding-right: 20px;
  }

  .question-context {
    padding-left: 20px;
    padding-right: 20px;
  }

  .composer-shell {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media print {
  @page {
    margin: 0.25in;
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html,
  body {
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    background:
      radial-gradient(circle at top right, rgba(241, 100, 63, 0.22), transparent 28%),
      radial-gradient(circle at bottom left, rgba(32, 153, 137, 0.12), transparent 22%),
      var(--paper) !important;
  }

  body {
    padding: 0;
  }

  .app-shell {
    display: block;
    width: min(100%, 430px);
    max-width: 430px;
    height: auto !important;
    min-height: auto !important;
    margin: 0 auto;
  }

  .topbar {
    padding: 18px 18px 14px !important;
  }

  .chat-stage {
    overflow: visible !important;
    padding: 0 16px 18px !important;
  }

  .composer-shell,
  .status-row,
  .welcome-panel,
  .message-meta,
  .source-drawer {
    display: none !important;
  }

  .question-context {
    padding: 0 16px 10px !important;
  }

  .question-pill {
    max-height: none;
    overflow: visible;
  }

  .message-list {
    display: grid;
    gap: 18px;
    padding-top: 10px;
  }

  .message {
    animation: none;
    break-inside: auto;
    page-break-inside: auto;
  }

  .message-column {
    gap: 8px;
  }

  .message.assistant .bubble.evaluation-report {
    gap: 12px;
  }

  .classification-hero,
  .outline-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
