/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 16px; border-radius: var(--radius-pill); border: 1px solid transparent;
  background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-600); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: .9rem; }
.btn-lg { padding: 13px 22px; font-size: 1.05rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: var(--radius-pill);
  background: transparent; border: 1px solid transparent; color: var(--text-2); cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.active { background: var(--brand-soft); color: var(--brand); }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-weight: 600; font-size: .9rem; color: var(--text-2); }
.input, .textarea, select.input {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); transition: border .15s ease, box-shadow .15s ease;
}
.input:focus, .textarea:focus, select.input:focus { border-color: var(--brand); box-shadow: var(--ring); outline: none; }
.textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.input-search {
  display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 42px;
  background: var(--surface-2); border-radius: var(--radius-pill); border: 1px solid transparent; color: var(--text-2);
}
.input-search:focus-within { border-color: var(--brand); box-shadow: var(--ring); background: var(--surface); }
.input-search input { border: 0; background: transparent; outline: none; width: 100%; color: var(--text); }

/* ---------- Toggle / segmented / slider ---------- */
.segmented { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-pill); padding: 4px; gap: 2px; }
.segmented button { border: 0; background: transparent; color: var(--text-2); font-weight: 600; padding: 7px 16px; border-radius: var(--radius-pill); cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); transition: background .2s ease; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s ease; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }

.slider { width: 100%; appearance: none; height: 6px; border-radius: 999px; background: var(--surface-3); outline: none; }
.slider::-webkit-slider-thumb { appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); cursor: pointer; box-shadow: var(--shadow-sm); border: 3px solid var(--surface); }
.slider::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); cursor: pointer; border: 3px solid var(--surface); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center;
}
.topbar .container { display: flex; align-items: center; gap: 14px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.brand .logo { width: 30px; height: 30px; }
.brand b { color: var(--brand); }
.wordmark { height: 1.5em; width: auto; color: var(--brand); display: block; }
.brand .wordmark { margin-right: 2px; }
.brand .sub { color: var(--text-2); font-weight: 700; }
.title-toggle { display: flex; align-items: center; gap: 12px; }
.title-toggle h1 { font-size: 1.3rem; }

/* ---------- Avatar ---------- */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 30px; height: 30px; font-size: .82rem; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { border: 0; background: transparent; color: var(--text-2); font-weight: 600; padding: 12px 14px; cursor: pointer; border-bottom: 2.5px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.subtabs { display: inline-flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--radius-pill); }
.subtabs button { border: 0; background: transparent; color: var(--text-2); font-weight: 600; padding: 6px 13px; border-radius: var(--radius-pill); cursor: pointer; font-size: .9rem; }
.subtabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Breadcrumb ---------- */
.breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 600; flex-wrap: wrap; }
.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb .sep { color: var(--text-3); }
.breadcrumb .current { color: var(--text); }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-pill); font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--text-2); }
.badge.emphasis-affection { background: var(--accent-soft); color: var(--accent); }
.badge.emphasis-agency { background: color-mix(in srgb, var(--sky) 18%, transparent); color: var(--sky); }
.badge.emphasis-belonging { background: color-mix(in srgb, var(--mint) 20%, transparent); color: var(--mint); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--radius-pill); background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: .82rem; border: 0; cursor: pointer; }
.pill:hover { filter: brightness(.97); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill); background: var(--surface-2); font-size: .82rem; color: var(--text-2); }

/* ---------- Modal / overlay ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10,12,20,.45); z-index: 60; display: grid; place-items: center; padding: 20px; opacity: 0; transition: opacity .15s ease; }
.scrim.show { opacity: 1; }
.modal { width: min(680px, 100%); max-height: 88vh; overflow: auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border); transform: translateY(8px) scale(.99); transition: transform .18s ease; }
.scrim.show .modal { transform: none; }
.modal.wide { width: min(940px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.modal-head h2 { font-size: 1.2rem; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: var(--radius-pill); box-shadow: var(--shadow-lg); font-weight: 600; display: flex; align-items: center; gap: 10px; animation: toastIn .2s ease; max-width: 90vw; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty .icon-lg { margin: 0 auto 14px; width: 48px; height: 48px; color: var(--text-3); }

/* ---------- Plans ---------- */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.plan-card { padding: 18px; cursor: pointer; display: flex; flex-direction: column; gap: 10px; transition: transform .1s ease, box-shadow .15s ease; }
.plan-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.plan-card .date { font-weight: 700; color: var(--brand); font-size: .85rem; display: flex; align-items: center; gap: 6px; }
.plan-card h3 { font-size: 1.15rem; }
.plan-card .meta { display: flex; gap: 8px; flex-wrap: wrap; }
.plan-card.drop-target { outline: 2.5px dashed var(--brand); outline-offset: 3px; }

/* ---------- Flow (Lesson Builder) ---------- */
.flow-list { display: flex; flex-direction: column; gap: 10px; }
.flow-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 12px 12px 8px; display: flex; gap: 8px; align-items: flex-start; }
.flow-item.dragging { opacity: .5; }
.flow-item.drag-over { border-color: var(--brand); box-shadow: var(--ring); }
.flow-item.type-header { background: var(--surface-2); border-style: dashed; }
.grip { cursor: grab; color: var(--text-3); padding: 4px; touch-action: none; }
.grip:active { cursor: grabbing; }
.flow-main { flex: 1; min-width: 0; }
.flow-top { display: flex; align-items: center; gap: 8px; }
.flow-top .ftitle { font-weight: 700; }
.flow-top .fnote { font-size: .8rem; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: var(--radius-pill); font-weight: 600; }
.flow-time { font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.flow-desc { color: var(--text-2); font-size: .92rem; margin-top: 3px; }
.flow-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s ease; }
.flow-item:hover .flow-actions, .flow-item:focus-within .flow-actions { opacity: 1; }
.flow-running-total { display: flex; justify-content: space-between; padding: 10px 14px; background: var(--brand-soft); color: var(--brand); border-radius: var(--radius); font-weight: 700; }

/* ---------- Curriculum panel ---------- */
.with-panel { display: grid; grid-template-columns: 1fr var(--panel-w, 360px); }
.with-panel.no-panel { grid-template-columns: 1fr; }
.cur-panel { border-left: 1px solid var(--border); background: var(--surface); min-height: calc(100vh - var(--header-h)); position: sticky; top: var(--header-h); align-self: start; height: calc(100vh - var(--header-h)); display: flex; flex-direction: column; }
.cur-resize { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; }
.cur-head { padding: 14px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--border); }
.cur-list { overflow: auto; padding: 8px; flex: 1; }
.cur-group-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 12px 8px 6px; font-weight: 700; }
.cur-item { padding: 11px 12px; border-radius: var(--radius-sm); cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.cur-item:hover { background: var(--surface-2); }
.cur-item .ci-title { font-weight: 600; }
.cur-item .ci-sub { font-size: .82rem; color: var(--text-2); }
.cur-item[draggable="true"] { -webkit-user-drag: element; }

/* ---------- Settings ---------- */
.settings-section { border-top: 1px solid var(--border); padding: 18px 0; }
.settings-section:first-child { border-top: 0; }
.settings-section h3 { margin-bottom: 4px; }
.dial-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--radius-pill); border: 1.5px solid var(--border-strong); cursor: pointer; user-select: none; font-weight: 600; color: var(--text-2); }
.check-pill.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.danger-zone { border: 1.5px solid var(--danger-soft); border-radius: var(--radius); padding: 16px; }

/* ---------- Layout helpers for main content ---------- */
.page { padding: 22px 0 80px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.tab-panels { padding-top: 18px; }
.tooltip-pop { position: fixed; z-index: 90; max-width: 280px; background: var(--text); color: var(--bg); padding: 10px 12px; border-radius: var(--radius-sm); font-size: .85rem; box-shadow: var(--shadow-lg); }

/* ---------- Leader-cue pills (flow preview + print) ---------- */
.rich-line { margin: 2px 0; }
.rich-h { font-weight: 800; margin: 10px 0 4px; }
.cue { font-size: .66rem; font-weight: 800; letter-spacing: .05em; padding: 2px 7px; border-radius: 6px; text-transform: uppercase; margin-right: 8px; display: inline-block; vertical-align: baseline; }
.cue-do { background: var(--brand-soft); color: var(--brand); }
.cue-ask { background: color-mix(in srgb, var(--sun) 24%, transparent); color: #9a6b00; }
.cue-read { background: color-mix(in srgb, var(--mint) 22%, transparent); color: #128067; }
.cue-personalize { background: var(--accent-soft); color: var(--accent); }
.cue-impress { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand-700); }
.cue-apply { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.cue-recycle { background: var(--surface-3); color: var(--text-2); }
.cue-debrief { background: color-mix(in srgb, var(--sky) 18%, transparent); color: #1f72b8; }

/* ---------- Lesson Builder: read-only sortable list + side editor ---------- */
.builder-cols { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: start; }
.builder-cols.editing { grid-template-columns: 1fr 380px; }
.flow-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: border .12s ease, box-shadow .12s ease; }
.flow-row:hover { border-color: var(--border-strong); }
.flow-row.selected { border-color: var(--brand); box-shadow: var(--ring); }
.flow-row.type-header { background: var(--surface-2); border-style: dashed; font-weight: 700; }
.flow-row .rtime { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 700; font-size: .85rem; min-width: 60px; text-align: right; }
.flow-row .rdur { font-variant-numeric: tabular-nums; color: var(--text-3); font-size: .82rem; min-width: 34px; }
.flow-row .rtitle { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-row .rtype { color: var(--text-3); }
.flow-row .flow-actions { opacity: 0; }
.flow-row:hover .flow-actions, .flow-row.selected .flow-actions { opacity: 1; }
.flow-row.dragging { opacity: .5; }
.flow-row.drag-over { border-color: var(--brand); }
.builder-editor { position: sticky; top: calc(var(--header-h) + 16px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); max-height: calc(100vh - var(--header-h) - 32px); overflow: auto; }
.builder-editor .ed-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.builder-editor .ed-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .builder-cols.editing { grid-template-columns: 1fr; }
  .builder-editor { position: fixed; inset: var(--header-h) 0 0 0; z-index: 55; border-radius: 0; max-height: none; }
}

@media (max-width: 860px) {
  .with-panel { grid-template-columns: 1fr; }
  .cur-panel { position: fixed; inset: var(--header-h) 0 0 0; z-index: 50; height: auto; border-left: 0; transform: translateX(100%); transition: transform .2s ease; }
  .cur-panel.open { transform: none; }
  .cur-resize { display: none; }
  .dial-grid { grid-template-columns: 1fr; }
  .topbar .hide-mobile { display: none; }
}
