/* Workspace themes are scoped to the signed-in portal. */
.workspace {
  --phase-blue: #137d9b;
  --phase-lime: #56751b;
  --phase-teal: #276966;
  --tone-ink: #165b70;
  --tone-wash: #e6f4f8;
  --tone-line: #c5e6ee;
  --workspace-sidebar: 252px;
}
.workspace .sidebar { width: var(--workspace-sidebar); padding: 24px 17px 16px; }
.workspace .shell { margin-left: var(--workspace-sidebar); }
.workspace .topbar { gap: 12px; height: 63px; }
.workspace .crumb { min-width: 0; }
.workspace .crumb b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace .sidebar-brand { flex: none; padding-bottom: 27px; }
.workspace .sidebar-brand::after { bottom: .8rem; }
.workspace .workspace-nav { display: block; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; padding: 3px 3px 8px; }
.nav-group + .nav-group { margin-top: .8rem; padding-top: .65rem; border-top: 1px solid var(--line); }
.workspace .nav button { width: 100%; min-height: 35px; padding: .48rem .65rem; gap: .62rem; line-height: 1.3; }
.workspace .nav .icon { width: 16px; height: 16px; }
.workspace .nav button.nav-sub { padding-left: 1.55rem; }
.workspace .nav button:focus-visible { outline-offset: -2px; }
.workspace .sidebar-bottom { flex: none; margin-top: .45rem; }
.workspace .sidebar-user { padding-top: .75rem; }
.phase-nav > p { margin: 0 0 .35rem; padding-left: .65rem; color: #516369; font-size: .72rem; font-weight: 600; }
.phase-nav-number {
  display: grid; place-items: center; width: 1.5rem; height: 1.5rem; flex: none; border-radius: 6px;
  background: var(--tone-wash); color: var(--tone-ink); font-size: .68rem; font-weight: 600;
}
.workspace .nav .phase-nav button.active { color: var(--tone-ink); background: var(--tone-wash); box-shadow: inset 3px 0 var(--tone-ink); }
.workspace .nav .phase-nav button.active .phase-nav-number { background: var(--white); }
.theme-switch {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 38px; flex: none; padding: 0 .75rem;
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--white);
  font-size: .78rem; font-weight: 600;
}
.theme-switch:hover { border-color: #91b9c2; }
.theme-symbol { color: var(--phase-blue); font-size: 1.12rem; line-height: 1; }
.workspace .dashboard-focus {
  background: #164c5d; border-left: 4px solid #90bb35;
}
.workspace .dashboard-focus::after { content: none; }
.workspace .dashboard-focus .btn { background: #eaf5d4; border-color: #eaf5d4; color: #29461e; }
.workspace .dashboard-focus .btn:hover { background: #fff; border-color: #fff; }
.workspace .dashboard-metric-icon { background: #e5f3f7; color: #13677e; }
.workspace .dashboard-pillars .lijf .dashboard-pillar-icon { background: #ebf4d5; color: #476317; }
.journey-section { margin: 1.65rem 0 0; }
.dashboard > .journey-section { margin-top: 0; }
.journey-grid, .phase-grid, .journey-stats, .goal-grid { display: grid; gap: 1rem; }
.journey-grid, .phase-grid, .journey-stats { grid-template-columns: repeat(3,minmax(0,1fr)); }
.goal-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.phase-tone-1, .phase-tone-4, .tone-blue { --tone-wash:#e5f3f9; --tone-line:#bbdfeb; --tone-ink:#155b75; }
.phase-tone-2, .phase-tone-5, .tone-lime { --tone-wash:#edf4db; --tone-line:#d3e6ac; --tone-ink:#456222; }
.phase-tone-3, .phase-tone-6, .tone-teal { --tone-wash:#e1f1ed; --tone-line:#c0e4db; --tone-ink:#23605c; }
.journey-tile, .phase-tile {
  position: relative; display: grid; align-content: start; justify-items: start; gap: .42rem;
  min-width: 0; min-height: 8.4rem; padding: 1.1rem; padding-right: 2.1rem;
  background: var(--tone-wash); color: var(--tone-ink); border: 1px solid var(--tone-line);
  border-radius: 10px; text-align: left;
}
.journey-tile:hover, .phase-tile:hover { border-color: var(--tone-ink); box-shadow: 0 4px 12px #182c3414; }
.journey-tile strong, .phase-tile strong { color: inherit; font-size: .98rem; font-weight: 650; line-height: 1.3; }
.journey-tile small, .phase-tile small { color: inherit; font-size: .75rem; }
.journey-tile > .icon, .phase-tile > .icon { position: absolute; right: .85rem; bottom: .95rem; width: 16px; }
.journey-tile-icon, .phase-number, .session-symbol {
  display: inline-grid; place-items: center; flex: none; width: 2rem; height: 2rem;
  background: var(--white); color: var(--tone-ink); border: 1px solid var(--tone-line);
  border-radius: 7px; font-size: .76rem; font-weight: 600;
}
.phase-banner {
  display: flex; align-items: center; gap: 1.1rem; margin-bottom: 1.4rem; padding: 1.35rem 1.5rem;
  border: 1px solid var(--tone-line); border-radius: 12px; background: var(--tone-wash); color: var(--tone-ink);
}
.phase-banner .phase-number { width: 3rem; height: 3rem; font-size: 1rem; }
.phase-banner p { margin: 0 0 .22rem; font-size: .76rem; }
.phase-banner h1 { margin: 0; color: inherit; font-size: clamp(1.8rem,4vw,2.8rem); line-height: 1.12; }
.phase-banner .btn { margin-left: auto; flex: none; }
.journey-stats { margin: 0 0 1.2rem; }
.journey-stats > div {
  padding: 1rem 1.2rem; border: 1px solid var(--tone-line); border-radius: 9px;
  background: var(--tone-wash); color: var(--tone-ink);
}
.journey-stats dt { font-size: .8rem; }
.journey-stats dd { margin: .24rem 0 0; font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.goal-card { display: flex; flex-direction: column; gap: .75rem; min-width: 0; margin-bottom: 0; }
.goal-card > .row { flex-wrap: wrap; gap: .4rem; }
.goal-card h2 { margin: 0; overflow-wrap: anywhere; }
.goal-card p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.goal-actions { padding-top: .4rem; margin-top: auto; }
.session-panel h2, .progress-panel h2 { margin: 0 0 .75rem; }
.session-panel > .muted { font-size: .85rem; margin: 0; }
.session-row { display: flex; align-items: center; gap: .8rem; padding: .85rem 0; border-top: 1px solid var(--line); }
.session-row > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.session-symbol { --tone-wash:#e5f3f9; background: var(--tone-wash); }
.session-row h3 { margin: 0; font-size: .91rem; }
.session-row p { margin: .2rem 0 0; font-size: .77rem; color: var(--muted); }
.session-row .btn { min-height: 36px; padding: .5rem .7rem; }
#session-form .hint { margin: -.25rem 0 .85rem; }
.phase-progress { padding: .8rem 0; border-top: 1px solid var(--line); }
.phase-progress .row { gap: .5rem; font-size: .86rem; }
.phase-progress .row > span { flex: none; font-variant-numeric: tabular-nums; }
.phase-progress progress {
  display: block; width: 100%; height: .48rem; margin: .6rem 0 .35rem; appearance: none;
  overflow: hidden; border: 0; border-radius: 99px; background: #e0edf0; color: var(--phase-blue);
}
.phase-progress progress::-webkit-progress-bar { background: #e0edf0; }
.phase-progress progress::-webkit-progress-value { background: #147e99; }
.phase-progress progress::-moz-progress-bar { background: #147e99; }
.phase-progress summary { width: fit-content; padding: .35rem 0; color: var(--tone-ink); font-size: .76rem; cursor: pointer; }
.progress-exercise { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: .6rem; padding: .6rem 0; border-top: 1px solid var(--line); font-size: .82rem; }
.progress-exercise small { display: block; margin-top: .2rem; color: var(--muted); }

@media(max-width: 1060px) {
  .workspace { --workspace-sidebar: 226px; }
  .phase-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media(max-width: 780px) {
  .workspace .sidebar { width: 246px; }
  .workspace .shell { margin-left: 0; }
  .workspace .topbar { padding-inline: 1rem; }
  .workspace .crumb > span { display: none; }
}
@media(max-width: 540px) {
  .journey-grid { grid-template-columns: 1fr; gap: .6rem; }
  .journey-tile { min-height: 0; grid-template-columns: auto 1fr; align-items: center; gap: .2rem .65rem; }
  .journey-tile-icon { grid-row: span 2; }
  .journey-stats { gap: .5rem; }
  .journey-stats > div { padding: .8rem .6rem; }
  .phase-tile { padding: .8rem; min-height: 7.7rem; }
  .phase-tile > .icon { display: none; }
  .phase-banner { padding: 1rem; flex-wrap: wrap; }
  .phase-banner > div { flex: 1; min-width: 0; }
  .phase-banner .btn { margin: .2rem 0 0; width: 100%; }
  .goal-grid { grid-template-columns: 1fr; }
  .session-row { flex-wrap: wrap; gap: .45rem; }
  .session-row .btn { width: auto; margin: 0 0 0 auto; }
  .progress-exercise { grid-template-columns: minmax(0,1fr) auto; }
  .progress-exercise .text-btn { justify-self: start; }
}

/* Dark surfaces, including dialogs and popovers outside the workspace shell. */
:root[data-workspace-theme="dark"] {
  color-scheme: dark;
  --paper:#111111; --white:#1c1c1c; --ink:#f4f4f3; --muted:#bcbcb8; --line:#383838;
}
[data-workspace-theme="dark"] body { background: var(--paper); color: var(--ink); }
[data-workspace-theme="dark"] .workspace .sidebar,
[data-workspace-theme="dark"] .workspace .topbar { color: var(--ink); background: #171717; border-color: var(--line); }

[data-workspace-theme="dark"] .workspace .sidebar-brand::after,
[data-workspace-theme="dark"] .workspace .sidebar-user { background-color: transparent; border-color: var(--line); }
[data-workspace-theme="dark"] .workspace .sidebar-brand::after { background: #383838; }
[data-workspace-theme="dark"] .workspace .sidebar-user,
[data-workspace-theme="dark"] .workspace .sidebar-user small,
[data-workspace-theme="dark"] .workspace .sidebar .icon-btn,
[data-workspace-theme="dark"] .workspace .nav button,
[data-workspace-theme="dark"] .workspace .phase-nav > p { color: var(--muted); }
[data-workspace-theme="dark"] .workspace .nav button:hover,
[data-workspace-theme="dark"] .workspace .nav button.active { background: #2a2a2a; color: #f4f4f3; }
[data-workspace-theme="dark"] .workspace .nav button.active { box-shadow: inset 3px 0 #a7c950; }
[data-workspace-theme="dark"] .workspace .phase-nav button.active { background: var(--tone-wash); color: var(--tone-ink); box-shadow: inset 3px 0 var(--tone-ink); }
[data-workspace-theme="dark"] .workspace .phase-tone-1,
[data-workspace-theme="dark"] .workspace .phase-tone-4,
[data-workspace-theme="dark"] .workspace .tone-blue { --tone-wash:#242424; --tone-line:#424242; --tone-ink:#b9dce5; }
[data-workspace-theme="dark"] .workspace .phase-tone-2,
[data-workspace-theme="dark"] .workspace .phase-tone-5,
[data-workspace-theme="dark"] .workspace .tone-lime { --tone-wash:#242424; --tone-line:#424242; --tone-ink:#d8e6b7; }
[data-workspace-theme="dark"] .workspace .phase-tone-3,
[data-workspace-theme="dark"] .workspace .phase-tone-6,
[data-workspace-theme="dark"] .workspace .tone-teal { --tone-wash:#242424; --tone-line:#424242; --tone-ink:#beddd2; }
[data-workspace-theme="dark"] .workspace { --tone-wash:#242424; --tone-line:#424242; --tone-ink:#deded9; --phase-blue:#a7c950; }
[data-workspace-theme="dark"] :is(.workspace .panel,.workspace .program-card,.workspace .table-wrap,.workspace .dashboard-metrics,.workspace .dashboard-pillar,.workspace .search,.workspace .reflection,dialog) {
  background: var(--white); border-color: var(--line); color: var(--ink);
}
[data-workspace-theme="dark"] :is(.workspace .dashboard-metrics dl > div,.workspace .card-bottom > .row:last-child,.workspace .exercise-row,.workspace td,.workspace .footer,.template-detail #template-form,.template-detail > .template-actions,.form-actions,.modal-header) { border-color: var(--line); }
[data-workspace-theme="dark"] :is(.workspace .dashboard-pillar:hover,.workspace .exercise-row:hover,.workspace tbody tr:hover,.workspace th,.workspace .tabs,.modal-header,.modal-header .icon-btn) { background: #252525; color: var(--ink); }
[data-workspace-theme="dark"] :is(.workspace .empty,.workspace .notice,.workspace .feedback) { background: #232323; color: var(--ink); border-color: var(--line); }
[data-workspace-theme="dark"] :is(.workspace label,dialog label,.workspace .hint,dialog .hint,.modal-body > p,.workspace .progress-exercise small) { color: var(--muted); }
[data-workspace-theme="dark"] :is(input,textarea,select,.select-trigger,.date-trigger,.select-menu,.calendar) { background: #151515; color: var(--ink); border-color: #595959; color-scheme: dark; }
[data-workspace-theme="dark"] :is(input,textarea)::placeholder,
[data-workspace-theme="dark"] .date-trigger.placeholder { color: #aaa9a4; }
[data-workspace-theme="dark"] :is(.select-option:hover,.select-option.is-focused,.select-option[aria-selected="true"],.calendar-navigation button,.calendar-days button:hover) { color: #f1f1ef; background: #2e2e2e; border-color: #575757; }
[data-workspace-theme="dark"] .calendar :is(.calendar-navigation strong,.calendar-days button:not(.selected),.calendar-footer button,.calendar-caption,.calendar-week) { color: var(--muted); }
[data-workspace-theme="dark"] :is(.btn.secondary,.workspace .tabs button.active) { color: var(--ink); background: #272727; border-color: #606060; }
[data-workspace-theme="dark"] .btn.secondary:hover { background: #333333; }
[data-workspace-theme="dark"] .workspace .badge { color: #e1e1de; background: #323232; }
[data-workspace-theme="dark"] .workspace .badge.completed { color: #e0f4bd; background: #34492b; }
[data-workspace-theme="dark"] .workspace .badge.submitted { color: #c1f1fe; background: #303739; }
[data-workspace-theme="dark"] .phase-progress progress,
[data-workspace-theme="dark"] .phase-progress progress::-webkit-progress-bar { background: #383838; }
[data-workspace-theme="dark"] .phase-progress progress::-webkit-progress-value { background: #a7c950; }
[data-workspace-theme="dark"] .phase-progress progress::-moz-progress-bar { background: #a7c950; }
[data-workspace-theme="dark"] :is(.workspace button,.workspace summary,dialog button):focus-visible { outline-color: #c2de80; }
[data-workspace-theme="dark"] .error { color: #ffdad0; background: #4a2a28; border-color: #92534c; }

.session-datetime { grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); }
.calendar-caption { text-transform: uppercase; }
.workspace .workspace-nav::-webkit-scrollbar { display: none; }
[data-workspace-theme="dark"] dialog::backdrop { background: #0009; }
[data-workspace-theme="dark"] .workspace .dashboard-focus { background: #222; border: 1px solid var(--line); border-left: 4px solid #a7c950; }
[data-workspace-theme="dark"] .workspace .dashboard-focus :is(.dashboard-kicker,.dashboard-focus-detail) { color: var(--muted); }
[data-workspace-theme="dark"] .workspace :is(.dashboard-metric-icon,.dashboard-pillar-icon,.session-symbol,.sidebar .avatar,.nav .count,.empty > .icon) { background: #2c2c2c; color: #d6e4ba; border-color: var(--line); }
[data-workspace-theme="dark"] .workspace :is(.progress,.meta-grid,.intro) { background-color: #303030; border-color: var(--line); }
[data-workspace-theme="dark"] .workspace :is(.footer,.text-btn,.back,.order,.crumb,.exercise-meta) { color: var(--muted); }
[data-workspace-theme="dark"] :is(.template-item,.calendar-heading,.calendar-footer,.prompt,.form-actions) { border-color: var(--line); }
[data-workspace-theme="dark"] .template-item:hover { background: #292929; }
[data-workspace-theme="dark"] :is(.workspace,dialog) .btn:not(.secondary):not(.danger) { background: #c5db91; color: #191e13; border-color: #c5db91; }
[data-workspace-theme="dark"] :is(.workspace,dialog) .btn:not(.secondary):not(.danger):hover { background: #d5e7ab; }
[data-workspace-theme="dark"] :is(input,textarea,select,.select-trigger,.date-trigger):focus,
[data-workspace-theme="dark"] :is(.select-trigger,.date-trigger)[aria-expanded="true"] { background: #151515; border-color: #b7d775; box-shadow: 0 0 0 3px #b7d77524; }
[data-workspace-theme="dark"] :is(.date-trigger,.select-trigger) svg { color: #bcbcb8; stroke: currentColor; }
[data-workspace-theme="dark"] .calendar-days button.selected { background: #c5db91; color: #191e13; box-shadow: none; }
[data-workspace-theme="dark"] .calendar-days button[aria-current="date"]::after { background: #a7c950; }
[data-workspace-theme="dark"] .calendar-days button.selected[aria-current="date"]::after { background: #30401c; }
[data-workspace-theme="dark"] .calendar .calendar-days button.outside:not(.selected) { color: #969691; }
[data-workspace-theme="dark"] .date-error { color: #ffb7a9; }
@media (max-width: 460px) {
  .session-datetime { grid-template-columns: 1fr; }
}
/* Sign-in shares the workspace preference while retaining its layout. */
.auth-top .theme-switch { margin-inline-start: auto; }
.auth-top { flex-wrap: nowrap; }
.auth-mobile-brand { min-width: 0; }
.auth-mobile-brand .brand-logo { max-width: 100%; }
.auth-top .theme-symbol { color: #16758c; }
[data-workspace-theme="dark"] .auth,
[data-workspace-theme="dark"] .auth-main { background: var(--paper); }
[data-workspace-theme="dark"] .auth-story {
  background: #191919;
  border-color: var(--line);
}
/* The supplied PNG already has a transparent background. */
[data-workspace-theme="dark"] .brand-logo { filter: brightness(1.45); }
[data-workspace-theme="dark"] .auth-box { background: var(--white); border-color: var(--line); }
[data-workspace-theme="dark"] .auth :is(label,.auth-box > p,.auth-foot,.auth-foot button) { color: var(--muted); }
[data-workspace-theme="dark"] .auth :is(.auth-sub button,.signup-link button,.theme-symbol) { color: #c5db91; }
[data-workspace-theme="dark"] .auth .divider { background: var(--line); }
[data-workspace-theme="dark"] .auth .password-wrap .icon-btn { color: var(--muted); }
[data-workspace-theme="dark"] .auth .password-wrap .icon-btn:hover { background: #2b2b2b; }
[data-workspace-theme="dark"] .auth .btn { background: #c5db91; color: #191e13; border-color: #c5db91; }
[data-workspace-theme="dark"] .auth .btn:hover { background: #d5e7ab; }
[data-workspace-theme="dark"] .auth .success { background: #283224; color: #e0efca; border-color: #526647; }
[data-workspace-theme="dark"] .auth .theme-switch:focus-visible { outline-color: #c2de80; }

[data-workspace-theme="dark"] .workspace .meta-grid { background: transparent; }
.workspace .dashboard-focus.dashboard-focus-pattern::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: repeating-radial-gradient(ellipse at 100% 100%, transparent 0 17px, #d3ecb633 18px 19px);
  mask-image: linear-gradient(105deg, transparent 38%, #000 94%);
}

/* Shared typography and validation styles for both themes. */
:root {
  --font-body: LevadaSans, Arial, sans-serif;
  --font-heading: LevadaSerif, Georgia, serif;
  --error-ink: #842f25;
  --error-fill: #fff3f0;
  --error-edge: #aa5144;
  --error-line: #e7bdb5;
}
:root[data-workspace-theme="dark"] {
  --error-ink: #ffc8bd;
  --error-fill: #30211f;
  --error-edge: #da8c7f;
  --error-line: #87544e;
}
body, :is(button,input,select,textarea,dialog,[popover]) { font-family: var(--font-body); }
:is(h1,h2,.serif) { font-family: var(--font-heading); }
.field-error {
  margin: .45rem 0 0;
  color: var(--error-ink);
  font-size: .8rem;
  line-height: 1.4;
  font-weight: 500;
}
.field-error::before { content: ''; display: inline-block; width: .35rem; height: .35rem; margin: 0 .45rem .12rem 0; border-radius: 50%; background: currentColor; }
:is(input,select,textarea,.date-trigger,.select-trigger)[aria-invalid="true"],
[data-workspace-theme="dark"] :is(input,select,textarea,.date-trigger,.select-trigger)[aria-invalid="true"] { border-color: var(--error-edge); }
:is(input,select,textarea,.date-trigger,.select-trigger)[aria-invalid="true"]:focus,
[data-workspace-theme="dark"] :is(input,select,textarea,.date-trigger,.select-trigger)[aria-invalid="true"]:focus { box-shadow: 0 0 0 2px var(--error-line); }
.error, [data-workspace-theme="dark"] .error, #toast[data-kind="error"] {
  color: var(--error-ink);
  background: var(--error-fill);
  border: 1px solid var(--error-line);
  border-inline-start: 3px solid var(--error-edge);
  border-radius: 6px;
  font-size: .82rem;
  line-height: 1.5;
}

.error-log-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.session-client-group { padding-top: .7rem; }
.session-client-group + .session-client-group { margin-top: .85rem; border-top: 1px solid var(--line); }
.session-client-group > h3 { font-size: .95rem; margin: 0 0 .35rem; }
.progress-filters { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)) auto; align-items: end; gap: .8rem; }
.progress-filters .form-field { margin: 0; }
.privacy-copy { display: grid; gap: 1rem; margin-bottom: 1.25rem; }
.privacy-copy h3 { margin-bottom: .35rem; }
.privacy-copy p { margin: 0; line-height: 1.6; }
@media (max-width: 620px) { .progress-filters { grid-template-columns: 1fr; } }
.phase-name-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem 1rem; }
.phase-name-fields .form-field { margin: 0; }
.exercise-image, .exercise-image-preview { margin: 1.25rem 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.exercise-image { display: grid; place-items: center; }
.exercise-image img { display: block; max-width: 100%; max-height: 34rem; width: auto; height: auto; object-fit: contain; }
.exercise-image-preview { max-width: 32rem; }
.exercise-image-preview img, .exercise-image-thumb { display: block; max-width: 100%; max-height: 18rem; margin: auto; object-fit: contain; }
.check-field { display: flex; align-items: center; gap: .6rem; margin: .8rem 0; }
.check-field input { width: 1rem; height: 1rem; accent-color: var(--accent); }
@media (max-width: 620px) { .phase-name-fields { grid-template-columns: 1fr; } }
