/* Nawodaya. Every font is served from this canister: nothing loads from outside. */
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/BricolageGrotesque-Regular.ttf") format("truetype"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/BricolageGrotesque-Bold.ttf") format("truetype"); font-weight: 700 800; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("fonts/InstrumentSans-Regular.ttf") format("truetype"); font-weight: 400 500; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("fonts/InstrumentSans-Bold.ttf") format("truetype"); font-weight: 600 800; font-display: swap; }
/* Sinhala letters (Noto Sans Sinhala, OFL). Only downloaded when Sinhala text is on screen. */
@font-face { font-family: "Noto Sans Sinhala"; src: url("fonts/NotoSansSinhala-400.woff2") format("woff2"); font-weight: 400 500; font-display: swap; unicode-range: U+0D80-0DFF, U+200C-200D, U+25CC; }
@font-face { font-family: "Noto Sans Sinhala"; src: url("fonts/NotoSansSinhala-600.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0D80-0DFF, U+200C-200D, U+25CC; }
@font-face { font-family: "Noto Sans Tamil"; src: url("fonts/NotoSansTamil-400.woff2") format("woff2"); font-weight: 400 500; font-display: swap; unicode-range: U+0B80-0BFF, U+200C-200D, U+25CC; }
@font-face { font-family: "Noto Sans Tamil"; src: url("fonts/NotoSansTamil-600.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0B80-0BFF, U+200C-200D, U+25CC; }
@font-face { font-family: "Noto Sans Tamil"; src: url("fonts/NotoSansTamil-700.woff2") format("woff2"); font-weight: 700 800; font-display: swap; unicode-range: U+0B80-0BFF, U+200C-200D, U+25CC; }
@font-face { font-family: "Noto Sans Sinhala"; src: url("fonts/NotoSansSinhala-700.woff2") format("woff2"); font-weight: 700 800; font-display: swap; unicode-range: U+0D80-0DFF, U+200C-200D, U+25CC; }

:root {
  /* Warm sunrise amber. --accent: text and links (readable on white).
     --primary: button colour. --fill: lines, bars and sliders. */
  --bg: #fdf9f2; --surface: #ffffff; --ink: #2a2015; --muted: #6f6252; --line: #efe4d2;
  --accent: #b45309; --accent-ink: #9a4507; --accent-soft: #fdf1dc; --on-accent: #ffffff;
  --primary: #f5a524; --on-primary: #2b1a03; --fill: #d97706;
  /* Green = progress and good news (pain down, goals reached, sessions done, on track). */
  --good: #15803d; --good-soft: #dcfce7;
  --warn: #9a5b08; --warn-soft: #fbeccf; --bad: #b3382c; --bad-soft: #fbe3df;
  --font-display: "Bricolage Grotesque", "Noto Sans Sinhala", "Noto Sans Tamil", "Segoe UI", system-ui, sans-serif;
  --font-body: "Instrument Sans", "Noto Sans Sinhala", "Noto Sans Tamil", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
/* Dark mode only when the person picks it with the switch (everyone starts in light). */
:root[data-theme="dark"] {
  --bg: #1a150e; --surface: #241d14; --ink: #f4ede2; --muted: #b3a690; --line: #3b3122;
  --accent: #fbbf4e; --accent-ink: #fbbf4e; --accent-soft: #3a2c12; --on-accent: #2b1a03;
  --primary: #f5a524; --on-primary: #2b1a03; --fill: #f5a524;
  --good: #4ade80; --good-soft: #13301f;
  --warn: #e5a94b; --warn-soft: #3a2c12; --bad: #ef7b6e; --bad-soft: #3d1d1a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
h1, h2, h3 { margin: 0; text-wrap: balance; font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); font-size: 13px; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.hidden { display: none !important; }

header.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: none; margin: 0; padding: 12px 28px 0; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 24px; }
.top-in > nav { margin-left: auto; }
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-weight: 700; font-size: 24px; padding-bottom: 12px; color: var(--ink); text-decoration: none; }
.brand:hover .word { opacity: .85; }
/* The logo runs from the top of the "N" in the name to the bottom of the caption's letters. */
.brand { gap: 11px; align-items: flex-start; }
.brand .logo { flex: none; display: block; width: 36.5px; height: 36.5px; margin-top: 5.2px; }
.brand .word span { color: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand small { font-family: var(--font-body); font-weight: 500; font-size: 12px; color: var(--muted); margin-top: 3px; letter-spacing: 0; }
nav { display: flex; gap: 2px; flex-wrap: wrap; align-items: flex-end; }
nav a { text-decoration: none; border-bottom: 3px solid transparent; padding: 10px 14px; font-weight: 600; color: var(--muted); }
nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.theme-toggle { background: none; border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 30px; display: inline-grid; place-items: center; cursor: pointer; color: var(--muted); padding: 0; }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.top-in > .theme-toggle { margin-bottom: 12px; }
.top-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.lang-select { background: var(--surface, transparent); border: 1px solid var(--line); border-radius: 8px; height: 30px; padding: 0 6px; cursor: pointer; color: var(--muted); font: 600 13px var(--font-body); }
.lang-select:hover, .lang-select:focus { color: var(--accent); border-color: var(--accent); }
.physio .top2 { flex-wrap: wrap; }
/* Sinhala reads better with a little more room and no tightened letter spacing. */
:lang(si) body, :lang(ta) body { line-height: 1.6; }
/* Tamil words are long: smaller headings and labels keep layouts from breaking. */
:lang(ta) h1 { font-size: clamp(24px, 3.2vw, 34px); }
:lang(ta) .stat .k, :lang(ta) th, :lang(ta) .field > label, :lang(ta) .lab { letter-spacing: 0; text-transform: none; }
:lang(ta) h1, :lang(ta) h2, :lang(ta) h3, :lang(ta) .brand { letter-spacing: 0; }
:lang(si) h1, :lang(si) h2, :lang(si) h3, :lang(si) .brand { letter-spacing: 0; }
:lang(si) .stat .k, :lang(si) th, :lang(si) .field > label, :lang(si) .lab { letter-spacing: 0; }
nav .who { padding: 10px 0 10px 14px; font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.devbar { background: var(--warn-soft); color: var(--warn); font-size: 13px; padding: 6px 16px; text-align: center; }

main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 56px; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px 16px; margin-bottom: 18px; }
.head p { color: var(--muted); max-width: 65ch; margin-top: 4px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.card > h2 { margin-bottom: 12px; }
.card.warnbox { border-color: var(--warn); }
.narrow { max-width: 560px; margin: 32px auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat .k { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1.15; }
.stat .v small { font-size: 15px; font-weight: 500; color: var(--muted); }
.stat .s { font-size: 13px; color: var(--muted); }

.cols { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.trio { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.brand { background: var(--accent-soft); color: var(--accent-ink, var(--accent)); }
.good-text { color: var(--good); font-weight: 600; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.mute { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.btn { display: inline-block; text-decoration: none; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; color: var(--ink); }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.05); color: var(--on-primary); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .goal { stroke: var(--good); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .line { fill: none; stroke: var(--fill); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent-soft); opacity: .6; }
.chart .dot { fill: var(--surface); stroke: var(--fill); stroke-width: 2; }
.chart .dot.last { fill: var(--fill); }
.chart .lbl { fill: var(--ink); font-weight: 700; font-size: 12px; }
.chart .goaltxt { fill: var(--good); font-weight: 600; }
.logger { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.logger label { font-weight: 600; }
.logger input[type=range] { flex: 1 1 160px; accent-color: var(--fill); }
.logger output { font-family: var(--font-display); font-weight: 700; font-size: 22px; min-width: 28px; text-align: center; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li.done { color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; flex: 1; }
/* Tick boxes: no browser margin (so they line up with headings), centred on the first line of text. */
.check input, .flags input, .opts input { width: 18px; height: 18px; margin: 3px 0 0 0; accent-color: var(--accent); flex: none; }
.flags label, .opts label, .check { line-height: 1.5; }

.bar { height: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0 12px; }
.bar > i { display: block; height: 100%; background: var(--fill); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.note { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-top: 12px; }

.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label, .field > .lab { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field select, .field input[type=text], .field input[type=tel], .field input[type=number], .field input[type=date] { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; }
.field.wide { grid-column: 1 / -1; }
.form > .pf-private { grid-column: 1 / -1; margin: -4px 0 0; }
.bad-text { color: var(--bad); }
.flags { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.cleared { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.flags label, .opts label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }

.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 14px; margin-top: 4px; }
.urgent { background: var(--bad-soft); border: 1px solid var(--bad); color: var(--ink); border-radius: 12px; padding: 18px; margin-top: 16px; }
.urgent h2 { color: var(--bad); margin-bottom: 6px; }
.idbox { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 13px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; }

.physios { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-top: 16px; }
.physio { display: flex; flex-direction: column; gap: 10px; }
.physio .top2 { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; flex: none; }
.whobox { display: flex; gap: 12px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; color: var(--muted); }
#signout .so-icon { display: none; }
/* Prices: the rupee sign never ends a line on its own. */
:lang(ta) .physio .price { font-size: 17px; }
.chip.speaks { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.price { font-family: var(--font-display); font-weight: 700; font-size: 20px; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }
.spark { display: block; }
.spark polyline { fill: none; stroke: var(--fill); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--fill); }

.overlay { position: fixed; inset: 0; background: rgba(20, 10, 35, .55); display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; overflow-y: auto; z-index: 10; }
.modal { width: 100%; max-width: 540px; margin-top: 4vh; }
.modal h2 { margin-bottom: 10px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 600; z-index: 20; max-width: calc(100% - 32px); }
.toast.err { background: var(--bad); color: #fff; }
.list li .btn.sm, .pill { white-space: nowrap; }
td.nowrap, .nowrap { white-space: nowrap; }
.field > label.check { text-transform: none; letter-spacing: 0; font-size: 15px; font-weight: 500; color: var(--ink); }
.resched { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; color: var(--ink); }
/* Phones: buttons big enough to tap comfortably. */
@media (max-width: 760px) {
  .btn { min-height: 40px; }
  .btn.sm { min-height: 36px; padding: 6px 12px; }
  .theme-toggle { width: 38px; height: 36px; }
  .lang-select { height: 36px; max-width: 86px; }
  /* Sign-out shows only its icon (the words stay for screen readers), so the
     buttons pinned top right are the same width in every language. */
  #signout { display: inline-flex; align-items: center; width: 38px; padding: 0; justify-content: center; }
  #signout .so-icon { display: block; }
  #signout .so-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* Keep the name clear of the buttons pinned to the top right. */
  .brand { max-width: calc(100% - 186px); }
  .brand .word { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Long labels wrap instead of pushing rows off the screen. */
  .list li { flex-wrap: wrap; }
  .list li .pill, .physio .pill { white-space: normal; }
  .back { display: inline-block; padding: 8px 0; }
  .head .btn-row { width: 100%; }
}
.err-detail { overflow-wrap: anywhere; font-family: ui-monospace, monospace; font-size: 12px; }
details summary { cursor: pointer; }
.foot-note { margin-top: 28px; font-size: 13px; color: var(--muted); max-width: 80ch; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

@media (max-width: 860px) { .cols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1000px) { .brand small { display: none; } .brand { padding-bottom: 10px; gap: 9px; } .brand { align-items: center; } .brand .logo { width: 34px; height: 34px; margin-top: 0; } }
/* Phones: sign-out and theme stay top right; the menu becomes one scrollable row. */
@media (max-width: 760px) {
  .top-in { position: relative; padding-top: 10px; }
  .top-in > nav { width: 100%; margin-left: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .top-in > nav::-webkit-scrollbar { display: none; }
  nav a { white-space: nowrap; padding: 8px 12px; }
  .top-in { padding-left: 16px; padding-right: 16px; }
  nav .who { position: absolute; top: 10px; right: 16px; padding: 0; }
  nav .who > a { display: none; }
}
@media (max-width: 520px) { h1 { font-size: 24px; } }
@media (prefers-reduced-motion: no-preference) { .btn, nav a { transition: border-color .12s, color .12s; } }
td.num { white-space: nowrap; }
.note.good-note { background: var(--good-soft); }

/* Physio's plan editor */
.plan-ed textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; resize: vertical; }
.plan-rows { width: 100%; }
.plan-rows select, .plan-rows input[type="date"] { background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; font: inherit; font-size: 14px; }
.plan-rows td { vertical-align: middle; }
.plan-ed details summary, #change-plan > summary { cursor: pointer; }
#change-plan[open] > summary { margin-bottom: 8px; }

/* Commands to copy into a terminal */
pre.cmd { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 13px ui-monospace, monospace; overflow-x: auto; white-space: pre; margin: 6px 0 0; user-select: all; }

/* Copyright line at the bottom of every page */
.site-foot { text-align: center; font-size: 13px; color: var(--muted); padding: 28px 16px 32px; border-top: 1px solid var(--line); margin-top: 40px; }
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; margin-bottom: 10px; }
.foot-links a { color: var(--muted); font-weight: 600; text-decoration: none; }
.foot-links a:hover, .foot-links a:focus-visible { color: var(--accent); text-decoration: underline; }
/* About, Privacy, Contact */
.info-main { max-width: 760px; margin: 0 auto; }
.back-link { margin: 4px 0 12px; font-size: 14px; }
.back-link a { color: var(--muted); text-decoration: none; }
.back-link a:hover { color: var(--accent); }
.info-page h1 { margin-bottom: 10px; }
.info-page .lead { font-size: 17px; color: var(--ink, inherit); }
.info-page h2 { margin: 26px 0 8px; }
.info-page p, .info-page li { line-height: 1.7; max-width: 70ch; }
.info-page p + p { margin-top: 10px; }
.info-page ol, .info-page ul { padding-left: 1.4em; margin: 6px 0 0; }
.info-page li + li { margin-top: 8px; }
.info-page a { color: var(--accent); }
.info-page .updated { margin-top: 26px; }
.info-page ul + p, .info-page ol + p { margin-top: 10px; }
