@font-face { font-family: 'Factor A'; font-weight: 400; src: url('fonts/FactorA-Regular.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Factor A'; font-weight: 500; src: url('fonts/FactorA-Medium.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Factor A'; font-weight: 700; src: url('fonts/FactorA-Bold.ttf') format('truetype'); font-display: swap; }

:root {
  --teal-950: #021d1f; --teal-900: #072a2d; --teal-800: #043336; --teal-700: #073234; --teal-600: #082a2c; --teal-500: #0d6367; --teal-400: #84a797;
  --sand: #e0ddbc; --sky: #c1ddeb; --pink: #e7c2d2; --peach: #ffd8cc; --coral: #ff7c52; --coral-300: #ffa488; --ink: #0c1f20;
  /* Ardoise muted whites: .8 for secondary copy, .6 (5.9:1 on teal-800) for short labels */
  --fg: #fff; --fg-2: rgba(255, 255, 255, 0.8); --fg-3: rgba(255, 255, 255, 0.6); --line: rgba(255, 255, 255, 0.15); --line-2: rgba(255, 255, 255, 0.35);
  --display: 'Factor A', 'Space Grotesk', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  --dress: 340px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--teal-800);
  isolation: isolate;
  color: var(--fg);
  font: 400 16px/1.4 var(--body);
  -webkit-font-smoothing: antialiased;
  caret-color: var(--coral);
}
body::before { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: url('assets/grain.png'); opacity: 0.05; }
::selection { background: var(--coral); color: var(--ink); }
:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--teal-500) transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.4; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
h1, h2 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: -0.01em; }

/* ---------- top bar ---------- */
.top {
  height: 64px; display: flex; align-items: center; gap: 20px; padding: 0 24px;
  border-bottom: 1px solid var(--line);
}
.mark { height: 20px; width: auto; }
.pick select {
  appearance: none; background: transparent; border: 1px solid var(--line); border-radius: 23px;
  padding: 9px 38px 9px 16px; font: 500 14px/1 var(--display); color: var(--fg);
  background-image: linear-gradient(45deg, transparent 50%, var(--fg) 50%), linear-gradient(-45deg, transparent 50%, var(--fg) 50%);
  background-size: 5px 5px; background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%; background-repeat: no-repeat;
  transition: border-color 180ms var(--ease);
}
.pick select:hover { border-color: var(--line-2); }
.pick option { background: var(--teal-700); }
.layouts { display: flex; margin-left: auto; border: 1px solid var(--line); border-radius: 23px; padding: 3px; }
.layouts button {
  border: 0; background: transparent; border-radius: 23px; padding: 7px 14px; font: 500 14px/1 var(--display); color: var(--fg-3);
  transition: background-color 220ms var(--ease), color 220ms var(--ease);
}
.layouts button:hover { color: var(--fg); }
.layouts button[aria-pressed='true'] { background: var(--fg); color: var(--teal-800); }
.clock { font: 500 14px/1 var(--body); font-variant-numeric: tabular-nums; color: var(--fg-3); min-width: 52px; text-align: right; }
body.live .clock { color: var(--coral); }
body.live .clock::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); margin-right: 8px; vertical-align: 1px; }
.ghost {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: transparent; border-radius: 23px;
  padding: 8px 14px; font: 500 14px/1 var(--display); transition: border-color 180ms var(--ease), transform 220ms var(--ease);
}
.ghost:hover { border-color: var(--line-2); }
.ghost:active { transform: scale(0.98); }
.ghost svg { width: 16px; height: 16px; }

/* ---------- room: one DOM, three arrangements ---------- */
.room {
  height: calc(100vh - 64px); min-height: 560px; display: grid; gap: 16px 20px; padding: 16px 24px 20px;
  grid-template-columns: minmax(0, 1fr) var(--dress);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: 'brief dress' 'stage dress' 'bar dress';
}
body.dress-closed .room { grid-template-columns: minmax(0, 1fr) 0; column-gap: 0; }
body.dress-closed .dress { visibility: hidden; }
/* in its 0 px column its padding and border would hang 5 px past the window; phones slide the sheet away instead */
@media (min-width: 901px) { body.dress-closed .dress { padding: 0; border: 0; margin: 0; } }
body[data-layout='strip'] .room {
  grid-template-rows: auto minmax(0, 1fr) 248px auto;
  grid-template-areas: 'brief dress' 'stage dress' 'strip dress' 'bar dress';
}
body[data-layout='face'] .room {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) var(--dress);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: 'brief brief dress' 'stage mirror dress' 'table table dress' 'bar bar dress';
}
body[data-layout='face'].dress-closed .room { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) 0; }

.brief { grid-area: brief; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; }
.brief h1 { font-size: 32px; line-height: 1.05; }
.brief .role { margin: 0; color: var(--fg-3); font-size: 14px; }
.brief .situation { margin: 0; flex-basis: 100%; color: var(--fg-2); max-width: 72ch; text-wrap: pretty; }
.brief .goal { color: var(--sand); }

.stage {
  grid-area: stage; position: relative; min-height: 0; border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow); background: var(--teal-800); transition: background-color 400ms var(--ease);
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.feeling {
  position: absolute; top: 14px; left: 14px; margin: 0; display: flex; align-items: center; gap: 8px;
  padding: 7px 12px 7px 10px; border-radius: 30px; background: rgba(2, 29, 31, 0.78);
  font: 500 14px/1 var(--display); color: var(--fg); transition: opacity 220ms var(--ease);
}
.feeling i { width: 9px; height: 9px; border-radius: 50%; background: var(--sand); transition: background-color 600ms var(--ease); }
.feeling:empty, body.hide-feeling .feeling, .feeling.idle { opacity: 0; }

.self {
  grid-area: stage; justify-self: end; align-self: start; margin: 14px; width: clamp(120px, 18%, 200px); aspect-ratio: 4 / 3;
  border-radius: 12px; overflow: hidden; background: var(--teal-700); border: 1px solid var(--line); position: relative; z-index: 1;
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.self video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.self span { font: 500 14px/1 var(--display); color: var(--fg-3); }
body.cam .self span { display: none; }
body:not(.cam) .self { background: rgba(2, 29, 31, 0.55); border: 1px dashed var(--line-2); box-shadow: none; }
body:not([data-layout='call']) .self { display: none; }

.captions {
  grid-area: stage; align-self: end; z-index: 1; margin: 0 14px 14px; display: grid; gap: 6px; justify-items: start; pointer-events: none;
}
.cap {
  margin: 0; max-width: min(64ch, 100%); padding: 9px 14px; border-radius: 12px; background: rgba(2, 29, 31, 0.82);
  font-size: 18px; line-height: 1.35; text-wrap: pretty; transition: opacity 220ms var(--ease);
}
.cap b { font: 500 12px/1 var(--display); margin-right: 10px; letter-spacing: 0.01em; }
.cap-her b { color: var(--sand); }
.cap-you b { color: var(--sky); }
.cap:has(span:empty) { opacity: 0; }
body[data-layout='face'] .captions {
  grid-area: table; margin: 0; padding: 14px 0 0; border-top: 1px solid var(--line); grid-template-columns: 1fr 1fr; gap: 20px; pointer-events: auto;
}
body[data-layout='face'] .cap { background: transparent; padding: 0; font-size: 18px; max-width: none; }
body[data-layout='face'] .cap-you { order: 2; }
body[data-layout='face'] .cap b { display: block; margin: 0 0 8px; }

/* ---------- face to face: the learner's portrait ---------- */
.mirror { grid-area: mirror; display: none; min-height: 0; grid-template-rows: minmax(0, 1fr) auto; gap: 14px; }
body[data-layout='face'] .mirror { display: grid; }
.portrait {
  position: relative; min-height: 0; border-radius: 16px; overflow: hidden; background: var(--teal-700); border: 1px solid var(--line);
  display: grid; place-items: center; container-type: size;
}
.portrait video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
/* a short, wide portrait caps the silhouette by height, keeping two lines of hint clear below the shoulders */
.silhouette { width: min(46%, 100cqh - 124px); height: auto; fill: var(--teal-500); stroke: none; opacity: 0.7; }
.cam-hint { position: absolute; bottom: 14px; left: 16px; right: 16px; margin: 0; font-size: 14px; color: var(--fg-3); text-align: center; }
body.cam .silhouette, body.cam .cam-hint { display: none; }
.reading { margin: 0; font: 400 18px/1.35 var(--body); color: var(--fg-2); text-wrap: pretty; }
.reading strong { font-weight: 700; color: var(--sand); }
body:not(.cam) .portrait { background: transparent; border: 1px dashed var(--line-2); }

/* ---------- the strip ---------- */
.strip { grid-area: strip; display: none; min-height: 0; }
body[data-layout='strip'] .strip { display: block; }
.strip ol { list-style: none; margin: 0; padding: 0 0 6px; height: 100%; display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x proximity; }
.strip .slot {
  flex: none; width: 214px; border: 1px dashed var(--line-2); border-radius: 14px; display: grid; place-items: center; padding: 18px;
  color: var(--fg-3); font-size: 14px; text-align: center; text-wrap: balance;
}
.panel {
  flex: none; width: 214px; height: 100%; position: relative; border-radius: 14px; overflow: hidden; scroll-snap-align: end;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--teal-700); border: 1px solid var(--line);
  animation: panel-in 320ms var(--ease) both;
}
.panel canvas { grid-area: 1 / 1 / -1 / -1; width: 100%; height: 100%; object-fit: cover; object-position: 50% 48%; }
.panel .you {
  grid-area: 1 / 1; position: relative; margin: 0; padding: 8px 10px 9px; background: var(--sky); color: var(--ink);
  font-size: 12px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.panel .tag {
  grid-area: 2 / 1; align-self: start; justify-self: start; position: relative; margin: 8px 10px; padding: 4px 9px; border-radius: 30px;
  background: rgba(2, 29, 31, 0.82); font: 500 12px/1 var(--display);
}
.panel .said {
  grid-area: 3 / 1; position: relative; margin: 0 10px 10px; padding: 7px 10px; border-radius: 12px; background: var(--fg); color: var(--ink);
  font-size: 12px; line-height: 1.3; align-self: end;
}
.panel .said span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.panel .said::after { content: ''; position: absolute; left: 46%; top: -7px; border: 7px solid transparent; border-bottom-color: var(--fg); border-top: 0; }
.panel .you b { font: 500 12px/1 var(--display); margin-right: 6px; }
@keyframes panel-in { from { opacity: 0; transform: scale(0.98); } }

/* ---------- call bar ---------- */
.bar { grid-area: bar; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; }
.controls { display: flex; align-items: center; gap: 12px; }
.call {
  border: 0; border-radius: 23px; padding: 13px 22px; background: var(--coral); color: var(--ink); font: 500 16px/1 var(--display);
  transition: transform 220ms var(--ease), filter 220ms var(--ease), background-color 220ms var(--ease), color 220ms var(--ease);
}
.call:hover { transform: scale(1.02); filter: brightness(1.06); }
.call:active { transform: scale(0.98); }
body.live .call { background: transparent; color: var(--coral); box-shadow: inset 0 0 0 1.5px var(--coral); }
body.connecting .call { opacity: 0.7; pointer-events: none; }
.round {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: transparent; display: grid; place-items: center;
  transition: border-color 180ms var(--ease), background-color 180ms var(--ease), color 180ms var(--ease);
}
.round:hover:not(:disabled) { border-color: var(--line-2); }
.round[aria-pressed='true'] { background: var(--fg); color: var(--teal-800); border-color: var(--fg); }
.type { display: flex; align-items: center; width: 100%; max-width: 320px; border-bottom: 1px solid var(--line); transition: border-color 180ms var(--ease); }
.type:focus-within { border-color: var(--line-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.type input { flex: 1; min-width: 0; background: transparent; border: 0; border-radius: 12px; padding: 10px 4px; font-size: 14px; }
.type input::placeholder { color: var(--fg-3); }
.type button { border: 0; background: transparent; font-size: 18px; padding: 6px 8px; }
.status { grid-column: 1 / -1; margin: -6px 0 0; justify-self: center; color: var(--fg-3); font-size: 14px; text-align: center; text-wrap: pretty; min-height: 1.4em; }
.status.error { color: var(--coral-300); }

/* ---------- dressing room ---------- */
.dress {
  grid-area: dress; min-height: 0; overflow-y: auto; border-left: 1px solid var(--line); padding: 2px 0 20px 20px; margin-right: -8px; padding-right: 8px;
}
.dress-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--teal-800); padding: 4px 0 14px; z-index: 1; }
.dress-head h2 { font-size: 24px; }
.done { display: none; }
.group { border: 0; margin: 0; padding: 16px 0; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.group legend { float: left; width: 100%; font: 500 14px/1 var(--display); margin-bottom: 10px; display: flex; justify-content: space-between; }
.group legend + * { clear: both; }
.styles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.styles button { border: 0; padding: 0; background: transparent; display: grid; gap: 6px; justify-items: center; font: 500 12px/1.1 var(--display); color: var(--fg-3); }
.styles canvas { width: 100%; aspect-ratio: 1; border-radius: 10px; box-shadow: 0 0 0 1px var(--line); transition: box-shadow 220ms var(--ease), transform 220ms var(--ease); }
.styles button:hover canvas { transform: scale(1.03); }
.styles button[aria-pressed='true'] { color: var(--fg); }
.styles button[aria-pressed='true'] canvas { box-shadow: 0 0 0 2px var(--fg); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  border: 1px solid var(--line); background: transparent; border-radius: 30px; padding: 7px 12px; font: 400 14px/1 var(--body); color: var(--fg-2);
  transition: border-color 180ms var(--ease), background-color 180ms var(--ease), color 180ms var(--ease);
}
.chips button:hover { border-color: var(--line-2); color: var(--fg); }
.chips button[aria-pressed='true'] { background: var(--fg); border-color: var(--fg); color: var(--teal-800); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2); transition: transform 180ms var(--ease), box-shadow 180ms var(--ease); }
.swatches button:hover { transform: scale(1.1); }
.swatches button[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--teal-800), 0 0 0 4px var(--fg); }
.slider { display: grid; grid-template-columns: 96px 1fr 36px; align-items: center; gap: 10px; font-size: 14px; color: var(--fg-2); }
.slider output { font-variant-numeric: tabular-nums; text-align: right; color: var(--fg-3); }
input[type='range'] { appearance: none; background: transparent; height: 22px; margin: 0; }
input[type='range']::-webkit-slider-runnable-track { height: 2px; background: var(--line-2); border-radius: 23px; }
input[type='range']::-moz-range-track { height: 2px; background: var(--line-2); }
input[type='range']::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: var(--sand); border: 0; }
input[type='range']::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--sand); border: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--fg-2); }
.dress select { background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 100%; }
.dress select option { background: var(--teal-700); }
.toggle { appearance: none; width: 38px; height: 22px; border-radius: 23px; background: var(--line); position: relative; margin: 0; transition: background-color 220ms var(--ease); }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--fg); transition: transform 220ms var(--ease); }
.toggle:checked { background: var(--teal-500); }
.toggle:checked::after { transform: translateX(16px); }
.hint { margin: 0; font-size: 14px; color: var(--fg-3); }

/* ---------- contact sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 10; background: var(--teal-800); overflow-y: auto; padding: 24px; }
.sheet-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.sheet-head h2 { margin-right: auto; }
.sheet-head h2 { font-size: 32px; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.sheet-grid figure { margin: 0; display: grid; gap: 8px; }
.sheet-grid canvas { width: 100%; aspect-ratio: 1; border-radius: 12px; }
.sheet-grid figcaption { font: 500 14px/1 var(--display); color: var(--fg-2); }

/* ---------- a narrow bar (dressing room open below 1280 px) stacks: controls, then a full typing field ---------- */
@media (max-width: 1280px) {
  body:not(.dress-closed) .bar { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 10px; }
  body:not(.dress-closed) .controls { order: -1; }
  body:not(.dress-closed) .type { max-width: 480px; }
  body:not(.dress-closed) .status { margin: 0; }
}

/* ---------- narrow screens: one column, the bar stays in reach ---------- */
@media (max-width: 900px) {
  .top { height: auto; flex-wrap: wrap; gap: 10px 12px; padding: 12px 16px; }
  .pick { order: 4; flex-basis: 100%; }
  .pick select { width: 100%; }
  .layouts { order: 5; margin-left: 0; width: 100%; }
  .layouts button { flex: 1; padding: 8px 6px; }
  .clock { margin-left: auto; }
  .room, body[data-layout] .room, body.dress-closed .room {
    height: auto; min-height: 0; padding: 12px 16px 96px; gap: 12px;
    grid-template-columns: minmax(0, 1fr); grid-template-rows: none;
    grid-template-areas: 'brief' 'stage' 'bar';
  }
  body[data-layout='strip'] .room { grid-template-areas: 'brief' 'stage' 'strip' 'bar'; }
  /* .dress-closed matches the desktop face rule's weight, or its three columns win on phones */
  body[data-layout='face'] .room, body[data-layout='face'].dress-closed .room {
    grid-template-columns: minmax(0, 1fr); grid-template-areas: 'brief' 'stage' 'mirror' 'table' 'bar';
  }
  .stage { height: min(68vh, 520px); }
  .strip { height: 236px; }
  .mirror { height: 300px; }
  .self { width: 104px; }
  .cap { font-size: 16px; }
  .bar {
    position: sticky; bottom: 0; z-index: 2; background: var(--teal-800); padding: 10px 0 12px; border-top: 1px solid var(--line);
    grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 10px;
  }
  .controls { order: -1; }
  .type { max-width: none; }
  .status { margin: 0; }
  /* the dressing room is a bottom sheet: she stays in view while you dress her */
  .dress {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; max-height: 50dvh; overflow-y: auto; margin: 0; padding: 0 16px 24px;
    background: var(--teal-700); border: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.35);
    transition: transform 220ms var(--ease), visibility 0s;
  }
  body.dress-closed .dress { transform: translateY(100%); visibility: hidden; transition: transform 220ms var(--ease), visibility 0s 220ms; }
  .dress-head { background: var(--teal-700); padding: 16px 0 12px; gap: 8px; }
  .dress-head h2 { margin-right: auto; font-size: 18px; }
  .done { display: inline-flex; }
  .styles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
