:root {
  /* IM8-style: warm off-white, near-black Inter grotesque, big bold tight
     headlines, generous whitespace, soft shadows, rose-magenta accent. */
  --bg:        #fafafa;     /* warm off-white */
  --bg-2:      #f4f3f1;
  --card:      #ffffff;     /* clean white */
  --ink:       #15171c;     /* near-black */
  --ink-soft:  #54585f;
  --muted:     #989ca3;
  --accent:    #e0568f;     /* IM8 rose-magenta */
  --accent-deep: #b3346c;   /* deeper rose for small text / citations (readable) */
  --line:      #eceae7;     /* hairline */
  --good:      #1f9d57;
  --warn:      #cf922b;
  --shadow:    0 10px 34px rgba(20, 20, 35, 0.06);
  --radius:    18px;
  --sans:      "Inter", -apple-system, system-ui, "Helvetica Neue", Arial, sans-serif;
  --serif:     "Inter", -apple-system, system-ui, sans-serif; /* legacy alias → sans */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(760px 380px at 92% -6%, rgba(224, 86, 143, 0.055) 0%, transparent 62%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: 700px; margin: 0 auto; padding: 56px 22px 80px; }

.masthead { text-align: center; margin: 8px 0 40px; }
.masthead h1 {
  font-weight: 900;
  font-size: 3.4rem;
  letter-spacing: -0.035em;
  line-height: 1;
  margin: 0;
  color: var(--ink);
}
.masthead h1::after { content: "."; color: var(--accent); }
.tagline { color: var(--ink-soft); margin: 14px auto 0; font-size: 1.05rem; max-width: 30em; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  margin: 20px 0;
  box-shadow: var(--shadow);
}

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

/* form */
form .row { margin-bottom: 16px; }
form .row.split { display: flex; gap: 14px; }
form .row.split label { flex: 1; }
label { display: block; font-size: 0.84rem; font-weight: 600; color: var(--ink-soft); letter-spacing: 0.01em; }
input, select, textarea {
  width: 100%;
  margin-top: 7px;
  padding: 13px 14px;
  background: #fff;
  color: var(--ink);
  border: 1px solid #e3e1dd;
  border-radius: 11px;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224, 86, 143, 0.16);
}
textarea { resize: vertical; }

button#go {
  width: 100%;
  margin-top: 8px;
  padding: 15px 16px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  color: #fff;
  background: var(--accent);
  border: none; border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(224, 86, 143, 0.26);
  transition: transform .08s ease, filter .15s ease;
}
button#go:hover { filter: brightness(1.04); }
button#go:active { transform: translateY(1px); }
button#go:disabled { filter: grayscale(.4) brightness(.97); cursor: progress; }

.resolved { margin: 14px 0 0; font-size: 0.8rem; }

/* status / errors */
.status { text-align: center; padding: 16px; color: var(--ink-soft); }
.status.error {
  color: #9a2222; background: #fdeceb;
  border: 1px solid #f0c5c0; border-radius: var(--radius);
}
.spinner {
  display: inline-block; width: 18px; height: 18px; margin-right: 10px;
  border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* reading — clean grotesque, airy, bold dark subheads */
.reading { font-size: 1.05rem; color: var(--ink); line-height: 1.75; }
.reading h1 {
  font-size: 1.85rem; font-weight: 800; letter-spacing: -0.025em;
  margin: 0 0 6px; line-height: 1.12; color: var(--ink);
}
.reading h2 {
  font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em;
  color: var(--ink); margin: 32px 0 10px;
}
.reading p { margin: 0 0 18px; color: var(--ink); }
.reading ul { margin: 0 0 18px; padding-left: 22px; }
.reading li { margin: 0 0 11px; }
/* citations: quiet, upright, legible (no more tiny italics) */
.reading em { color: var(--ink-soft); font-style: normal; font-size: 0.92em; font-weight: 500; }
/* keyword takeaways: bordeaux + bold, same body size, upright — the "pop" */
.reading strong { color: var(--accent-deep); font-weight: 700; font-style: normal; }
.reading .sub { color: var(--muted); font-size: 0.84rem; }

/* chart detail */
.chart summary {
  cursor: pointer; font-weight: 600; color: var(--ink-soft); font-size: 0.9rem;
}
.chart table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 0.85rem; }
.chart th, .chart td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
.chart tbody tr:nth-child(even) { background: #faf9f8; }
.chart th { color: var(--muted); font-weight: 600; }
.chart h4 { margin: 20px 0 6px; color: var(--accent-deep); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.tag { font-size: 0.72rem; padding: 1px 8px; border-radius: 999px; }
.tag.app { background: rgba(31, 157, 87, 0.13); color: #18814a; }
.tag.sep { background: #f0eff2; color: var(--muted); }

.foot { text-align: center; margin-top: 36px; font-size: 0.78rem; }

/* multi-step flow */
.step { font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.11em; color: var(--accent-deep); margin: 0 0 18px; }
.confirm { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); margin: 0 0 6px; }
.small { font-size: 0.85rem; }

button.ghost {
  background: transparent; color: var(--ink-soft);
  border: 1px solid #e3e1dd; border-radius: 12px;
  padding: 13px 18px; font: inherit; font-weight: 600; cursor: pointer; flex: 0 0 auto;
}
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.small { width: auto; padding: 11px 18px; margin-top: 12px; font-size: 0.92rem; font-weight: 600; }
#interests-form .row.split { display: flex; gap: 12px; margin-top: 16px; }
#interests-form .row.split button { flex: 1; }
#interests-form textarea { width: 100%; }

/* profile header */
.profile-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.who { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.profile-head .small { margin-top: 3px; }

/* tabs */
.tabs { display: flex; gap: 6px; margin: 4px 0 0; }
.tab {
  flex: 1; padding: 14px; font: inherit; font-weight: 600; font-size: 0.94rem;
  color: var(--ink-soft); background: #efedea;
  border: 1px solid var(--line); border-bottom: none;
  border-radius: 14px 14px 0 0; cursor: pointer;
}
.tab.active { color: var(--ink); background: var(--card); border-top: 2px solid var(--accent); }
.tabpane .card { border-top-left-radius: 0; border-top-right-radius: 0; margin-top: 0; }

/* period toggle — dark segmented control */
.period-toggle { display: flex; gap: 6px; margin-bottom: 18px; }
.pt {
  flex: 1; padding: 11px; font: inherit; font-size: 0.88rem; font-weight: 600;
  color: var(--ink-soft); background: #fff;
  border: 1px solid #e3e1dd; border-radius: 11px; cursor: pointer;
}
.pt.active { color: #fff; background: var(--ink); border-color: var(--ink); }

/* daily energy/mood glance */
.glance { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 20px; }
.chip {
  font-size: 0.8rem; font-weight: 600;
  padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: #f4f3f1; color: var(--ink-soft); letter-spacing: 0.01em;
}
.chip.mood { text-transform: capitalize; }
.chip.energy { color: #fff; border: none; }
.chip.energy.high { background: var(--good); }
.chip.energy.mid  { background: var(--warn); color: #fff; }
.chip.energy.low  { background: #4a72c8; }

/* ask-a-question chat (sits ABOVE the reading) */
.tabpane .chat { border-radius: var(--radius); margin: 0 0 16px; }
.ask-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--accent-deep); margin-bottom: 12px; }
.thread { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.thread:empty { display: none; }
.bubble { padding: 12px 15px; border-radius: 14px; max-width: 92%; font-size: 0.95rem; line-height: 1.6; }
.bubble.q { align-self: flex-end; background: #fbeaf2; color: var(--ink); }
.bubble.a { align-self: flex-start; background: #f5f4f2; color: var(--ink); }
.bubble.a em { color: var(--ink-soft); font-style: normal; }
.bubble.a strong { color: var(--accent-deep); font-weight: 700; }
.bubble.pending { color: var(--muted); }
form.ask { display: flex; gap: 8px; }
form.ask input { flex: 1; margin-top: 0; }
form.ask button {
  flex: 0 0 auto; padding: 13px 20px; font: inherit; font-weight: 600;
  color: #fff; background: var(--accent);
  border: none; border-radius: 11px; cursor: pointer;
}
form.ask button:disabled { filter: grayscale(.4) brightness(.97); cursor: progress; }

/* city typeahead */
.place-field { position: relative; }
.place-results {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20;
  background: #fff; border: 1px solid #e1dfdb; border-radius: 11px;
  margin-top: 4px; box-shadow: var(--shadow); overflow: hidden; max-height: 280px; overflow-y: auto;
}
.place-results .item { padding: 11px 13px; cursor: pointer; font-size: 0.95rem; border-bottom: 1px solid var(--line); }
.place-results .item:last-child { border-bottom: none; }
.place-results .item:hover, .place-results .item.active { background: #faf3f7; }
.place-results .muted { padding: 11px 13px; }

/* auth + account */
.head-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.auth-switch { margin-top: 16px; }
.auth-switch a { color: var(--accent-deep); cursor: pointer; font-weight: 600; }

/* 👍/👎 rating bar appended to a reading */
.rate { display: flex; align-items: center; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.rate .rate-label { font-size: 0.8rem; color: var(--muted); margin-right: auto; }
.rate button { font: inherit; font-size: 1rem; line-height: 1; padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft); cursor: pointer; transition: all .12s ease; }
.rate button:hover { border-color: var(--accent); }
.rate button.active.up { background: rgba(31, 157, 87, 0.13); border-color: var(--good); color: #18814a; }
.rate button.active.down { background: #fdeceb; border-color: #e6b8b2; color: #9a2222; }

/* beta feedback */
.beta-feedback textarea { width: 100%; }
.feedback-thanks { color: var(--good); font-size: 0.85rem; margin-left: 12px; font-weight: 600; }

/* history list */
.hist-item { border-bottom: 1px solid var(--line); padding: 4px 0; }
.hist-item:last-child { border-bottom: none; }
.hist-item summary { cursor: pointer; font-weight: 600; padding: 12px 2px; color: var(--ink); list-style: none; }
.hist-item summary::-webkit-details-marker { display: none; }
.hist-item summary::before { content: "▸ "; color: var(--accent); }
.hist-item[open] summary::before { content: "▾ "; }
.hist-item .reading { padding: 4px 2px 16px; }
#history-list > .muted { padding: 6px 2px; }
