/* My Wife - chat UI. Light and dark, no dependencies, no web fonts. */

:root {
  color-scheme: light dark;

  --bg: #f4f1ec;
  --panel: #fffdfb;
  --ink: #1d1b19;
  --ink-soft: #5f5a55;
  --line: #e6e0d7;
  --accent: #9a5b3f;
  --accent-soft: #f5e8e1;
  --bot-bubble: #ffffff;
  --user-bubble: #2f2b28;
  --user-ink: #faf8f6;
  --shadow: 0 1px 2px rgba(29, 27, 25, 0.05), 0 10px 28px rgba(29, 27, 25, 0.07);

  /* Per-category accent. Overridden by the [data-category] rules below. */
  --cat: var(--accent);
}

[data-category="cleaning"]    { --cat: #0f766e; }
[data-category="laundry"]     { --cat: #4338ca; }
[data-category="kitchen"]     { --cat: #b45309; }
[data-category="cooking"]     { --cat: #4d7c0f; }
[data-category="mains"]       { --cat: #9a3412; }
[data-category="sides"]       { --cat: #0e7490; }
[data-category="baking"]      { --cat: #a21caf; }
[data-category="sweets"]      { --cat: #be123c; }
[data-category="drinks"]      { --cat: #1d4ed8; }
[data-category="plumbing"]    { --cat: #0369a1; }
[data-category="electrical"]  { --cat: #a16207; }
[data-category="maintenance"] { --cat: #475569; }
[data-category="organizing"]  { --cat: #7e22ce; }
[data-category="safety"]      { --cat: #b91c1c; }
[data-category="outdoors"]    { --cat: #15803d; }
[data-category="pets"]        { --cat: #be185d; }
[data-category="car"]         { --cat: #155e75; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15131a;
    --panel: #1e1b23;
    --ink: #f0ebe6;
    --ink-soft: #a79f98;
    --line: #322d38;
    --accent: #e0a183;
    --accent-soft: #33262a;
    --bot-bubble: #262229;
    --user-bubble: #e0a183;
    --user-ink: #1e1b23;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.28);
  }

  [data-category="cleaning"]    { --cat: #2dd4bf; }
  [data-category="laundry"]     { --cat: #a5b4fc; }
  [data-category="kitchen"]     { --cat: #fdba74; }
  [data-category="cooking"]     { --cat: #bef264; }
  [data-category="mains"]       { --cat: #fb923c; }
  [data-category="sides"]       { --cat: #67e8f9; }
  [data-category="baking"]      { --cat: #f0abfc; }
  [data-category="sweets"]      { --cat: #fda4af; }
  [data-category="drinks"]      { --cat: #93c5fd; }
  [data-category="plumbing"]    { --cat: #7dd3fc; }
  [data-category="electrical"]  { --cat: #fcd34d; }
  [data-category="maintenance"] { --cat: #cbd5e1; }
  [data-category="organizing"]  { --cat: #d8b4fe; }
  [data-category="safety"]      { --cat: #fca5a5; }
  [data-category="outdoors"]    { --cat: #86efac; }
  [data-category="pets"]        { --cat: #f9a8d4; }
  [data-category="car"]         { --cat: #a5f3fc; }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 820px;
  margin: 0 auto;
  background: var(--panel);
  border-inline: 1px solid var(--line);
}

/* ------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 2;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  object-fit: cover;
  flex: none;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}

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

.ghost-btn,
.icon-btn {
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.icon-btn {
  padding: 0;
  width: 38px;
  height: 38px;
  font-size: 19px;
  line-height: 1;
}

.ghost-btn:hover,
.icon-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.icon-btn:active {
  transform: rotate(-18deg) scale(0.94);
}

.ghost-btn.with-icon {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding-left: 12px;
}

.btn-icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
}

.accent-btn {
  color: var(--panel);
  background: var(--accent);
  border-color: var(--accent);
}

.accent-btn:hover {
  background: var(--accent);
  filter: brightness(1.08);
}

/* ----------------------------------------------------------------- plan */

.plan {
  margin: 12px 0 4px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
}

.plan-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 10px;
}

.plan-price {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.plan-interval {
  font-size: 14px;
  color: var(--ink-soft);
}

.plan-includes {
  list-style: none;
  margin: 0;
  padding: 0;
}

.plan-includes li {
  position: relative;
  padding-left: 24px;
  font-size: 14.5px;
}

.plan-includes li + li {
  margin-top: 6px;
}

.plan-includes li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 8px;
  width: 10px;
  height: 5px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}

.plan-cta {
  display: block;
  margin-top: 14px;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: var(--panel);
  background: var(--accent);
  transition: filter 0.15s, transform 0.15s;
}

.plan-cta:hover {
  filter: brightness(1.08);
}

.plan-cta:active {
  transform: scale(0.99);
}

/* Shown instead of the button while no payment link is configured. */
.plan-pending {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.plan-note {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* ---------------------------------------------------------------- toast */

.toast {
  margin: 10px 18px 0;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  animation: rise 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}

/* ---------------------------------------------------------- transcript */

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 22px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Before the first question there is one short message; sitting it in the
   middle of the panel beats stranding it above a screen of nothing. */
.transcript.welcome {
  justify-content: center;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 94%;
  animation: rise 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.msg.user {
  align-self: flex-end;
  align-items: flex-end;
  max-width: 85%;
}

.msg .who {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
  margin-bottom: 5px;
}

.who-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  object-fit: cover;
}

/* ------------------------------------------------------- the welcome hero */

.msg.hello {
  flex-direction: row;
  align-items: flex-end;
  gap: 14px;
  max-width: 100%;
}

.hello-figure {
  width: auto;
  height: 300px;
  flex: none;
  align-self: flex-end;
  animation: wave-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes wave-in {
  from {
    opacity: 0;
    transform: translateY(14px) rotate(-3deg);
  }
}

.hello-said {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* She introduces herself, so the name above the greeting is redundant. */
.msg.hello .who {
  display: none;
}

.bubble {
  padding: 13px 16px;
  border-radius: 18px;
  background: var(--bot-bubble);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.msg.user .bubble {
  background: var(--user-bubble);
  color: var(--user-ink);
  border-color: transparent;
  border-bottom-right-radius: 5px;
}

.msg.bot .bubble {
  border-bottom-left-radius: 5px;
}

/* A bot message about a topic wears that category's colour. */
.msg.bot[data-category] .bubble {
  border-left: 3px solid var(--cat);
}

.bubble p {
  margin: 0 0 8px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------- typing dots */

.dots {
  display: inline-flex;
  gap: 5px;
  padding: 3px 2px;
}

.dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-soft);
  opacity: 0.4;
  animation: blink 1.1s infinite ease-in-out;
}

.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40%           { opacity: 1;    transform: translateY(-3px); }
}

/* -------------------------------------------------------- topic answer */

.topic-head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 10px;
}

.topic-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 11px;
  font-size: 17px;
  background: color-mix(in srgb, var(--cat) 14%, transparent);
}

.topic-title {
  margin: 1px 0 1px;
  font-size: 16.5px;
  line-height: 1.28;
  color: var(--cat);
}

.topic-meta {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
}

.topic-summary {
  margin: 0 0 14px;
  font-style: italic;
  color: var(--ink-soft);
}

/* ------------------------------------------------------- ingredients */

.ingredients {
  margin-bottom: 12px;
  padding: 11px 13px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--cat) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat) 22%, transparent);
}

.ingredients-label {
  display: block;
  margin-bottom: 7px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--cat);
  font-weight: 600;
}

.ingredients ul {
  columns: 2;
  column-gap: 22px;
  margin: 0;
  padding-left: 1.1em;
  font-size: 14.5px;
}

.ingredients li {
  break-inside: avoid;
  margin-bottom: 3px;
}

@media (max-width: 520px) {
  .ingredients ul {
    columns: 1;
  }
}

/* ------------------------------------------------------------- steps */

.steps-block {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px 12px;
}

.steps-progress {
  margin: 0 0 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
  transition: color 0.2s;
}

.steps-block.complete {
  border-color: var(--cat);
  background: color-mix(in srgb, var(--cat) 7%, transparent);
}

.steps-block.complete .steps-progress {
  color: var(--cat);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13.5px;
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes pop {
  from { transform: scale(0.92); opacity: 0.4; }
}

.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
}

.steps li {
  counter-increment: step;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 5px 0;
}

.steps li + li {
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.step-box {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--cat);
  cursor: pointer;
}

.steps label {
  cursor: pointer;
  transition: opacity 0.2s;
}

.steps label::before {
  content: counter(step) ". ";
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--cat);
}

.steps li.done label {
  opacity: 0.45;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* --------------------------------------------------------------- tips */

.tips {
  list-style: none;
  margin: 14px 0 0;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--accent-soft);
}

.tips li {
  position: relative;
  padding-left: 23px;
  font-size: 14.5px;
}

.tips li + li {
  margin-top: 7px;
}

.tips li::before {
  content: "!";
  position: absolute;
  left: 0;
  top: 2px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--panel);
  font-size: 11px;
  font-weight: 700;
}

/* --------------------------------------------- choices, lists, related */

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

.choice-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.choice-btn:hover {
  border-color: var(--cat);
  background: color-mix(in srgb, var(--cat) 8%, transparent);
  transform: translateX(2px);
}

.choice-icon {
  font-size: 17px;
  flex: none;
}

.choice-title {
  flex: 1;
}

.choice-btn .num {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--cat);
  background: color-mix(in srgb, var(--cat) 13%, transparent);
}

.cat-group {
  padding: 11px 0;
}

.cat-group + .cat-group {
  border-top: 1px solid var(--line);
}

.cat-group h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 2px;
  font-size: 14.5px;
  color: var(--cat);
}

.cat-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--cat) 13%, transparent);
  border-radius: 999px;
  padding: 1px 8px;
}

.cat-blurb {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.cat-topics,
.related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.related {
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px dashed var(--line);
}

.related-label {
  display: block;
  margin-bottom: 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
}

/* -------------------------------------------------- starters and chips */

.starters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.starter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  font: inherit;
  font-size: 14px;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.starter:hover {
  border-color: var(--cat);
  background: color-mix(in srgb, var(--cat) 8%, transparent);
  transform: translateY(-2px);
}

.starter-icon {
  font-size: 20px;
  flex: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 18px 0;
}

.chips:empty {
  padding: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  font: inherit;
  font-size: 13.5px;
  color: var(--cat);
  background: color-mix(in srgb, var(--cat) 11%, transparent);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.chip:hover {
  border-color: var(--cat);
  transform: translateY(-1px);
}

.chip:active {
  transform: translateY(0) scale(0.97);
}

.chip-icon {
  font-size: 14px;
}

/* ------------------------------------------------------------ composer */

.composer {
  display: flex;
  gap: 10px;
  padding: 14px 18px 10px;
  background: var(--panel);
}

.composer input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.15s;
}

.composer input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.composer input:disabled {
  opacity: 0.6;
}

.composer button {
  padding: 12px 22px;
  font: inherit;
  font-weight: 600;
  color: var(--panel);
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s;
}

.composer button:hover {
  filter: brightness(1.08);
}

.composer button:active {
  transform: scale(0.97);
}

/* -------------------------------------------------------------- footer */

.footer {
  padding: 0 18px calc(12px + env(safe-area-inset-bottom));
  background: var(--panel);
}

.footer p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-soft);
  text-align: center;
}

/* ------------------------------------------------------------ narrow */

@media (max-width: 520px) {
  .transcript {
    padding: 16px 12px 4px;
  }
  .chips,
  .composer,
  .footer {
    padding-inline: 12px;
  }
  .msg {
    max-width: 100%;
  }
  .brand p {
    display: none;
  }
  /* No room for three labelled controls; the icon and its tooltip carry it. */
  .ghost-btn.with-icon .btn-label {
    display: none;
  }
  .ghost-btn.with-icon {
    padding: 8px 11px;
  }
  .toast {
    margin-inline: 12px;
  }
  .starters {
    grid-template-columns: 1fr;
  }
  /* Too narrow to stand beside the greeting; she goes above it instead. */
  .msg.hello {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .hello-figure {
    height: 150px;
    align-self: center;
  }
}

/* Everything above is decoration; none of it should move for someone who
   asked the operating system to stop things moving. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .transcript {
    scroll-behavior: auto;
  }
}
