/* study-goals.css: study goals (Journal page), the goal screen and the Reports "at a glance" cards (study-goals.js).
   Tokens from city/nous-tokens.css (docs/design-system.md). Green = at or ahead of pace, red-orange = behind. */
.sg-home, .sg-card, .sg-sheet, .sg-screen, .sg-cheer { --sg-pad: 20px; font-family: inherit; color: var(--nx-ink, #363f51); }
.sg-hint { font-size: 13px; font-weight: 300; color: var(--nx-ink-soft, #7d8ca8); line-height: 1.4; }
.sg-hint.is-behind { color: var(--nx-warn, #f97316); }
.sg-h4 { font-size: 15px; font-weight: 400; color: var(--nx-brand-ink, #4a69b0); margin-bottom: 12px; }
.sg-num { font-size: 22px; font-weight: 300; color: var(--nx-ink-deep, #252d3d); letter-spacing: -0.01em; line-height: 1.2; }
.sg-num--big { font-size: 34px; }
.sg-num.is-good { color: var(--nx-good-ink, #047857); font-size: 17px; }
.sg-num.is-behind { color: var(--nx-warn, #f97316); font-size: 17px; }
.sg-ic { flex: none; }

/* ---- pace bars ---- */
.sg-bar { position: relative; height: 10px; border-radius: 999px; background: var(--nx-surface-2, #f1f3f7); margin-top: 8px; }
.sg-bar.is-thin { height: 6px; }
.sg-fill { position: relative; height: 100%; border-radius: inherit; background: var(--nx-good, #10b981); transition: width .5s ease; }
.sg-fill.is-behind { background: linear-gradient(90deg, var(--nx-danger, #ef4444), var(--nx-warn, #f97316)); }
.sg-fill.is-done { background: var(--nx-good, #10b981); }
.sg-pace-tick { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 2px dashed var(--nx-ink-mute, #9aa5b8); transform: translateX(-1px); }

/* ---- Journal section ---- */
.sg-home { background: var(--nx-surface, #fff); border-radius: 20px; padding: 18px var(--sg-pad) 14px; box-shadow: 0 2px 12px rgba(99,110,129,.08), 0 1px 4px rgba(99,110,129,.04); }
.sg-home__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sg-home__head h3 { font-size: 20px; font-weight: 300; color: var(--nx-ink-strong, #1f2937); }
.sg-home__rows { display: flex; flex-direction: column; }
.sg-hrow { display: block; width: 100%; text-align: left; padding: 12px 0; border-top: 1px solid var(--nx-line-soft, #eef1f5); background: none; cursor: pointer; }
.sg-hrow:first-child { border-top: 0; }
.sg-hrow:focus-visible { outline: 2px solid var(--nx-brand, #6b8dd6); outline-offset: 2px; border-radius: 8px; }
.sg-hrow__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sg-hrow__name { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; font-weight: 400; color: var(--nx-brand-ink, #4a69b0); }
.sg-hrow__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-hrow__right { flex: none; font-size: 14px; font-weight: 500; color: var(--nx-good-ink, #047857); font-variant-numeric: tabular-nums; }
.sg-hrow__right.is-behind { color: var(--nx-warn, #f97316); }
.sg-hrow__sub { margin-top: 6px; font-size: 12px; font-weight: 300; color: var(--nx-ink-soft, #7d8ca8); }
.sg-hrow__sub.is-nudge { color: var(--nx-warn, #f97316); font-weight: 400; }
.sg-setup p { font-size: 14px; font-weight: 300; color: var(--nx-ink-soft, #7d8ca8); margin-bottom: 10px; }

/* ---- buttons, chips, fields ---- */
.sg-round { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 999px; background: var(--nx-surface, #fff); color: var(--nx-ink, #363f51); box-shadow: 0 2px 10px rgba(99,110,129,.14); flex: none; }
.sg-round--sm { width: 36px; height: 36px; box-shadow: none; background: var(--nx-brand-wash, #edf2fb); color: var(--nx-brand-ink, #4a69b0); }
.sg-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.sg-chips.is-small { gap: 6px; margin: 4px 0 0; }
.sg-chip { padding: 8px 14px; border-radius: 999px; font-size: 13px; background: var(--nx-surface-2, #f1f3f7); color: var(--nx-ink, #363f51); min-height: 36px; }
.sg-chips.is-small .sg-chip { padding: 4px 10px; min-height: 28px; font-size: 12px; }
.sg-chip.is-on { background: var(--nx-brand, #6b8dd6); color: var(--nx-on-accent, #fff); }
.sg-link { font-size: 14px; color: var(--nx-brand-ink, #4a69b0); padding: 8px 0; background: none; }
.sg-btn { padding: 11px 18px; border-radius: 12px; font-size: 14px; background: var(--nx-brand, #6b8dd6); color: var(--nx-on-accent, #fff); min-height: 44px; }
.sg-btn:disabled { opacity: .45; }
.sg-btn--ghost { background: var(--nx-surface-2, #f1f3f7); color: var(--nx-ink, #363f51); }
.sg-btn--danger { background: var(--nx-danger, #ef4444); color: #fff; }
.sg-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.sg-x { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; color: var(--nx-ink-soft, #7d8ca8); flex: none; }
.sg-editor { display: flex; flex-direction: column; gap: 10px; }
.sg-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.sg-field > span { font-size: 12px; color: var(--nx-ink-soft, #7d8ca8); }
.sg-input { width: 100%; min-width: 0; border: 1px solid var(--nx-line, #e3e7ee); border-radius: 10px; padding: 9px 10px; font-size: 15px; background: var(--nx-surface, #fff); color: var(--nx-ink, #363f51); }
.sg-input--num { max-width: 84px; }
.sg-row2 { display: flex; gap: 8px; align-items: flex-end; }
.sg-icons { display: flex; flex-wrap: wrap; gap: 6px; }
.sg-iconpick { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: var(--nx-ink-soft, #7d8ca8); background: var(--nx-surface-2, #f1f3f7); }
.sg-iconpick.is-on { background: var(--nx-brand-wash, #edf2fb); color: var(--nx-brand-ink, #4a69b0); box-shadow: inset 0 0 0 2px var(--nx-brand, #6b8dd6); }
.sg-ms-edit { border-top: 1px solid var(--nx-line-soft, #eef1f5); padding-top: 10px; }
.sg-ms-card { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px dashed var(--nx-line, #e3e7ee); border-radius: 12px; margin: 8px 0; }
.sg-pick { display: flex; flex-direction: column; gap: 8px; }
.sg-pick__item { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--nx-surface-2, #f1f3f7); text-align: left; color: var(--nx-brand-ink, #4a69b0); }
.sg-pick__item span { display: flex; flex-direction: column; }
.sg-pick__item b { font-weight: 500; font-size: 15px; }
.sg-pick__item small { font-size: 12px; color: var(--nx-ink-soft, #7d8ca8); }

/* ---- sheets and the cheer ---- */
.sg-scrim { position: fixed; inset: 0; z-index: 70; background: rgba(15,23,42,.4); display: flex; align-items: flex-end; justify-content: center; }
.sg-scrim--center { align-items: center; }
.sg-sheet { width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; background: var(--nx-surface, #fff); border-radius: 22px 22px 0 0; padding: 18px var(--sg-pad) calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .sg-scrim { align-items: center; } .sg-sheet { border-radius: 22px; } }
.sg-sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sg-sheet__head h3 { font-size: 19px; font-weight: 400; color: var(--nx-brand-ink, #4a69b0); }
.sg-sheet__head .sg-round { width: 36px; height: 36px; box-shadow: none; background: var(--nx-surface-2, #f1f3f7); }
.sg-cheer { width: calc(100% - 32px); max-width: 340px; background: var(--nx-surface, #fff); border-radius: 22px; padding: 26px 22px 20px; text-align: center; animation: sg-pop .35s ease-out; }
.sg-cheer__ring { width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 999px; display: flex; align-items: center; justify-content: center; color: #fff; background: var(--nx-good, #10b981); box-shadow: 0 0 0 8px var(--nx-good-wash, #ecfdf5); }
.sg-cheer__kicker { font-size: 13px; color: var(--nx-good-ink, #047857); }
.sg-cheer__title { font-size: 19px; font-weight: 400; color: var(--nx-ink-strong, #1f2937); margin: 4px 0; }
.sg-cheer .sg-actions { justify-content: center; }
@keyframes sg-pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- the goal screen ---- */
.sg-screen { position: fixed; inset: 0; z-index: 60; overflow-y: auto; -webkit-overflow-scrolling: touch; background: #f3f6fb; }
.sg-screen__inner { max-width: 640px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom)); }
.sg-screen__head { display: flex; align-items: center; gap: 10px; }
.sg-screen__title { flex: 1; min-width: 0; text-align: center; }
.sg-screen__title h2 { font-size: 21px; font-weight: 500; color: var(--nx-ink-strong, #1f2937); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-screen__icon { display: inline-flex; vertical-align: -3px; color: var(--nx-brand, #6b8dd6); }
.sg-screen__title p { font-size: 15px; color: var(--nx-brand, #6b8dd6); margin-top: 2px; }
.sg-tabs { display: flex; justify-content: space-between; gap: 4px; margin: 16px 0 14px; }
.sg-tabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 4px; min-height: 40px; border-radius: 999px; font-size: 14px; color: var(--nx-ink-soft, #7d8ca8); border: 1px solid transparent; }
.sg-tabs button.is-on { background: var(--nx-surface, #fff); color: var(--nx-brand-ink, #4a69b0); border-color: var(--nx-line, #e3e7ee); }
.sg-toast { text-align: center; font-size: 13px; color: var(--nx-brand-ink, #4a69b0); margin-bottom: 8px; }
.sg-stack > * + * { margin-top: 14px; }
.sg-card { position: relative; background: var(--nx-surface, #fff); border-radius: 22px; padding: 18px var(--sg-pad); box-shadow: 0 2px 12px rgba(99,110,129,.07); }
.sg-overall { padding-top: 50px; }
.sg-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--nx-ink-mute, #9aa5b8); font-variant-numeric: tabular-nums; margin-top: 8px; }
.sg-axis--top { margin: 0 0 8px; }
.sg-big-bar { position: relative; height: 56px; border-radius: 10px; background: var(--nx-surface-2, #f4f6f9); }
.sg-big-bar .sg-fill { border-radius: 10px; display: flex; align-items: center; justify-content: flex-end; }
.sg-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--nx-line-soft, #e8ecf2); }
.sg-fill__pct { color: #fff; font-size: 15px; font-weight: 500; padding: 0 12px; font-variant-numeric: tabular-nums; }
.sg-big-bar__pct { position: absolute; top: 50%; transform: translateY(-50%); font-size: 15px; font-weight: 500; color: var(--nx-brand-ink, #4a69b0); }
.sg-pace-line { position: absolute; top: -15px; bottom: 0; width: 0; border-left: 1.5px dashed var(--nx-ink-mute, #9aa5b8); z-index: 2; pointer-events: none; }
.sg-pace-line.is-top { top: 14px; bottom: -15px; }
.sg-pace-line.is-solo { bottom: 12px; }
.sg-pace-tag { position: absolute; top: 0; left: 0; transform: translateX(-50%); white-space: nowrap; padding: 3px 8px; font-size: 12px; color: var(--nx-brand-ink, #4a69b0); background: var(--nx-surface, #fff); border: 1px dashed var(--nx-ink-mute, #9aa5b8); border-radius: 4px; }
.sg-ms { padding-top: 14px; }
.sg-ms__row + .sg-ms__row { margin-top: 16px; }
.sg-ms__top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.sg-ms__name { font-size: 16px; color: var(--nx-brand-ink, #4a69b0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-ms__dates { flex: none; font-size: 12px; color: var(--nx-ink-mute, #9aa5b8); font-variant-numeric: tabular-nums; }
.sg-ms__lane { position: relative; height: 44px; border: 1px dashed var(--nx-line, #dfe4ec); border-radius: 8px; }
.sg-ms__win { position: absolute; top: 0; bottom: 0; background: var(--nx-surface-2, #f4f6f9); border-radius: 7px; }
.sg-ms__win .sg-fill { border-radius: 7px; display: flex; align-items: center; justify-content: flex-end; }
.sg-ms__win .sg-fill__pct { font-size: 14px; padding: 0 8px; }
.sg-ms__pct { position: absolute; top: 50%; transform: translateY(-50%); font-size: 14px; font-weight: 500; color: var(--nx-brand-ink, #4a69b0); white-space: nowrap; }
.sg-ms__meta { font-size: 12px; color: var(--nx-ink-soft, #7d8ca8); margin-top: 4px; }
.sg-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sg-line__head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.sg-line__date { font-size: 18px; color: var(--nx-brand-ink, #4a69b0); }
.sg-line__pct { font-size: 26px; font-weight: 500; color: var(--nx-brand-ink, #4a69b0); font-variant-numeric: tabular-nums; }
.sg-line__plot { display: flex; gap: 8px; height: 150px; }
.sg-line__y { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--nx-ink-mute, #9aa5b8); font-variant-numeric: tabular-nums; margin: -6px 0; }
.sg-line__svg { flex: 1; height: 100%; overflow: visible; touch-action: pan-y; border-left: 1px solid var(--nx-line, #e3e7ee); border-bottom: 1px solid var(--nx-line, #e3e7ee); }
.sg-line__grid { stroke: var(--nx-line-soft, #eef1f5); stroke-width: 1; vector-effect: non-scaling-stroke; }
.sg-line__pace { stroke: var(--nx-brand, #6b8dd6); stroke-width: 1.5; stroke-dasharray: 2 4; vector-effect: non-scaling-stroke; opacity: .8; }
.sg-line__actual { fill: none; stroke: var(--nx-good, #10b981); stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sg-line__actual.is-behind { stroke: var(--nx-warn, #f97316); }
.sg-line__cursor { stroke: var(--nx-brand-ink, #4a69b0); stroke-width: 1; vector-effect: non-scaling-stroke; }
.sg-line__dot { fill: var(--nx-brand-ink, #4a69b0); stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.sg-axis--line { padding-left: 34px; }
.sg-hist__row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--nx-line-soft, #eef1f5); }
.sg-hist__row:first-child { border-top: 0; }
.sg-hist__day { font-size: 14px; color: var(--nx-brand-ink, #4a69b0); }
.sg-hist__val { font-size: 15px; font-variant-numeric: tabular-nums; flex: none; }
.sg-notes { width: 100%; border: 0; resize: vertical; font-size: 15px; line-height: 1.5; background: transparent; color: var(--nx-ink, #363f51); outline: none; }

/* ---- columns and horizontal bars (weekly goal, Reports) ---- */
.sg-cols { display: flex; gap: 8px; height: 120px; align-items: stretch; }
.sg-cols--short { height: 90px; }
.sg-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.sg-col > span { font-size: 11px; color: var(--nx-ink-mute, #9aa5b8); white-space: nowrap; }
.sg-col.is-today > span { color: var(--nx-brand-ink, #4a69b0); font-weight: 500; }
.sg-col__track { position: relative; flex: 1; width: 100%; display: flex; align-items: flex-end; }
.sg-col__bar { width: 100%; min-height: 3px; border-radius: 6px 6px 3px 3px; background: rgba(107,141,214,.45); }
.sg-col.is-today .sg-col__bar { background: var(--nx-brand, #6b8dd6); }
.sg-col__bar.is-good { background: var(--nx-good, #10b981); }
.sg-col__even { position: absolute; left: -4px; right: -4px; border-top: 1.5px dashed var(--nx-ink-mute, #9aa5b8); }
.sg-hbar { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
.sg-hbar__name { width: 84px; flex: none; font-size: 13px; color: var(--nx-ink, #363f51); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-hbar__name.is-peak { color: var(--nx-brand-ink, #4a69b0); font-weight: 500; }
.sg-hbar__track { flex: 1; height: 8px; border-radius: 999px; background: var(--nx-surface-2, #f1f3f7); overflow: hidden; }
.sg-hbar__fill { height: 100%; border-radius: inherit; background: var(--nx-brand, #6b8dd6); }
.sg-hbar__val { width: 44px; text-align: right; font-size: 12px; color: var(--nx-ink-soft, #7d8ca8); font-variant-numeric: tabular-nums; }

/* ---- Reports: at a glance ---- */
.rp-glance { margin-bottom: 18px; }
.rp-explore { margin: 22px 0 0; }
.sg-glance > * + * { margin-top: 12px; }
.sg-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sg-today { display: flex; align-items: center; gap: 14px; }
.sg-today__ring { position: relative; width: 64px; height: 64px; flex: none; }
.sg-today__ring span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 500; color: var(--nx-brand-ink, #4a69b0); }
.sg-ring__bg { fill: none; stroke: var(--nx-surface-2, #f1f3f7); stroke-width: 7; }
.sg-ring__fg { fill: none; stroke: var(--nx-brand, #6b8dd6); stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.sg-ring__fg.is-done { stroke: var(--nx-good, #10b981); }
.sg-today__side { text-align: right; font-size: 13px; color: var(--nx-ink, #363f51); }
.sg-today__side b { font-weight: 500; font-size: 16px; color: var(--nx-ink-deep, #252d3d); }
.sg-delta { font-size: 12px; color: var(--nx-ink-soft, #7d8ca8); margin-top: 2px; }
.sg-delta.is-up { color: var(--nx-good-ink, #047857); }
.sg-best { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.sg-best__n { width: 20px; height: 20px; border-radius: 999px; background: var(--nx-brand-wash, #edf2fb); color: var(--nx-brand-ink, #4a69b0); font-size: 11px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.sg-best__d { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-best__v { font-variant-numeric: tabular-nums; color: var(--nx-ink-soft, #7d8ca8); }
.sg-city__rows p { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 6px 0; }
.sg-city__rows svg { color: var(--nx-brand, #6b8dd6); }
@media (max-width: 420px) { .sg-grid2:not(.is-tight) { grid-template-columns: 1fr; } .sg-tabs button { font-size: 13px; gap: 4px; } .sg-tabs button svg { display: none; } }
@media (prefers-reduced-motion: reduce) { .sg-fill, .sg-ring__fg { transition: none; } .sg-cheer { animation: none; } }

/* ---- night ---- */
body.night-mode .sg-home, body.night-mode .sg-card { background: rgba(30,41,59,.6); box-shadow: none; border: 1px solid rgba(148,163,184,.1); }
body.night-mode .sg-screen { background: #0f172a; }
body.night-mode .sg-sheet, body.night-mode .sg-cheer { background: #1e293b; }
body.night-mode .sg-round { background: #1e293b; color: #d1d7e3; box-shadow: none; }
body.night-mode .sg-round--sm { background: rgba(107,141,214,.18); color: #c7d4f2; }
body.night-mode .sg-tabs button.is-on { background: rgba(255,255,255,.06); color: #c7d4f2; border-color: rgba(148,163,184,.2); }
body.night-mode .sg-bar, body.night-mode .sg-big-bar, body.night-mode .sg-ms__win, body.night-mode .sg-hbar__track, body.night-mode .sg-chip, body.night-mode .sg-pick__item, body.night-mode .sg-btn--ghost, body.night-mode .sg-iconpick { background: rgba(255,255,255,.06); color: #d1d7e3; }
body.night-mode .sg-chip.is-on { background: #6b8dd6; color: #fff; }
body.night-mode .sg-input { background: rgba(255,255,255,.04); border-color: rgba(148,163,184,.2); color: #e4e8ee; }
body.night-mode .sg-pace-tag { background: #1e293b; }
body.night-mode .sg-hrow, body.night-mode .sg-hist__row { border-color: rgba(148,163,184,.12); }
body.night-mode .sg-ring__bg { stroke: rgba(255,255,255,.08); }
