/* Calma: warm paper, deep green ink, soft cards. Fraunces for the name and headings, Inter for text.
   Light theme only. Sell-coloured (terracotta) only marks a warning or a sell level. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-weight: 400; font-size: 16px; line-height: 1.45; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0 0 .4em; }
img { max-width: 100%; }
a { color: var(--ink); }
:focus-visible { outline: 3px solid var(--buy); outline-offset: 2px; }

.wordmark { display: flex; flex-direction: column; line-height: 1.1; }
.wordmark-name { font-family: var(--serif); font-weight: 600; font-size: 30px; letter-spacing: -.5px; }
.wordmark-tag { font-size: 13px; color: var(--muted); margin-top: 2px; }

.card, .box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }

.field { margin: 0 0 14px; }
.field label, .field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  display: block; width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink); font: inherit; }
.field.has-error input, .field.has-error .pw { border-color: var(--sell); }
.field-error { color: var(--ink); font-size: 13px; margin-top: 4px; border-left: 3px solid var(--sell); padding-left: 8px; }
.field-hint { font-size: 13px; margin-top: 4px; color: var(--muted); }

.btn { display: block; width: 100%; min-height: 44px; padding: 12px; border: 1px solid var(--ink); border-radius: 8px; font: inherit; font-weight: 600; font-size: 15px; text-align: center; cursor: pointer; text-decoration: none; }
.btn.ink { background: var(--ink); color: var(--paper); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.warn { background: var(--card); color: var(--ink); border-color: var(--sell); }
.btn:disabled { opacity: .5; cursor: default; }
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }
a.btn { line-height: 1.25; }

.banner { border: 1px solid var(--line); border-left: 4px solid var(--ink); border-radius: 8px; background: var(--card); padding: 8px 12px; font-size: 14px; margin: 10px 0; }
.banner.ok { border-left-color: var(--buy); background: var(--tip); }
.banner.warn { border-left-color: var(--sell); }
.banner a { font-weight: 600; }

.sheet-scrim { position: fixed; inset: 0; background: rgba(31, 61, 54, .4); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet { background: var(--paper); border-radius: 16px 16px 0 0; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 16px; }
.sheet:focus { outline: none; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sheet-head h2 { margin: 6px 0 0; font-size: 24px; line-height: 1.1; overflow-wrap: anywhere; }
.sheet-x { flex: none; background: none; border: 0; font-size: 26px; line-height: 1; min-width: 44px; min-height: 44px; cursor: pointer; color: var(--ink); }
.sheet-sub { margin: 4px 0 14px; font-size: 14px; color: var(--muted); }

.toast { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 60; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.toast-x { background: none; border: 0; font-size: 22px; line-height: 1; min-width: 44px; min-height: 44px; cursor: pointer; color: var(--ink); }

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

/* The "?" explanation: a small round button, and its text on the soft green. */
.tip-wrap { display: inline; }
.tip-q { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-left: 6px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--tip); color: var(--ink); font: 700 12px var(--sans); cursor: pointer; vertical-align: middle; }
.tip { display: block; margin: 6px 0 8px; padding: 9px 11px; border-radius: 10px; background: var(--tip); color: var(--ink); font-size: 13px; line-height: 1.45; }

/* Sign-in screens (auth-app.js): one phone-width column, the name on top. */
.auth { max-width: 420px; margin: 0 auto; padding: 16px 16px 40px; }
.auth-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.lang { display: flex; flex: none; border: 1px solid var(--line); border-radius: 8px; background: var(--card); overflow: hidden; }
.lang button { min-width: 44px; min-height: 40px; padding: 0 8px; border: 0; background: transparent; color: var(--ink); font: 600 14px var(--sans); letter-spacing: .04em; cursor: pointer; }
.lang button + button { border-left: 1px solid var(--line); }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.auth-main { padding-top: 24px; }
.auth-title { margin: 0; font-size: 28px; line-height: 1.15; }
.lede { margin: 10px 0 0; font-size: 15px; color: var(--muted); }
.auth-main .banner { margin: 16px 0 0; }
.auth-form { margin-top: 18px; }
.auth-form > .btn { margin-top: 8px; }
.auth-actions { margin-top: 18px; display: grid; gap: 10px; }
.remember-hint { margin: -4px 0 12px 32px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); }
.auth input[readonly] { background: transparent; }
.pw { display: flex; border: 1px solid var(--line); border-radius: 8px; background: var(--card); overflow: hidden; }
.pw input { flex: 1; min-width: 0; border: 0; border-radius: 0; }
.pw input:focus-visible { outline: none; }
.pw:focus-within { outline: 3px solid var(--buy); outline-offset: 2px; }
.pw button { flex: none; min-width: 76px; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--ink); font: 600 14px var(--sans); cursor: pointer; }
.meter { display: flex; gap: 4px; margin-top: 8px; }
.meter i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.meter i.on { background: var(--muted); }
.meter.full i { background: var(--buy); }
.reqs { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; color: var(--muted); }
.reqs li { display: flex; align-items: center; gap: 6px; }
.reqs em { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border: 1px solid var(--line); border-radius: 50%; font-style: normal; font-size: 11px; font-weight: 700; line-height: 1; }
.reqs li.ok { color: var(--ink); }
.reqs li.ok em { background: var(--buy); border-color: var(--buy); color: var(--card); }
.auth-links { margin-top: 10px; }
.auth-links a { display: inline-block; padding: 11px 0; font-weight: 600; }
.auth-foot { margin: 22px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }

/* Signed-in app: top bar, then the screen. */
.app { max-width: 1180px; margin: 0 auto; padding: 0 16px 48px; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.brand-link { text-decoration: none; color: var(--ink); }
.topnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topnav a { padding: 10px 12px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 15px; color: var(--muted); }
.topnav a.on { color: var(--ink); background: var(--tip); }
.topbar-end { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.linkbtn { background: none; border: 0; padding: 10px 4px; min-height: 44px; font: 600 14px var(--sans); color: var(--ink); text-decoration: underline; cursor: pointer; }
.main { padding-top: 22px; }
.inline-action { max-width: 240px; margin-top: 12px; }
.lede { color: var(--muted); }

/* Results */
.rhead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.rtitle { margin: 0; font-size: 26px; line-height: 1.15; }
.rsub { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.viewsw button { min-width: 80px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip { display: inline-flex; align-items: center; min-height: 34px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font: 400 13.5px var(--sans); color: var(--ink); }
.chip-adjust { min-height: 44px; padding: 4px 18px; border-color: var(--ink); font-weight: 600; cursor: pointer; }
.sheet-actions { display: grid; gap: 10px; margin-top: 8px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.scard { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.scard-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.scard-name { display: flex; flex-direction: column; text-decoration: none; min-width: 0; }
.tkr { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.co { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scard-close { font-weight: 600; font-size: 17px; white-space: nowrap; }
.spark { display: block; width: 100%; height: 60px; }
.spark-empty { background: var(--tip); border-radius: 8px; }
.spark-line { fill: none; stroke: var(--ink); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark-buy, .spark-sell { stroke-width: 1.4; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.spark-buy { stroke: var(--buy); }
.spark-sell { stroke: var(--sell); }
.clines { display: grid; gap: 8px; }
.cline-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.cline-label { font-size: 14.5px; }
.cline-value { font-size: 16px; white-space: nowrap; }
.cline.buy .cline-value { color: var(--buy); }
.cline.sell .cline-value { color: var(--sell); }
.cline.warn .cline-label { color: var(--ink); border-left: 3px solid var(--sell); padding-left: 8px; display: block; }
.cline-note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stale { font-size: 13px; color: var(--muted); }
.scard-foot { margin-top: auto; }
.watch { min-height: 44px; width: 100%; border: 1px solid var(--ink); border-radius: 8px; background: transparent; color: var(--ink); font: 600 15px var(--sans); cursor: pointer; }
.watch.on { background: var(--ink); color: var(--paper); }

.table-wrap { position: relative; overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.stable { width: 100%; border-collapse: collapse; font-size: 14.5px; text-align: right; white-space: nowrap; }
.stable th, .stable td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 400; vertical-align: top; }
.stable thead th { color: var(--muted); font-weight: 600; font-size: 13.5px; }
.stable th.left, .stable td.left { text-align: left; }
.stable tbody tr:last-child > * { border-bottom: 0; }
.stable a { text-decoration: none; }
.stable .tkr { font-size: 16px; }
.stable .co { display: inline; }
.sortbtn { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; min-height: 24px; }
.stable .cell-note { display: inline-block; min-width: 190px; max-width: 240px; white-space: normal; text-align: left; font-size: 13px; }
.stable .watch { width: auto; min-width: 96px; padding: 0 12px; }

@media (max-width: 700px) {
  .cards { grid-template-columns: 1fr; }
  .rtitle { font-size: 22px; }
  .topbar-end { margin-left: 0; width: 100%; justify-content: space-between; }
}

/* One stock (stock.js, chart.js). */
.stockpage { display: grid; gap: 16px; }
.stockpage .back { margin: 0; font-size: 14px; }
.co-big { color: var(--muted); font: 400 17px var(--sans); }
.box-pad { padding: 16px; }
.box-title { margin: 0 0 8px; font-size: 20px; }
.chart-card { padding: 8px; }
.chart { display: block; width: 100%; height: auto; font: 12px var(--sans); }
.ch-grid line { stroke: var(--line); stroke-width: 1; }
.ch-grid text { fill: var(--muted); }
.ch-up line, .ch-down line { stroke-width: 1.4; }
.ch-up line { stroke: var(--buy); } .ch-up rect { fill: var(--buy); }
.ch-down line { stroke: var(--sell); } .ch-down rect { fill: var(--sell); }
.ch-line line { stroke-width: 1.6; stroke-dasharray: 6 4; }
.ch-line text { font-weight: 600; }
.ch-line .ch-price { font-weight: 400; }
.ch-buy line { stroke: var(--buy); } .ch-buy text { fill: var(--buy); }
.ch-sell line { stroke: var(--sell); } .ch-sell text { fill: var(--sell); }
.ch-today line { stroke: var(--muted); stroke-dasharray: 2 3; } .ch-today text { fill: var(--ink); }
.ch-peak circle, .ch-dip circle { fill: var(--card); stroke-width: 2; }
.ch-peak circle { stroke: var(--ink); } .ch-peak text { fill: var(--ink); font-weight: 600; }
.ch-peak.ath circle { fill: var(--ink); }
.ch-dip circle { stroke: var(--sell); } .ch-dip text { fill: var(--muted); font-weight: 600; }
.ch-wave path { fill: none; stroke: var(--muted); }
.ch-wave text { fill: var(--muted); }
.stock-lines { display: grid; gap: 10px; }
.facts { margin: 0; display: grid; gap: 8px; }
.fact { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.fact dt { color: var(--muted); font-size: 14.5px; }
.fact dd { margin: 0; font-weight: 600; }
.how-steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 15px; line-height: 1.45; }
.how-note { margin: 0; font-size: 15px; }
.how-note.warn { margin-top: 8px; border-left: 3px solid var(--sell); padding-left: 8px; }
.stock-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stock-actions .btn, .stock-actions .watch { width: 100%; }
.bought-note { margin: 0 0 12px; }
@media (max-width: 700px) { .stock-actions { grid-template-columns: 1fr; } }
.chart-box { width: 100%; }
.ch-legend { list-style: none; margin: 6px 4px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.ch-legend li { display: flex; align-items: center; gap: 6px; }
.ch-legend i { width: 16px; border-top: 2px dashed currentColor; }
.ch-legend .ch-buy { color: var(--buy); } .ch-legend .ch-sell { color: var(--sell); } .ch-legend .ch-today { color: var(--muted); }
.ch-legend b { color: var(--ink); }
.ch-caption { margin: 4px 6px 4px; font-size: 13px; color: var(--muted); }

/* My stocks, Settings, People */
.minepage, .settingspage, .peoplepage { display: grid; gap: 16px; max-width: 1180px; }
.settingspage, .peoplepage { max-width: 560px; }
.minepage .rtitle, .settingspage .rtitle, .peoplepage .rtitle { margin: 0; }
.minepage .rsub, .settingspage .rsub, .peoplepage .rsub { margin: -10px 0 0; }
.msec { margin: 8px 0 0; font-size: 20px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.mrow { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.mrow.reached { border-left: 4px solid var(--sell); }
.mrow-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.mrow-line { margin: 0; font-size: 14.5px; }
.mrow-line.sell { color: var(--sell); }
.mrow-line.strong { font-weight: 600; }
.mrow-actions { display: grid; gap: 8px; margin-top: auto; }
.mrow-actions.two { grid-template-columns: 1fr 1fr; }
.mrow-actions .btn { padding: 10px 8px; }
.badge-sell { flex: none; padding: 3px 10px; border: 1px solid var(--sell); border-radius: 999px; font-size: 13px; font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; font-weight: 400; }
.gain { color: var(--buy); } .loss { color: var(--sell); }
.settings-form > .btn { margin-top: 8px; }
.settings-lang .lang { margin-top: 4px; width: max-content; }
.settings-lang .lang button { padding: 0 16px; }
.invite-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.invite-form > .btn { margin-top: 4px; }
.plist { list-style: none; margin: 0; padding: 0; }
.prow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.prow:first-child { border-top: 0; }
.prow-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.prow-actions { display: flex; gap: 8px; }
.prow-actions .btn { width: auto; min-width: 96px; padding: 8px 14px; }
.prow-confirm { flex-basis: 100%; }
.prow-confirm p { margin: 0 0 8px; font-size: 14.5px; }
@media (max-width: 420px) { .invite-pair { grid-template-columns: 1fr; } .mrow-actions.two { grid-template-columns: 1fr; } }
