/* All colours and fonts come from CSS variables set from the theme (theme.json / orgs.settings_json).
   Do not add colour values here. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-body); font-size: 17px; line-height: 1.5;
  color: var(--color-text); background: var(--color-bg);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
h1, h2, h3 { color: var(--color-heading); line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
a { color: var(--color-primary); }
p { margin: 0 0 .8em; }
img { max-width: 100%; }
.loading { padding: 2rem 1rem; color: var(--color-text-muted); }
.muted { color: var(--color-text-muted); font-size: .92rem; }
.small { font-size: .85rem; }
.hidden, [hidden] { display: none !important; }

/* Header: DHF lead brand left, Be Learning partner right */
.app-header {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--color-card); border-bottom: 3px solid var(--color-primary);
}
.brand-lead img { height: 32px; display: block; }
.brand-partner { display: flex; align-items: center; }
.brand-partner img { height: 38px; width: 38px; display: block; }
.brand-fallback { font-weight: 700; }
.brand-lead .brand-fallback { color: var(--color-primary); font-size: .95rem; }
.brand-partner .brand-fallback { color: var(--be-dark-grey); font-family: var(--font-program); font-size: .8rem; }

main { max-width: 640px; margin: 0 auto; padding: 16px; outline: none; }

/* Bottom tab bar, one-handed use */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex;
  background: var(--color-card); border-top: 1px solid var(--color-border-soft);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 10px;
  min-height: 60px; font-size: .72rem; color: var(--color-text-muted); text-decoration: none;
}
.tabbar a span { font-size: 1.3rem; line-height: 1; }
.tabbar a.active { color: var(--color-primary); font-weight: 700; }
.tabbar a.tab-field span { color: var(--color-primary); }

/* Cards and panels */
.card { background: var(--color-card); border: 1px solid var(--color-border-soft); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.card.surface { background: var(--color-surface); border-color: var(--color-surface); }
.card.attention { background: var(--color-attention-surface); border-color: var(--color-attention-surface); }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack > * + * { margin-top: 10px; }

/* Be Learning program elements: session cards, step badges, progress */
.program { font-family: var(--font-program); }
.badge {
  display: inline-block; font-family: var(--font-program); font-weight: 700; font-size: .78rem;
  padding: 3px 10px; border-radius: 999px; background: var(--be-orange); color: var(--be-on-orange);
}
.badge.soft { background: var(--be-light-grey); color: var(--be-dark-grey); }
.session-card { background: var(--color-card); border-left: 5px solid var(--be-orange); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; border-top: 1px solid var(--color-border-soft); border-right: 1px solid var(--color-border-soft); border-bottom: 1px solid var(--color-border-soft); }
.session-card.locked { border-left-color: var(--be-light-grey); opacity: .75; }
.session-card h3 { font-family: var(--font-program); margin: 6px 0 4px; }
.program-panel { background: var(--be-light-grey); color: var(--be-dark-grey); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.program-panel h2, .program-panel h3 { font-family: var(--font-program); color: var(--be-dark-grey); }
.progress { height: 10px; background: var(--be-light-grey); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--be-orange); }

/* Buttons: large tap targets */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 12px 18px;
  border-radius: 10px; border: 2px solid var(--color-primary); background: var(--color-primary); color: var(--color-on-primary);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; text-align: center;
}
.btn:hover, .btn:focus-visible { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn:active { background: var(--color-primary-darker); }
.btn.block { display: flex; width: 100%; }
.btn.secondary { background: var(--color-card); color: var(--color-primary); }
.btn.secondary:hover { background: var(--color-surface); }
.btn.program-btn { background: var(--be-orange); border-color: var(--be-orange); color: var(--be-on-orange); font-family: var(--font-program); }
.btn.link { background: none; border: none; color: var(--color-primary); min-height: 44px; padding: 8px; text-decoration: underline; font-weight: 400; }
.btn[disabled] { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--color-primary-light); outline-offset: 2px; }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick .btn { min-height: 64px; font-size: .95rem; }
.quick .btn:last-child:nth-child(odd) { grid-column: span 2; }

/* Forms */
label { display: block; font-weight: 700; margin: 14px 0 6px; color: var(--color-heading); }
label .hint { display: block; font-weight: 400; color: var(--color-text-muted); font-size: .88rem; }
input[type=text], input[type=email], input[type=number], input[type=time], select, textarea {
  width: 100%; font: inherit; padding: 12px; min-height: 48px; border: 1px solid var(--color-border); border-radius: 8px;
  background: var(--color-card); color: var(--color-text);
}
textarea { min-height: 96px; resize: vertical; }
.scale { display: flex; gap: 6px; }
.scale button {
  flex: 1; min-height: 48px; border-radius: 8px; border: 1px solid var(--color-border); background: var(--color-card);
  font: inherit; font-weight: 700; color: var(--color-text); cursor: pointer;
}
.scale button[aria-pressed=true] { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--color-border); background: var(--color-card);
  font: inherit; color: var(--color-text); cursor: pointer;
}
.chips button[aria-pressed=true] { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.error { color: var(--color-error); font-weight: 700; }
.success { color: var(--color-success); font-weight: 700; }
.privacy-note { font-size: .82rem; color: var(--color-text-muted); margin-top: 6px; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.bubble p:last-child { margin-bottom: 0; }
.bubble.user { align-self: flex-end; background: var(--color-primary); color: var(--color-on-primary); border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--color-card); border: 1px solid var(--color-border-soft); border-bottom-left-radius: 4px; }
.bubble.member { background: var(--color-surface); }
.bubble .who { display: block; font-size: .72rem; font-weight: 700; color: var(--color-text-muted); margin-bottom: 2px; }
.composer { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); background: var(--color-bg); padding: 8px 0; }
.composer textarea { min-height: 56px; }
.composer .row { margin-top: 8px; }
.composer .row .btn { flex: 1; }
.typing::after { content: '...'; }

/* Rubric */
.rubric { width: 100%; border-collapse: collapse; font-size: .92rem; }
.rubric td { padding: 8px 4px; border-bottom: 1px solid var(--color-border-soft); vertical-align: top; }
.rating { font-weight: 700; white-space: nowrap; }
.rating.consistent { color: var(--color-success); }
.rating.developing { color: var(--color-primary); }
.rating.not-yet { color: var(--color-text-muted); }

/* Charts */
.chart { width: 100%; height: auto; }
.chart .line { fill: none; stroke: var(--color-primary); stroke-width: 3; }
.chart .dot { fill: var(--color-primary); }
.chart .axis { stroke: var(--color-border); }
.chart text { fill: var(--color-text-muted); font-size: 11px; }
.bars .bar-row { display: grid; grid-template-columns: 96px 1fr 1fr; gap: 8px; align-items: center; font-size: .88rem; margin-bottom: 6px; }
.bar { height: 12px; border-radius: 6px; background: var(--color-surface); position: relative; overflow: hidden; }
.bar > span { position: absolute; inset: 0 auto 0 0; background: var(--color-primary-light); }
.bar.now > span { background: var(--color-primary); }

.weeks { display: grid; grid-template-columns: repeat(13, 1fr); gap: 4px; }
.weeks span { aspect-ratio: 1; border-radius: 4px; background: var(--color-border-soft); }
.weeks span.done { background: var(--color-success); }
.weeks span.missed { background: var(--color-border); }
.weeks span.paused { background: var(--color-surface); border: 1px dashed var(--color-border); }
.weeks span.open { background: var(--be-orange); }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--color-text-strong); color: var(--color-on-primary); padding: 10px 16px; border-radius: 8px;
  max-width: 90vw; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30;
}
#toast.show { opacity: 1; }

dialog { border: none; border-radius: 12px; padding: 20px; max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: var(--color-overlay); }

/* Login */
.login { max-width: 420px; margin: 8vh auto 0; text-align: center; }
.login .lead-logo { height: 84px; max-width: 100%; margin: 0 auto 16px; display: block; }
.partner-lockup { display: inline-flex; align-items: center; gap: 10px; margin-top: 20px; color: var(--be-dark-grey); font-family: var(--font-program); font-size: .9rem; }
.partner-lockup img { height: 52px; width: 52px; display: block; }
.login form { text-align: left; }
.footer-note { text-align: center; margin-top: 24px; }
