/* InvestPersona — mobile-first, 480px base, sharing the SlowAcorn token set.
   Nothing scrolls sideways at any width: every flex child holding text carries
   min-width:0, every row wraps, and body overflow-x is a backstop only. */

:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel2: #1e222b;
  --line: #2a2f3a;
  --ink: #e7e9ee;
  --muted: #8b93a5;
  --accent: #7c9cff;
  --accent2: #59e0b8;
  --warn: #f0b354;
  --danger: #f2705f;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* The UA rule for [hidden] is display:none at the lowest specificity, so any
   class here that sets display (.examples, .totalRow, .clearBtn) silently wins
   and the element stays on screen despite node.hidden = true. Every toggle in
   app.js goes through .hidden, so this rule is what makes them work at all. */
[hidden] { display: none !important; }

html {
  /* Safari inflates text in landscape unless told not to. Without this the
     layout that fits in portrait quietly breaks when the phone is turned. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  /* -apple-system first so iOS uses San Francisco; Apple SD Gothic Neo is the
     system Korean face and must come before any Windows fallback. */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
               "Malgun Gothic", Roboto, sans-serif;
  line-height: 1.55;
  overflow-x: hidden;
}

.wrap {
  max-width: 480px;
  margin: 0 auto;
  /* viewport-fit=cover lets the background reach the screen edges, so the
     content has to keep itself clear of the notch and the home indicator —
     in landscape the inset is on the sides, not just the bottom. */
  padding: 16px calc(14px + env(safe-area-inset-right))
           calc(24px + env(safe-area-inset-bottom))
           calc(14px + env(safe-area-inset-left));
}

@media (min-width: 900px) {
  .wrap { max-width: 620px; }
}

/* Every control: no iOS chrome, no long-press callout, no 300ms double-tap
   delay, and a tap flash in our own colour rather than Safari's grey block. */
button, input {
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: rgba(124, 156, 255, .25);
  touch-action: manipulation;
}

button {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- top bar ---------- */
.topBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

a.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  transition: transform .15s ease, border-color .15s ease;
}
a.back:hover { transform: translateX(-2px); border-color: var(--accent); }

/* ---------- segmented controls ---------- */
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel);
  flex-shrink: 0;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  /* 44px is Apple's minimum comfortable touch target; a 31px pill is hittable
     with a mouse and frustrating with a thumb. */
  min-height: 44px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: #0f1115; }

/* ---------- header ---------- */
.appHeader { margin-bottom: 16px; }
.appHeader h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.02em; }
.appHeader p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- cards ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 16px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }

/* ---------- input ---------- */
.searchWrap { position: relative; }

input[type="text"] {
  width: 100%;
  min-height: 46px;
  line-height: 1.4;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel2);
  color: var(--ink);
  /* 16px minimum: anything smaller makes iOS Safari zoom in on focus. */
  font-size: 16px;
  font-family: inherit;
}
input[type="text"]:focus { outline: none; border-color: var(--accent); }
input::placeholder { color: #5d6577; }

.suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.suggestions li {
  min-height: 44px;
  padding: 10px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.suggestions li:hover, .suggestions li[aria-selected="true"] { background: #2a3040; }
.suggestions .sName {
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.suggestions .sMeta { font-size: 11.5px; color: var(--muted); flex-shrink: 0; }

.amountRow {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}
.amountRow input { flex: 1 1 110px; min-width: 0; }

button.primary {
  border: 0;
  min-height: 46px;
  border-radius: 10px;
  background: var(--accent);
  color: #0f1115;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 18px;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}
button.primary:disabled { opacity: .4; cursor: default; }

/* the one button the whole page is built around */
button.huge {
  display: block;
  width: 100%;
  font-size: 17px;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 10px;
}

button.ghost {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  min-height: 44px;
  padding: 0 16px;
  cursor: pointer;
  font-family: inherit;
}
button.ghost:hover { color: var(--ink); border-color: var(--accent); }
.clearBtn { display: block; margin: 0 auto 18px; }

/* ---------- holdings ---------- */
.holdings { list-style: none; margin: 12px 0 0; padding: 0; }
.holdings li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.holdings li:last-child { border-bottom: 0; }
.hMain { flex: 1 1 auto; min-width: 0; }
.hName {
  font-size: 14.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hMeta { font-size: 11.5px; color: var(--muted); }
.hRight { text-align: right; flex-shrink: 0; }
.hValue { font-size: 14px; font-variant-numeric: tabular-nums; }
.hWeight { font-size: 11.5px; color: var(--accent2); font-variant-numeric: tabular-nums; }
.hDel {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  /* Square enough to hit with a thumb without nudging the row taller: the
     negative margin lets the target overhang the row's own padding. */
  width: 44px;
  height: 44px;
  margin: -10px -12px -10px 0;
  flex-shrink: 0;
}
.hDel:hover { color: var(--danger); }

.totalRow {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.totalRow span:last-child {
  color: var(--accent2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.examples { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.examples .hint { margin: 0; }
.chip {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel2);
  color: var(--ink);
  font-size: 12.5px;
  min-height: 44px;
  padding: 0 14px;
  cursor: pointer;
  font-family: inherit;
}
.chip:hover { border-color: var(--accent); }

/* ---------- the answer ---------- */
.result { animation: fade .3s ease; }
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.riskCard { text-align: center; padding-bottom: 12px; }
#dial {
  width: 190px;
  max-width: 100%;
  /* Explicit ratio rather than height:auto — iOS Safari's intrinsic sizing for
     inline SVG with only a viewBox is unreliable, and the element can paint at
     the wrong height before settling. Matches the 200x118 viewBox. */
  aspect-ratio: 200 / 118;
  height: auto;
  display: block;
  margin: 0 auto;
}
.riskLine {
  font-size: 13px;
  color: var(--muted);
  margin-top: -2px;
}

.personaName {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.personaBody { margin: 0; font-size: 14px; }
.blindSpot {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: var(--panel2);
  border-radius: 9px;
  font-size: 13px;
  color: var(--muted);
}
.blindSpot strong { color: var(--warn); }

/* ---------- actions ---------- */
.actionsHint { margin: -4px 0 4px; }
.actions { list-style: none; margin: 0; padding: 0; counter-reset: action; }
.actions li {
  position: relative;
  padding: 12px 0 12px 30px;
  border-bottom: 1px solid var(--line);
  counter-increment: action;
}
.actions li:last-child { border-bottom: 0; padding-bottom: 0; }
.actions li::before {
  content: counter(action);
  position: absolute;
  left: 0;
  top: 12px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #0f1115;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.actions li:first-child::before { top: 12px; }
.aTitle { font-size: 14.5px; font-weight: 700; }
.aDetail { font-size: 13px; color: var(--muted); margin-top: 3px; }
.aBuy {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--panel2);
  border-radius: 8px;
}
.aInstrument {
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aAmount {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent2);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.coachNote {
  font-size: 12.5px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 2px solid var(--warn);
  border-radius: 9px;
  padding: 10px 12px;
  margin: 0 0 14px;
}

/* ---------- disclaimer, footer ---------- */
.disclaimer {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 14px;
}
.disclaimer strong { color: var(--warn); }

footer {
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  padding-bottom: 8px;
}
footer a {
  color: var(--muted);
  text-decoration: none;
  /* Bare footer links render ~16px tall, well under a thumb's reach. Padding
     gives them a real target without changing how the line looks. */
  display: inline-block;
  padding: 13px 4px;
}
footer a:hover { color: var(--accent); }

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