/* ============================================================================
   THE CONFESSIONAL — "the quiet room"
   A calm space you step into to say something hard. It holds you, and it
   slows you down on purpose.
   ========================================================================== */

:root {
  /* Dusk, not daylight. Evening light in a room with the lamps low. */
  --ink:        #0F1216; /* the room itself — deep ink, blue-leaning, never black */
  --ink-raised: #161A20; /* a surface that is holding something */
  --ink-lift:   #1D222A; /* the one thing asking for your hands */
  --ink-edge:   #232A33; /* hairlines — present, never drawn attention to */

  --mist:       #E4E6E3; /* what you read — cool greige off-white, no cream */
  --mist-soft:  #A7ADAB; /* what you glance at */
  --mist-faint: #808789; /* what is merely true */

  --clay:       #C08D7C; /* the single warm signal — muted rose-taupe. Warmth,
                            connection, the human side. Used with discipline. */
  --clay-deep:  #6E4B41;
  --clay-glow:  rgba(192, 141, 124, 0.16);

  --slate:      #7E9AA6; /* the cool counterweight — calm, trust, the listening
                            side. Its tension with the clay is what keeps this
                            room from going saccharine. */
  --slate-deep: #35474F;
  --slate-glow: rgba(126, 154, 166, 0.14);

  --warn:       #C8A46B;

  --serif: "Newsreader", ui-serif, Georgia, "Iowan Old Style", serif;
  --sans:  "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Breath. Nothing here snaps. */
  --breath: 900ms cubic-bezier(0.22, 0.61, 0.36, 1);
  --settle: 560ms cubic-bezier(0.22, 0.61, 0.36, 1);
  --touch:  240ms cubic-bezier(0.22, 0.61, 0.36, 1);

  --gutter: clamp(1.25rem, 5vw, 2rem);
  --measure: 34rem;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--mist);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

body {
  min-height: 100svh;
  /* the faintest suggestion that the light in here comes from somewhere */
  background-image:
    radial-gradient(120% 70% at 50% -10%, rgba(126, 154, 166, 0.07), transparent 60%),
    radial-gradient(90% 55% at 50% 108%, rgba(192, 141, 124, 0.06), transparent 62%);
  background-attachment: fixed;
}

/* ------------------------------------------------------------------ layout */

#app {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: max(1.25rem, env(safe-area-inset-top)) var(--gutter)
           calc(2.5rem + env(safe-area-inset-bottom));
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: arrive var(--breath) both;
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.stack   { display: flex; flex-direction: column; gap: 1rem; }
.stack-s { display: flex; flex-direction: column; gap: 0.5rem; }
.row     { display: flex; gap: 0.625rem; flex-wrap: wrap; align-items: center; }
.grow    { flex: 1; }
.spacer  { flex: 1; min-height: 1rem; }

/* -------------------------------------------------------------- typography */

h1, h2, h3 { margin: 0; font-weight: 400; }

.display {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(2rem, 7.5vw, 2.9rem);
  line-height: 1.14;
  letter-spacing: -0.018em;
  color: var(--mist);
}

.title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  line-height: 1.24;
  letter-spacing: -0.012em;
}

.lede {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--mist-soft);
}

.body  { font-size: 1rem; color: var(--mist-soft); }
.small { font-size: 0.9rem; color: var(--mist-soft); }

.meta {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mist-faint);
  font-weight: 500;
}

.warm { color: var(--clay); }
.cool { color: var(--slate); }
em.q { font-family: var(--serif); font-style: italic; color: var(--mist); }

/* ---------------------------------------------------------------- surfaces */

.card {
  background: var(--ink-raised);
  border: 1px solid var(--ink-edge);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
}

.card.warm-edge { border-color: rgba(192, 141, 124, 0.28); background: linear-gradient(180deg, rgba(192,141,124,0.05), transparent 70%), var(--ink-raised); }
.card.cool-edge { border-color: rgba(126, 154, 166, 0.26); background: linear-gradient(180deg, rgba(126,154,166,0.05), transparent 70%), var(--ink-raised); }

hr.rule { border: 0; border-top: 1px solid var(--ink-edge); margin: 0.5rem 0; }

/* --------------------------------------------------------------- controls */

button { font-family: inherit; font-size: inherit; }

.btn {
  appearance: none;
  border: 1px solid var(--ink-edge);
  background: var(--ink-lift);
  color: var(--mist);
  padding: 0.85rem 1.25rem;
  border-radius: 11px;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background var(--touch), border-color var(--touch), transform var(--touch), opacity var(--touch);
  text-align: center;
}

.btn:hover  { background: #232932; }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: linear-gradient(180deg, rgba(192, 141, 124, 0.22), rgba(192, 141, 124, 0.12));
  border-color: rgba(192, 141, 124, 0.45);
  color: #F2DFD7;
}
.btn.primary:hover { background: linear-gradient(180deg, rgba(192,141,124,0.3), rgba(192,141,124,0.16)); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--mist-soft); padding-left: 0.25rem; padding-right: 0.25rem; }
.btn.ghost:hover { color: var(--mist); background: transparent; }

.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.38; cursor: not-allowed; transform: none; }

:where(button, a, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--slate);
  outline-offset: 3px;
  border-radius: 8px;
}

/* choice chips — finish line, medium, severity */

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.chip {
  appearance: none;
  background: transparent;
  border: 1px solid var(--ink-edge);
  color: var(--mist-soft);
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--touch);
}
.chip:hover { color: var(--mist); border-color: #333B45; }
.chip[aria-pressed="true"] {
  color: #F2DFD7;
  border-color: rgba(192, 141, 124, 0.55);
  background: rgba(192, 141, 124, 0.13);
}

/* fields */

.field {
  width: 100%;
  background: var(--ink-raised);
  border: 1px solid var(--ink-edge);
  border-radius: 11px;
  color: var(--mist);
  padding: 0.85rem 0.95rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.55;
  resize: vertical;
  transition: border-color var(--touch), background var(--touch);
}
.field::placeholder { color: var(--mist-faint); }
.field:focus { border-color: var(--slate-deep); background: #171C23; outline: none; }
.field:focus-visible { outline: 2px solid var(--slate); outline-offset: 2px; }

textarea.field { min-height: 6.5rem; }
textarea.script { font-family: var(--serif); font-size: 1.15rem; line-height: 1.55; min-height: 8rem; }

label.lbl { display: block; font-size: 0.9rem; color: var(--mist-soft); margin-bottom: 0.4rem; }

/* ------------------------------------------------------------------ header */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  min-height: 1.75rem;
}

.mark {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: var(--mist-soft);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.mark .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--clay); box-shadow: 0 0 12px var(--clay); }

/* Quiet to the eye, but a real target for a thumb — 44px of reachable
   height, spent on padding rather than on looking bigger. */
.linkish {
  background: none; border: 0;
  padding: 0.72rem 0.3rem; margin: -0.72rem -0.3rem;
  color: var(--mist-faint); font-size: 0.82rem; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--ink-edge);
}
.linkish:hover { color: var(--mist-soft); }

/* ------------------------------------------------- the space between (canvas) */

.space-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0C0F13;
  border: 1px solid var(--ink-edge);
}
.space-wrap canvas { display: block; width: 100%; height: 100%; }
.space-caption {
  position: absolute; left: 0; right: 0; bottom: 0.6rem;
  text-align: center; pointer-events: none;
}

/* ------------------------------------------------------------ conversation */

.thread {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding-bottom: 0.5rem;
}

.msg { max-width: 92%; animation: arrive var(--settle) both; }

.msg.coach {
  align-self: flex-start;
  font-family: var(--serif);
  font-size: 1.16rem;
  line-height: 1.55;
  color: var(--mist);
  border-left: 2px solid var(--slate-deep);
  padding-left: 1rem;
}

.msg.you {
  align-self: flex-end;
  background: var(--ink-raised);
  border: 1px solid var(--ink-edge);
  border-radius: 13px 13px 4px 13px;
  padding: 0.7rem 0.95rem;
  font-size: 1rem;
  color: var(--mist);
}

.msg.coach p, .msg.you p { margin: 0 0 0.6rem; }
.msg.coach p:last-child, .msg.you p:last-child { margin-bottom: 0; }
.msg.coach strong, .msg.you strong { font-weight: 600; color: var(--mist); }
.msg.coach em, .msg.you em { font-style: italic; }

.thinking { display: inline-flex; gap: 5px; align-items: center; padding-left: 1rem; }
.thinking i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--slate);
  opacity: 0.35; animation: pulse 2.4s var(--breath) infinite;
}
.thinking i:nth-child(2) { animation-delay: 0.3s; }
.thinking i:nth-child(3) { animation-delay: 0.6s; }
@keyframes pulse { 0%, 100% { opacity: 0.22; transform: scale(0.85); } 50% { opacity: 0.85; transform: scale(1); } }

.composer { display: flex; gap: 0.6rem; align-items: flex-end; }
.composer textarea { max-height: 9rem; min-height: 3rem; }
.composer .send {
  flex: 0 0 auto; width: 3rem; height: 3rem; border-radius: 11px;
  border: 1px solid var(--ink-edge); background: var(--ink-lift); color: var(--mist);
  cursor: pointer; display: grid; place-items: center; transition: all var(--touch);
}
.composer .send:hover { border-color: rgba(192,141,124,0.5); color: var(--clay); }

/* ------------------------------------------------------------ the keystone */

.keystone { display: flex; flex-direction: column; align-items: center; gap: 1.25rem; padding: 1rem 0; }

.orb {
  position: relative;
  width: 148px; height: 148px;
  border-radius: 50%;
  border: 1px solid var(--ink-edge);
  background: radial-gradient(circle at 50% 45%, rgba(192,141,124,0.14), rgba(22,26,32,0.9) 68%);
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform var(--settle), box-shadow var(--settle), border-color var(--settle);
}
.orb:hover { border-color: rgba(192,141,124,0.4); }
.orb .glyph { width: 22px; height: 22px; border-radius: 50%; background: var(--clay); box-shadow: 0 0 22px var(--clay-glow); transition: all var(--settle); }

.orb.armed { animation: held 4.2s ease-in-out infinite; border-color: rgba(192,141,124,0.55); box-shadow: 0 0 0 0 var(--clay-glow); }
.orb.armed .glyph { width: 18px; height: 18px; border-radius: 5px; background: var(--clay); }

@keyframes held {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0     var(--clay-glow); }
  50%      { transform: scale(1.045); box-shadow: 0 0 0 22px rgba(192,141,124,0); }
}

.timer { font-family: var(--serif); font-size: 1.5rem; color: var(--mist-soft); font-variant-numeric: tabular-nums; }

/* Playback, built rather than borrowed.

   The browser's own player is a grey plastic widget from another building, and
   it lets you drag past the part you're meant to hear. This one has a play
   button and a line that fills. There is no scrubber, on purpose: the only way
   through the listen-back gate is to actually listen. */

.tape { width: 100%; }

.tape video {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: 12px; background: #0A0D10; display: block; margin-bottom: 0.9rem;
}

.tape-row { display: flex; align-items: center; gap: 0.9rem; }

.tape-play {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid rgba(192, 141, 124, 0.4);
  background: radial-gradient(circle at 50% 45%, rgba(192,141,124,0.16), rgba(22,26,32,0.9) 70%);
  color: var(--clay); cursor: pointer; display: grid; place-items: center;
  transition: border-color var(--touch), transform var(--touch);
}
.tape-play:hover { border-color: rgba(192, 141, 124, 0.7); }
.tape-play:active { transform: scale(0.96); }

.tape-track {
  flex: 1; height: 2px; background: var(--ink-edge); border-radius: 2px; overflow: hidden;
}
.tape-track i {
  display: block; height: 100%; width: 0%;
  background: var(--clay); border-radius: 2px;
  transition: width 220ms linear;
}
.tape-time {
  flex: 0 0 auto; font-variant-numeric: tabular-nums;
  font-size: 0.85rem; color: var(--mist-faint); min-width: 3.2rem; text-align: right;
}
.tape.playing .tape-play { box-shadow: 0 0 0 6px var(--clay-glow); }
video.preview { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 11px; background: #0A0D10; transform: scaleX(-1); }

.gate {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.9rem; color: var(--mist-faint);
}
.gate .tick { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--ink-edge); flex: 0 0 auto; transition: all var(--settle); }
.gate.done { color: var(--slate); }
.gate.done .tick { background: var(--slate); border-color: var(--slate); box-shadow: 0 0 14px var(--slate-glow); }

/* the exhale on approve */
.exhale { position: fixed; inset: 0; pointer-events: none; z-index: 60; display: grid; place-items: center; }
.exhale i {
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle,
    rgba(192,141,124,0) 52%,
    rgba(192,141,124,0.20) 66%,
    rgba(192,141,124,0) 82%);
  filter: blur(6px);
  animation: exhale 2.4s cubic-bezier(0.16, 0.9, 0.3, 1) forwards;
}
@keyframes exhale {
  from { transform: scale(0.35); opacity: 0.95; }
  to   { transform: scale(9);    opacity: 0; }
}

/* ---------------------------------------------------------------- together */

.trend { width: 100%; height: 130px; display: block; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: var(--mist-faint); }
.legend i { width: 10px; height: 2px; background: var(--clay); border-radius: 2px; }

.entry { display: flex; gap: 0.9rem; padding: 0.85rem 0; border-bottom: 1px solid var(--ink-edge); }
.entry:last-child { border-bottom: 0; }
.entry .when { flex: 0 0 4.5rem; color: var(--mist-faint); font-size: 0.8rem; padding-top: 0.15rem; }

/* ------------------------------------------------------------------ sheets */

.veil {
  position: fixed; inset: 0; background: rgba(6, 8, 10, 0.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 80; display: flex; align-items: flex-end; justify-content: center;
  animation: fade var(--settle) both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%; max-width: var(--measure);
  background: var(--ink-raised);
  border: 1px solid var(--ink-edge);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 1.5rem var(--gutter) calc(1.75rem + env(safe-area-inset-bottom));
  animation: rise var(--breath) both;
  max-height: 88svh; overflow-y: auto;
}
@keyframes rise { from { transform: translateY(28px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------------ notice */

.notice {
  border: 1px solid rgba(200, 164, 107, 0.34);
  background: rgba(200, 164, 107, 0.07);
  border-radius: 11px; padding: 0.85rem 1rem; font-size: 0.92rem; color: #E3D3B4;
}
.notice.bad { border-color: rgba(192,141,124,0.4); background: rgba(192,141,124,0.08); color: #EBD3C9; }

/* ------------------------------------------------------------------- misc */

.center { text-align: center; }
.hidden { display: none !important; }
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.footer {
  margin-top: 2rem; padding-top: 1.25rem;
  border-top: 1px solid var(--ink-edge);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}

/* ------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .screen, .msg, .sheet, .veil { animation: none; }
}
