/* Double mirror layout. Shared tokens own typography, colors and controls.
 * Load after base.css and before appearance.css / design-system.css. */
html { scroll-behavior: auto; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.small { font-size: var(--font-size-meta); line-height: var(--line-height-ui); }
.muted { color: var(--color-text-secondary); }
.pill { display: inline-flex; align-items: center; padding: calc(var(--space-1) / 2) var(--space-2); border-radius: var(--radius-pill); background: var(--color-primary-subtle); color: var(--color-primary); font-size: var(--font-size-meta); line-height: var(--line-height-ui); }
/* Use the site's compact controls, as in the mirror feeling picker. */
#app .ds-button, .fusion-dialog .ds-button {
  min-height: var(--touch-target-sm);
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-button);
  line-height: var(--line-height-ui);
}
main#app { width: calc(100% - var(--space-8)); max-width: 1000px; margin-inline: auto; padding-block: calc(var(--space-16) + env(safe-area-inset-top, 0px) + var(--space-6)) var(--space-8); }
.practice-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-4); }
.practice-heading h1, .practice-heading h2 { margin: 0; }
.practice-note { width: calc(100% - var(--space-8)); max-width: 1000px; margin-inline: auto; padding: var(--space-4) 0; border-top: 1px solid var(--color-border); color: var(--color-text-muted); text-align: center; }
.premises { margin-bottom: var(--space-4); padding: var(--space-4); border: 1px solid color-mix(in srgb, var(--color-primary) 12%, var(--color-surface)); border-radius: var(--radius-card); background: color-mix(in srgb, var(--color-primary) 4%, var(--color-surface)); }
.premises h2 { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); font-family: var(--font-sans); font-size: var(--font-size-label); font-weight: var(--font-weight-medium); line-height: var(--line-height-ui); color: var(--color-text-secondary); }
.premise-badge { padding: calc(var(--space-1) / 2) var(--space-2); border-radius: var(--radius-control); background: var(--color-primary-subtle); color: var(--color-primary); font-size: var(--font-size-label); font-weight: var(--font-weight-semibold); }
.premise-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.premise-option { display: flex; align-items: center; gap: var(--space-2); min-height: var(--space-10); padding: var(--space-2) var(--space-3); border: 1px solid color-mix(in srgb, var(--color-primary) 12%, var(--color-surface)); border-radius: var(--radius-control); background: var(--color-surface); color: var(--color-text-secondary); font-size: var(--font-size-label); line-height: var(--line-height-ui); cursor: pointer; transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease; }
.premise-option input { appearance: none; -webkit-appearance: none; display: grid; place-content: center; flex: 0 0 var(--space-4); width: var(--space-4); height: var(--space-4); padding: 0; margin: 0; border: 1px solid color-mix(in srgb, var(--color-primary) 40%, var(--color-surface)); border-radius: 50%; background: var(--color-surface); color: var(--color-primary); cursor: pointer; }
.premise-option input::before { content: ''; width: 7px; height: 4px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-1px) rotate(-45deg); visibility: hidden; }
.premise-option input:checked { border-color: var(--color-primary); background: var(--color-primary-subtle); }
.premise-option input:checked::before { visibility: visible; }
.premise-option span { min-width: 0; overflow-wrap: anywhere; }
.premise-option:has(input:checked) { border-color: color-mix(in srgb, var(--color-primary) 40%, var(--color-surface)); background: var(--color-primary-subtle); color: var(--color-text); }
.premise-option:has(input:focus-visible) { outline: 2px solid var(--color-focus); outline-offset: 3px; }
@media (hover: hover) {
  .premise-option:hover { border-color: var(--color-primary); }
}
@media (prefers-reduced-motion: reduce) {
  .premise-option { transition: none; }
}
@media (forced-colors: active) {
  .premise-option input { appearance: auto; -webkit-appearance: auto; }
  .premise-option input::before { content: none; }
}
.board-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); align-items: start; margin-top: var(--space-4); }
.mirror-panel { min-width: 0; padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-card); background: var(--color-surface); }
.mirror-panel h2 { margin: 0 0 var(--space-2); }
.mirror-panel > button { margin-top: var(--space-3); }
.saved-ideals { margin-top: var(--space-6); }
.saved-ideals h2 { margin: 0 0 var(--space-3); }
.saved-ideal { margin-top: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-card); background: var(--color-surface); }
.saved-ideal dl { display: grid; gap: var(--space-2); margin: 0; font-size: var(--font-size-helper); }
.saved-ideal dl > div { display: grid; grid-template-columns: 5em minmax(0, 1fr); gap: var(--space-2); }
.saved-ideal dt { color: var(--color-text-secondary); }
.saved-ideal dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.saved-ideal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }
.saved-scene { margin-top: var(--space-3); padding-top: var(--space-2); border-top: 1px solid var(--color-border); font-size: var(--font-size-helper); }
.saved-scene p { margin: var(--space-1) 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog-header .flow-context:not(.flow-context-present), .dialog-header .flow-context-from-ideal { max-height: 36dvh; overflow-y: auto; overscroll-behavior: contain; }
.field { margin-top: var(--space-3); }
.field:first-child { margin-top: 0; }
.field label { display: block; margin-bottom: var(--space-1); color: var(--color-text-secondary); font-size: var(--font-size-label); font-weight: var(--font-weight-medium); line-height: var(--line-height-ui); }
.field textarea { display: block; width: 100%; height: var(--space-12); min-height: var(--space-12); resize: vertical; }
.field textarea:focus { border-color: var(--color-focus); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.chips .chip { min-height: var(--touch-target-sm); padding: var(--space-1) var(--space-3); border-radius: var(--radius-pill); font-size: var(--font-size-label); }
.chips [data-action="select-scene"] { max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: left; }
.chips .chip.selected, .choice-list .choice.selected { background: var(--color-primary-subtle); border-color: var(--color-primary); color: var(--color-primary); }
/* Context remains in the dialog header; only questions scroll. */
dialog.fusion-dialog { width: min(600px, calc(100% - var(--space-8))); max-height: calc(100dvh - var(--space-8)); margin: auto; padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-dialog); background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.fusion-dialog[open] { display: flex; flex-direction: column; }
dialog.fusion-dialog::backdrop { background: var(--color-overlay); }
.dialog-header { flex: 0 0 auto; background: var(--color-surface); }
.dialog-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--color-border); }
.dialog-content { min-height: 0; padding: var(--space-4); overflow-y: auto; overscroll-behavior: contain; }
.flow-context { margin: var(--space-3) var(--space-4) 0; padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-primary-subtle); }
.flow-context dl { display: grid; gap: var(--space-2); margin: 0; }
.flow-context-item { display: grid; grid-template-columns: 7em minmax(0, 1fr); align-items: start; gap: var(--space-3); font-size: var(--font-size-helper); }
.flow-context dt { color: var(--color-text-secondary); font-size: var(--font-size-label); line-height: var(--line-height-ui); }
.flow-context dd { margin: 0; max-height: min(12dvh, var(--space-24)); overflow-y: auto; overscroll-behavior: contain; color: var(--color-text); font-size: var(--font-size-helper); line-height: var(--line-height-ui); white-space: pre-wrap; overflow-wrap: anywhere; }
.flow-context-present dd { max-height: min(9dvh, var(--space-16)); }
.release-focus { margin: 0 0 var(--space-3); max-height: 20vh; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.stage-meta { margin-bottom: var(--space-2); color: var(--color-text-muted); font-size: var(--font-size-meta); line-height: var(--line-height-ui); }
.progress-track { height: var(--space-1); margin-bottom: var(--space-4); overflow: hidden; border-radius: var(--radius-pill); background: var(--color-border); }
.progress-fill { height: 100%; background: var(--color-primary); }
.question-card { min-width: 0; }
.question-card h2 { margin: 0 0 var(--space-3); }
.question-description { margin: 0 0 var(--space-3); color: var(--color-text-secondary); font-size: var(--font-size-helper); line-height: var(--line-height-body); }
/* Step headings receive focus for screen readers, but are not controls. */
.fusion-dialog #questionTitle:focus { outline: none; }
.question-card .ds-prompt { font-family: var(--font-sans); font-size: var(--font-size-body); font-weight: var(--font-weight-semibold); line-height: var(--line-height-ui); }
.choice-list { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.choice-list .choice { display: flex; align-items: center; justify-content: flex-start; max-width: 100%; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.step-actions, .summary-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-3); }
.step-actions > div, .summary-actions > div { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.dialog-content > .summary-actions { margin-top: var(--space-2); }
/* JS manages this toast; disable the legacy base.css disappearance animation. */
#toast { position: fixed; left: 50%; right: auto; bottom: var(--space-6); transform: translateX(-50%); max-width: calc(100% - var(--space-8)); margin: 0; padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-raised); color: var(--color-text); box-shadow: var(--shadow-md); font-size: var(--font-size-helper); line-height: var(--line-height-ui); text-align: center; animation: none; z-index: 9999; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 768px) {
  .board-grid { grid-template-columns: 1fr; }
  .premise-grid { grid-template-columns: 1fr; gap: var(--space-2); }
}
@media (max-width: 480px) {
  .flow-context-item { grid-template-columns: 6em minmax(0, 1fr); gap: var(--space-2); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Reused unchanged from mirror/css/theme.css: .mr-rf-feeling-ref-btn and
 * .cap-ref-* emotion reference sheet. Native dialog reset follows below. */
.mr-rf-feeling-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.question-card > .mr-rf-feeling-ref-btn { margin-top: var(--space-3); }
.mr-rf-feeling-ref-btn {
  min-height: var(--touch-target-sm);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-text-secondary);
  font: inherit;
  font-size: var(--font-size-button);
  cursor: pointer;
}

/* ── Emotion reference sheet ── */
.cap-ref-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}
.cap-ref-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  overflow: hidden;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--color-bg);
  box-shadow: var(--shadow-lg);
}
.cap-ref-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-4) var(--space-2);
  color: var(--color-text);
  font-size: var(--font-size-body);
  font-weight: 700;
}
.cap-ref-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target);
  height: var(--touch-target);
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  cursor: pointer;
}
.cap-ref-dream {
  flex: 0 0 auto;
  margin: 0 var(--space-4) var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-size-body-sm);
  line-height: 1.5;
}
.cap-ref-dream-label {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--color-primary);
  font-size: var(--font-size-button);
  font-weight: 700;
}
.cap-ref-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 var(--space-4) var(--space-5);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.cap-ref-group {
  margin-bottom: var(--space-4);
}
.cap-ref-group-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  color: var(--color-text);
  font-size: var(--font-size-body);
  font-weight: 700;
}
.cap-ref-group-sub {
  color: var(--color-text-muted);
  font-size: var(--font-size-meta);
  font-weight: 400;
}
.cap-ref-sub-label {
  margin: var(--space-2) 0 var(--space-1);
  color: var(--color-text-secondary);
  font-size: var(--font-size-button);
  font-weight: 600;
}
.cap-ref-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.cap-ref-chip {
  min-height: var(--touch-target-sm);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: var(--font-size-button);
  cursor: pointer;
}
.cap-ref-chip.selected {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: 600;
}

/* Native dialog adaptation: retain the original overlay; only open dialogs
 * participate in layout. showModal() places the sheet above the release flow. */
dialog.cap-ref-overlay {
  display: none;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
}
dialog.cap-ref-overlay[open] {
  display: flex;
}
dialog.cap-ref-overlay::backdrop {
  background: transparent;
}
/* Longer ideals stay readable without taking the feeling list's space. */
dialog.cap-ref-overlay .cap-ref-dream {
  max-height: 20vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Wanting segments use the mirror exercise controls. */
.mr-rf-wanting-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.mr-rf-wanting-group {
  display: inline-flex;
}
.mr-rf-wanting-chip {
  position: relative;
  min-height: var(--touch-target-sm);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: var(--font-size-button);
  cursor: pointer;
}
.mr-rf-wanting-chip.selected {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-on-primary);
}
.mr-rf-wanting-group .mr-rf-wanting-chip {
  border-radius: 0;
}
.mr-rf-wanting-group .mr-chip-first {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.mr-rf-wanting-group .mr-chip-last {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
@media (max-width: 480px) {
  .mr-rf-wanting-group .mr-rf-wanting-chip { padding-inline: var(--space-2); white-space: nowrap; }
}

.mirror-switch { margin-top: var(--space-3); }
