/* MarketBot app — mobile first. Palette from the approved brand board (see /css/style.css). */
:root {
  --cineraria: #6A2FC9;
  --tansy: #3B1F5C;
  --ivory: #FBF7F2;
  --dove: #D8DBE2;
  --harbor: #6E7686;
  --crow: #17141F;
  --flamingo: #F2437E;
  --marigold: #FFB330;
  --card: #FFFFFF;
  --ok: #1E7A4C;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ivory); color: var(--crow); overscroll-behavior-y: none; }
body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
h1, h2 { font-family: Georgia, 'Times New Roman', serif; line-height: 1.2; margin: 0 0 10px; }
h1 { font-size: 30px; }
h2 { font-size: 23px; }
h3 { font-size: 17px; margin: 0 0 6px; }
p { margin: 0 0 12px; }
a { color: var(--cineraria); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

#app { height: 100%; }

/* ---- layout: header / scrolling main / tab bar ---- */
.screen { height: 100dvh; display: flex; flex-direction: column; }
.appbar {
  background: var(--tansy); color: #fff; flex: 0 0 auto;
  padding: calc(10px + var(--safe-top)) 16px 10px; display: flex; align-items: center; gap: 10px;
}
.appbar .title { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar .back { background: none; border: 0; color: #fff; font-size: 15px; padding: 8px 6px; margin-left: -6px; cursor: pointer; }
.beta { background: var(--marigold); color: var(--crow); font-size: 11px; font-weight: 800; letter-spacing: 1px; border-radius: 999px; padding: 2px 8px; }
.main { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 18px 16px 24px; }
.main.pad-bottom { padding-bottom: 96px; }
.wrap { max-width: 640px; margin: 0 auto; }

.tabbar {
  flex: 0 0 auto; display: flex; background: #fff; border-top: 1px solid var(--dove);
  padding-bottom: var(--safe-bottom);
}
.tab { flex: 1; background: none; border: 0; padding: 8px 2px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--harbor); cursor: pointer; position: relative; text-decoration: none; }
.tab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--cineraria); }
.tab .dot { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--flamingo); color: #fff; font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* ---- buttons / forms ---- */
.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 50px; border-radius: 999px; border: 2px solid transparent; font-weight: 700; font-size: 16px; padding: 12px 20px; cursor: pointer; text-decoration: none; text-align: center; }
.btn + .btn { margin-top: 10px; }
.btn-primary { background: var(--flamingo); color: #fff; }
.btn-primary:active { background: #d6316a; }
.btn-secondary { background: #fff; color: var(--tansy); border-color: var(--tansy); }
.btn-ghost { background: none; color: var(--cineraria); min-height: 44px; }
.btn-small { width: auto; min-height: 40px; font-size: 14px; padding: 8px 16px; display: inline-flex; }
.btn[disabled] { opacity: .55; cursor: default; }
.link { background: none; border: 0; color: var(--cineraria); text-decoration: underline; cursor: pointer; padding: 4px 0; font-size: inherit; }

label { display: block; font-weight: 700; font-size: 14px; margin: 14px 0 6px; }
.hint { font-weight: 400; color: var(--harbor); font-size: 13px; display: block; margin-top: 2px; }
input, select, textarea { width: 100%; font-size: 16px; /* 16px stops iOS zooming on focus */ padding: 12px 14px; border: 1.5px solid var(--dove); border-radius: 12px; background: #fff; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(106,47,201,.25); border-color: var(--cineraria); }
.pw { position: relative; }
.pw button { position: absolute; right: 6px; top: 6px; height: 36px; border: 0; background: none; color: var(--cineraria); font-weight: 700; padding: 0 10px; cursor: pointer; }

.msg { border-radius: 12px; padding: 12px 14px; font-size: 14.5px; margin: 14px 0 0; }
.msg.err { background: #FDE8EF; color: #8A1240; }
.msg.ok { background: #E4F5EC; color: #0F5A35; }
.msg.info { background: #EFE9FA; color: var(--tansy); }

/* ---- cards / chips / pills ---- */
.card { background: var(--card); border: 1px solid var(--dove); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.card.tap { display: block; width: 100%; text-align: left; cursor: pointer; }
.card.tap:active { background: #F4EEFB; }
.card h3 { margin-bottom: 2px; }
.muted { color: var(--harbor); font-size: 14px; }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.pill { display: inline-block; font-size: 12px; font-weight: 800; border-radius: 999px; padding: 3px 10px; background: #FFF1D6; color: #7A4B00; }
.pill.ok { background: #E4F5EC; color: #0F5A35; }
.pill.ex { background: #EFE9FA; color: var(--tansy); }
.banner { background: #EFE9FA; color: var(--tansy); border-radius: 12px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px; }
.later { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--dove); font-size: 15px; }
.later:last-child { border-bottom: 0; }
.later .pill { background: var(--dove); color: var(--crow); white-space: nowrap; align-self: flex-start; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip { background: #fff; border: 1.5px solid var(--cineraria); color: var(--cineraria); border-radius: 999px; padding: 9px 14px; font-size: 14px; font-weight: 700; cursor: pointer; }

/* ---- welcome ---- */
.hero { text-align: center; padding-top: 6px; }
.hero img.mascot { width: 84px; border-radius: 22px; box-shadow: 0 1px 4px rgba(23,20,31,.18); margin-bottom: 14px; }
.hero .eyebrow { text-transform: uppercase; letter-spacing: 2px; font-size: 12px; font-weight: 800; color: var(--flamingo); margin-bottom: 8px; }
.hero p.lede { color: var(--harbor); font-size: 17px; }
.steps { list-style: none; padding: 0; margin: 20px 0; text-align: left; }
.steps li { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.steps .n { flex: 0 0 30px; height: 30px; border-radius: 50%; background: var(--tansy); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.fine { font-size: 12.5px; color: var(--harbor); text-align: center; margin-top: 16px; }

/* ---- rendered markdown (plans + chat) ---- */
.md h3 { font-size: 16px; color: var(--tansy); margin: 18px 0 6px; padding-top: 12px; border-top: 1px solid var(--dove); }
.md h3:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.md p { margin: 0 0 8px; }
.md ul { margin: 0 0 8px; padding-left: 20px; }
.md li { margin-bottom: 4px; }
.md strong { color: var(--crow); }
.reveal { animation: fade .5s ease both; }
.md .reveal + .reveal { border-top: 1px solid var(--dove); padding-top: 12px; margin-top: 14px; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- chat ---- */
.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 92%; border-radius: 16px; padding: 10px 14px; font-size: 15.5px; overflow-wrap: anywhere; }
.bubble.user { align-self: flex-end; background: var(--cineraria); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.bubble.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--dove); border-bottom-left-radius: 4px; }
.bubble.team { align-self: flex-start; background: #FFF4DB; border: 1px solid #F2D089; border-bottom-left-radius: 4px; }
.bubble .who { font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: #7A4B00; margin-bottom: 4px; }
.bubble .actions { margin-top: 8px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--harbor); animation: bounce 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }
.composer { flex: 0 0 auto; background: #fff; border-top: 1px solid var(--dove); padding: 8px 12px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 46px; max-height: 120px; padding: 11px 14px; border-radius: 22px; resize: none; }
.composer .send { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--flamingo); color: #fff; font-size: 20px; cursor: pointer; }
.composer .send[disabled] { opacity: .5; }

/* ---- generating ---- */
.center { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; }
.spinner { width: 46px; height: 46px; border: 5px solid var(--dove); border-top-color: var(--cineraria); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

.sticky-cta { position: sticky; bottom: 0; background: linear-gradient(to top, var(--ivory) 70%, rgba(251,247,242,0)); padding: 18px 0 calc(8px + var(--safe-bottom)); }

/* ---- toast ---- */
#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translate(-50%, 20px); background: var(--crow); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

details.card summary { cursor: pointer; font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--dove); margin: 18px 0; }

@media (min-width: 700px) {
  .screen { max-width: 640px; margin: 0 auto; border-left: 1px solid var(--dove); border-right: 1px solid var(--dove); background: var(--ivory); }
  body { background: #EFEAE3; }
}

/* ---- Progress tab (coming-soon preview; all sample data) ---- */
.pill.soon { background: var(--marigold); color: var(--crow); white-space: nowrap; }
.pill.sample { background: #ECE6F7; color: var(--tansy); white-space: nowrap; }
.banner.soonbanner { background: #FFF4DB; color: #5A3A00; border: 1px solid #F2D089; line-height: 1.45; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 8px; }
.kpi { background: #fff; border-radius: 18px; padding: 14px 14px 10px; border: 1px solid var(--dove); border-top: 5px solid var(--c); box-shadow: 0 2px 8px rgba(59,31,92,.07); animation: fade .55s ease both; min-width: 0; }
.kpi:nth-child(2) { animation-delay: .08s; } .kpi:nth-child(3) { animation-delay: .16s; } .kpi:nth-child(4) { animation-delay: .24s; }
.kpi-top { display: flex; align-items: flex-start; min-height: 46px; justify-content: space-between; gap: 6px; }
.kpi-label { font-size: 11px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--harbor); }
.delta { font-size: 11px; font-weight: 800; color: var(--ok); background: #E4F5EC; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.kpi-num { font-family: Georgia, 'Times New Roman', serif; font-weight: 700; font-size: 38px; line-height: 1.1; letter-spacing: -1px; color: var(--tansy); margin: 8px 0 4px; }
.spark { width: 100%; height: 32px; display: block; }
.spark .line { animation: draw 1.4s .2s ease forwards; stroke-dasharray: 1; stroke-dashoffset: 1; }

.chartcard { padding-bottom: 8px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: #E6E1EE; stroke-dasharray: 3 4; stroke-width: 1; }
.chart .ax { font-size: 10px; fill: var(--harbor); }
.chart .line { fill: none; stroke: var(--cineraria); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.5s ease forwards; }
.chart .fadein { animation: fade 1.2s .4s ease both; }
.chart .halo { fill: rgba(242,67,126,.18); animation: pulse 2.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.chart .dot { fill: var(--flamingo); stroke: #fff; stroke-width: 2; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.5); opacity: .3; } }

.bar { margin: 12px 0; }
.bar-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.bar-track { height: 11px; border-radius: 6px; background: #ECE6F7; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; animation: grow 1.1s .15s ease both; }
@keyframes grow { from { width: 0; } }

.ringcard { display: flex; gap: 14px; align-items: center; }
.ringwrap { flex: 0 0 96px; }
.ringtext { flex: 1; min-width: 0; }
.ring { width: 96px; height: 96px; display: block; }
.ringtext h3 { white-space: nowrap; }
.ring .rnum { font-family: Georgia, serif; font-weight: 700; font-size: 26px; fill: var(--tansy); }
.ring .rlab { font-size: 10px; fill: var(--harbor); }
.ringfill { animation: ringgrow 1.4s .1s ease both; }
@keyframes ringgrow { from { stroke-dashoffset: var(--full); } }
.tick { position: relative; padding-left: 26px; margin: 5px 0; font-size: 14px; color: var(--harbor); }
.tick::before { content: ""; position: absolute; left: 0; top: 2px; width: 17px; height: 17px; border-radius: 50%; border: 2px solid var(--dove); }
.tick.done { color: var(--crow); }
.tick.done::before { background: var(--ok); border-color: var(--ok); }
.tick.done::after { content: "\2713"; position: absolute; left: 3.5px; top: 1px; font-size: 11px; font-weight: 800; color: #fff; }

.connlist { padding: 2px 14px; }
.conn { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--dove); }
.conn:last-child { border-bottom: 0; }
.conn-ic { flex: 0 0 42px; height: 42px; border-radius: 13px; background: #F1EBFB; display: flex; align-items: center; justify-content: center; color: var(--cineraria); }
.conn-ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.conn-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14.5px; line-height: 1.3; }
.conn-tx span { color: var(--harbor); font-size: 12.5px; margin-top: 2px; }
.howitworks .steps { margin: 12px 0; }

@media (prefers-reduced-motion: reduce) {
  .kpi, .spark .line, .chart .line, .chart .fadein, .chart .halo, .bar-fill, .ringfill, .reveal { animation: none !important; stroke-dashoffset: 0 !important; }
}

/* ---- round 1 fixes ---- */
.sticky-cta { background: var(--ivory); border-top: 1px solid var(--dove); margin: 0 -16px; padding: 10px 16px calc(10px + var(--safe-bottom)); }
.how { background: none; border: 0; padding: 0; margin-left: 4px; color: var(--cineraria); font-size: 13px; font-weight: 700; text-decoration: underline; cursor: pointer; white-space: nowrap; }
.md li { margin-bottom: 6px; }
.hint { display: block; }
.hero { padding-bottom: 6px; }
.hero h1 { font-size: 28px; }
.hero p.lede { font-size: 16.5px; margin-bottom: 14px; }

/* ---- round 2 fixes ---- */
mark.ph { background: #FFE38A; color: #5A3A00; border-radius: 4px; padding: 0 3px; font-weight: 700; }
.banner.phbanner { background: #FFF4DB; color: #5A3A00; border: 1px solid #F2D089; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--flamingo); background: #FFF5F8; box-shadow: 0 0 0 3px rgba(242,67,126,.15); }
.bubble .actions { display: flex; gap: 6px; margin-top: 4px; }
.bubble .actions .link { padding: 10px 12px 10px 0; min-height: 40px; }
.md p .how { margin-left: 8px; padding: 6px 4px; }
.md li .how { padding: 6px 4px; }
