/* Prostate Care Companion — shared design system
   Direction: human-approachable. Calm private-clinic posture.
   No severity colours, no risk red, no gamification. */

:root {
  --bg:      oklch(98% 0.004 240);
  --surface: oklch(100% 0 0);
  --fg:      oklch(20% 0.02 240);
  --muted:   oklch(50% 0.018 240);
  --border:  oklch(90% 0.006 240);
  --accent:  oklch(56% 0.12 170);

  --font-display: 'Söhne', 'Avenir Next', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;

  /* derived */
  --accent-ink:   oklch(40% 0.09 170);
  --accent-soft:  oklch(96.5% 0.025 170);
  --accent-line:  oklch(86% 0.05 170);
  --clinic:       oklch(52% 0.088 245);
  --clinic-ink:   oklch(38% 0.07 245);
  --clinic-soft:  oklch(96.5% 0.022 245);
  --clinic-line:  oklch(87% 0.04 245);
  --attention:     oklch(58% 0.09 72);
  --attention-soft:oklch(96.5% 0.03 78);
  --attention-line:oklch(87% 0.05 78);
  --fg-2:    oklch(34% 0.02 240);
  --sunken:  oklch(96.5% 0.005 240);

  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow-card: 0 1px 2px oklch(20% 0.02 240 / .05), 0 8px 24px -14px oklch(20% 0.02 240 / .22);
  --shadow-lift: 0 2px 4px oklch(20% 0.02 240 / .06), 0 18px 40px -20px oklch(20% 0.02 240 / .34);
  --nav-h: 0px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .display { font-family: var(--font-display); letter-spacing: -0.018em; text-wrap: balance; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); line-height: 1.16; margin: 0 0 .25rem; font-weight: 600; }
h2 { font-size: 1.24rem; line-height: 1.22; margin: 0 0 .38rem; font-weight: 600; }
h3 { font-size: 1.05rem; line-height: 1.28; margin: 0 0 .22rem; font-weight: 600; }
p  { margin: 0 0 .62rem; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }
a  { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- App shell: bottom tabs on mobile, rail on desktop ---------- */
.app { min-height: 100dvh; }
.main { padding: 0 0 40px; }
.wrap { width: min(100% - 32px, 760px); margin-inline: auto; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: oklch(100% 0 0 / .86);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-in { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em; }
.mark { width: 30px; height: 30px; flex: none; border-radius: 9px; background: var(--accent); display: grid; place-items: center; }
.mark svg { width: 17px; height: 17px; }
.topbar .spacer { margin-left: auto; }
.clinic-tag { font-size: .78rem; color: var(--muted); text-align: right; line-height: 1.25; }
.clinic-tag b { display: block; color: var(--fg-2); font-weight: 600; }

/* narrow screens get a horizontal nav strip at the top, not a fixed phone tab bar */
.tabbar {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: oklch(100% 0 0 / .95); backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 45;
}
.tabbar::-webkit-scrollbar { display: none; }
.tabbar a {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 14px; border-radius: 999px; white-space: nowrap;
  color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 600;
  transition: background .2s ease, color .2s ease;
}
.tabbar a svg { width: 19px; height: 19px; }
.tabbar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.tabbar a:hover:not([aria-current]) { background: var(--sunken); color: var(--fg-2); }

@media (min-width: 940px) {
  .app { display: grid; grid-template-columns: 268px minmax(0, 1fr); }
  .rail-col { border-right: 1px solid var(--border); background: var(--surface); }
  .rail-inner { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 22px 18px; gap: 26px; }
  .main { padding-bottom: 64px; }
  .wrap { width: min(100% - 56px, 880px); margin-inline: 0; margin-left: 40px; }
  .tabbar {
    position: static; background: none; border: 0; backdrop-filter: none;
    flex-direction: column; overflow: visible; gap: 3px; padding: 0;
  }
  .tabbar a {
    justify-content: flex-start; gap: 12px; white-space: normal;
    min-height: 46px; padding: 0 12px; border-radius: var(--r-sm); font-size: .95rem; font-weight: 500;
  }
  .tabbar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
  .tabbar a:hover:not([aria-current]) { background: var(--sunken); }
  .rail-foot { margin-top: auto; }
  .desk-only { display: block; }
}

@media (max-width: 939px) {
  .desk-only { display: none; }
  .rail-col .rail-inner > *:not(.tabbar) { display: none; }
  .rail-col { display: contents; }
  /* the nav strip leads the page here, so the brand bar would only push content down */
  .topbar { display: none; }
}

/* ---------- Page header ---------- */
.page-head { padding: 18px 0 2px; }
.eyebrow { font-size: .74rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin: 0 0 .34rem; }
.lede { color: var(--muted); font-size: 1.02rem; max-width: 56ch; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--shadow-card);
}
.card + .card, .stack > * + * { margin-top: 10px; }
.stack-lg > * + * { margin-top: 18px; }
.card-tight { padding: 13px 15px; }
a.card, button.card { display: block; width: 100%; text-align: left; text-decoration: none; color: inherit; font: inherit; cursor: pointer; transition: box-shadow .22s ease, transform .22s ease, border-color .22s ease; }
a.card:hover, button.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); border-color: var(--accent-line); }
.card-accent { border-color: var(--accent-line); background: linear-gradient(var(--accent-soft), var(--surface) 62%); }
.card-clinic { border-color: var(--clinic-line); background: var(--clinic-soft); box-shadow: none; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin: 22px 0 9px; }
.section-head h2 { margin: 0; }
.section-head .count { margin-left: auto; font-size: .82rem; color: var(--muted); font-weight: 600; }

/* ---------- Chips & meta ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font-size: .76rem; font-weight: 600; letter-spacing: .005em;
  background: var(--sunken); color: var(--fg-2); border: 1px solid var(--border); white-space: nowrap;
}
.chip-accent    { background: var(--accent-soft);   color: var(--accent-ink);   border-color: var(--accent-line); }
.chip-clinic    { background: var(--clinic-soft);   color: var(--clinic-ink);   border-color: var(--clinic-line); }
.chip-attention { background: var(--attention-soft); color: var(--attention);   border-color: var(--attention-line); }
.chip-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.meta { font-size: .85rem; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; gap: 14px; justify-content: space-between; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 46px; padding: 0 20px; border-radius: var(--r-md);
  font-family: var(--font-body); font-size: 1rem; font-weight: 600; letter-spacing: -.005em;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background .2s ease, box-shadow .2s ease, transform .12s ease, border-color .2s ease, color .2s ease;
}
.btn svg { width: 19px; height: 19px; flex: none; }
.btn-primary {
  background: var(--accent); color: oklch(100% 0 0);
  box-shadow: 0 1px 2px oklch(40% .09 170 / .3), 0 10px 20px -10px oklch(46% .1 170 / .6);
}
.btn-primary:hover { background: var(--accent-ink); box-shadow: 0 2px 4px oklch(40% .09 170 / .3), 0 14px 26px -12px oklch(46% .1 170 / .7); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--fg-2); }
.btn-ghost:hover { border-color: var(--accent-line); color: var(--accent-ink); background: var(--accent-soft); }
.btn-quiet { background: none; border-color: transparent; color: var(--muted); min-height: 44px; padding: 0 10px; }
.btn-quiet:hover { color: var(--accent-ink); background: var(--accent-soft); }
.btn-block { width: 100%; }
.btn-lg { min-height: 50px; font-size: 1.02rem; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------- Checklist ---------- */
.tasklist { list-style: none; margin: 0; padding: 0; }
.task {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 11px 14px; box-shadow: var(--shadow-card);
}
.task + .task { margin-top: 7px; }
.task-check {
  appearance: none; flex: none; margin: 1px 0 0; width: 26px; height: 26px;
  border: 2px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer;
  display: grid; place-items: center; transition: background .2s ease, border-color .2s ease;
}
.task-check::after {
  content: ""; width: 12px; height: 7px; border-left: 2.5px solid oklch(100% 0 0); border-bottom: 2.5px solid oklch(100% 0 0);
  transform: rotate(-45deg) scale(.4); opacity: 0; transition: opacity .18s ease, transform .18s ease; margin-top: -3px;
}
.task-check:hover { border-color: var(--accent); }
.task-check:checked { background: var(--accent); border-color: var(--accent); }
.task-check:checked::after { opacity: 1; transform: rotate(-45deg) scale(1); }
.task-body { min-width: 0; flex: 1; }
.task-title { font-weight: 600; font-size: 1rem; margin: 0 0 3px; }
.task:has(.task-check:checked) { background: var(--sunken); box-shadow: none; }
.task:has(.task-check:checked) .task-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border); }

/* ---------- Timeline ---------- */
.tl { list-style: none; margin: 0; padding: 0 0 0 30px; position: relative; }
.tl::before { content: ""; position: absolute; left: 8px; top: 12px; bottom: 12px; width: 2px; background: var(--border); border-radius: 2px; }
.tl > li { position: relative; padding-bottom: 11px; }
.tl > li::before {
  content: ""; position: absolute; left: -30px; top: 20px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--border);
}
.tl > li.is-done::before  { background: var(--accent); border-color: var(--accent); }
.tl > li.is-now::before   { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.tl > li.is-now > .card   { border-color: var(--accent-line); }

/* ---------- Form controls ---------- */
label.field { display: block; margin-bottom: 12px; }
.field > span.lab { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 6px; }
.field .hint { display: block; font-size: .84rem; color: var(--muted); margin-bottom: 8px; }
input[type=text], input[type=tel], input[type=email], input[type=date], input[type=time], select, textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--fg);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 11px 13px; min-height: 46px;
}
textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 19px center, right 13px center; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 40px; }

.optionset { display: grid; gap: 7px; }
.opt {
  display: flex; gap: 13px; align-items: flex-start; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 11px 14px; background: var(--surface);
  transition: border-color .2s ease, background .2s ease;
}
.opt:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.opt input { appearance: none; flex: none; width: 22px; height: 22px; margin: 1px 0 0; border: 2px solid var(--border); background: var(--surface); cursor: pointer; transition: border-width .15s ease, border-color .2s ease; }
.opt input[type=radio] { border-radius: 50%; }
.opt input[type=checkbox] { border-radius: 6px; }
.opt input:checked { border-color: var(--accent); border-width: 7px; }
.opt input[type=checkbox]:checked { border-width: 2px; background: var(--accent); }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt-body { min-width: 0; }
.opt-title { font-weight: 600; }
.opt-note { font-size: .86rem; color: var(--muted); }

.switch { position: relative; flex: none; width: 52px; height: 32px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 2; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: oklch(88% .008 240); transition: background .22s ease; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: oklch(100% 0 0); box-shadow: 0 1px 3px oklch(20% .02 240 / .3); transition: transform .22s cubic-bezier(.3,1.4,.5,1); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 3px solid var(--accent); outline-offset: 2px; }

.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale label { position: relative; }
.scale input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.scale span {
  display: grid; place-items: center; min-height: 46px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); font-weight: 600; font-size: .95rem; color: var(--fg-2); cursor: pointer; transition: all .18s ease;
}
.scale label:hover span { border-color: var(--accent-line); }
.scale input:checked + span { background: var(--accent); border-color: var(--accent); color: oklch(100% 0 0); }
.scale input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.scale-ends { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-top: 5px; }

/* ---------- Notes, banners ---------- */
.note { border-radius: var(--r-md); padding: 11px 14px; font-size: .9rem; line-height: 1.45; }
.note-quiet  { background: var(--sunken); color: var(--muted); border: 1px solid var(--border); }
.note-clinic { background: var(--clinic-soft); color: var(--clinic-ink); border: 1px solid var(--clinic-line); }
.note-accent { background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--accent-line); }
.disclaimer { display: flex; gap: 11px; align-items: flex-start; margin: 20px 0 0; }
.disclaimer svg { width: 19px; height: 19px; flex: none; margin-top: 2px; opacity: .75; }

/* ---------- Progress ---------- */
.bar { height: 8px; border-radius: 99px; background: var(--sunken); overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.steps { display: flex; gap: 6px; }
.steps > i { height: 5px; flex: 1; border-radius: 99px; background: var(--border); transition: background .3s ease; }
.steps > i.on { background: var(--accent); }

/* ---------- Photos ---------- */
.photo { border-radius: var(--r-lg); overflow: hidden; position: relative; background: var(--sunken); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-cap {
  position: absolute; left: 14px; bottom: 14px; right: 14px;
  background: oklch(100% 0 0 / .93); backdrop-filter: blur(8px);
  border-radius: var(--r-sm); padding: 10px 13px; box-shadow: var(--shadow-lift);
  font-size: .84rem; color: var(--fg-2); font-weight: 600;
}

/* ---------- Modal / sheet ---------- */
/* a centred web modal, reachable at every width. the old bottom-sheet variant
   put its close button off-screen in a narrow pane. */
.sheet {
  border: 0; padding: 0; background: none;
  width: min(100% - 32px, 560px); max-width: min(100% - 32px, 560px);
  max-height: 86dvh; overflow: visible;
}
.sheet::backdrop { background: oklch(20% .02 240 / .45); backdrop-filter: blur(3px); }
.sheet-in {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 22px; max-height: 86dvh; overflow-y: auto; box-shadow: var(--shadow-lift);
}
.sheet-grip { display: none; }
@media (min-width: 700px) {
  .sheet { width: min(100% - 48px, 600px); max-width: min(100% - 48px, 600px); }
  .sheet-in { padding: 26px; }
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 16px);
  background: var(--fg); color: oklch(100% 0 0); padding: 13px 18px; border-radius: 999px;
  font-size: .9rem; font-weight: 600; box-shadow: var(--shadow-lift); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease; max-width: calc(100% - 32px); text-align: center;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 940px) { #toast { bottom: 26px; } }

/* ---------- Utility ---------- */
.grid-2 { display: grid; gap: 10px; }
@media (min-width: 620px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.avatar { width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center; font-family: var(--font-display); font-weight: 600; font-size: .95rem; background: var(--clinic-soft); color: var(--clinic-ink); border: 1px solid var(--clinic-line); }
.avatar-accent { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-line); }
.divide { height: 1px; background: var(--border); margin: 11px 0; border: 0; }
@media print {
  .topbar, .tabbar, .no-print, #toast { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .card { box-shadow: none; break-inside: avoid; }
  .app { display: block; }
  .wrap { width: auto; margin: 0; }
}
