/* Page-level patterns (home, goal, lists, stock, login). Loaded after style.css.
   Colours come only from theme variables, so light and dark both work. */

/* ---------- base for simple pages ---------- */
.s-page h1 { font-size: 1.55rem; }
.s-page h2 { font-size: 1.15rem; }
.s-page .muted { color: var(--muted); }
.s-page .link-btn, .s-tap { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; justify-content: center; }
.s-page .data th a { display: inline-block; padding: 4px 0; }
.s-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.s-lead { font-size: 1rem; color: var(--text-2); margin: 0 0 .4em; max-width: 46rem; }
.s-label { font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.s-section-title { margin: 28px 0 12px; }
.s-btn-big { min-height: 46px; font-size: .96rem; padding: 10px 22px; }

/* ---------- home ---------- */
.s-hello { margin: 0 0 4px; }
.s-hello h1 { font-size: 1.5rem; margin-bottom: 0; }
.s-ask { font-size: .95rem; font-weight: 500; color: var(--muted); margin: 0; }
.home-first { margin-top: 18px; }
.home-ix { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.home-ix > .card { margin-bottom: 0; }
.ix-tile { display: grid; gap: 2px; color: var(--text); font-weight: 500; padding: 16px 18px 10px; }
.ix-tile:hover { text-decoration: none; border-color: var(--border-strong); }
.ix-name { font-size: .86rem; font-weight: 600; color: var(--text-2); }
.ix-value { font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; color: var(--navy); }
.ix-chg { font-size: .88rem; }
.ix-chg .chg { font-size: .9rem; }
.mk-spark.ix-spark { display: block; height: 56px; margin: 6px -6px 0; }

.s-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.s-tile {
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 2px; align-items: center;
  padding: 14px 16px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-weight: 500; text-decoration: none; transition: border-color .15s;
}
.s-tile:hover { text-decoration: none; border-color: var(--accent); }
.s-tile-ico { grid-row: 1 / span 2; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); }
.s-tile-ico .ico { width: 19px; height: 19px; }
.s-tile-title { font-size: .95rem; font-weight: 600; line-height: 1.3; }
.s-tile-text { font-size: .8rem; color: var(--muted); line-height: 1.4; }
.s-tile-text strong { color: var(--text-2); font-weight: 700; }

.s-mood { padding: 18px 20px; }
.s-mood-line { font-size: 1.08rem; font-weight: 600; line-height: 1.35; margin: 0; }
.s-mood-sub { margin: 4px 0 0; font-size: .9rem; color: var(--text-2); }
.ad-bar { display: flex; height: 6px; border-radius: 999px; overflow: hidden; margin: 14px 0 6px; background: var(--down); gap: 2px; }
.ad-up { background: var(--up); border-radius: 999px 0 0 999px; }
.ad-down { flex: 1; background: var(--down); border-radius: 0 999px 999px 0; }
.ad-legend { display: flex; justify-content: space-between; gap: 10px; font-size: .82rem; font-weight: 600; flex-wrap: wrap; }
.preview-sub { margin: 2px 0 4px; }
.home-lists .preview { padding-bottom: 8px; }
.home-lists .preview.bearish { border-left: 1px solid var(--border); }
.home-lists .preview.bearish h3 a { color: var(--down); }
.preview-head h3 a { color: var(--text); }
.preview-head h3 a:hover { color: var(--accent-ink); }

.s-expert { margin-top: 8px; }
.link-list { padding: 4px 0; margin-top: 16px; }
.lrow { display: flex; align-items: center; gap: 12px; padding: 13px 18px; color: var(--text); font-weight: 600; border-bottom: 1px solid var(--border); }
.lrow:last-child { border-bottom: 0; }
.lrow:hover { text-decoration: none; background: var(--surface-2); }
.lrow > .ico:first-child { color: var(--accent); width: 18px; height: 18px; }
.lrow > span { flex: 1; min-width: 0; }
.lrow-go { color: var(--muted); width: 16px; height: 16px; }
.s-chips { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.s-chips li { background: var(--surface-2); border-radius: 999px; padding: 4px 10px; font-size: .84rem; font-weight: 600; color: var(--text-2); }
.s-more-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 20px; }

/* ---------- empty / error ---------- */
.s-empty { text-align: center; padding: 32px 20px; }
.s-empty-ico { margin: 0 0 10px; line-height: 1; }
.s-empty-ico .ico-badge { width: 44px; height: 44px; border-radius: 12px; }
.s-error .s-lead { margin: 0 auto 1em; }
.s-error-actions { margin-top: 18px; }
.s-suggest { list-style: none; padding: 0; margin: 0 auto; display: grid; max-width: 32rem; text-align: left; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.s-suggest-item { display: flex; gap: 10px; align-items: center; min-height: 48px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.s-suggest li:last-child .s-suggest-item { border-bottom: 0; }
.s-suggest-item:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- goal: form ---------- */
.s-goal { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 16px; padding: 22px; }
.s-goal > input[type="hidden"] { display: none; }
.s-q { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; align-content: start; }
.s-q-text { display: block; font-size: .86rem; font-weight: 600; color: var(--text-2); line-height: 1.35; padding: 0; }
.s-q-num { display: none; }
.s-q input { width: 100%; min-height: 46px; font-size: 1.1rem; font-weight: 700; padding: 8px 14px; }
.s-hint { font-size: .78rem; font-weight: 500; color: var(--muted); }
.s-risk { grid-column: 1 / -1; }
.s-risk legend { margin-bottom: 8px; }
.s-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.s-choice { display: block; position: relative; cursor: pointer; min-width: 0; }
.s-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.s-choice-box {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  padding: 6px 10px; border-radius: 9px; color: var(--text-2); transition: background-color .15s, color .15s, box-shadow .15s;
}
.s-choice-ico { display: inline-flex; color: inherit; }
.s-choice-ico .ico { width: 16px; height: 16px; }
.s-choice-name { font-size: .92rem; font-weight: 700; }
.s-choice-line { display: none; }
.s-choice:hover .s-choice-box { color: var(--text); }
.s-choice input:checked + .s-choice-box { background: var(--surface); color: var(--accent-ink); box-shadow: 0 0 0 1px var(--border-strong); }
[data-theme="dark"] .s-choice input:checked + .s-choice-box { background: var(--accent-soft); box-shadow: none; }
.s-choice input:focus-visible + .s-choice-box { outline: 2px solid var(--accent); outline-offset: 1px; }
.s-risk-help { margin: 8px 0 0; font-size: .82rem; color: var(--muted); }
.s-risk-help span { display: none; }
.s-risk:has(input[value="safe"]:checked) .s-risk-help [data-for="safe"],
.s-risk:has(input[value="moderate"]:checked) .s-risk-help [data-for="moderate"],
.s-risk:has(input[value="aggressive"]:checked) .s-risk-help [data-for="aggressive"] { display: inline; }
.s-goal-actions { grid-column: 1 / -1; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.s-spin { font-weight: 600; color: var(--accent-ink); font-size: .9rem; }
.s-spin-ico { animation: s-rot 1s linear infinite; }
@keyframes s-rot { to { transform: rotate(360deg); } }
.s-examples { margin: 0 0 18px; }
.s-example-list { display: flex; flex-wrap: wrap; gap: 8px; }
.s-example { margin: 0; min-width: 0; }
.s-chip-btn { min-height: 34px; padding: 5px 12px; border-radius: 999px; font-size: .84rem; font-weight: 600; color: var(--text-2); white-space: normal; text-align: left; }

/* ---------- goal: result ---------- */
.s-verdict { border-left-width: 4px; }
.s-goal-recap { margin: 0 0 10px; color: var(--text-2); font-size: .9rem; }
.s-page .s-verdict-line { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; line-height: 1.25; margin: 0 0 6px; }
.s-verdict-line .ico-badge { width: 32px; height: 32px; border-radius: 9px; }
.s-verdict-why { font-size: .98rem; font-weight: 500; color: var(--text-2); margin: 0 0 12px; }
.s-code { margin: 12px 0 0; font-size: .76rem; color: var(--muted); }
.s-facts { list-style: none; padding: 0; margin: 8px 0; display: grid; }
.s-facts li { display: flex; gap: 12px; align-items: flex-start; font-size: .94rem; line-height: 1.5; padding: 9px 0; border-bottom: 1px solid var(--border); }
.s-facts li:last-child { border-bottom: 0; }
.s-fact-ico { flex-shrink: 0; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); color: var(--accent-ink); }
.s-fact-ico .ico { width: 15px; height: 15px; }
.s-fact-ico.up { color: var(--up); background: var(--up-bg); }
.s-fact-ico.down { color: var(--down); background: var(--down-bg); }
.s-fact-ico.flat { color: var(--muted); }
.s-fact-warn .s-fact-ico { color: var(--down); background: var(--down-bg); }
.s-fact-warn { color: var(--down); }
.s-pick-name { display: block; font-weight: 500; white-space: normal; }
.s-td-action { white-space: nowrap; }
.s-td-action form { display: inline; margin: 0; }

/* ---------- screener lists ---------- */
.s-list { padding: 0; overflow: hidden; }
.s-list-grid { display: grid; grid-template-columns: 1fr; }
.s-screen-card { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--border); color: var(--text); font-weight: 500; }
.s-screen-card:last-child { border-bottom: 0; }
.s-screen-card:hover { background: var(--surface-2); text-decoration: none; }
.s-screen-card.bearish { border-left: 0; }
.s-screen-ico { flex-shrink: 0; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); }
.s-screen-ico .ico { width: 18px; height: 18px; }
.s-screen-card.bearish .s-screen-ico { background: var(--down-bg); color: var(--down); }
.s-h1-badge { display: none !important; }
.s-page h1 > .ico, .s-page h2 > .ico { color: var(--accent); }
.s-screen-body { display: grid; gap: 1px; flex: 1; min-width: 0; }
.s-screen-title { font-weight: 600; font-size: .98rem; }
.s-screen-plain { color: var(--muted); font-size: .84rem; line-height: 1.4; }
.s-screen-card .count { flex-shrink: 0; }
.s-rules > summary { min-height: 24px; display: flex; align-items: center; font-size: .95rem; }
.s-rules { padding: 14px 18px; }
.s-rules[open] > summary { margin-bottom: 8px; }
.s-filters { padding: 16px; }
.s-filters label { flex: 1 1 180px; }
.s-filters input, .s-filters select { width: 100%; }
.s-count-line { font-size: .9rem; margin: 0 0 8px; color: var(--text-2); }
.s-legend { margin-top: 8px; }
.s-callout { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .95rem; }
.s-callout > .ico { color: var(--accent); }
.s-table { padding: 0; }
.s-table .data th:first-child, .s-table .data td:first-child { padding-left: 16px; }

/* ---------- stock page ---------- */
.stock-hero { padding: 20px 22px; }
.stock-hero .crumbs { margin-bottom: 10px; }
.stock-id h1 { margin: 0; font-size: 1.45rem; }
.stock-id p { margin: 2px 0 0; }
.stock-quote { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 14px 0 2px; }
.stock-quote .big { font-size: 2.1rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; color: var(--navy); }
.stock-asof { margin: 0; }
.s-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0 0; }
.s-actions #watch-btn form { margin: 0; }
.subnav {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  position: sticky; top: var(--topbar-h); z-index: 10; background: var(--bg);
  border-bottom: 1px solid var(--border); margin: 0 0 16px; padding: 0;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a { flex: none; padding: 11px 14px; color: var(--text-2); font-size: .9rem; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--accent-ink); text-decoration: none; border-bottom-color: var(--accent); }
.s-page section[id], .s-page [id="company"], .s-page [id="results"] { scroll-margin-top: calc(var(--topbar-h) + 56px); }
.s-meaning h2 { margin-bottom: .2em; display: flex; align-items: center; gap: 8px; }
.s-chart-title { font-size: 1.05rem; margin: 2px 2px 10px; }

/* ---------- login ---------- */
.s-login .s-lead { font-size: .95rem; color: var(--muted); }
.s-login .s-q-text { font-size: .86rem; }
.s-login .s-q input { font-size: 1rem; font-weight: 500; }
.s-login .btn { width: 100%; }

/* ---------- phones ---------- */
@media (max-width: 960px) {
  .home-ix { grid-template-columns: 1fr 1fr; }
  .home-ix > .mkt-card { grid-column: 1 / -1; }
  .s-tiles { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .s-page h1 { font-size: 1.35rem; }
  .home-ix { gap: 10px; }
  .ix-tile { padding: 12px 14px 8px; }
  .ix-value { font-size: 1.3rem; }
  .s-tiles { gap: 10px; }
  .s-tile { grid-template-columns: 1fr; padding: 14px; align-items: start; row-gap: 4px; }
  .s-tile-ico { grid-row: auto; width: 34px; height: 34px; margin-bottom: 6px; }
  .s-tile-title { font-size: .9rem; }
  .s-tile-text { font-size: .76rem; }
  .s-goal { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .s-goal-actions .btn { width: 100%; }
  .stock-hero { padding: 16px; }
  .stock-quote .big { font-size: 1.8rem; }
  .s-actions > * { flex: 1 1 160px; }
  .s-actions .btn, .s-actions #watch-btn .btn { width: 100%; }

  /* tables that turn into rows */
  .s-cardwrap { background: none; border: 0; box-shadow: none; padding: 0; overflow: visible; }
  .s-cardtable, .s-cardtable tbody, .s-cardtable tr, .s-cardtable td { display: block; width: 100%; }
  .s-cardtable thead { display: none; }
  .s-cardtable tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 6px 14px; margin-bottom: 10px; }
  .s-cardtable tbody tr:hover { background: var(--surface); }
  .data.s-cardtable td, .data.s-cardtable td:first-child {
    display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
    position: static; background: none; white-space: normal; text-align: right;
    padding: 7px 0; border-bottom: 1px solid var(--border); font-size: .9rem; min-width: 0;
  }
  .s-cardtable td::before { content: attr(data-label); font-weight: 500; color: var(--muted); text-align: left; font-size: .84rem; }
  .data.s-cardtable td:first-child { font-size: 1rem; justify-content: flex-start; text-align: left; padding: 9px 0; }
  .data.s-cardtable td:first-child::before { content: none; }
  .s-cardtable td:last-child { border-bottom: 0; }
  .s-cardtable .s-pick-name { flex-basis: 100%; }
  .s-cardtable .pill { white-space: normal; text-align: left; }
  .s-cardtable .s-td-action { justify-content: stretch; gap: 8px; padding-top: 10px; flex-wrap: nowrap; }
  .s-cardtable .s-td-action::before { content: none; }
  .s-cardtable .s-td-action > .btn { flex: 1; }
  .s-cardtable .s-td-action form { display: flex; }
}
@media (max-width: 380px) {
  .s-choice-ico { display: none; }
}
@media (prefers-reduced-motion: reduce) { .s-spin-ico { animation: none; } }

/* verdict badge colours */
.ico-badge.orange { background: color-mix(in srgb, var(--warn-bg) 70%, var(--down-bg)); color: var(--warn); }
.ico-badge.gray { background: var(--surface-2); color: var(--muted); }
@media (max-width: 720px) { .s-tile { align-content: start; } }
.s-goal-actions .s-spin { display: none; }
.s-goal-actions .s-spin.htmx-request { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 720px) {
  .data.s-cardtable td { justify-content: flex-end; gap: 6px; }
  .s-cardtable td::before { margin-right: auto; }
}
.table-wrap.s-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); }
.s-filters { gap: 12px; }
.s-filters label { flex: 1 1 140px; min-width: 0; }
.s-filters label:first-of-type { flex-basis: 220px; }
@media (max-width: 720px) {
  .s-filters label:first-of-type { flex-basis: 100%; }
  .s-filters { padding: 14px; }
}
.ad-legend a { text-decoration: none; }
.ad-legend a:hover { text-decoration: underline; }
.s-mood-more { margin: 10px 0 0; font-size: .86rem; font-weight: 600; display: flex; gap: 16px; flex-wrap: wrap; }
.s-mood-more a { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-ink); text-decoration: none; }
.cmp-inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cmp-inline input { width: 9.5rem; }
.home-wl .wl-events { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 6px; font-size: .92rem; }
.home-wl .wl-events .sym { margin-right: 6px; }
.stock-jump { position: sticky; top: var(--topbar-h, 56px); z-index: 5; display: flex; gap: 6px; overflow-x: auto;
  scrollbar-width: none; padding: 8px 2px; margin: 0 0 12px; background: var(--bg); border-bottom: 1px solid var(--border); }
.stock-jump::-webkit-scrollbar { display: none; }
.stock-jump a { flex: none; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: .82rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.stock-jump a:hover, .stock-jump a:focus-visible { border-color: var(--accent); color: var(--accent-ink); }
.t-card, .card[id] { scroll-margin-top: calc(var(--topbar-h, 56px) + 56px); }
.home-world { display: flex; gap: 14px; align-items: center; overflow-x: auto; scrollbar-width: none; margin: 10px 0 4px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-md, 12px); background: var(--surface);
  color: var(--text-2); text-decoration: none; font-size: .84rem; white-space: nowrap; }
.home-world::-webkit-scrollbar { display: none; }
.home-world-lab { font-weight: 700; color: var(--text); }
.home-world-item { flex: none; }
.home-search { margin: 4px 0 14px; width: 100%; }
.home-search input { width: 100%; height: 46px; font-size: 16px; border-radius: 12px; padding: 8px 14px;
  background: var(--surface); border: 1px solid var(--border); }
@media (min-width: 901px) { .home-search { display: none; } }
