/*
 * IWonnaP — Pages
 * Page-specific styles in priority order (most-used first).
 *
 * NOTE (ADR-026): the CALENDAR block was extracted into its own file
 * (static/styles/calendar.css). Day-timeline rules moved with it.
 * Feedback keyframes referenced from this file (none currently) live
 * in motion.css.
 *
 * Replaces: dashboard.css, statistics.css, quick_marks.css,
 *           edit.css, projects.css, psych_tests.css, vault.css,
 *           wishlist.css, login.css, pagination.css
 */

/* FB-5/FB-6 redesigned operational screens */
.ev-page,
.st-page,
.db-page,
.sx-page {
  display: grid;
  gap: var(--sp-4);
  width: 100%;
}

.ev-head,
.st-head,
.db-head,
.sx-head,
.ev-detail__hero,
.st-detail__hero {
  align-items: flex-start;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: var(--sp-4);
  justify-content: space-between;
  padding: var(--sp-5);
}

.ev-kicker,
.st-kicker,
.db-kicker,
.sx-kicker {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  margin: 0 0 var(--sp-1);
  text-transform: uppercase;
}

.ev-head h1,
.st-head h1,
.db-head h1,
.sx-head h1,
.ev-detail__title h1,
.st-detail__title h1 {
  color: var(--text-strong);
  font-size: var(--text-xl);
  line-height: 1.1;
  margin: 0;
}

.ev-sub,
.st-sub,
.ev-detail__title p,
.st-detail__title p,
.sx-head p {
  color: var(--muted);
  margin: var(--sp-1) 0 0;
}

.ev-actions,
.st-actions,
.db-weather,
.sx-period {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.ev-toolbar,
.ev-meta,
.st-card__meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.ev-grid,
.st-grid,
.db-grid,
.sx-grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.ev-card,
.st-card,
.ev-panel,
.st-panel,
.db-card,
.sx-card,
.ev-history,
.st-history {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  display: grid;
  gap: var(--sp-3);
  min-width: 0;
  padding: var(--sp-4);
}

.ev-card,
.st-card {
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.ev-card:hover,
.st-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}
.ev-card.is-muted,
.st-card.is-muted { opacity: .65; }
.ev-card.is-running {
  border-color: color-mix(in srgb, var(--success) 55%, var(--line));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--success) 18%, transparent);
}

.ev-card__top,
.st-card__actions,
.ev-live,
.ev-card__actions,
.ev-section-head,
.st-section-head,
.db-card__head,
.sx-card__head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: space-between;
}

.ev-card__identity,
.st-card__title,
.ev-detail__title,
.st-detail__title {
  align-items: center;
  color: var(--text);
  display: flex;
  gap: var(--sp-3);
  min-width: 0;
  text-decoration: none;
}
.ev-card__identity strong,
.st-card__title strong {
  color: var(--text-strong);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ev-card__identity small,
.st-card__title small {
  color: var(--muted);
  display: block;
  font-size: var(--text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ev-card__emoji,
.ev-detail__emoji,
.st-card__emoji {
  align-items: center;
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: inline-flex;
  flex: 0 0 44px;
  font-size: 24px;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.ev-live { justify-content: flex-start; }
.ev-history,
.st-history { grid-column: 1 / -1; }
.ev-section-head h2,
.st-section-head h2,
.db-card__head h2,
.sx-card__head h2 {
  color: var(--text-strong);
  font-size: var(--text-md);
  margin: 0;
}
.ev-log-row,
.st-report-row,
.db-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  min-height: 40px;
  padding: var(--sp-2) 0;
}
.ev-log-row:last-child,
.st-report-row:last-child,
.db-row:last-child { border-bottom: none; }
.ev-log-row a,
.db-row a,
.st-report-row a {
  color: var(--text);
  text-decoration: none;
}
.ev-row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  margin-left: auto;
}
.ev-empty-note,
.st-empty-note,
.db-empty,
.sx-empty {
  color: var(--muted);
  margin: 0;
}

.ev-detail__hero,
.st-detail__hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
}
.ev-detail__grid,
.st-detail__grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}
.ev-stats {
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}
.ev-stats div {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-3);
}
.ev-stats dt {
  color: var(--muted);
  font-size: var(--text-xs);
}
.ev-stats dd {
  color: var(--text-strong);
  font-size: var(--text-md);
  font-weight: 700;
  margin: var(--sp-1) 0 0;
}

.st-meter,
.db-progress {
  background: var(--surface-elev);
  border-radius: var(--r-full);
  height: 8px;
  overflow: hidden;
  width: 100%;
}
.st-meter span,
.db-progress span {
  background: var(--grad-success);
  border-radius: inherit;
  display: block;
  height: 100%;
  min-width: 2px;
}
.st-meter--large { height: 12px; }
.st-card__empty,
.st-muted {
  color: var(--muted);
  margin: 0;
}
.st-current-value {
  color: var(--text-strong);
  font-size: var(--text-2xl);
  font-weight: 800;
  margin: 0;
}
.st-mini-chart,
.sx-line-chart {
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent) 8%, transparent)), var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  height: 180px;
  overflow: hidden;
  position: relative;
}
.st-chart-point,
.sx-point {
  background: var(--accent-strong);
  border: 2px solid var(--surface);
  border-radius: var(--r-full);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  height: 12px;
  left: var(--x);
  position: absolute;
  top: var(--y);
  transform: translate(-50%, -50%);
  width: 12px;
}
.st-chart-point.state-good { background: var(--success); }
.st-chart-point.state-mid { background: var(--warning); }
.st-chart-point.state-low { background: var(--text-warning); }
.st-chart-point.state-bad { background: var(--danger); }
.st-binary-strip,
.sx-binary-strip {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}
.st-binary-dot,
.sx-binary-dot {
  background: color-mix(in srgb, var(--danger) 22%, var(--surface-elev));
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  border-radius: var(--r-sm);
  display: inline-block;
  height: 28px;
  width: 12px;
}
.st-binary-dot.is-on,
.sx-binary-dot.is-on {
  background: color-mix(in srgb, var(--success) 30%, var(--surface-elev));
  border-color: color-mix(in srgb, var(--success) 50%, var(--line));
}

.db-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.db-card--tasks,
.db-card--numbers,
.sx-card--event-time,
.sx-card--states { grid-column: span 2; }
.db-list,
.sx-bars,
.sx-state-stack {
  display: grid;
  gap: var(--sp-2);
}
.db-row {
  justify-content: flex-start;
}
.db-row a {
  color: var(--text-strong);
  min-width: 0;
  overflow-wrap: anywhere;
}
.db-weather {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
}
.db-numbers,
.sx-outcomes {
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
.db-numbers article,
.sx-outcome {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-3);
}
.db-numbers strong,
.sx-big,
.sx-outcome strong {
  color: var(--text-strong);
  font-size: var(--text-xl);
  line-height: 1;
}
.db-numbers span,
.sx-outcome span {
  color: var(--muted);
  font-size: var(--text-xs);
}

.sx-period a {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--text-sm);
  min-height: 36px;
  padding: 8px var(--sp-3);
  text-decoration: none;
}
.sx-period a.active {
  background: var(--grad-accent);
  border-color: transparent;
  color: var(--on-accent);
}
.sx-card--heatmap,
.sx-card--tasks,
.sx-card--streak,
.sx-card--binary { grid-column: span 2; }
.sx-big {
  font-size: var(--text-2xl);
  font-weight: 800;
  margin: 0;
}
.sx-heatmap {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(auto-fill, minmax(12px, 1fr));
}
.sx-heat {
  aspect-ratio: 1;
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.sx-heat--1 { background: color-mix(in srgb, var(--accent) 18%, var(--surface-elev)); }
.sx-heat--2 { background: color-mix(in srgb, var(--accent) 34%, var(--surface-elev)); }
.sx-heat--3 { background: color-mix(in srgb, var(--accent) 52%, var(--surface-elev)); }
.sx-heat--4 { background: color-mix(in srgb, var(--accent) 72%, var(--surface-elev)); }
.sx-bar-row {
  display: grid;
  gap: var(--sp-2);
}
.sx-bar-row > div:first-child {
  align-items: center;
  display: flex;
  gap: var(--sp-2);
  justify-content: space-between;
}
.sx-bar-row span {
  color: var(--muted);
  font-size: var(--text-xs);
}
.sx-bar {
  background: var(--surface-elev);
  border-radius: var(--r-full);
  height: 10px;
  overflow: hidden;
}
.sx-bar span {
  background: var(--grad-accent);
  border-radius: inherit;
  display: block;
  height: 100%;
}
.sx-state-chart,
.sx-binary-row {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
}
.sx-state-chart header,
.sx-binary-row {
  align-items: center;
}
.sx-state-chart header {
  display: flex;
  justify-content: space-between;
}
.sx-state-chart header span {
  color: var(--muted);
  font-size: var(--text-xs);
}
.sx-outcome--done { border-color: color-mix(in srgb, var(--success) 45%, var(--line)); }
.sx-outcome--failed { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.sx-outcome--overdue { border-color: color-mix(in srgb, var(--warning) 45%, var(--line)); }

/* FB-9 grouped ideas */
.ig-page,
.ig-detail,
.ig-form {
  display: grid;
  gap: var(--sp-4);
  width: 100%;
}

.ig-head,
.ig-manager,
.ig-section,
.ig-all,
.ig-detail,
.ig-form,
.ig-detail__groups,
.ig-detail__projects,
.ig-detail__photos,
.ig-photo-upload {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.ig-head,
.ig-detail,
.ig-form {
  padding: var(--sp-5);
}

.ig-head,
.ig-detail__head {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  justify-content: space-between;
}

.ig-kicker {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  margin: 0 0 var(--sp-1);
  text-transform: uppercase;
}

.ig-head h1,
.ig-detail h1,
.ig-form h1 {
  color: var(--text-strong);
  font-size: var(--text-xl);
  line-height: 1.1;
  margin: 0;
}

.ig-sub,
.ig-muted,
.ig-empty {
  color: var(--muted);
  margin: var(--sp-1) 0 0;
}

.ig-actions,
.ig-group-create,
.ig-group-edit,
.ig-card__groups,
.ig-card__tags,
.ig-detail__actions,
.ig-attach-list {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.ig-manager,
.ig-section,
.ig-all {
  overflow: hidden;
}

.ig-all summary,
.ig-section__summary {
  color: var(--text-strong);
  cursor: pointer;
  font-weight: 700;
  padding: var(--sp-3) var(--sp-4);
}

.ig-manager__title {
  color: var(--text-strong);
  font-size: var(--text-md);
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
}

.ig-group-create,
.ig-group-settings {
  border-top: 1px solid var(--line);
  padding: var(--sp-3) var(--sp-4);
}

.ig-group-create__submit:disabled {
  background: var(--surface-elev);
  border-color: var(--line);
  color: var(--muted);
}

.ig-group-create__submit--ready {
  background: var(--grad-success);
  color: var(--on-success);
}

.ig-group-filter {
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) auto;
  padding: var(--sp-4);
}

.ig-group-filter__field,
.ig-group-edit label {
  display: grid;
  gap: var(--sp-1);
}

.ig-group-filter__field > span,
.ig-group-edit label > span,
.ig-group-reorder > span {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.ig-group-filter__actions,
.ig-group-settings__head,
.ig-group-reorder {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.ig-group-settings {
  background: var(--surface-soft);
  display: grid;
  gap: var(--sp-3);
}

.ig-group-settings__head { justify-content: space-between; }
.ig-group-settings__head h3 { font-size: var(--text-md); margin: 0; }
.ig-group-edit { align-items: end; }
.ig-group-delete { border-top: 1px solid var(--line); padding-top: var(--sp-3); }
.ig-group-filter__empty {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  color: var(--muted);
  margin: 0;
  padding: var(--sp-4);
}

.ig-group-create .form-control,
.ig-group-create .form-select,
.ig-group-edit .form-control,
.ig-group-edit .form-select {
  max-width: 220px;
}

.ig-section {
  --ig-color: var(--accent);
  border-color: color-mix(in srgb, var(--ig-color) 30%, var(--line));
}

.ig-section--default,
.ig-chip--default { --ig-color: var(--accent); }
.ig-section--accent,
.ig-chip--accent { --ig-color: var(--accent); }
.ig-section--success,
.ig-chip--success { --ig-color: var(--success); }
.ig-section--warning,
.ig-chip--warning { --ig-color: var(--warning); }
.ig-section--danger,
.ig-chip--danger { --ig-color: var(--danger); }
.ig-section--info,
.ig-chip--info { --ig-color: var(--text-binary); }

.ig-section__title {
  align-items: center;
  display: inline-flex;
  gap: var(--sp-2);
}

.ig-group-row {
  align-items: center;
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: 32px minmax(0, 1fr) auto auto;
}

.ig-group-row__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ig-group-row__count { color: var(--muted); font-size: var(--text-xs); }
.ig-group-row__edit { justify-self: end; }

@media (max-width: 700px) {
  .ig-group-filter { grid-template-columns: 1fr; }
  .ig-group-filter__actions { align-items: stretch; flex-direction: column; }
  .ig-group-row { grid-template-columns: 32px minmax(0, 1fr) auto; }
  .ig-group-row__edit { grid-column: 1 / -1; justify-self: stretch; }
}

.ig-section__emoji {
  align-items: center;
  background: color-mix(in srgb, var(--ig-color) 16%, var(--surface-elev));
  border: 1px solid color-mix(in srgb, var(--ig-color) 40%, var(--line));
  border-radius: var(--r-md);
  display: inline-flex;
  height: 32px;
  justify-content: center;
  width: 32px;
}

.ig-section__title small {
  color: var(--muted);
  font-size: var(--text-xs);
}

.ig-sections,
.ig-grid {
  display: grid;
  gap: var(--sp-3);
}

.ig-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  padding: var(--sp-4);
}

.ig-card {
  display: grid;
  gap: var(--sp-3);
  min-width: 0;
}

.ig-card__main {
  color: inherit;
  display: grid;
  gap: var(--sp-3);
  text-decoration: none;
}

.ig-card__main:focus-visible { border-radius: var(--r-md); box-shadow: var(--focus-ring); outline: none; }
.ig-card__image {
  display: block;
  overflow: hidden;
  position: relative;
}

.ig-card__carousel {
  aspect-ratio: 16 / 10;
}

.ig-card__carousel .ig-card__slide {
  height: 100%;
  inset: 0;
  opacity: 0;
  position: absolute;
  width: 100%;
}

.ig-card__carousel .ig-card__slide.is-active {
  opacity: 1;
}

.ig-card__photo-count {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  color: var(--text-strong);
  font-size: var(--text-xs);
  font-weight: 700;
  inset-block-start: var(--sp-2);
  inset-inline-end: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.ig-card__image img,
.ig-detail__image {
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.ig-card__body h3 {
  font-size: var(--text-md);
  margin: 0;
}

.ig-card__body h3 {
  color: var(--text-strong);
}

.ig-card__body p {
  color: var(--text);
  margin: var(--sp-1) 0 0;
}

.ig-chip {
  --ig-color: var(--accent);
  background: color-mix(in srgb, var(--ig-color) 12%, var(--surface-elev));
  border: 1px solid color-mix(in srgb, var(--ig-color) 45%, var(--line));
  border-radius: var(--r-full);
  color: var(--text);
  display: inline-flex;
  font: inherit;
  font-size: var(--text-xs);
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-2);
  text-decoration: none;
}

.ig-detail__image {
  border-radius: var(--r-md);
  display: block;
  max-height: 420px;
  width: 100%;
}

.ig-detail__text {
  color: var(--text);
  font-size: var(--text-md);
  white-space: pre-line;
}

.ig-detail__groups,
.ig-detail__projects,
.ig-detail__photos,
.ig-photo-upload {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
}

.ig-detail__groups h2,
.ig-detail__projects h2,
.ig-detail__photos h2,
.ig-photo-upload h2 {
  color: var(--text-strong);
  font-size: var(--text-md);
  margin: 0;
}

.ig-project-links,
.ig-project-attach {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.ig-project-attach label { color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.ig-project-attach .form-select { flex: 1 1 220px; }

.ig-photo-grid,
.ig-photo-upload__slots {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}
.ig-photo { display: grid; gap: var(--sp-2); margin: 0; min-width: 0; }
.ig-photo > img { aspect-ratio: 4 / 3; border-radius: var(--r-md); object-fit: cover; width: 100%; }
.ig-photo__caption { color: var(--text); white-space: pre-line; }
.ig-photo__edit { border-top: 1px solid var(--line); padding-top: var(--sp-2); }
.ig-photo__edit summary { color: var(--muted); cursor: pointer; font-size: var(--text-xs); }
.ig-photo__edit form,
.ig-photo-upload form,
.ig-photo-upload__slot { display: grid; gap: var(--sp-2); }
.ig-photo__edit form + form { border-top: 1px solid var(--line); margin-top: var(--sp-2); padding-top: var(--sp-2); }
.ig-photo__edit label,
.ig-photo-upload label { color: var(--muted); display: grid; font-size: var(--text-xs); gap: var(--sp-1); }
.ig-photo-upload__slot { background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3); }

@media (max-width: 900px) {
  .ev-head,
  .st-head,
  .db-head,
  .sx-head,
  .ev-detail__hero,
  .st-detail__hero {
    grid-template-columns: 1fr;
  }
  .db-grid,
  .sx-grid {
    grid-template-columns: 1fr;
  }
  .db-card--tasks,
  .db-card--numbers,
  .sx-card--event-time,
  .sx-card--states,
  .sx-card--heatmap,
  .sx-card--tasks,
  .sx-card--streak,
  .sx-card--binary {
    grid-column: span 1;
  }
}

/* ─── Companion always-on placement and policy controls (CMP-5) ─── */

.cmp-privacy-toggle {
  align-items: center;
  background: var(--surface-overlay);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  position: absolute;
  right: var(--sp-4);
  top: var(--sp-4);
  transition: background var(--t-base), border-color var(--t-base), box-shadow var(--t-base), color var(--t-base);
  z-index: 4;
}

.cmp-privacy-toggle[aria-pressed="true"] {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: var(--accent-glow);
  color: var(--on-accent);
}

.cmp-privacy-toggle [data-companion-privacy-icon] {
  font-size: var(--text-md);
  line-height: 1;
}

.cmp-privacy-help {
  background: var(--surface-overlay);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: var(--text-xs);
  margin: 0;
  max-width: calc(100% - var(--sp-6));
  padding: var(--sp-2) var(--sp-3);
  position: absolute;
  right: var(--sp-4);
  top: calc(var(--sp-7) + var(--sp-3));
  width: 32rem;
  z-index: 3;
}

.cmp-corner {
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  bottom: calc(var(--mobile-nav-h) + var(--sp-4));
  box-shadow: var(--shadow-lg);
  height: 11rem;
  overflow: hidden;
  position: fixed;
  right: var(--sp-4);
  width: 16rem;
  z-index: 60;
}

.cmp-corner__canvas {
  cursor: pointer;
  display: block;
  height: 100%;
  width: 100%;
}

.cmp-corner__fallback {
  align-items: center;
  color: var(--accent-strong);
  display: flex;
  font-family: var(--font-mono);
  inset: 0;
  justify-content: center;
  padding: var(--sp-3);
  position: absolute;
  text-align: center;
}

.cmp-corner__fallback[hidden] {
  display: none;
}

.cmp-corner__deadline {
  color: var(--danger);
  font-weight: 700;
  margin: 0;
  max-width: calc(100% - var(--sp-6));
  overflow-wrap: anywhere;
}

.cmp-corner__open {
  align-items: center;
  background: var(--surface-overlay);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  bottom: var(--sp-2);
  color: var(--text);
  display: inline-flex;
  font-size: var(--text-xs);
  gap: var(--sp-2);
  left: 50%;
  max-width: calc(100% - var(--sp-4));
  padding: var(--sp-1) var(--sp-3);
  position: absolute;
  text-decoration: none;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 3;
}

.cmp-corner__open:hover,
.cmp-corner__open:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  color: var(--accent-strong);
  outline: none;
}

.cmp-privacy-toggle--corner {
  padding: var(--sp-2);
  right: var(--sp-2);
  top: var(--sp-2);
}

.cmp-privacy-help--corner {
  max-width: calc(100% - var(--sp-4));
  opacity: 0;
  pointer-events: none;
  right: var(--sp-2);
  top: calc(var(--sp-6) + var(--sp-2));
  transform: translateY(calc(-1 * var(--sp-1)));
  transition: opacity var(--t-fast), transform var(--t-fast), visibility var(--t-fast);
  visibility: hidden;
  width: calc(100% - var(--sp-4));
  z-index: 5;
}

.cmp-privacy-toggle--corner:hover + .cmp-privacy-help--corner,
.cmp-privacy-toggle--corner:focus-visible + .cmp-privacy-help--corner {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.cmp-settings__quiet {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin: 0;
  padding: var(--sp-3);
}

.cmp-settings__quiet legend {
  color: var(--text);
  font-weight: 600;
  padding-inline: var(--sp-1);
}

.cmp-settings__quiet-fields {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cmp-settings__quiet-fields label {
  display: grid;
  gap: var(--sp-1);
}

.cmp-settings__charset .profile-setting-help {
  margin: var(--sp-2) 0 0;
}

.cmp-settings__sources > div {
  display: grid;
  gap: var(--sp-2);
}

.cmp-settings__sources label {
  align-items: center;
  display: flex;
  gap: var(--sp-2);
}

@media (min-width: 1101px) {
  .cmp-corner {
    bottom: var(--sp-4);
  }
}

@media (max-width: 700px) {
  .cmp-corner {
    display: none;
    height: 8.5rem;
    right: var(--sp-2);
    width: 12rem;
  }

  .cmp-corner.cmp-corner--enabled {
    display: block;
  }

  .cmp-corner__open {
    font-size: var(--text-xs);
    max-width: calc(100% - var(--sp-3));
    padding-inline: var(--sp-2);
  }

  .cmp-privacy-toggle {
    right: var(--sp-2);
    top: var(--sp-2);
  }

  .cmp-privacy-help:not(.cmp-privacy-help--corner) {
    max-width: calc(100% - var(--sp-4));
    right: var(--sp-2);
    top: calc(var(--sp-7) + var(--sp-2));
    width: calc(100% - var(--sp-4));
  }

  .cmp-settings__quiet-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .ev-head,
  .st-head,
  .db-head,
  .sx-head,
  .ev-card,
  .st-card,
  .ev-panel,
  .st-panel,
  .db-card,
  .sx-card,
  .ev-history,
  .st-history {
    border-radius: var(--r-md);
    padding: var(--sp-3);
  }
  .ev-card__top,
  .st-card__actions,
  .ev-live,
  .ev-card__actions,
  .ev-section-head,
  .st-section-head,
  .db-card__head,
  .sx-card__head {
    align-items: stretch;
    flex-direction: column;
  }
  .ev-stats,
  .db-numbers,
  .sx-outcomes {
    grid-template-columns: 1fr;
  }
  .ev-row-actions {
    margin-left: 0;
    width: 100%;
  }
}

/* ═══════════════════════════════════════════════════════
   DASHBOARD
   ══════════════════════════════════════════════════════ */

.dashboard {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0;
  width: 100%;
}
.dashboard-header { grid-column: 1 / -1; }
.dashboard-header h1 { font-size: var(--text-lg); font-weight: 700; margin: 0 0 var(--sp-2); }

.dashboard-card {
  max-height: 360px;
  overflow: auto;
}
.dashboard-card h2 {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0 0 var(--sp-2);
}
.dashboard-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: 7px 0;
}
.dashboard-row:last-child { border-bottom: none; }

/* ═══════════════════════════════════════════════════════
   STATISTICS
   Chart.js mobile fix — explicit canvas height.
   IMPORTANT: also set maintainAspectRatio: false in
   statistics.js for this to take full effect.
   ══════════════════════════════════════════════════════ */

.statistics { display: grid; gap: var(--sp-4); padding: 0; }
.statistics-header {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: space-between;
}
.statistics-header h1 { font-size: var(--text-lg); font-weight: 700; margin: 0 0 3px; }
.statistics-header p  { color: var(--muted); font-size: var(--text-sm); margin: 0; }

.statistics-period { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.statistics-period a {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--text-sm);
  padding: 7px var(--sp-3);
  text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.statistics-period a:hover { background: var(--surface-soft); }
.statistics-period a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.statistics-cards {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.stat-card h2 { color: var(--muted); font-size: var(--text-sm); font-weight: 500; margin: 0 0 var(--sp-2); }
.stat-big { font-size: 2rem; font-weight: 700; line-height: 1; margin: 0; }

.statistics-charts {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}
.chart-wrapper { display: flex; flex-direction: column; }
.chart-wrapper h2 { font-size: var(--text-sm); font-weight: 600; margin: 0 0 var(--sp-3); }
.chart-wrapper canvas {
  flex: 1;
  height: 260px !important;
  max-height: 320px;
  min-height: 220px;
  width: 100% !important;
}

/* ═══════════════════════════════════════════════════════
   QUICK MARKS — font-scale metaphor preserved
   ══════════════════════════════════════════════════════ */

.quick-marks { padding: var(--sp-4); width: 100%; }
.quick-marks-header { margin-bottom: var(--sp-4); }
.quick-marks-header h1 { font-size: var(--text-lg); font-weight: 700; margin: 0 0 4px; }
.quick-marks-header p  { color: var(--muted); font-size: var(--text-sm); margin: 0; }

.quick-marks-cloud { align-items: center; display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.quick-mark-bubble {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  display: inline-flex;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 8px var(--sp-3);
  text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.quick-mark-bubble small { color: var(--muted); font-size: .75em; }
.quick-mark-bubble:hover { background: var(--accent-muted); border-color: var(--accent); color: var(--text); }
.quick-mark-event { border-left: 3px solid var(--accent); }
.quick-mark-state { border-left: 3px solid var(--success); }
.quick-mark-task  { border-left: 3px solid var(--warning); }

/* ═══════════════════════════════════════════════════════
   PROJECTS
   ══════════════════════════════════════════════════════ */

.projects-page { display: grid; gap: var(--sp-4); padding: 0; }
.project-card { display: grid; gap: var(--sp-2); }
.pj-header { align-items: start; display: flex; gap: var(--sp-3); justify-content: space-between; }
.pj-filter-form {
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(150px, 1fr)) auto;
  padding: var(--sp-4);
}
.pj-filter-field { display: grid; gap: var(--sp-1); min-width: 0; }
.pj-filter-field > span { color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.pj-filter-field input,
.pj-filter-field select {
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font: inherit;
  min-height: 40px;
  min-width: 0;
  padding: 8px var(--sp-3);
  width: 100%;
}
.pj-filter-field input:focus-visible,
.pj-filter-field select:focus-visible { border-color: var(--accent); box-shadow: var(--focus-ring); outline: none; }
.pj-filter-actions { display: flex; gap: var(--sp-2); }
.pj-status-filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.pj-status-filters a {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: var(--text-sm);
  padding: var(--sp-1) var(--sp-3);
  text-decoration: none;
}
.pj-status-filters a:hover,
.pj-status-filters a.active { background: var(--accent-muted); border-color: var(--accent); color: var(--accent-strong); }
.pj-empty {
  align-items: start;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  display: grid;
  gap: var(--sp-2);
  justify-items: start;
  padding: var(--sp-5);
}
.pj-empty h2,
.pj-empty p { margin: 0; }
.pj-empty p { color: var(--muted); }
.pj-grid > .pj-empty { grid-column: 1 / -1; }
@media (max-width: 900px) {
  .pj-filter-form { grid-template-columns: 1fr 1fr; }
  .pj-filter-search,
  .pj-filter-actions { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .pj-header { align-items: stretch; flex-direction: column; }
  .pj-filter-form { grid-template-columns: 1fr; }
  .pj-filter-search,
  .pj-filter-actions { grid-column: auto; }
  .pj-filter-actions { align-items: stretch; flex-direction: column; }
}
.project-summary { align-items: center; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.project-actions { align-items: center; display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.project-badge {
  background: var(--accent-muted);
  border-radius: var(--r-sm);
  color: var(--accent-strong);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 3px 8px;
}
.project-task-add,
.project-task-link {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.project-task-add .form-control[type="text"] { flex: 1 1 200px; min-width: 0; }
.project-task-link .form-select { flex: 1 1 200px; min-width: 0; }

/* ═══════════════════════════════════════════════════════
   VAULT
   ══════════════════════════════════════════════════════ */

.vault-entry {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-3);
}
.vault-password,
.vault-secret-value,
.vault-secret-mask {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: 'Courier New', monospace;
  font-size: var(--text-sm);
  padding: var(--sp-2) var(--sp-3);
  word-break: break-all;
}
.vault-secret-mask { color: var(--muted); letter-spacing: 0.15em; }
.vault-reveal-countdown { color: var(--muted); font-size: var(--text-xs); margin-top: 4px; }

/* Reveal modal — countdown ring (reveal.js attaches by [data-vault-reveal]) */
.vault-reveal-overlay { /* re-uses .modal-overlay from components.css */ }
.vault-reveal-modal {
  margin: 0 auto;
  max-width: 380px;
  text-align: center;
}
.vault-reveal-body {
  display: grid;
  gap: var(--sp-3);
  justify-items: center;
}
.vault-reveal-caption {
  color: var(--muted);
  font-size: var(--text-sm);
  margin: 0;
  max-width: 28ch;
}
.vault-countdown-ring { display: block; height: 96px; margin: 0 auto; width: 96px; }
.vault-countdown-ring circle.bg { fill: none; stroke: var(--line); stroke-width: 6; }
.vault-countdown-ring circle.fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 270;
  stroke-dashoffset: 0;
  transform: rotate(-90deg);
  transform-origin: center;
  animation: vault-cd-tick var(--vault-cd, 10s) linear forwards;
}
.vault-countdown-ring text { fill: var(--text-strong); font-family: var(--font-mono); font-size: 28px; font-weight: 700; text-anchor: middle; }
.vault-revealed-pw {
  background: var(--surface-strong);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: var(--r-md);
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 12px var(--sp-3);
  word-break: break-all;
}

/* ═══════════════════════════════════════════════════════
   WISHLIST
   ══════════════════════════════════════════════════════ */

.wishlist-card, .wishlist-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}
.wishlist-form { display: grid; gap: var(--sp-3); }
.wishlist-item-priority-1 { border-left: 3px solid var(--muted); }
.wishlist-item-priority-2 { border-left: 3px solid var(--warning); }
.wishlist-item-priority-3 { border-left: 3px solid var(--danger); }

.public-body {
  --page-bg: var(--public-page-bg);
  --page-bg-mesh: var(--public-page-bg-mesh);
  --surface: var(--public-surface);
  --surface-soft: var(--public-surface-soft);
  --surface-elev: var(--public-surface-elev);
  --surface-strong: var(--public-surface-strong);
  --text: var(--public-text);
  --text-strong: var(--public-text-strong);
  --muted: var(--public-muted);
  --line: var(--public-line);
  --line-strong: var(--public-line-strong);
  --accent: var(--public-accent);
  --accent-strong: var(--public-accent-strong);
  --accent-deep: var(--public-accent-deep);
  --accent-muted: var(--public-accent-muted);
  --accent-glow: var(--public-accent-glow);
  --grad-accent: var(--public-grad-accent);
  --shadow-sm: var(--public-shadow-sm);
  --shadow: var(--public-shadow);
  --shadow-lg: var(--public-shadow-lg);
  background: var(--page-bg-mesh), var(--page-bg);
  color: var(--text);
  font-family: var(--public-font-sans);
  min-height: 100vh;
}

.public-wrap {
  margin: 0 auto;
  max-width: 1120px;
  padding: clamp(var(--sp-4), 4vw, var(--sp-7)) var(--sp-4) var(--sp-6);
}

.public-messages {
  display: grid;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}

.public-message {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-sm);
  margin: 0;
  padding: 10px 14px;
}

.public-message.is-success {
  border-color: color-mix(in srgb, var(--success) 40%, var(--line));
}

.public-message.is-error {
  border-color: color-mix(in srgb, var(--danger) 38%, var(--line));
}

.public-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-xs);
  margin-top: var(--sp-6);
  padding-top: var(--sp-3);
  text-align: center;
}

.wishlist-public-page {
  display: grid;
  gap: var(--sp-5);
}

.wishlist-public-hero {
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent 58%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: clamp(var(--sp-4), 5vw, var(--sp-6));
  position: relative;
}

.wishlist-public-hero::after {
  background: radial-gradient(circle at center, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%);
  content: "";
  height: 220px;
  inset: auto -8% -30% auto;
  pointer-events: none;
  position: absolute;
  width: 220px;
}

.wishlist-public-eyebrow {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: .18em;
  margin: 0 0 var(--sp-3);
  text-transform: uppercase;
}

.wishlist-public-hero__grid {
  align-items: start;
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: minmax(0, 1.5fr) minmax(220px, .8fr);
  position: relative;
  z-index: 1;
}

.wishlist-public-hero h1 {
  color: var(--text-strong);
  font-family: var(--public-font-display);
  font-size: clamp(2.1rem, 5vw, 4rem);
  letter-spacing: -0.04em;
  line-height: .96;
  margin: 0 0 var(--sp-3);
}

.wishlist-public-hero p {
  color: var(--muted);
  font-size: clamp(var(--text-md), 1.6vw, var(--text-lg));
  margin: 0;
  max-width: 42ch;
}

.wishlist-public-meta {
  align-content: start;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: flex-end;
}

.wishlist-public-chip,
.wishlist-public-meta .tag-chip {
  background: color-mix(in srgb, var(--surface-soft) 84%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line));
  border-radius: var(--r-full);
  color: var(--text-strong);
  font-size: var(--text-sm);
  padding: 8px 12px;
}

.wishlist-public-grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.wishlist-public-card {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  display: grid;
  overflow: hidden;
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}

.wishlist-public-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.wishlist-public-card__media img {
  display: block;
  height: 220px;
  object-fit: cover;
  width: 100%;
}

.wishlist-public-card__body {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
}

.wishlist-public-card__head {
  align-items: start;
  display: flex;
  gap: var(--sp-2);
  justify-content: space-between;
}

.wishlist-public-card__head h2 {
  color: var(--text-strong);
  font-family: var(--public-font-display);
  font-size: clamp(var(--text-lg), 1.4vw, 1.7rem);
  margin: 0;
}

.wishlist-public-card__text {
  color: var(--muted);
  margin: 0;
}

.wishlist-public-card__meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.wishlist-public-card__meta a {
  color: var(--accent-strong);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
}

.wishlist-public-card__meta a:hover {
  color: var(--accent-deep);
}

.wishlist-public-form {
  display: grid;
  gap: var(--sp-2);
}

.wishlist-public-form label {
  color: var(--text-strong);
  font-size: var(--text-sm);
}

.wishlist-public-form input {
  background: color-mix(in srgb, var(--surface-soft) 92%, transparent);
}

.wishlist-public-status {
  border-radius: var(--r-full);
  display: inline-flex;
  font-size: var(--text-sm);
  font-weight: 600;
  justify-self: start;
  margin: 0;
  padding: 8px 12px;
}

.wishlist-public-status.is-fulfilled {
  background: color-mix(in srgb, var(--success) 16%, var(--surface));
  color: var(--success);
}

.wishlist-public-status.is-reserved {
  background: color-mix(in srgb, var(--warning) 18%, var(--surface));
  color: color-mix(in srgb, var(--warning) 80%, var(--text-strong));
}

.wishlist-public-empty {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  color: var(--muted);
  padding: var(--sp-5);
  text-align: center;
}

.wishlist-public-empty p {
  margin: 0;
}

/* ═══════════════════════════════════════════════════════
   PSYCH TESTS
   ══════════════════════════════════════════════════════ */

.psych-test-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}
.psych-question {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
}
.psych-scale { align-items: center; display: flex; gap: var(--sp-2); }
.psych-scale input[type="range"] { accent-color: var(--accent); flex: 1; min-height: 40px; }

/* ═══════════════════════════════════════════════════════
   FAMILY TREE — minimal nav only, leave D3 alone
   ══════════════════════════════════════════════════════ */

.family-container,
.family-tree-view,
.family-tree-settings {
  display: grid;
  gap: var(--sp-3);
  padding: 0;
}

.family-tree-shell {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  width: 100%;
}

.family-tree-sidebar,
.family-tree-toolbar,
.family-tree-canvas {
  padding: var(--sp-4);
}

.family-tree-sidebar {
  align-content: start;
  display: grid;
  gap: var(--sp-4);
  height: fit-content;
  position: sticky;
  top: calc(var(--header-h) + var(--sp-3));
}

.family-tree-sidebar__section {
  display: grid;
  gap: var(--sp-2);
}

.family-tree-kicker {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: .16em;
  margin: 0;
  text-transform: uppercase;
}

.family-tree-sidebar h1,
.family-tree-sidebar h2,
.family-tree-sidebar h3 {
  margin: 0;
}

.family-tree-sidebar p {
  color: var(--muted);
  margin: 0;
}

.family-tree-breadcrumbs {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: var(--text-sm);
}

.family-tree-breadcrumbs a {
  color: var(--text);
  text-decoration: none;
}

.family-tree-breadcrumbs a:hover {
  color: var(--accent-strong);
}

.family-tree-settings-list {
  display: grid;
  gap: var(--sp-2);
  margin: 0;
}

.family-tree-settings-list div {
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: var(--sp-2);
  justify-content: space-between;
  padding-bottom: var(--sp-2);
}

.family-tree-settings-list div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.family-tree-settings-list dt,
.family-tree-settings-list dd {
  margin: 0;
}

.family-tree-settings-list dt {
  color: var(--muted);
  font-size: var(--text-sm);
}

.family-tree-settings-list dd {
  color: var(--text-strong);
  font-weight: 600;
  text-align: right;
}

.family-tree-root-list {
  display: grid;
  gap: var(--sp-2);
  max-height: 360px;
  overflow: auto;
}

.family-tree-root-list a {
  align-items: center;
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  display: flex;
  min-height: 44px;
  padding: 10px 12px;
  text-decoration: none;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}

.family-tree-root-list a:hover {
  background: var(--surface-soft);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.family-tree-root-list a.is-active {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  color: var(--text-strong);
}

.family-tree-stage {
  display: grid;
  gap: var(--sp-3);
  min-width: 0;
}

.family-tree-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: space-between;
}

.family-tree-toolbar__group {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.family-tree-toolbar__stat {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.family-tree-canvas {
  min-width: 0;
}

.family-tree-canvas__viewport {
  align-self: start;
  position: relative;
  width: 100%;
}

.family-tree-canvas__surface {
  background: color-mix(in srgb, var(--surface-soft) 70%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  height: calc(100vh - 220px);
  min-height: 560px;
  overflow: hidden;
  width: 100%;
}

.family-tree-view svg {
  max-width: 100%;
  overflow: visible;
}

.family-tree-svg {
  cursor: grab;
  display: block;
  font-family: var(--font-body);
  touch-action: none;
}

.family-tree-svg:active {
  cursor: grabbing;
}

.family-tree-link {
  fill: none;
  stroke: color-mix(in srgb, var(--line-strong) 80%, var(--accent));
  stroke-linecap: round;
  stroke-width: 2.5;
}

.family-tree-node {
  cursor: pointer;
  outline: none;
}

.family-tree-node:focus-visible .family-tree-card-bg,
.family-tree-node.is-selected .family-tree-card-bg {
  filter: drop-shadow(0 0 0.6rem color-mix(in srgb, var(--accent) 34%, transparent));
}

.family-tree-svg-pill {
  cursor: pointer;
}

.tree-loading,
.family-tree-empty {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  justify-content: center;
  min-height: 400px;
  padding: var(--sp-5);
  text-align: center;
}

.tree-loading__spinner {
  animation: ft-spin .8s linear infinite;
  border: 3px solid color-mix(in srgb, var(--line-strong) 80%, transparent);
  border-radius: var(--r-full);
  border-top-color: var(--accent);
  flex: 0 0 auto;
  height: 34px;
  width: 34px;
}

.family-tree-empty i {
  color: color-mix(in srgb, var(--accent) 30%, var(--muted));
  font-size: clamp(3rem, 7vw, 5rem);
}

.family-tree-empty h3,
.family-tree-empty p {
  margin: 0;
}

.family-tree-empty--error {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  border: 1px dashed color-mix(in srgb, var(--danger) 35%, var(--line));
  border-radius: var(--r-lg);
  color: color-mix(in srgb, var(--danger) 72%, var(--text));
  min-height: 220px;
}

.family-tree-empty__action {
  margin-top: var(--sp-2);
}

.family-tree-empty--polished {
  gap: var(--sp-4);
}

.family-tree-empty__art {
  align-items: center;
  display: grid;
  height: 132px;
  justify-items: center;
  position: relative;
  width: 132px;
}

.family-tree-empty__ring {
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 50%;
  height: 132px;
  position: absolute;
  width: 132px;
}

.family-tree-empty__ring--small {
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  height: 86px;
  width: 86px;
}

.family-tree-empty__seed {
  align-items: center;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 28%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line));
  border-radius: 50%;
  color: var(--accent-strong);
  display: flex;
  font-size: 2rem;
  font-weight: 700;
  height: 56px;
  justify-content: center;
  position: relative;
  width: 56px;
}

.family-tree-modal .modal {
  max-width: min(640px, calc(100vw - 32px));
  width: min(640px, calc(100vw - 32px));
}

.family-tree-modal .modal-form .form-row {
  margin: 0;
}

.family-tree-fab {
  align-items: center;
  display: inline-flex;
  font-size: 1.5rem;
  justify-content: center;
}

.family-page {
  position: relative;
}

.family-tree-sidebar__head,
.family-tree-toolbar__row,
.family-tree-minimap__head,
.family-side-panel__header,
.family-side-panel__inline-form-head,
.family-side-panel__relatives-head {
  align-items: center;
  display: flex;
  gap: var(--sp-2);
  justify-content: space-between;
}

.family-tree-sidebar__close,
.family-tree-drawer-toggle {
  display: none;
}

.family-tree-search {
  display: grid;
  gap: var(--sp-2);
  position: relative;
}

.family-tree-search-results {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  display: grid;
  gap: 6px;
  left: 0;
  max-height: 280px;
  overflow: auto;
  padding: var(--sp-2);
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 12;
}

.family-tree-search-result {
  background: var(--surface-elev);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  text-align: left;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}

.family-tree-search-result:hover,
.family-tree-search-result:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  outline: none;
  transform: translateY(-1px);
}

.family-tree-search-result span,
.family-tree-search-results__empty {
  color: var(--muted);
  font-size: var(--text-sm);
}

.family-tree-layout-switcher {
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.family-tree-layout-switcher .btn-ghost.is-active {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
  color: var(--text-strong);
}

.family-tree-full-link {
  justify-content: center;
  width: 100%;
}

.family-tree-depth-controls {
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.family-tree-depth-controls label {
  display: grid;
  gap: 6px;
}

.family-tree-depth-controls span {
  color: var(--muted);
  font-size: var(--text-sm);
}

.family-tree-breadcrumbs button.btn-link {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  margin: 0;
  padding: 0;
}

.family-tree-breadcrumbs button.btn-link:hover,
.family-tree-breadcrumbs button.btn-link:focus-visible {
  color: var(--accent-strong);
  outline: none;
  text-decoration: underline;
}

.family-tree-canvas {
  min-width: 0;
  position: relative;
}

.family-tree-minimap {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  bottom: 20px;
  box-shadow: var(--shadow);
  padding: var(--sp-2);
  position: absolute;
  right: 20px;
  width: 224px;
  z-index: 6;
}

.family-tree-minimap svg {
  cursor: pointer;
  display: block;
  height: auto;
  width: 100%;
}

.family-tree-minimap__bg {
  fill: color-mix(in srgb, var(--surface-soft) 78%, transparent);
  stroke: color-mix(in srgb, var(--line-strong) 60%, transparent);
}

.family-tree-minimap circle {
  fill: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.family-tree-minimap circle.is-main {
  fill: var(--accent-strong);
}

.family-tree-minimap__viewport {
  fill: color-mix(in srgb, var(--accent) 10%, transparent);
  stroke: color-mix(in srgb, var(--accent) 58%, var(--line));
  stroke-width: 2;
}

@media (min-width: 761px) {
  .family-tree-view {
    min-height: calc(100dvh - var(--header-h) - var(--sp-4));
  }

  .family-tree-shell {
    min-height: inherit;
  }

  .family-tree-stage {
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
  }

  .family-tree-canvas {
    display: grid;
    min-height: 0;
  }

  .family-tree-canvas__surface {
    height: clamp(440px, calc(100dvh - 320px), 680px);
    min-height: 0;
  }
}

.family-card {
  --family-card-accent: color-mix(in srgb, var(--accent) 38%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--surface-elev) 96%, transparent));
  border: 1px solid color-mix(in srgb, var(--family-card-accent) 56%, var(--line));
  border-radius: 28px;
  box-sizing: border-box;
  box-shadow: 0 18px 36px rgba(11, 18, 27, .18);
  color: var(--text);
  display: grid;
  gap: 10px;
  grid-template-columns: 74px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 14px;
  position: relative;
  width: 100%;
}

.card-inner {
  box-sizing: border-box;
  display: block;
  height: 160px;
  min-height: 160px;
  width: 100%;
}

.family-card.card-inner {
  display: grid;
  height: 160px;
  min-height: 160px;
}

.family-card .family-card__title { color: var(--text-strong); }
.family-card .family-card__dates,
.family-card .family-card__meta { color: var(--muted); }

.family-card::before {
  background: linear-gradient(180deg, color-mix(in srgb, var(--family-card-accent) 88%, white), color-mix(in srgb, var(--family-card-accent) 28%, transparent));
  border-radius: var(--r-full);
  content: "";
  inset: 12px auto 12px 12px;
  position: absolute;
  width: 4px;
}

.family-card--male {
  --family-card-accent: #4f8ac9;
}

.family-card--female {
  --family-card-accent: #c46b89;
}

.family-card.is-deceased {
  box-shadow: 0 14px 24px rgba(11, 18, 27, .12);
  opacity: .94;
}

.family-card__media,
.family-card__placeholder {
  align-items: center;
  aspect-ratio: 1;
  background: var(--surface-elev);
  border-radius: 22px;
  display: flex;
  height: 74px;
  justify-content: center;
  overflow: hidden;
  width: 74px;
}

.family-card__media img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.family-card__placeholder {
  background: color-mix(in srgb, var(--family-card-accent) 18%, var(--surface));
  color: color-mix(in srgb, var(--family-card-accent) 84%, var(--text-strong));
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .04em;
}

.family-card__body {
  display: grid;
  align-content: start;
  gap: 4px;
  grid-auto-rows: min-content;
  height: 100%;
  min-width: 0;
}

.family-card__title {
  color: var(--text-strong);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.family-card__dates,
.family-card__meta {
  color: var(--muted);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.family-card__actions {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.family-card__expand {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--family-card-accent) 34%, var(--line));
  border-radius: var(--r-full);
  color: color-mix(in srgb, var(--family-card-accent) 84%, var(--text-strong));
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
}

.family-card__expand:hover,
.family-card__expand:focus-visible {
  background: color-mix(in srgb, var(--family-card-accent) 12%, var(--surface));
  outline: none;
}

.family-card--group {
  align-items: center;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    color-mix(in srgb, var(--surface) 96%, transparent);
  grid-template-columns: 1fr;
  min-height: 120px;
  padding-left: 18px;
}

.family-card--fallback {
  grid-template-columns: 1fr;
}

.family-card__body--fallback {
  margin-left: 10px;
}

.family-card--group::before {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 90%, white), color-mix(in srgb, var(--accent) 32%, transparent));
}

.family-card__group-copy {
  display: grid;
  gap: 8px;
}

.family-side-panel-backdrop {
  background: rgba(11, 18, 27, .36);
  inset: 0;
  opacity: 0;
  position: fixed;
  transition: opacity var(--t-base);
  z-index: 39;
}

.family-side-panel-backdrop.is-open {
  opacity: 1;
}

.family-side-panel {
  border-radius: 28px 0 0 28px;
  bottom: 0;
  display: grid;
  gap: var(--sp-3);
  max-width: min(460px, 100vw);
  overflow: hidden;
  padding: 0;
  position: fixed;
  right: 0;
  top: 0;
  transform: translateX(104%);
  transition: transform var(--t-base);
  width: min(460px, 100vw);
  z-index: 40;
}

.family-side-panel.is-open {
  transform: translateX(0);
}

.family-side-panel__header,
.family-side-panel__body {
  padding: var(--sp-4);
}

.family-side-panel__header {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, transparent), transparent 58%),
    var(--surface);
  border-bottom: 1px solid var(--line);
}

.family-side-panel__body {
  display: grid;
  gap: var(--sp-4);
  overflow: auto;
}

.family-side-panel__summary,
.family-side-panel__form,
.family-side-panel__relatives {
  display: grid;
  gap: var(--sp-3);
}

.family-side-panel__hero {
  align-items: start;
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: 88px minmax(0, 1fr);
}

.family-side-panel__photo,
.family-side-panel__photo-placeholder {
  aspect-ratio: 1;
  border-radius: 24px;
  overflow: hidden;
  width: 88px;
}

.family-side-panel__photo img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.family-side-panel__photo-placeholder {
  align-items: center;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--accent-strong);
  display: flex;
  font-size: 1.35rem;
  font-weight: 700;
  justify-content: center;
}

.family-side-panel__photo-placeholder--female {
  background: color-mix(in srgb, #c46b89 16%, var(--surface));
  color: #c46b89;
}

.family-side-panel__copy {
  display: grid;
  gap: 6px;
}

.family-side-panel__copy h3,
.family-side-panel__copy p,
.family-side-panel__bio {
  margin: 0;
}

.family-side-panel__copy p,
.family-side-panel__bio,
.family-side-panel__relatives-head p {
  color: var(--muted);
}

.family-side-panel__facts {
  display: grid;
  gap: var(--sp-2);
}

.family-side-panel__facts div {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: 4px;
  padding: 10px 12px;
}

.family-side-panel__facts span {
  color: var(--muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
}

.family-side-panel__facts strong {
  color: var(--text-strong);
  font-size: var(--text-sm);
}

.family-side-panel__actions {
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.family-side-panel__actions #sidePanelSetRootBtn {
  grid-column: 1 / -1;
}

.family-side-panel__relative-buttons,
.family-side-panel__inline-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.family-side-panel__relative-buttons .action-btn,
.family-side-panel__inline-form-actions .action-btn {
  flex: 1 1 160px;
}

.family-side-panel__inline-form {
  background: color-mix(in srgb, var(--surface-elev) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-3);
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE PAGES
   Calendar-specific @media rules moved to calendar.css.
   ══════════════════════════════════════════════════════ */

.family-relationship-editor {
  display: grid;
  gap: var(--sp-3);
}

.family-relationship-editor__group {
  display: grid;
  gap: var(--sp-2);
}

.family-relationship-editor__group label {
  color: var(--text-strong);
  font-size: var(--text-sm);
  font-weight: 600;
}

.family-relationship-editor__head,
.family-relationship-editor__select-row,
.family-relationship-editor__child-item {
  align-items: center;
  display: flex;
  gap: var(--sp-2);
  justify-content: space-between;
}

.family-relationship-editor__head {
  flex-wrap: wrap;
}

.family-relationship-editor__hint,
.family-relationship-editor__empty {
  color: var(--muted);
  font-size: var(--text-xs);
  margin: 0;
}

.family-relationship-editor__children {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
}

.family-relationship-editor__child-item {
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  padding-bottom: var(--sp-2);
}

.family-relationship-editor__child-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.family-relationship-editor__child-item span {
  color: var(--text-strong);
}

.family-relationship-editor__select-row select,
.family-relationship-editor__group select {
  width: 100%;
}

.family-relationship-editor__select-row .action-btn {
  flex: 0 0 auto;
}

.family-tree-dashboard-stage {
  display: grid;
  gap: var(--sp-3);
  min-width: 0;
}

.family-tree-dashboard-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: space-between;
  padding: var(--sp-4);
}

.family-tree-dashboard-header h2 {
  margin: 0 0 var(--sp-1);
}

.family-tree-dashboard-header p {
  color: var(--muted);
  margin: 0;
  max-width: 54ch;
}

.family-tree-dashboard-summary {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

.family-tree-person-grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}

.family-tree-person-card {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
}

.family-tree-person-top {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: 88px minmax(0, 1fr);
}

.family-tree-person-photo {
  align-self: start;
  aspect-ratio: 1;
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.family-tree-person-photo img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.family-tree-person-avatar {
  align-items: center;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent-strong);
  display: flex;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  font-weight: 700;
  height: 100%;
  justify-content: center;
  width: 100%;
}

.family-tree-person-avatar.is-female {
  background: color-mix(in srgb, var(--warning) 14%, var(--surface));
  color: color-mix(in srgb, var(--warning) 86%, var(--text-strong));
}

.family-tree-person-copy {
  display: grid;
  gap: var(--sp-2);
}

.family-tree-person-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.family-tree-person-head h2 {
  margin: 0;
}

.family-tree-person-meta {
  color: var(--muted);
  margin: 0;
}

.family-tree-person-links,
.family-tree-person-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.family-tree-person-actions .action-btn,
.family-tree-person-links .action-btn {
  flex: 1 1 132px;
}

.family-photo-album {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-3);
}

.family-photo-album__head,
.family-photo-album__actions,
.family-photo-modal__tags-head,
.family-photo-modal__tagger,
.family-photo-chip,
.family-photo-modal__footer {
  align-items: center;
  display: flex;
  gap: var(--sp-2);
}

.family-photo-album__head,
.family-photo-modal__tags-head {
  justify-content: space-between;
}

.family-photo-album__head h3,
.family-photo-album__head p,
.family-photo-modal__subhead,
.family-photo-modal__tags-head p {
  margin: 0;
}

.family-photo-album__head p,
.family-photo-modal__subhead {
  color: var(--muted);
}

.family-photo-strip {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding-bottom: 2px;
}

.family-photo-thumb {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  flex: 0 0 88px;
  overflow: hidden;
  padding: 0;
}

.family-photo-thumb img {
  aspect-ratio: 1;
  display: block;
  height: auto;
  object-fit: cover;
  width: 100%;
}

.family-photo-album__empty {
  color: var(--muted);
  font-size: var(--text-sm);
  margin: 0;
}

.family-photo-modal__dialog {
  max-width: min(860px, 96vw);
  width: min(860px, 96vw);
}

.family-photo-modal__body,
.family-photo-modal__form,
.family-photo-modal__tags {
  display: grid;
  gap: var(--sp-3);
}

.family-photo-modal__frame {
  align-items: center;
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.family-photo-modal__nav {
  min-width: 56px;
}

.family-photo-modal__image-wrap {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  min-height: 320px;
  overflow: hidden;
}

.family-photo-modal__image-wrap img {
  display: block;
  height: 100%;
  max-height: 62vh;
  object-fit: contain;
  width: 100%;
}

.family-photo-modal__meta-action {
  align-self: end;
}

.family-photo-modal__meta-action .action-btn {
  width: 100%;
}

.family-photo-modal__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.family-photo-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  flex-wrap: wrap;
  padding: 6px 10px;
}

.family-photo-chip .tag-chip {
  border: 0;
  min-height: auto;
  padding-left: 0;
  padding-right: 0;
}

.family-photo-modal__tagger select {
  min-width: 220px;
}

.family-tree-person-relations {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
}

.family-tree-relation-row {
  align-items: baseline;
  display: flex;
  gap: var(--sp-2);
  justify-content: space-between;
}

.family-tree-relation-row span {
  color: var(--muted);
}

.family-tree-relation-row strong {
  color: var(--text-strong);
  text-align: right;
}

.family-tree-photo-preview {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  max-width: 180px;
  overflow: hidden;
}

.family-tree-photo-preview img {
  aspect-ratio: 1;
  display: block;
  height: auto;
  object-fit: cover;
  width: 100%;
}

.family-tree-modal__status {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 24%, var(--line));
  border-radius: var(--r-md);
  color: color-mix(in srgb, var(--danger) 75%, var(--text));
  margin: var(--sp-3) 0 0;
  padding: var(--sp-2) var(--sp-3);
}

@media (max-width: 760px) {
  .dashboard { grid-template-columns: 1fr; }

  .statistics-charts { grid-template-columns: 1fr; }
  .chart-wrapper canvas { height: 220px !important; }

  .dashboard-row,
  .project-summary,
  .project-actions { align-items: stretch; flex-direction: column; }
  .dashboard-row .action-btn,
  .project-actions .action-btn,
  .project-actions form,
  .project-actions button { width: 100%; }
}

@media (max-width: 480px) {
  .statistics-period a { flex: 1 1 auto; text-align: center; }
}

/* ═══════════════════════════════════════════════════════
   FINANCE
   ══════════════════════════════════════════════════════ */

.finance-page { display: flex; flex-direction: column; gap: var(--sp-4); }

.finance-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
}
.finance-header h1 { margin: 0 0 var(--sp-1); }
.finance-header p { margin: 0; color: var(--muted); }

.finance-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }

.finance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-3);
}

.finance-budget-card { display: flex; flex-direction: column; gap: var(--sp-2); }
.finance-budget-card h2 { margin: 0; font-size: var(--text-md); }
.finance-budget-card h3 { margin: 0; font-size: var(--text-base); }
.finance-budget-card p { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.finance-budget-card.is-archived { opacity: 0.6; }

.finance-meta { display: flex; gap: var(--sp-2); font-size: var(--text-sm); color: var(--muted); }

.finance-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}
.finance-summary .card { text-align: center; }
.finance-summary h2 { margin: 0 0 var(--sp-1); font-size: var(--text-sm); color: var(--muted); }
.finance-summary strong { font-size: var(--text-lg); }

.finance-columns { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

.finance-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-2); }
.finance-card-head h2 { margin: 0; font-size: var(--text-base); }

.finance-list { display: flex; flex-direction: column; gap: var(--sp-2); }

.finance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) 0;
  border-bottom: 1px solid var(--line);
}
.finance-row:last-child { border-bottom: none; }
.finance-row-stack { flex-direction: column; align-items: flex-start; }
.finance-row strong { display: block; }

.finance-subline { display: flex; gap: var(--sp-2); font-size: var(--text-sm); color: var(--muted); flex-wrap: wrap; }

.finance-member-row { align-items: flex-start; }

.finance-inline-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

.finance-form-card { max-width: 540px; margin: 0 auto; }
.finance-danger-form { margin-top: var(--sp-2); }
.finance-archive { margin-top: var(--sp-2); }

@media (max-width: 900px) {
  .finance-summary { grid-template-columns: 1fr 1fr; }
  .finance-columns { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .finance-summary { grid-template-columns: 1fr; }
  .finance-header { flex-direction: column; }
  .finance-grid { grid-template-columns: 1fr; }
}

/* ═══════════════
   AUDIT HISTORY
   ═══════════════ */

.history-page {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.history-hero,
.history-filters {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
}

.history-hero h1 {
  margin: 0 0 var(--sp-1);
}

.history-hero p {
  margin: 0;
  color: var(--muted);
  max-width: 64ch;
}

.history-hero__eyebrow {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: .14em;
  margin: 0 0 var(--sp-2);
  text-transform: uppercase;
}

.history-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-content: flex-start;
  justify-content: flex-end;
}

.history-filters {
  align-items: flex-start;
  flex-direction: column;
}

.history-filter-block {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: 100%;
}

.history-filter-label {
  color: var(--muted);
  font-size: var(--text-sm);
  margin: 0;
}

.history-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.history-chip {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--muted);
  font-size: var(--text-sm);
  padding: 10px 14px;
  text-decoration: none;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}

.history-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
  transform: translateY(-1px);
}

.history-chip.is-active {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--text-strong);
}

.history-timeline {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.history-day {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.history-day__head {
  align-items: baseline;
  display: flex;
  gap: var(--sp-2);
  justify-content: space-between;
}

.history-day__head h2 {
  margin: 0;
}

.history-day__head span {
  color: var(--muted);
  font-size: var(--text-sm);
}

.history-day__entries {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.history-entry {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, transparent), transparent 55%), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-4);
}

.history-entry.is-reverted {
  opacity: .72;
}

.history-entry__main {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.history-entry__head {
  display: flex;
  gap: var(--sp-3);
  justify-content: space-between;
}

.history-entry__head h3 {
  color: var(--text-strong);
  margin: 0 0 var(--sp-1);
}

.history-entry__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.history-kind-chip {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  border-radius: var(--r-full);
  color: var(--text-strong);
  display: inline-flex;
  font-size: var(--text-xs);
  padding: 6px 10px;
}

.history-kind-chip--ghost {
  background: var(--surface-elev);
  border-color: var(--line);
  color: var(--muted);
}

.history-entry__meta,
.history-entry__status {
  color: var(--muted);
  font-size: var(--text-sm);
  margin: 0;
}

.history-entry__side {
  align-items: flex-start;
  display: flex;
}

.history-diff {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.history-diff__row {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
}

.history-diff__field {
  color: var(--text-strong);
  font-size: var(--text-sm);
  font-weight: 600;
  margin: 0;
}

.history-diff__values {
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: 1fr 1fr;
}

.history-diff__cell {
  background: color-mix(in srgb, var(--surface-soft) 80%, transparent);
  border-radius: var(--r-sm);
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-2);
}

.history-diff__label {
  color: var(--muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
}

.history-diff__cell code {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* AI assistant */
.ai-assistant-page {
  display: grid;
  gap: var(--sp-5);
}

.ai-assistant-hero {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: var(--sp-4);
  justify-content: space-between;
  padding-bottom: var(--sp-4);
}

.ai-hero-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* ── Assistant chat (FB-D / D1) ─────────────────────────────────────────── */
.ch-page { display: grid; gap: var(--sp-4); }
.ch-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: space-between;
  padding-bottom: var(--sp-3);
}
.ch-header-actions { align-items: center; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.ch-layout {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: minmax(0, 16rem) minmax(0, 1fr);
}
.ch-history { display: grid; align-content: start; gap: var(--sp-1); }
.ch-history-item {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  display: grid;
  gap: 2px;
  padding: var(--sp-2);
  text-decoration: none;
}
.ch-history-item.is-active { border-color: var(--accent); background: var(--accent-muted); }
.ch-history-title { font-size: var(--text-sm); font-weight: 600; overflow-wrap: anywhere; }
.ch-history-date { color: var(--muted); font-size: var(--text-xs); }
.ch-main { display: grid; gap: var(--sp-3); }
.ch-messages {
  display: grid;
  gap: var(--sp-2);
  min-height: 12rem;
}
.ch-msg { border-radius: var(--r-md); max-width: 80%; padding: var(--sp-2) var(--sp-3); }
.ch-msg--user {
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  justify-self: end;
}
.ch-msg--assistant {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  justify-self: start;
}
.ch-msg--tool { justify-self: start; }
.ch-msg-body { overflow-wrap: anywhere; white-space: pre-wrap; }
.ch-msg-meta { color: var(--muted); font-size: var(--text-xs); }
.ch-msg-tools {
  color: var(--muted);
  font-size: var(--text-xs);
  margin-top: var(--sp-1);
}
.ch-msg-tools code { color: var(--text); }
.ch-empty { color: var(--muted); }
.ch-composer { align-items: flex-end; display: flex; gap: var(--sp-2); }
.ch-input { flex: 1 1 auto; min-width: 0; resize: vertical; }
.ch-drafts {
  border: 1px solid var(--warning);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
}
.ch-drafts-head {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: space-between;
  font-size: var(--text-sm);
}
.ch-draft {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: space-between;
  padding: var(--sp-2);
}
.ch-draft-summary { font-size: var(--text-sm); overflow-wrap: anywhere; }
.ch-draft-actions { display: flex; gap: var(--sp-2); }
.ch-voice {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  font-size: var(--text-xs);
}
.ch-voice-input { flex: 1 1 auto; min-width: 0; }
.ch-voice-status { color: var(--muted); font-size: var(--text-xs); }

.ai-assistant-hero h1 {
  margin: 0 0 var(--sp-2);
}

.ai-assistant-hero p {
  color: var(--muted);
  margin: 0;
  max-width: 68ch;
}

.ai-assistant-eyebrow {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  margin: 0 0 var(--sp-2);
  text-transform: uppercase;
}

.ai-metrics,
.ai-context-grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.ai-metric,
.ai-context,
.ai-insight,
.ai-memory,
.ai-tool-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.ai-metric {
  display: grid;
  gap: var(--sp-2);
  min-height: 108px;
  padding: var(--sp-4);
}

.ai-metric span,
.ai-memory span,
.ai-insight__meta {
  color: var(--muted);
  font-size: var(--text-sm);
}

.ai-metric strong {
  color: var(--text-strong);
  font-size: clamp(1.75rem, 2vw, 2.25rem);
  line-height: 1;
}

.ai-metric--warn {
  border-color: color-mix(in srgb, var(--danger) 34%, var(--line));
}

.ai-ask-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: var(--sp-4);
  padding: var(--sp-4);
}

.ai-ask-panel__head,
.ai-run__head,
.ai-run__meta,
.ai-provider-metrics {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: space-between;
}

.ai-ask-panel__head h2,
.ai-run h3 {
  margin: 0;
}

.ai-provider-status {
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 7px 11px;
}

.ai-provider-status.is-ready {
  background: color-mix(in srgb, var(--success) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--success) 42%, var(--line));
  color: var(--success);
}

.ai-provider-status.is-blocked {
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--warning) 42%, var(--line));
  color: var(--warning);
}

.ai-ask-form {
  display: grid;
  gap: var(--sp-2);
}

.ai-ask-form label {
  color: var(--muted);
  font-size: var(--text-sm);
}

.ai-ask-form button {
  justify-self: start;
}

.ai-provider-metrics {
  justify-content: flex-start;
}

.ai-provider-metrics span {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--muted);
  display: grid;
  font-size: var(--text-xs);
  gap: 2px;
  min-width: 120px;
  padding: var(--sp-2);
}

.ai-provider-metrics strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.ai-provider-blockers {
  color: var(--warning);
  display: flex;
  flex-wrap: wrap;
  font-size: var(--text-sm);
  gap: var(--sp-2) var(--sp-4);
  margin: 0;
  padding-left: var(--sp-4);
}

.ai-layout {
  align-items: start;
  display: grid;
  gap: var(--sp-5);
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr);
}

.ai-section,
.ai-side {
  display: grid;
  gap: var(--sp-3);
}

.ai-section-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.ai-section-head h2,
.ai-tool-panel h2,
.ai-context h2,
.ai-insight h3,
.ai-memory h3 {
  margin: 0;
}

.ai-section-note {
  color: var(--muted);
  font-size: var(--text-sm);
  margin: var(--sp-1) 0 0;
}

.ai-section-head span {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--muted);
  font-size: var(--text-sm);
  min-width: 36px;
  padding: 6px 10px;
  text-align: center;
}

.ai-insight-list,
.ai-memory-list,
.ai-run-list,
.ai-experiment-list {
  display: grid;
  gap: var(--sp-3);
}

.ai-insight {
  align-items: flex-start;
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: minmax(0, 1fr) auto;
  padding: var(--sp-4);
}

.ai-insight--high {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line));
}

.ai-insight--medium {
  border-color: color-mix(in srgb, var(--warning) 42%, var(--line));
}

.ai-insight__main {
  display: grid;
  gap: var(--sp-2);
}

.ai-insight__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.ai-insight p,
.ai-memory p,
.ai-context p {
  color: var(--muted);
  margin: 0;
}

.ai-evidence {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3);
}

.ai-evidence summary {
  color: var(--text);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
}

.ai-evidence pre {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  margin: var(--sp-2) 0 0;
  overflow-x: auto;
  white-space: pre-wrap;
}

.ai-evidence p {
  color: var(--text);
  font-size: var(--text-sm);
  margin: var(--sp-2) 0 0;
}

.ai-tool-panel {
  padding: var(--sp-4);
}

.ai-memory-form {
  display: grid;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}

.ai-memory-form label {
  display: grid;
  gap: var(--sp-1);
}

.ai-memory-form label > span {
  color: var(--muted);
  font-size: var(--text-sm);
}

.ai-checkbox {
  align-items: center;
  display: flex !important;
  gap: var(--sp-2);
}

.ai-checkbox input {
  width: auto;
}

.ai-memory {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-3);
}

.ai-memory form,
.ai-insight form {
  justify-self: end;
}

.ai-context {
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-4);
}

.ai-context ul {
  color: var(--text);
  margin: 0;
  padding-left: var(--sp-4);
}

.ai-run {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
}

.ai-run--completed,
.ai-run--queued {
  border-color: color-mix(in srgb, var(--success) 32%, var(--line));
}

.ai-run--failed,
.ai-run--blocked,
.ai-run--pending {
  border-color: color-mix(in srgb, var(--warning) 36%, var(--line));
}

.ai-run__head span,
.ai-run__head time,
.ai-run__meta {
  color: var(--muted);
  font-size: var(--text-xs);
}

.ai-run__head div {
  display: grid;
  gap: var(--sp-1);
}

.ai-run__answer,
.ai-run__error {
  background: var(--surface-elev);
  border-left: 3px solid var(--accent);
  color: var(--text);
  margin: 0;
  padding: var(--sp-3);
}

.ai-run__error {
  border-left-color: var(--warning);
  color: var(--warning);
}

.ai-run__meta {
  justify-content: flex-start;
}

.ai-run__stop {
  color: var(--warning);
}

.ai-run-steps {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3);
}

.ai-run-steps summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
}

.ai-run-steps ol {
  display: grid;
  gap: var(--sp-2);
  margin: var(--sp-2) 0 0;
  padding-left: var(--sp-4);
}

.ai-run-steps li {
  min-width: 0;
}

.ai-run-step__head {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: var(--text-xs);
  gap: var(--sp-2);
}

.ai-run-step__status.is-ok { color: var(--success); }
.ai-run-step__status.is-failed { color: var(--warning); }

.ai-run-step__args {
  color: var(--muted);
  display: block;
  font-size: var(--text-xs);
  margin-top: var(--sp-1);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ai-correlation-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.ai-correlation-controls form {
  margin: 0;
}

.ai-correlation__score {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: var(--text-xl);
}

.ai-correlation--high {
  border-color: color-mix(in srgb, var(--success) 45%, var(--line));
}

.ai-correlation--medium {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
}

.ai-weekly-review,
.ai-experiment {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
}

.ai-weekly-review h3,
.ai-weekly-review h4,
.ai-experiment h3 {
  margin: 0;
}

.ai-review-grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ai-review-grid section {
  border-top: 1px solid var(--line);
  display: grid;
  gap: var(--sp-2);
  padding-top: var(--sp-3);
}

.ai-review-grid ol,
.ai-review-grid ul {
  display: grid;
  gap: var(--sp-2);
  margin: 0;
  padding-left: var(--sp-4);
}

.ai-review-grid li span {
  color: var(--muted);
  display: block;
  font-size: var(--text-xs);
}

.ai-experiment p {
  color: var(--muted);
  margin: 0;
}

.ai-experiment--active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.ai-experiment--completed {
  border-color: color-mix(in srgb, var(--success) 45%, var(--line));
}

.ai-experiment-actions,
.ai-experiment-complete {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.ai-experiment-actions form {
  margin: 0;
}

.ai-experiment-complete {
  flex: 1 1 360px;
}

.ai-experiment-complete input {
  flex: 1 1 220px;
}

.ai-action-tools {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ai-action-tool {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
}

.ai-action-tool h3 {
  margin: 0;
}

.ai-action-tool label {
  display: grid;
  gap: var(--sp-1);
}

.ai-action-tool label span {
  color: var(--muted);
  font-size: var(--text-sm);
}

.ai-action-draft--applied {
  border-color: color-mix(in srgb, var(--success) 42%, var(--line));
}

.ai-action-draft--cancelled {
  opacity: .72;
}

.ai-action-draft__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.ai-action-draft__actions form {
  margin: 0;
}

@media (max-width: 900px) {
  .ai-assistant-hero,
  .ai-insight {
    grid-template-columns: 1fr;
  }

  .ai-assistant-hero,
  .ai-insight {
    display: grid;
  }

  .ai-layout {
    grid-template-columns: 1fr;
  }

  .ai-review-grid {
    grid-template-columns: 1fr;
  }

  .ai-action-tools {
    grid-template-columns: 1fr;
  }

  .ai-memory form,
  .ai-insight form {
    justify-self: stretch;
  }

  .ai-ask-form button {
    justify-self: stretch;
  }
}

/* ── Просмотровая / watchlist (FB-C / C1) ───────────────────────────────── */
.wl-page { display: grid; gap: var(--sp-4); }
.wl-head {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: space-between;
}
.wl-kicker { color: var(--muted); font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; margin: 0; }
.wl-sub { color: var(--muted); margin: var(--sp-1) 0 0; }
.wl-muted { color: var(--muted); }
.wl-filters { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.wl-grid {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
}
.wl-card {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-2);
  overflow: hidden;
  padding: var(--sp-2);
}
.wl-card__link { color: var(--text); display: grid; gap: var(--sp-2); text-decoration: none; }
.wl-card__poster {
  aspect-ratio: 2 / 3;
  border-radius: var(--r-sm);
  object-fit: cover;
  width: 100%;
}
.wl-card__poster--empty {
  align-items: center;
  background: var(--surface);
  color: var(--muted);
  display: flex;
  font-size: var(--text-sm);
  justify-content: center;
}
.wl-card__title { font-size: var(--text-sm); font-weight: 600; overflow-wrap: anywhere; }
.wl-card__meta { align-items: center; display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.wl-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--muted);
  font-size: var(--text-xs);
  padding: 1px var(--sp-2);
}
.wl-chip--want { border-color: var(--accent); color: var(--accent-strong); }
.wl-chip--watching { border-color: var(--warning); color: var(--warning); }
.wl-chip--seen { border-color: var(--success); color: var(--success); }
.wl-chip--dropped { color: var(--muted); }
.wl-rating { color: var(--warning); font-weight: 600; }
.wl-empty { color: var(--muted); }
.wl-detail { display: grid; gap: var(--sp-3); max-width: 52rem; }
.wl-detail__head {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: space-between;
}
.wl-detail__poster { border-radius: var(--r-md); max-width: 16rem; }
.wl-detail__text { overflow-wrap: anywhere; }
.wl-detail__ideas, .wl-detail__controls { display: grid; gap: var(--sp-2); }
.wl-detail__controls { border-top: 1px solid var(--line); padding-top: var(--sp-3); }
.wl-tags { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.wl-form-row { align-items: flex-end; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.wl-form-row label { display: grid; gap: 2px; }
.wl-grow { flex: 1 1 12rem; }
.wl-form__actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }
.wl-detail__head-actions { align-items: center; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.wl-head-actions { align-items: center; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.wl-shelf-list { display: grid; gap: var(--sp-2); }
.wl-shelf-row {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
  text-decoration: none;
}
.wl-shelf-row__name { font-weight: 600; overflow-wrap: anywhere; }
.wl-shelf-add { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); }
.wl-token { overflow-wrap: anywhere; word-break: break-all; }
.wl-dup-hint {
  background: var(--warning-soft);
  border: 1px solid var(--warning);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
}
.wl-recommend { align-items: center; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.wl-rec-panel {
  background: var(--surface-soft);
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-3);
}
.wl-rec-head { align-items: center; display: flex; gap: var(--sp-2); justify-content: space-between; }
.wl-rec-reason { color: var(--muted); font-size: var(--text-xs); margin: 0; overflow-wrap: anywhere; }

/* RV3 tasks list */
.tk-wrap {
  display: grid;
  gap: var(--sp-3);
  margin: 0 auto;
  max-width: 46rem;
  width: 100%;
}

.tk-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: var(--sp-3);
  justify-content: space-between;
  padding-bottom: var(--sp-3);
}

.tk-kicker {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  margin: 0 0 var(--sp-1);
  text-transform: uppercase;
}

.tk-head h1 {
  color: var(--text-strong);
  font-size: var(--text-xl);
  margin: 0;
}

.tk-create {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--r-full);
  color: var(--on-accent);
  display: inline-flex;
  font-size: var(--text-lg);
  font-weight: 700;
  height: var(--tap-target);
  justify-content: center;
  text-decoration: none;
  width: var(--tap-target);
}

.tk-create:hover {
  background: var(--accent-strong);
  color: var(--on-accent);
  text-decoration: none;
}

.tk-search {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  display: flex;
  gap: var(--sp-2);
  padding: 0 var(--sp-2) 0 var(--sp-4);
}

.tk-search:focus-within {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.tk-search-ic {
  color: var(--muted);
  flex: none;
}

.tk-search input[type="search"] {
  background: none;
  border: 0;
  color: var(--text);
  flex: 1;
  font: inherit;
  min-height: var(--tap-target);
  min-width: 0;
  outline: none;
  padding: 0;
}

.tk-search input::placeholder { color: var(--muted); }

.tk-search-deep,
.tk-search-clear {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--muted);
  cursor: pointer;
  flex: none;
  font: inherit;
  font-size: var(--text-xs);
  min-height: 32px;
  padding: 0 var(--sp-3);
  text-decoration: none;
}

.tk-search-clear {
  align-items: center;
  display: inline-flex;
}

.tk-search-deep:hover,
.tk-search-clear:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  text-decoration: none;
}

.tk-search-deep kbd {
  font-family: var(--font-mono);
  font-size: inherit;
}

.tk-pulse {
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tk-stat {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  display: flex;
  gap: var(--sp-2);
  min-height: var(--tap-target);
  min-width: 0;
  padding: var(--sp-1) var(--sp-3);
  text-align: left;
  text-decoration: none;
}

.tk-stat:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.tk-stat[aria-pressed="true"] {
  background: var(--surface-soft);
  box-shadow: var(--focus-ring);
}

.tk-stat-num {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1;
}

.tk-stat-lbl {
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.15;
}

.tk-stat--over { border-color: color-mix(in srgb, var(--danger) 45%, var(--line-strong)); }
.tk-stat--over .tk-stat-num { color: var(--text-danger); }
.tk-stat--soon { border-color: color-mix(in srgb, var(--warning) 40%, var(--line-strong)); }
.tk-stat--soon .tk-stat-num { color: var(--text-warning); }
.tk-stat--today .tk-stat-num { color: var(--accent-strong); }
.tk-stat--done .tk-stat-num { color: var(--text-success); }
.tk-stat.is-zero { border-color: var(--line); }
.tk-stat.is-zero .tk-stat-num { color: var(--muted); }

.tk-filter-state {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--muted);
  display: flex;
  gap: var(--sp-2);
  justify-self: start;
  min-height: var(--tap-target);
  padding: var(--sp-1) var(--sp-3);
}

.tk-filter-state strong {
  color: var(--text-strong);
}

.tk-filter-clear {
  color: var(--accent-strong);
  font-size: var(--text-xs);
  font-weight: 600;
}

.tk-empty {
  color: var(--muted);
  margin: 0;
  padding: var(--sp-2);
}

.tk-sort {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.tk-sort-label {
  color: var(--muted);
  font-size: var(--text-xs);
}

.tk-chip {
  align-items: center;
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  gap: 6px;
  min-height: 36px;
  padding: 0 var(--sp-3);
  text-decoration: none;
}

.tk-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
  text-decoration: none;
}

.tk-chip[aria-pressed="true"] {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.tk-chip-ord {
  background: var(--accent);
  border-radius: var(--r-full);
  color: var(--on-accent);
  display: none;
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 16px;
  min-width: 16px;
  text-align: center;
}

.tk-chip[aria-pressed="true"] .tk-chip-ord { display: inline-block; }

.tk-chip-reset {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
  color: var(--text-danger);
  opacity: 0;
  pointer-events: none;
  transform: scale(.7);
}

.tk-chip-reset.is-in {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.tk-tree,
.tk-tree-zone,
.tk-sortable-tree {
  display: grid;
  gap: var(--sp-3);
  min-width: 0;
}

.tk-card {
  display: grid;
  gap: var(--sp-2);
  min-width: 0;
}

.tk-card-main {
  padding-left: 22px;
  position: relative;
}

.tk-card-in {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  min-width: 0;
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  position: relative;
  z-index: 1;
}

.tk-tab {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  bottom: 0;
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  justify-content: center;
  left: 0;
  padding-right: 22px;
  position: absolute;
  top: 0;
  width: 46px;
  z-index: 0;
}

.tk-glyph {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1;
}

.tk-scale {
  align-items: flex-end;
  display: inline-flex;
  gap: 2px;
  height: 14px;
}

.tk-scale i {
  background: color-mix(in srgb, currentColor 26%, transparent);
  border-radius: 1px;
  display: block;
  width: 3px;
}

.tk-scale i:nth-child(1) { height: 5px; }
.tk-scale i:nth-child(2) { height: 8px; }
.tk-scale i:nth-child(3) { height: 11px; }
.tk-scale i:nth-child(4) { height: 14px; }
.tk-scale i.on { background: currentColor; }

.tk-s-done .tk-tab {
  background: color-mix(in srgb, var(--success) 30%, var(--surface));
  border-color: color-mix(in srgb, var(--success) 50%, var(--line-strong));
  color: var(--text-success);
}

.tk-s-done .tk-card-in {
  background: color-mix(in srgb, var(--success) 5%, var(--surface));
  border-color: color-mix(in srgb, var(--success) 30%, var(--line-strong));
}

.tk-s-fail .tk-tab {
  background: color-mix(in srgb, var(--muted) 22%, var(--surface));
  border-color: color-mix(in srgb, var(--muted) 40%, var(--line-strong));
  color: var(--muted);
}

.tk-s-fail .tk-card-in {
  border-color: color-mix(in srgb, var(--muted) 25%, var(--line-strong));
  color: var(--muted);
}

.tk-s-fail .tk-name {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent);
}

.tk-p4 .tk-tab {
  background: color-mix(in srgb, var(--danger) 28%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line-strong));
  color: var(--text-danger);
}

.tk-p4 .tk-card-in {
  background: color-mix(in srgb, var(--danger) 4%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line-strong));
}

.tk-p3 .tk-tab {
  background: color-mix(in srgb, var(--warning) 24%, var(--surface));
  border-color: color-mix(in srgb, var(--warning) 50%, var(--line-strong));
  color: var(--text-warning);
}

.tk-p3 .tk-card-in {
  background: color-mix(in srgb, var(--warning) 4%, var(--surface));
  border-color: color-mix(in srgb, var(--warning) 30%, var(--line-strong));
}

.tk-p2 .tk-tab {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line-strong));
  color: var(--accent-strong);
}

.tk-p1 .tk-tab {
  background: color-mix(in srgb, var(--muted) 16%, var(--surface));
  border-color: color-mix(in srgb, var(--muted) 35%, var(--line-strong));
  color: var(--muted);
}

.tk-p1 .tk-card-in { border-color: var(--line); }

.tk-clock {
  align-items: center;
  border-radius: var(--r-full);
  display: inline-flex;
  font-size: var(--text-xs);
  height: 18px;
  justify-content: center;
  line-height: 1;
  position: relative;
  width: 18px;
}

.tk-clock--dl { color: var(--text-danger); }
.tk-clock--start {
  color: var(--accent-strong);
  font-size: 8px;
  font-weight: 700;
}

.tk-tab-state {
  align-items: center;
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  justify-content: center;
  line-height: 1;
  min-height: 18px;
}

.tk-tab-state--pause { color: var(--accent-strong); font-size: 8px; }
.tk-tab-state--eternal { color: var(--muted); }

.tk-row {
  align-items: flex-start;
  display: flex;
  gap: var(--sp-2);
}

.tk-row-text {
  flex: 1;
  min-width: 0;
}

.tk-name {
  color: var(--text-strong);
  display: inline;
  font-size: var(--text-md);
  font-weight: 600;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.tk-name:hover {
  color: var(--accent-strong);
  text-decoration: none;
}

.tk-parent-link {
  color: var(--muted);
  display: inline-block;
  font-size: var(--text-xs);
  margin-right: var(--sp-1);
}

.tk-when {
  align-items: baseline;
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-left: var(--sp-2);
}

.tk-date {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.tk-inf {
  color: var(--muted);
  cursor: default;
  font-size: var(--text-sm);
  line-height: 1;
}

.tk-cd {
  background: var(--surface-elev);
  border-radius: var(--r-full);
  color: var(--text-warning);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px var(--sp-2);
  white-space: nowrap;
}

.tk-cd--over { color: var(--text-danger); }
.tk-cd--muted { color: var(--muted); }
.tk-planned {
  color: var(--muted);
  font-size: var(--text-xs);
  font-style: italic;
  white-space: nowrap;
}

.tk-mark {
  align-items: center;
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  flex: none;
  height: 36px;
  justify-content: center;
  text-decoration: none;
  width: 36px;
}

.tk-mark:hover {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.tk-mark--attention {
  background: color-mix(in srgb, var(--success) 16%, var(--surface-elev));
  border-color: var(--success);
  color: var(--text-success);
}

.tk-progress {
  align-items: center;
  display: flex;
  gap: var(--sp-2);
  margin-top: 14px;
}

.tk-progress-track {
  border-radius: var(--r-full);
  display: flex;
  flex: 1;
  gap: 2px;
  height: 6px;
  min-width: 0;
}

.tk-seg {
  border-radius: 2px;
  flex: 1 1 0;
  min-width: 4px;
  position: relative;
}

.tk-seg--done { background: var(--success); }
.tk-seg--fail { background: var(--muted); }
.tk-seg--p4 { background: var(--danger); }
.tk-seg--p3 { background: var(--warning); }
.tk-seg--p2 { background: var(--accent); }
.tk-seg--p1 { background: color-mix(in srgb, var(--muted) 72%, var(--surface)); }

.tk-seg-attention {
  align-items: flex-end;
  bottom: calc(100% + 2px);
  color: var(--text-warning);
  display: inline-flex;
  gap: 1px;
  height: 9px;
  justify-content: center;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
  transform-origin: center bottom;
}

.tk-seg-attention i {
  background: color-mix(in srgb, currentColor 25%, transparent);
  border-radius: 1px;
  display: block;
  width: 2px;
}

.tk-seg-attention i:nth-child(1) { height: 3px; }
.tk-seg-attention i:nth-child(2) { height: 5px; }
.tk-seg-attention i:nth-child(3) { height: 7px; }
.tk-seg-attention i:nth-child(4) { height: 9px; }
.tk-seg-attention--p1 i:nth-child(-n+1),
.tk-seg-attention--p2 i:nth-child(-n+2),
.tk-seg-attention--p3 i:nth-child(-n+3),
.tk-seg-attention--p4 i:nth-child(-n+4) { background: currentColor; }
.tk-seg-attention--p4 { color: var(--text-danger); }

.tk-progress-num {
  color: var(--muted);
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.tk-meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  margin-top: var(--sp-2);
}

.tk-proj,
.tk-tag--sm {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--muted);
  font-size: var(--text-xs);
  padding: 2px var(--sp-2);
}

.tk-proj { text-decoration: none; }
.tk-proj:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.tk-foot {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.tk-chev,
.tk-desc-btn {
  align-items: center;
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: var(--text-xs);
  gap: var(--sp-1);
  padding: var(--sp-1) 0;
}

.tk-chev:hover,
.tk-desc-btn:hover {
  color: var(--accent-strong);
}

.tk-chev-ic {
  display: inline-block;
  height: 12px;
  position: relative;
  width: 12px;
}

.tk-chev-ic::before,
.tk-chev-ic::after {
  background: currentColor;
  border-radius: var(--r-full);
  content: "";
  height: 2px;
  left: 2px;
  position: absolute;
  top: 5px;
  transform-origin: center;
  width: 8px;
}

.tk-chev-ic::before { transform: rotate(45deg) translateX(-2px); }
.tk-chev-ic::after { transform: rotate(-45deg) translateX(2px); }
.tk-chev[aria-expanded="true"] .tk-chev-ic::before { transform: rotate(-45deg) translateX(-2px); }
.tk-chev[aria-expanded="true"] .tk-chev-ic::after { transform: rotate(45deg) translateX(2px); }

.tk-desc-wrap {
  display: inline-grid;
  min-width: min(100%, 16rem);
}

.tk-desc-wrap summary {
  list-style: none;
}

.tk-desc-wrap summary::-webkit-details-marker { display: none; }

.tk-desc {
  color: var(--text);
  font-size: var(--text-sm);
  margin-top: var(--sp-1);
  overflow-wrap: anywhere;
}

.tk-children {
  display: grid;
  grid-template-rows: 0fr;
  margin-left: clamp(var(--sp-2), calc((var(--tk-depth, 0) + 1) * var(--sp-3)), var(--sp-6));
}

.tk-children > .tk-children-in {
  border-left: 1px dashed var(--line-strong);
  display: grid;
  gap: var(--sp-2);
  min-height: 0;
  overflow: hidden;
  padding-left: var(--sp-3);
}

.tk-children.is-open { grid-template-rows: 1fr; }
.tk-card.is-live-hidden { display: none; }
.tk-card.is-live-match > .tk-card-main > .tk-card-in { border-color: var(--accent); }

.tk-depth-1 { --tk-depth: 1; }
.tk-depth-2 { --tk-depth: 2; }
.tk-depth-3 { --tk-depth: 3; }
.tk-depth-4 { --tk-depth: 4; }
.tk-depth-max,
.tk-depth-5,
.tk-depth-6,
.tk-depth-7,
.tk-depth-8,
.tk-depth-9,
.tk-depth-10 { --tk-depth: 5; }

.tk-sec {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.tk-sec--mini {
  background: var(--surface-elev);
}

.tk-sec-head {
  align-items: center;
  color: var(--text-strong);
  cursor: pointer;
  display: flex;
  font-weight: 700;
  gap: var(--sp-2);
  justify-content: space-between;
  padding: var(--sp-3);
}

.tk-sec-head::-webkit-details-marker { display: none; }

.tk-sec-head span {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: 2px var(--sp-2);
}

.tk-sec-body {
  border-top: 1px solid var(--line);
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
}

.tk-sec-title {
  color: var(--text-strong);
  font-size: var(--text-md);
  margin: 0 0 var(--sp-2);
}

.tk-search-results {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-3);
}

.tk-idea-results {
  display: grid;
  gap: var(--sp-1);
  margin: 0;
  padding-left: var(--sp-4);
}

.tk-idea-results a {
  color: var(--accent-strong);
}

.tk-log {
  border-top: 1px solid var(--line);
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-3);
}

.tk-log p {
  margin: 0;
}

.tk-scrim {
  background: color-mix(in srgb, var(--page-bg) 72%, transparent);
  inset: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  z-index: 1200;
}

.tk-scrim.is-on {
  opacity: 1;
  pointer-events: auto;
}

.tk-menu {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: var(--sp-3);
  grid-template-rows: auto minmax(0, 1fr);
  left: 50%;
  max-height: calc(100dvh - var(--sp-6));
  max-width: min(calc(100vw - var(--sp-6)), 40rem);
  opacity: 0;
  padding: var(--sp-3);
  pointer-events: none;
  position: fixed;
  top: 50%;
  transform: translate(-50%, calc(-50% + 6px));
  width: 40rem;
  z-index: 1300;
}

.tk-menu.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.tk-sheet-grip {
  display: none;
}

.tk-menu-tabs {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  padding: 3px;
  position: relative;
}

.tk-mtab-ind {
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  border-radius: var(--r-full);
  bottom: 3px;
  left: 3px;
  position: absolute;
  top: 3px;
  width: calc((100% - 6px) / 3);
}

.tk-menu[data-tab="1"] .tk-mtab-ind {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  border-color: var(--danger);
  transform: translateX(100%);
}

.tk-menu[data-tab="2"] .tk-mtab-ind {
  background: var(--accent-muted);
  border-color: var(--accent);
  transform: translateX(200%);
}

.tk-mtab {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: var(--text-sm);
  min-height: 34px;
  position: relative;
  z-index: 1;
}

.tk-mtab[aria-selected="true"] {
  color: var(--text-strong);
  font-weight: 700;
}

.tk-menu-body {
  max-height: 100%;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1px;
}

.tk-mpanel {
  display: none;
  gap: var(--sp-2);
}

.tk-menu[data-tab="0"] .tk-mpanel:nth-child(1),
.tk-menu[data-tab="1"] .tk-mpanel:nth-child(2),
.tk-menu[data-tab="2"] .tk-mpanel:nth-child(3) {
  display: grid;
}

.tk-menu-task {
  color: var(--text-strong);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.tk-check {
  align-items: center;
  color: var(--text);
  display: flex;
  gap: var(--sp-2);
  font-size: var(--text-sm);
}

.tk-check input {
  inline-size: auto;
}

.tk-check-box {
  align-items: center;
  background: var(--success);
  border-radius: var(--r-sm);
  color: var(--on-success);
  display: inline-flex;
  height: 18px;
  justify-content: center;
  width: 18px;
}

.tk-input {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  min-height: 40px;
  padding: var(--sp-2) var(--sp-3);
  resize: vertical;
  width: 100%;
}

.tk-input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  outline: none;
}

.tk-confirm {
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--on-accent);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 40px;
  padding: 0 var(--sp-3);
}

.tk-confirm--done {
  background: var(--success);
  color: var(--on-success);
}

.tk-confirm--fail {
  background: var(--danger);
  color: var(--text-strong);
}

.tk-confirm--move {
  background: var(--accent);
}

.tk-quick {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.tk-completion-attention {
  background: color-mix(in srgb, var(--success) 10%, var(--surface-elev));
  border: 1px solid color-mix(in srgb, var(--success) 45%, var(--line));
  border-radius: var(--r-sm);
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
}

.tk-completion-attention[hidden] { display: none; }
.tk-completion-attention p { margin: 0; }

.tk-detail-wrap {
  padding-bottom: var(--sp-6);
}

.tk-detail {
  padding-left: 22px;
  position: relative;
}

.tk-detail > .tk-tab {
  border-radius: var(--r-md);
}

.tk-detail-in {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  display: grid;
  gap: var(--sp-4);
  min-width: 0;
  padding: var(--sp-5);
  position: relative;
  z-index: 1;
}

.tk-detail-head {
  align-items: flex-start;
  display: flex;
  gap: var(--sp-3);
  justify-content: space-between;
  min-width: 0;
}

.tk-detail-title {
  display: grid;
  flex: 1;
  gap: var(--sp-1);
  min-width: 0;
}

.tk-detail-title h2 {
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-strong);
  font-size: var(--text-xl);
  line-height: 1.2;
  margin: 0;
  min-height: var(--tap-target);
  overflow-wrap: anywhere;
  padding: var(--sp-1) var(--sp-2);
}

.tk-detail-title h2:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  outline: none;
}

.tk-edit-hint,
.tk-muted {
  color: var(--muted);
  font-size: var(--text-xs);
}

.tk-detail-meta {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  margin: 0;
}

.tk-meta-cell {
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-3);
}

.tk-meta-cell dt {
  color: var(--muted);
  font-size: var(--text-xs);
}

.tk-meta-cell dd {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: 0;
  min-width: 0;
}

.tk-meta-summary {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: grid;
  gap: var(--sp-1);
  padding: 0;
  text-align: left;
  width: 100%;
}

.tk-meta-summary:hover .tk-meta-label,
.tk-meta-summary[aria-expanded="true"] .tk-meta-label { color: var(--accent-strong); }

.tk-meta-label {
  color: var(--muted);
  font-size: var(--text-xs);
}

.tk-meta-value {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  min-height: 24px;
}

.tk-meta-editor {
  border-top: 1px solid var(--line);
  display: grid;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
}

.tk-meta-editor[hidden] { display: none; }
.tk-meta-editor select[multiple] { min-height: 7rem; }

.tk-tagrow {
  align-items: center;
}

.tk-tag {
  background: var(--accent-muted);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--r-full);
  color: var(--accent-strong);
  display: inline-flex;
  font-size: var(--text-xs);
  line-height: 1.2;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 2px var(--sp-2);
  text-decoration: none;
}

.tk-tag:hover {
  border-color: var(--accent);
  color: var(--text-strong);
}

.tk-prio-pick {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.tk-prio-pick .tk-chip {
  font-family: var(--font-mono);
  font-weight: 700;
  min-height: 32px;
  padding: 0 var(--sp-2);
}

.tk-prio-pick .tk-chip[aria-pressed="true"].tk-pc1 {
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  border-color: var(--muted);
}

.tk-prio-pick .tk-chip[aria-pressed="true"].tk-pc2 {
  background: var(--accent-muted);
  border-color: var(--accent);
}

.tk-prio-pick .tk-chip[aria-pressed="true"].tk-pc3 {
  background: color-mix(in srgb, var(--warning) 18%, transparent);
  border-color: var(--warning);
}

.tk-prio-pick .tk-chip[aria-pressed="true"].tk-pc4 {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
  border-color: var(--danger);
}

.tk-detail-desc {
  display: grid;
  gap: var(--sp-1);
}

.tk-detail-desc label,
.tk-detail-sub h3,
.tk-detail-log h3 {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 700;
  margin: 0;
}

.tk-detail-sub {
  display: grid;
  gap: var(--sp-3);
}

.tk-detail .tk-progress {
  margin-top: 0;
}

.tk-progress-track .tk-seg {
  flex: 1 0 4px;
}

.tk-sub-list {
  display: grid;
  gap: var(--sp-1);
}

.tk-sub-row {
  align-items: center;
  background: var(--surface-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  display: flex;
  gap: var(--sp-2);
  min-height: var(--tap-target);
  min-width: 0;
  padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-3);
}

.tk-sub-row--done .tk-sub-name {
  color: var(--muted);
  text-decoration: line-through;
}

.tk-sub-row--fail .tk-sub-name {
  color: var(--muted);
}

.tk-sub-name {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tk-sub-name:hover {
  color: var(--accent-strong);
}

.tk-glyph--done {
  color: var(--text-success);
}

.tk-glyph--fail {
  color: var(--muted);
}

.tk-sub-remove {
  align-items: center;
  background: none;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  flex: none;
  font: inherit;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.tk-sub-remove:hover {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--text-danger);
}

.tk-sub-add,
.tk-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.tk-sub-add .tk-input {
  flex: 1 1 14rem;
}

.tk-btn--attach {
  background: var(--success);
  border-color: var(--success);
  color: var(--on-success);
}

.tk-btn--attach:hover {
  background: color-mix(in srgb, var(--success) 82%, var(--surface));
  border-color: var(--success);
  color: var(--on-success);
}

.tk-btn--attach[hidden] { display: none; }

.tk-project-attach {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding-top: var(--sp-2);
}

.tk-project-attach .tk-input { flex: 1 1 14rem; }

.tk-btn {
  align-items: center;
  background: var(--surface-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  gap: var(--sp-1);
  min-height: 40px;
  padding: 0 var(--sp-3);
  text-decoration: none;
}

.tk-btn:hover {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--text-strong);
}

.tk-btn--danger:hover {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  border-color: var(--danger);
  color: var(--text-danger);
}

.tk-detail-actions form {
  margin: 0;
}

.tk-detail-actions {
  align-items: center;
  justify-content: space-between;
}

.tk-lifecycle-actions,
.tk-danger-actions {
  align-items: center;
  display: flex;
  gap: var(--sp-2);
}

.tk-toggle {
  align-items: center;
  background: var(--surface-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  gap: var(--sp-2);
  min-height: 40px;
  padding: var(--sp-1) var(--sp-3) var(--sp-1) var(--sp-1);
}

.tk-toggle-track {
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  display: inline-flex;
  padding: 2px;
  width: 38px;
}

.tk-toggle-thumb {
  background: var(--muted);
  border-radius: var(--r-full);
  height: 16px;
  transition: transform var(--t-fast);
  width: 16px;
}

.tk-toggle[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--success) 55%, var(--line));
  color: var(--text-success);
}

.tk-toggle[aria-pressed="true"] .tk-toggle-track {
  background: color-mix(in srgb, var(--success) 22%, var(--surface));
  border-color: var(--success);
}

.tk-toggle[aria-pressed="true"] .tk-toggle-thumb {
  background: var(--success);
  transform: translateX(16px);
}

.tk-toggle:focus-visible,
.tk-danger-icon:focus-visible {
  box-shadow: var(--focus-ring);
  outline: none;
}

.tk-danger-icon {
  align-items: center;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 50%, var(--line));
  border-radius: var(--r-sm);
  color: var(--text-danger);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  height: var(--tap-target);
  justify-content: center;
  width: var(--tap-target);
}

.tk-danger-icon:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--text-strong);
}

.tk-fallback {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.tk-fallback summary::-webkit-details-marker {
  display: none;
}

.tk-fallback-form {
  border-top: 1px solid var(--line);
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-3);
}

.tk-fallback-form .field-row {
  display: grid;
  gap: var(--sp-1);
}

.tk-fallback-form label {
  color: var(--muted);
  font-size: var(--text-xs);
}

.tk-fallback-form input,
.tk-fallback-form textarea,
.tk-fallback-form select {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  min-height: 40px;
  padding: var(--sp-2);
  width: 100%;
}

.tk-fallback-form input:focus,
.tk-fallback-form textarea:focus,
.tk-fallback-form select:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  outline: none;
}

.field-errors {
  color: var(--text-danger);
  font-size: var(--text-xs);
}

.tk-detail-log {
  border-top: 1px dashed var(--line);
  display: grid;
  gap: var(--sp-2);
  padding-top: var(--sp-3);
}

.tk-log-item {
  align-items: baseline;
  color: var(--muted);
  display: flex;
  gap: var(--sp-2);
  min-width: 0;
}

.tk-log-item .tk-date {
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.tk-log-item span:last-child {
  overflow-wrap: anywhere;
}

.tk-detail [contenteditable].is-saving,
.tk-detail textarea.is-saving,
.tk-detail button.is-saving {
  opacity: .72;
}

.tk-detail [contenteditable].is-saved,
.tk-detail textarea.is-saved,
.tk-detail button.is-saved {
  border-color: var(--success);
}

.tk-detail [contenteditable].is-error,
.tk-detail textarea.is-error,
.tk-detail button.is-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 35%, transparent);
}

[data-tip] {
  position: relative;
}

@media (hover: hover) and (pointer: fine) {
  [data-tip]::after {
    background: var(--surface-strong);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow);
    color: var(--text);
    content: attr(data-tip);
    font-size: var(--text-xs);
    left: 50%;
    max-width: 18rem;
    opacity: 0;
    padding: var(--sp-2);
    pointer-events: none;
    position: absolute;
    top: calc(100% + var(--sp-1));
    transform: translate(-50%, 4px);
    white-space: pre-wrap;
    width: max-content;
    z-index: 1400;
  }

  [data-tip]:hover::after,
  [data-tip]:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (max-width: 700px) {
  .tk-wrap {
    max-width: none;
  }

  .tk-pulse {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tk-sort {
    flex-wrap: nowrap;
    margin-inline: calc(var(--sp-3) * -1);
    overflow-x: auto;
    padding-inline: var(--sp-3);
  }

  .tk-sort-label {
    flex: 0 0 auto;
  }

  .tk-search {
    border-radius: var(--r-sm);
    flex-wrap: wrap;
    padding: var(--sp-2);
  }

  .tk-search input[type="search"] {
    flex-basis: calc(100% - var(--sp-6));
  }

  .tk-row {
    align-items: stretch;
  }

  .tk-when {
    display: flex;
    margin-left: 0;
    margin-top: var(--sp-1);
  }

  .tk-menu {
    border-radius: var(--r-md) var(--r-md) 0 0;
    bottom: var(--mobile-nav-h);
    left: 0 !important;
    max-height: calc(100dvh - var(--mobile-nav-h) - var(--sp-3));
    max-width: none;
    padding-bottom: var(--sp-3);
    position: fixed;
    right: 0;
    top: auto !important;
    transform: translateY(100%);
    width: auto;
  }

  .tk-menu.is-open {
    transform: translateY(0);
  }

  .tk-menu-body { padding-bottom: 0; }

  .tk-confirm {
    bottom: 0;
    position: sticky;
  }

  .tk-sheet-grip {
    background: var(--line-strong);
    border-radius: var(--r-full);
    display: block;
    height: 4px;
    justify-self: center;
    width: 44px;
  }

  .tk-detail {
    padding-left: 16px;
  }

  .tk-detail-in {
    padding: var(--sp-3);
  }

  .tk-detail-head {
    align-items: stretch;
  }

  .tk-detail-title h2 {
    font-size: var(--text-lg);
  }

  .tk-detail-meta {
    grid-template-columns: 1fr;
  }

  .tk-sub-row {
    padding-left: var(--sp-2);
  }

  .tk-sub-add,
  .tk-detail-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .tk-sub-add .tk-input,
  .tk-btn,
  .tk-detail-actions form,
  .tk-detail-actions button {
    width: 100%;
  }

  .tk-danger-actions { justify-content: flex-end; }
  .tk-detail-actions .tk-danger-icon { width: var(--tap-target); }
}

/* ─── Companion full-screen surface (CMP-2) ─── */

.cmp-shell {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  min-height: calc(100dvh - var(--header-h) - var(--mobile-nav-h) - var(--sp-7));
  overflow: hidden;
  position: relative;
}

.cmp-controls {
  bottom: var(--sp-4);
  display: flex;
  gap: var(--sp-2);
  justify-content: center;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
  z-index: 6;
}

.cmp-control,
.cmp-composer button {
  align-items: center;
  background: var(--surface-overlay);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  gap: var(--sp-2);
  justify-content: center;
  min-height: calc(var(--sp-6) + var(--sp-3));
  padding: var(--sp-2) var(--sp-3);
}

.cmp-control:hover,
.cmp-control:focus-visible,
.cmp-composer button:hover,
.cmp-composer button:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  color: var(--accent-strong);
  outline: none;
}

.cmp-control[aria-pressed="true"] {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.cmp-shortcut-hint {
  align-items: center;
  background: var(--surface-overlay);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--muted);
  display: flex;
  font-size: var(--text-xs);
  gap: var(--sp-2);
  left: var(--sp-4);
  padding: var(--sp-2) var(--sp-3);
  position: absolute;
  top: var(--sp-4);
  z-index: 6;
}

.cmp-shortcut-hint[hidden] {
  display: none;
}

.cmp-shortcut-hint kbd {
  color: var(--text);
  font-family: var(--font-mono);
}

.cmp-shortcut-hint button {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: var(--sp-1);
}

.cmp-composer,
.cmp-response {
  background: var(--surface-overlay);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  left: 50%;
  max-width: calc(100% - var(--sp-6));
  padding: var(--sp-3);
  position: absolute;
  transform: translateX(-50%);
  width: min(36rem, calc(100% - var(--sp-6)));
  z-index: 7;
}

.cmp-composer {
  bottom: calc(var(--sp-7) + var(--sp-5));
}

.cmp-composer[hidden],
.cmp-response[hidden] {
  display: none;
}

.cmp-composer label {
  color: var(--muted);
  display: block;
  font-size: var(--text-xs);
  margin-bottom: var(--sp-2);
}

.cmp-composer > div {
  display: flex;
  gap: var(--sp-2);
}

.cmp-composer input {
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  color: var(--text);
  flex: 1;
  font: inherit;
  min-width: 0;
  padding: var(--sp-3);
}

.cmp-composer input:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  outline: none;
}

.cmp-response {
  bottom: calc(var(--sp-7) + var(--sp-5));
  color: var(--text);
  max-height: 40%;
  overflow: auto;
}

.cmp-response p {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.cmp-response__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.cmp-response__links:not(:empty),
.cmp-response__draft:not([hidden]) {
  margin-top: var(--sp-3);
}

.cmp-response__links a,
.cmp-response__draft {
  color: var(--accent-strong);
}

.cmp-is-off .cmp-controls,
.cmp-is-off .cmp-shortcut-hint,
.cmp-is-off .cmp-composer,
.cmp-is-off .cmp-response {
  display: none;
}

.cmp-canvas {
  display: block;
  height: 100%;
  inset: 0;
  min-height: inherit;
  position: absolute;
  width: 100%;
}

.cmp-canvas[hidden] {
  display: none;
}

.cmp-off,
.cmp-fallback-grid {
  align-items: center;
  color: var(--text);
  display: flex;
  flex-direction: column;
  inset: 0;
  justify-content: center;
  padding: var(--sp-6);
  position: absolute;
  text-align: center;
}

.cmp-off[hidden],
.cmp-fallback-grid[hidden] {
  display: none;
}

.cmp-off-mark {
  color: var(--accent-strong);
  font-size: var(--text-2xl);
  text-shadow: var(--accent-glow);
}

.cmp-off h1 {
  color: var(--text-strong);
  margin: var(--sp-3) 0 var(--sp-2);
}

.cmp-off p {
  color: var(--muted);
  margin: 0;
  max-width: 34rem;
}

.cmp-fallback-grid {
  background: var(--surface-strong);
  font-family: var(--font-mono);
  gap: var(--sp-4);
}

.cmp-fallback-status,
.cmp-fallback-glyphs {
  margin: 0;
}

.cmp-fallback-status {
  color: var(--accent-strong);
  font-size: var(--text-md);
}

.cmp-fallback-art {
  color: var(--text);
  font-family: inherit;
  font-size: clamp(var(--text-xs), 1.4vw, var(--text-base));
  line-height: 1.05;
  margin: 0;
  max-width: 100%;
  overflow: hidden;
}

.cmp-fallback-glyphs {
  color: var(--muted);
  max-width: 42rem;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .cmp-shell {
    border-radius: var(--r-md);
    min-height: calc(100dvh - var(--header-h) - var(--mobile-nav-h) - var(--sp-6));
  }

  .cmp-off,
  .cmp-fallback-grid {
    padding: var(--sp-4);
  }

  .cmp-controls {
    bottom: var(--sp-2);
    flex-wrap: wrap;
    width: calc(100% - var(--sp-4));
  }

  .cmp-control {
    flex: 1;
    min-width: calc(var(--sp-7) + var(--sp-5));
  }

  .cmp-shortcut-hint {
    left: var(--sp-2);
    max-width: calc(100% - var(--sp-7) - var(--sp-6));
    top: var(--sp-2);
  }

  .cmp-composer,
  .cmp-response {
    bottom: calc(var(--sp-7) + var(--sp-7));
    max-width: calc(100% - var(--sp-4));
    width: calc(100% - var(--sp-4));
  }
}
