/* The research lab's dashboard: a warm lab-notebook page, gold for the brand, and five tones
   (good, bad, wait, flat, best) that always come with a word and a mark, never colour alone. */
:root {
  --bg: #f5f1e8; --surface: #fffdf8; --surface-2: #f3eee3; --line: #e3dccd;
  --ink: #1e1b15; --ink-2: #514a3d; --ink-3: #8a816f;
  --gold: #a26f05; --gold-soft: #f6e8c6;
  --good: #1b7547; --good-soft: #e1f2e7;
  --bad: #b3261e; --bad-soft: #fbe5e1;
  --wait: #995700; --wait-soft: #fcecd4;
  --flat: #56606d; --flat-soft: #eceef1;
  --best: #8a5d00; --best-soft: #fbedc4;
  --link: #8a5a00;
  --shadow: 0 1px 2px rgba(60, 45, 10, .06), 0 6px 18px rgba(60, 45, 10, .05);
  --radius: 14px;
  --font: "Noto Sans Thai", "Noto Sans Thai UI", "Sarabun", "Leelawadee UI", "Thonburi", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12110d; --surface: #1b1914; --surface-2: #24211a; --line: #363125;
    --ink: #f0eadc; --ink-2: #c9bfaa; --ink-3: #8f8774;
    --gold: #e3b24b; --gold-soft: #3a2e12;
    --good: #5ccb8e; --good-soft: #15301f;
    --bad: #f2806f; --bad-soft: #3a1c17;
    --wait: #eeab4f; --wait-soft: #392810;
    --flat: #a9b2be; --flat-soft: #262a30;
    --best: #f0c45a; --best-soft: #3b2f10;
    --link: #e9bd5c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.65 var(--font);
  font-variant-numeric: tabular-nums; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
p { margin: 0 0 10px; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
small { font-size: 12px; }

/* ------------------------------------------------------------ header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-in { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.seal { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font: 700 15px/1 Georgia, "Times New Roman", serif; color: #3d2a00; letter-spacing: .5px;
  background: radial-gradient(circle at 32% 28%, #ffe9a8, #e0b04a 55%, #a87a14);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35), 0 1px 3px rgba(80, 55, 0, .3); }
.name { display: flex; flex-direction: column; line-height: 1.25; }
.name b { font-size: 17px; }
.name small { color: var(--ink-3); }
.top nav { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.top nav::-webkit-scrollbar { display: none; }
.top nav a { color: var(--ink-2); padding: 7px 12px; border-radius: 999px; white-space: nowrap; font-size: 14.5px; }
.top nav a:hover { background: var(--surface-2); text-decoration: none; }
.top nav a.on { background: var(--ink); color: var(--surface); }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 10px; }
.foot-note { max-width: 1180px; margin: 0 auto; padding: 18px 20px 36px; color: var(--ink-3); font-size: 13px; }

/* ------------------------------------------------------------ building blocks */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2, .block h2 { font-size: 18px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.block { margin: 8px 0 22px; }
.block > h2 { margin-bottom: 6px; }
.more { font-size: 14px; font-weight: 400; margin-left: auto; white-space: nowrap; }
.muted { color: var(--ink-3); font-size: 14px; }
.empty { color: var(--ink-3); font-style: normal; background: var(--surface-2); border: 1px dashed var(--line);
  border-radius: 10px; padding: 12px 14px; margin: 0; }
.lede { color: var(--ink-2); font-size: 16px; max-width: 760px; }
.lead { font-size: 16.5px; color: var(--ink); }
.eyebrow { color: var(--gold); font-size: 13px; font-weight: 600; letter-spacing: .3px; margin-bottom: 4px; }
.byline { color: var(--ink-3); font-size: 13.5px; margin-bottom: 8px; }
.code { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.count { font-size: 13px; color: var(--ink-3); background: var(--surface-2); border-radius: 999px; padding: 0 9px; font-weight: 500; }
.page-head { margin: 4px 0 20px; }
.page-head h1 { font-size: 28px; margin-bottom: 8px; }
.crumbs { font-size: 14px; color: var(--ink-3); margin-bottom: 12px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.split > .card { margin-bottom: 18px; }

/* chips: a mark + a word, coloured by tone */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; line-height: 1; padding: 5px 10px 5px 8px;
  border-radius: 999px; font-weight: 600; white-space: nowrap; vertical-align: middle; border: 1px solid transparent; }
.chip i { font-style: normal; font-size: 12px; }
.chip.good { color: var(--good); background: var(--good-soft); }
.chip.bad { color: var(--bad); background: var(--bad-soft); }
.chip.wait { color: var(--wait); background: var(--wait-soft); }
.chip.flat { color: var(--flat); background: var(--flat-soft); }
.chip.best { color: var(--best); background: var(--best-soft); border-color: var(--gold); }
.chip.plain { color: var(--ink-2); background: transparent; border-color: var(--line); font-weight: 500; padding-left: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.good { color: var(--good); } .bad { color: var(--bad); }

/* ------------------------------------------------------------ overview */
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 26px 28px 22px;
  margin-bottom: 14px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.hero::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--flat); }
.hero.tone-good::before { background: var(--good); } .hero.tone-best::before { background: var(--gold); }
.hero::after { content: "Au"; position: absolute; right: -10px; top: -38px; font: 700 190px/1 Georgia, serif;
  color: var(--gold); opacity: .07; pointer-events: none; }
.hero h1 { font-size: clamp(26px, 4vw, 38px); margin-bottom: 10px; letter-spacing: -.2px; }
.hero .lede { margin-bottom: 18px; }
.funnel { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.funnel li { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; position: relative; }
.funnel b { display: block; font-size: 26px; line-height: 1.2; }
.funnel span { color: var(--ink-2); font-size: 13.5px; }
.funnel .wait b { color: var(--wait); } .funnel .good b { color: var(--good); }
.funnel .best b { color: var(--best); } .funnel .bad b { color: var(--bad); }

.pulse { display: flex; flex-wrap: wrap; gap: 6px 22px; align-items: center; color: var(--ink-2); font-size: 14px;
  padding: 10px 4px 18px; }
.pulse b { color: var(--ink); font-weight: 600; }
.pulse em { font-style: normal; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.dot.warn { background: var(--wait); box-shadow: 0 0 0 4px var(--wait-soft); }

.steps { list-style: none; margin: 0; padding: 0; }
.step { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 0 0 16px; position: relative; }
.step::before { content: ""; position: absolute; left: 97px; top: 8px; bottom: -2px; width: 2px; background: var(--line); }
.step.last::before { display: none; }
.step > div { padding-left: 18px; position: relative; min-width: 0; }
.step > div::before { content: ""; position: absolute; left: -9px; top: 7px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--gold); }
.step .t { color: var(--ink-3); font-size: 13px; text-align: right; padding-top: 1px; white-space: nowrap; }
.job .who { margin-bottom: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.job .title { font-weight: 600; margin-bottom: 6px; }
.job .hyp, .task .hyp { color: var(--ink-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden; }
.mini { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.mini li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.mini li span { color: var(--ink-3); min-width: 74px; }
.decision { font-size: 14px; color: var(--ink-2); margin: 6px 0; }

.prose h2, .prose h3, .prose h4, .prose h5 { font-size: 16px; margin: 14px 0 6px; }
.prose > :first-child { margin-top: 0; }
.prose ul { margin: 4px 0 10px; padding-left: 20px; }
.prose code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.clamp { max-height: 520px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 82%, transparent); mask-image: linear-gradient(#000 82%, transparent); }
.clamp-sm { max-height: 150px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.feed li:last-child { border-bottom: 0; }
.feed .t { color: var(--ink-3); font-size: 13px; text-align: right; white-space: nowrap; }
.howto ul { margin: 0 0 10px; padding-left: 18px; }
.howto li { margin-bottom: 8px; }
.howto li .chip { margin: 2px 2px 2px 0; }

/* ------------------------------------------------------------ idea cards */
.ideas { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.idea { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 12px;
  display: flex; flex-direction: column; box-shadow: var(--shadow); border-top: 4px solid var(--flat); min-width: 0; }
.idea.tone-good { border-top-color: var(--good); } .idea.tone-bad { border-top-color: var(--bad); }
.idea.tone-wait { border-top-color: var(--wait); } .idea.tone-best { border-top-color: var(--gold); }
.idea h3 { font-size: 17px; margin-bottom: 4px; }
.idea h3 a { color: var(--ink); }
.results { margin: 6px 0 4px; display: grid; gap: 10px; }
.results .row { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.results dt { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.results dt small { color: var(--ink-3); font-weight: 400; margin-left: 4px; }
.results dd { margin: 0; }
.results dd.sub { color: var(--ink-2); font-size: 13.5px; margin-top: 5px; }
.idea .foot { margin-top: auto; padding-top: 10px; display: flex; justify-content: space-between; gap: 10px;
  color: var(--ink-3); font-size: 13.5px; border-top: 1px solid var(--line); margin-bottom: 0; }
.group > h2 .chip { font-size: 15px; padding: 7px 14px 7px 11px; }

/* ------------------------------------------------------------ one idea */
.idea-head { margin-bottom: 18px; }
.idea-head h1 { font-size: clamp(24px, 3.4vw, 32px); margin-bottom: 6px; }
.status-why { color: var(--ink-2); }
.periods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.period { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; border-top: 4px solid var(--line); min-width: 0; }
.period.tone-good { border-top-color: var(--good); } .period.tone-bad { border-top-color: var(--bad); }
.period.tone-wait { border-top-color: var(--wait); } .period.tone-flat { border-top-color: var(--flat); }
.period.is-empty { background: var(--surface-2); box-shadow: none; }
.period header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.period header b { font-size: 17px; } .period header small { color: var(--ink-3); }
.period .verdict { margin-bottom: 10px; }
.period .why { color: var(--ink-3); font-size: 13px; margin: auto 0 0; padding-top: 10px; }
.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.facts li { display: grid; grid-template-columns: 1fr auto; column-gap: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.facts li span { color: var(--ink-2); font-size: 14px; }
.facts li b { text-align: right; font-size: 14.5px; }
.facts li small { grid-column: 1 / -1; color: var(--ink-3); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; margin-bottom: 10px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; color: var(--ink-2); font: inherit; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.plot { height: 340px; }
.decision-box { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.decision-box .reason { color: var(--ink-2); margin: 6px 0 0; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.checklist li { display: grid; grid-template-columns: 28px 1fr; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .m { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--flat-soft); color: var(--flat); }
.checklist li.ok .m { background: var(--good-soft); color: var(--good); }
.checklist li.no .m { background: var(--bad-soft); color: var(--bad); }
.checklist p { margin: 2px 0; }
.checklist small { color: var(--ink-3); display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
details.more-text summary, details.expert > summary { cursor: pointer; color: var(--link); font-size: 14.5px; }
details.more-text { margin-top: 8px; } details.more-text p { margin-top: 6px; color: var(--ink-2); font-size: 14.5px; }
details.expert > summary { font-weight: 600; }
details.expert h3 { font-size: 15px; margin: 18px 0 8px; }
details.expert h3 small { color: var(--ink-3); font-weight: 400; }
.params { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin: 0; }
.params div { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; }
.params dt { color: var(--ink-3); font-family: var(--mono); font-size: 12px; } .params dd { margin: 0; font-weight: 600; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-3); font-weight: 500; }
td.num, th.num { text-align: right; } td.wrap { white-space: normal; min-width: 220px; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow: auto; max-height: 520px; }

/* ------------------------------------------------------------ tasks, reports, chart, guide */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.lane { background: var(--surface-2); border-radius: var(--radius); padding: 12px; min-width: 0; }
.lane > h2 { font-size: 15px; margin-bottom: 10px; display: flex; gap: 8px; align-items: center; }
.task { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow); }
.task h3 { font-size: 15.5px; margin-bottom: 4px; }
.reports { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.report-link { display: block; color: var(--ink); }
.report-link:hover { text-decoration: none; border-color: var(--gold); }
.report-full { max-width: 860px; }
.report-full figure { margin: 14px 0 0; } .report-full img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.controls { display: flex; gap: 10px 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.controls label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-3); }
.controls label.grow { flex: 1 1 280px; } .controls label.grow select { width: 100%; }
.controls .btns { display: flex; gap: 6px; flex-wrap: wrap; }
select, input, button { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font: inherit; font-size: 14.5px; min-height: 40px; }
button { cursor: pointer; font-weight: 600; }
button:hover { border-color: var(--gold); }
#go { background: var(--ink); color: var(--surface); border-color: var(--ink); }
#chart { height: 600px; }
.legend-inline { display: inline-flex; gap: 6px 12px; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); margin-left: 4px; }
.legend-inline i { font-style: normal; font-weight: 700; }
.legend-inline .buy { color: var(--good); } .legend-inline .sell { color: var(--bad); } .legend-inline .sl { color: var(--ink-3); }
.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin: 0; }
.glossary div { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.glossary dt { font-weight: 700; margin-bottom: 4px; } .glossary dd { margin: 0; color: var(--ink-2); font-size: 14.5px; }
.legend { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.login { max-width: 400px; margin: 40px auto; }
.login h1 { font-size: 24px; margin-bottom: 6px; }
.login input { width: 100%; } .login button { width: 100%; background: var(--ink); color: var(--surface); }

/* ------------------------------------------------------------ narrow screens */
@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; gap: 0; }
  .board { grid-template-columns: 1fr 1fr; }
  .periods { grid-template-columns: 1fr; }
  .funnel { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .top-in { padding: 8px 16px; gap: 8px; }
  .name small { display: none; }
  .top nav { margin: 0 -16px; padding: 0 16px 2px; width: calc(100% + 32px); }
  main { padding: 16px 16px 6px; }
  .foot-note { padding: 14px 16px 28px; }
  .hero { padding: 20px 18px 16px; }
  .hero::after { font-size: 130px; top: -24px; }
  .funnel { grid-template-columns: 1fr 1fr; gap: 8px; }
  .funnel li { padding: 8px 12px; }
  .funnel b { font-size: 22px; }
  .funnel li:first-child { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; }
  .hero h1 { font-size: 25px; }
  .hero .lede { font-size: 15px; }
  .pulse { gap: 2px 14px; font-size: 13.5px; }
  .card { padding: 16px; }
  .ideas, .reports, .glossary { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr; }
  .step { display: block; padding: 0 0 14px 24px; }
  .step::before { left: 6px; top: 8px; }
  .step .t { display: block; text-align: left; margin-bottom: 2px; position: relative; }
  .step .t::after { content: ""; position: absolute; left: -23px; top: 6px; width: 10px; height: 10px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--gold); }
  .step > div { padding-left: 0; }
  .step > div::before { display: none; }
  .facts li { grid-template-columns: 1fr; }
  .facts li b { text-align: left; }
  .feed li { grid-template-columns: 1fr; gap: 0; }
  .feed .t { text-align: left; }
  #chart { height: 440px; }
  .plot { height: 280px; }
}
