/* PersonalAgent design system.
   Tokens mirror the OneLifeVibe hub palette so the product cannot drift from
   the family look: --night ground, --ink text, --iri accent. */

:root {
  --night: #0a0c11;
  --night-2: #0f131b;
  --panel: #121722;
  --panel-2: #171d2a;
  --line: #232b3b;
  --line-soft: #1a2130;
  --ink: #e9edf7;
  --ink-dim: #a2adc4;
  --ink-faint: #6d7a93;
  --iri: #5b8cff;
  --iri-2: #8f6bff;
  --ok: #3ecf8e;
  --warn: #f2b544;
  --bad: #ff6b6b;
  --radius: 12px;
  --radius-sm: 8px;
  --gutter: clamp(16px, 3vw, 28px);
  --display: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--display);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--iri); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(30px, 5vw, 52px); font-weight: 700; }
h2 { font-size: clamp(22px, 3vw, 30px); font-weight: 650; }
h3 { font-size: 17px; font-weight: 620; }
p { margin: 0 0 14px; color: var(--ink-dim); }
small, .small { font-size: 12.5px; color: var(--ink-faint); }
code, .mono { font-family: var(--mono); font-size: 13px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }
.narrow { max-width: 760px; margin: 0 auto; padding: 0 var(--gutter); }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }

/* ------------------------------------------------------------------ topbar */

.pa-top {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  padding: 10px var(--gutter);
  background: rgba(10, 12, 17, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -0.01em; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--iri), var(--iri-2));
  display: grid; place-items: center; font-size: 13px; color: #fff; font-weight: 800;
}
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 7px 11px; border-radius: var(--radius-sm); color: var(--ink-dim);
  font-size: 14px; font-weight: 500;
}
.nav a:hover { background: var(--panel); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--panel-2); color: var(--ink); }

/* live meter */
.meter {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 13px; font-size: 12.5px; color: var(--ink-dim);
  white-space: nowrap;
}
.meter b { color: var(--ink); font-weight: 620; font-variant-numeric: tabular-nums; }
.meter .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(62, 207, 142, 0.6); animation: pulse 2.4s infinite; }
.meter .dot.off { background: var(--ink-faint); animation: none; }
.meter .bar { width: 54px; height: 4px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--iri), var(--iri-2)); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(62,207,142,.55);} 70% { box-shadow: 0 0 0 7px rgba(62,207,142,0);} 100% { box-shadow: 0 0 0 0 rgba(62,207,142,0);} }

/* ------------------------------------------------------------------ layout */

.shell { display: grid; grid-template-columns: 268px 1fr; min-height: calc(100vh - 53px); }
.side {
  border-right: 1px solid var(--line-soft); background: var(--night-2);
  padding: 14px 12px; display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: 53px; height: calc(100vh - 53px); overflow: auto;
}
.main { min-width: 0; padding: 20px var(--gutter) 60px; }
.side h4 { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin: 12px 4px 4px; }

.conv {
  display: block; padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--ink-dim); font-size: 13.5px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border: 1px solid transparent;
  /* .conv is used on <button> too, so neutralise the UA button chrome. */
  background: transparent; width: 100%; text-align: left; font-family: inherit;
}
.conv:hover { background: var(--panel); color: var(--ink); }
.conv.on { background: var(--panel-2); color: var(--ink); border-color: var(--line); }

/* ------------------------------------------------------------------ pieces */

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.card.tight { padding: 14px; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; }
.kpi .label { font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); }
.kpi .value { font-size: 26px; font-weight: 680; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 3px; }
.kpi .sub { font-size: 12.5px; color: var(--ink-dim); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); font: inherit; font-size: 14px; font-weight: 550;
  cursor: pointer; text-decoration: none; transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: #1c2434; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--iri), var(--iri-2)); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: #3a2330; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--ink);
  background: var(--night-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--iri); box-shadow: 0 0 0 3px rgba(91,140,255,0.15); }
textarea { resize: vertical; min-height: 90px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--ink-dim); margin-bottom: 5px; }
.hint { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.switch input { width: 38px; height: 22px; appearance: none; background: var(--line); border-radius: 999px; position: relative; cursor: pointer; padding: 0; }
.switch input:checked { background: var(--iri); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked::after { transform: translateX(16px); }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--panel-2); color: var(--ink-dim); border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: #1e3b31; background: #0f2019; }
.pill.warn { color: var(--warn); border-color: #3b3220; background: #201b0f; }
.pill.bad { color: var(--bad); border-color: #3b2323; background: #200f0f; }
.pill.iri { color: #cdd9ff; border-color: #2a3560; background: #141a33; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-faint); font-weight: 600; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

hr { border: 0; border-top: 1px solid var(--line-soft); margin: 18px 0; }

/* --------------------------------------------------------------------- chat */

.chat { display: flex; flex-direction: column; height: calc(100vh - 53px - 40px); max-height: 1000px; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 8px 2px 18px; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 11px; max-width: 860px; }
.msg .avatar {
  width: 27px; height: 27px; border-radius: 8px; flex: 0 0 27px; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; color: #fff; background: var(--panel-2); border: 1px solid var(--line);
}
.msg.user .avatar { background: linear-gradient(135deg, #2a3550, #3a4a72); }
.msg.assistant .avatar { background: linear-gradient(135deg, var(--iri), var(--iri-2)); }
.msg .body { min-width: 0; }
.msg .who { font-size: 12px; color: var(--ink-faint); margin-bottom: 3px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .text h3 { margin: 10px 0 6px; }
.msg .text ul { margin: 6px 0; padding-left: 20px; }
.msg .text code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }
.msg .meta { font-size: 11.5px; color: var(--ink-faint); margin-top: 5px; }
.msg .cursor { display: inline-block; width: 7px; height: 14px; background: var(--iri); vertical-align: text-bottom; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 10px; display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { border: 0; background: transparent; min-height: 44px; max-height: 200px; padding: 6px 4px; }
.composer textarea:focus { box-shadow: none; }

.empty { display: grid; place-items: center; height: 100%; text-align: center; color: var(--ink-faint); }
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 13px; font-size: 13px; color: var(--ink-dim); cursor: pointer; }
.chip:hover { border-color: var(--iri); color: var(--ink); }

/* --------------------------------------------------------------- marketing */

.hero { padding: clamp(48px, 9vw, 104px) 0 56px; text-align: center; }
.hero p.lead { font-size: clamp(16px, 2.2vw, 19px); max-width: 660px; margin: 18px auto 26px; color: var(--ink-dim); }
.grad { background: linear-gradient(120deg, #cdd9ff, var(--iri) 40%, var(--iri-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.feature { padding: 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
.feature h3 { margin-bottom: 6px; }
.feature p { margin: 0; font-size: 13.5px; }
.price-card { display: flex; flex-direction: column; gap: 12px; }
.price-card .amount { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }
.price-card ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.price-card li { font-size: 13.5px; color: var(--ink-dim); padding-left: 18px; position: relative; }
.price-card li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }
.price-card.pop { border-color: #2c3a66; box-shadow: 0 0 0 1px rgba(91,140,255,0.2), var(--shadow); }

.auth-card { max-width: 420px; margin: clamp(30px, 7vh, 80px) auto; }
.form-error { color: var(--bad); font-size: 13px; min-height: 18px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); padding: 10px 16px; border-radius: 999px; font-size: 13.5px; box-shadow: var(--shadow); z-index: 80; }
.toast.bad { border-color: #3b2323; color: #ffd0d0; }

.footer { border-top: 1px solid var(--line-soft); padding: 26px 0; margin-top: 60px; color: var(--ink-faint); font-size: 13px; }
.footer a { color: var(--ink-dim); }

.spark { width: 100%; height: 64px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-faint); flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }

/* -------------------------------------------------------------- responsive */

.mobile-only { display: none; }
.side-nav { display: none; gap: 2px; margin-top: 4px; }

@media (max-width: 1000px) {
  /* Brand + 5 nav links + meter + plan button cannot fit a tablet width:
     drop the topbar nav and expose it in the sidebar instead. */
  .nav { display: none; }
  .mobile-only { display: inline-flex; }
  .side-nav { display: grid; }
}

@media (max-width: 980px) {
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 53px auto 0 0; width: 280px; z-index: 50;
    transform: translateX(-104%); transition: transform 0.22s ease; box-shadow: var(--shadow);
  }
  .side.open { transform: none; }
  .main { padding-bottom: 100px; }
  .meter .label-long { display: none; }
  .chat { height: calc(100vh - 53px - 120px); }
}

@media (max-width: 620px) {
  .grid.c4, .grid.c3, .grid.c2 { grid-template-columns: 1fr; }
  .hero { padding-top: 34px; }
  .pa-top { gap: 8px; padding: 8px var(--gutter); }
  .meter { padding: 5px 10px; font-size: 11.5px; gap: 7px; }
  .meter .bar { width: 34px; }
  /* The wordmark plus a full meter plus the plan button cannot fit 390px:
     drop the wordmark and the meter furniture, keep the numbers. */
  .pa-top .brand > span:last-child { display: none; }
  .meter .bar { display: none; }
  #planBtn { padding: 5px 9px; font-size: 12px; }
  html, body { overflow-x: hidden; }
  table.responsive thead { display: none; }
  table.responsive tr { display: block; border-bottom: 1px solid var(--line-soft); padding: 8px 0; }
  table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 2px; }
  table.responsive td::before { content: attr(data-label); color: var(--ink-faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
