/* Capri on the iPhone — laid out for a 14 Pro Max (430 × 932 pt), safe around the Dynamic Island
   and the home indicator, and fine on any other phone. */

:root {
  --ink: #0d0914;
  --ink-2: #171021;
  --ink-3: #221833;
  --paper: #f8eff4;
  --paper-2: #cbbccc;
  --paper-3: #8e7f99;
  --violet: #7b3cf0;
  --violet-2: #a679ff;
  --red: #ff2e5b;
  --green: #45f58c;
  --blue: #5fa8ff;
  --font: 'Chakra Petch', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --vh: 1dvh;
  --cut: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--paper); font-family: var(--font); overscroll-behavior: none; }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ------------------------------------------------ backdrop: violet night, scanlines, a faint grid */
.bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 60% at 50% 18%, rgba(123, 60, 240, 0.28), transparent 60%),
    radial-gradient(90% 50% at 85% 80%, rgba(255, 46, 91, 0.12), transparent 70%),
    linear-gradient(180deg, #0d0914 0%, #120b1c 60%, #0b0711 100%);
}
.bg::before {
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(166, 121, 255, 0.07) 1px, transparent 1px), linear-gradient(90deg, rgba(166, 121, 255, 0.07) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 60%, transparent);
}
.bg::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px);
}

/* ------------------------------------------------ login */
.login {
  position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--top) + 24px) 28px calc(var(--bottom) + 24px); text-align: center;
}
.login__mark {
  width: 92px; height: 92px; display: grid; place-items: center; margin-bottom: 22px;
  background: var(--ink-2); border: 1.5px solid var(--violet);
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}
.login__mark span { font-size: 54px; font-weight: 700; color: var(--paper); text-shadow: -3px 0 var(--green), 3px 0 var(--red); }
.login__title { margin: 0; font-size: 28px; letter-spacing: 0.14em; }
.login__title b { color: var(--violet-2); }
.login__sub { margin: 10px 0 26px; color: var(--paper-2); font-size: 15px; max-width: 300px; line-height: 1.4; }
.login__form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login__form input {
  width: 100%; padding: 15px 16px; font: 600 17px var(--font); color: var(--paper);
  background: var(--ink-2); border: 1px solid var(--ink-3); border-bottom: 2px solid var(--violet); outline: none; border-radius: 0;
}
.login__form input:focus { border-color: var(--violet-2); }
.login__error { min-height: 22px; color: var(--red); font: 13px var(--mono); margin-top: 14px; }

.btn {
  border: 0; cursor: pointer; padding: 13px 18px; font-weight: 700; font-size: 15px; letter-spacing: 0.12em; text-transform: uppercase;
  background: var(--ink-3); color: var(--paper);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}
.btn--primary { background: var(--green); color: #07150c; }
.btn--big { padding: 17px 28px; font-size: 17px; }
.btn:active { transform: translateY(1px); filter: brightness(1.1); }

/* ------------------------------------------------ gate: home-screen app only, phones only */
.gate {
  position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--top) + 24px) 30px calc(var(--bottom) + 24px); text-align: center;
}
.gate__title { margin: 0 0 22px; font-size: 26px; line-height: 1.15; letter-spacing: 0.02em; }
.gate__steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 340px; text-align: left; }
.gate__steps li {
  counter-increment: s; position: relative; padding: 14px 14px 14px 52px; background: var(--ink-2); border-left: 2px solid var(--violet);
  font-size: 16px; line-height: 1.35; color: var(--paper-2);
}
.gate__steps li::before {
  content: counter(s); position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 26px; height: 26px; display: grid; place-items: center;
  background: var(--violet); color: #fff; font: 700 14px var(--mono);
}
.gate__steps b { color: var(--paper); }
.gate__steps svg { width: 18px; height: 18px; vertical-align: -3px; fill: none; stroke: var(--blue); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gate__note { margin: 22px 0 0; color: var(--paper-3); font: 12px/1.5 var(--mono); max-width: 320px; }

/* ------------------------------------------------ app shell */
.app {
  position: fixed; inset: 0; z-index: 1;
  height: calc(var(--vh) * 100);
  display: flex; flex-direction: column;
  padding-top: var(--top);
}

.top {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 6px 14px 4px 18px; min-height: 48px;
}
.brand { font-weight: 700; letter-spacing: 0.22em; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.brand__dot { width: 9px; height: 9px; background: var(--green); box-shadow: 0 0 10px var(--green); }
.brand__dot.is-off { background: var(--paper-3); box-shadow: none; }
.status { flex: 1; font: 600 10.5px var(--mono); letter-spacing: 0.1em; color: var(--paper-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon {
  width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; padding: 0; color: var(--paper-2);
}
.icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon svg circle { fill: currentColor; stroke: none; }
#voiceBtn .wave { opacity: 0.25; }
#voiceBtn[aria-pressed='true'] { color: var(--green); }
#voiceBtn[aria-pressed='true'] .wave { opacity: 1; }

/* ------------------------------------------------ stage: her, floating, with her line under her */
.stage {
  position: relative; flex: none; height: calc(var(--vh) * 46); min-height: 300px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  transition: height 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.app.is-typing .stage { height: calc(var(--vh) * 30); min-height: 220px; }
.shards { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sat {
  position: absolute; top: 14%; left: -6px; width: 3px; height: 3px; background: #fff; border-radius: 50%;
  box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.6); animation: sat 70s linear infinite; opacity: 0.85;
}
@keyframes sat { from { transform: translateX(0); } to { transform: translateX(110vw); } }

.capri {
  position: relative; flex: 1; width: 100%; border: 0; background: none; padding: 0; cursor: pointer;
  display: flex; justify-content: center; align-items: flex-end; min-height: 0;
}
.capri img {
  position: absolute; bottom: 0; height: 100%; max-height: 380px; width: auto; aspect-ratio: 240 / 420;
  user-select: none; -webkit-user-select: none; pointer-events: none;
  animation: float 3.2s steps(4, jump-none) infinite alternate;
}
.capri__body { filter: drop-shadow(5px 5px 0 rgba(123, 60, 240, 0.85)); }
.capri__ghost { opacity: 0; mix-blend-mode: screen; }
.capri__ghost--g { filter: brightness(0) saturate(100%) invert(76%) sepia(77%) saturate(507%) hue-rotate(84deg); }
.capri__ghost--r { filter: brightness(0) saturate(100%) invert(30%) sepia(98%) saturate(4000%) hue-rotate(335deg); }
@keyframes float { from { translate: 0 0; } to { translate: 0 -12px; } }

.capri.is-glitch .capri__ghost { opacity: 0.75; }
.capri.is-glitch .capri__ghost--g { transform: translateX(-7px); clip-path: inset(10% 0 55% 0); }
.capri.is-glitch .capri__ghost--r { transform: translateX(7px); clip-path: inset(48% 0 20% 0); }
.capri.is-glitch .capri__body { animation: float 3.2s steps(4, jump-none) infinite alternate, slice 0.32s steps(3) 1; }
@keyframes slice {
  0% { clip-path: inset(0 0 0 0); transform: translateX(0); }
  33% { clip-path: inset(20% 0 40% 0); transform: translateX(6px); }
  66% { clip-path: inset(55% 0 10% 0); transform: translateX(-5px); }
  100% { clip-path: inset(0 0 0 0); transform: translateX(0); }
}
.capri.is-spin img { animation: spin 0.6s cubic-bezier(0.3, 0.1, 0.2, 1) 1; }
@keyframes spin { 0% { transform: scaleX(1); } 25% { transform: scaleX(0.04); } 50% { transform: scaleX(-1); } 75% { transform: scaleX(0.04); } 100% { transform: scaleX(1); } }
.capri.is-talking .capri__body { animation-duration: 0.5s; }

.capri__ring {
  position: absolute; bottom: 42%; width: 190px; height: 56px; border: 2px solid var(--violet-2); border-radius: 50%;
  opacity: 0; transform: scale(0.6); pointer-events: none;
}
.app.is-thinking .capri__ring { opacity: 0.9; animation: ring 1.2s ease-out infinite; }
@keyframes ring { from { transform: scale(0.6) rotate(0deg); opacity: 0.9; } to { transform: scale(1.25) rotate(25deg); opacity: 0; } }

/* her line, in her transmission panel */
.say {
  position: relative; z-index: 2; width: calc(100% - 28px); margin: 8px 14px 0;
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px 13px 12px;
  background: rgba(23, 16, 33, 0.94); border: 1px solid rgba(123, 60, 240, 0.9);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.say::before { content: ''; position: absolute; left: 0; top: 0; bottom: var(--cut); width: 3px; background: linear-gradient(var(--red), var(--violet)); }
.say__face { flex: none; width: 54px; height: 54px; border: 1px solid var(--red); overflow: hidden; clip-path: polygon(0 0, 100% 0, 100% 76%, 76% 100%, 0 100%); }
.say__face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.say__face img.is-swap { animation: faceswap 0.24s steps(3) 1; }
@keyframes faceswap { 0% { filter: hue-rotate(90deg) contrast(2); transform: translateX(3px); } 50% { transform: translateX(-3px); } 100% { filter: none; transform: none; } }
.say__body { flex: 1; min-width: 0; }
.say__meta { display: flex; justify-content: space-between; font: 600 10.5px var(--mono); letter-spacing: 0.14em; color: var(--violet-2); margin-bottom: 4px; }
.say__state { color: var(--green); }
.say__state.is-busy { color: var(--red); animation: blink 0.9s steps(2) infinite; }
.say__line {
  margin: 0; font-size: 17px; font-weight: 600; line-height: 1.28; white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: calc(1.28em * 5); overflow-y: auto; scrollbar-width: none;
}
.say__line::-webkit-scrollbar { display: none; }
@keyframes blink { 50% { opacity: 0.35; } }

/* ------------------------------------------------ the conversation */
.log {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 14px 8px; display: flex; flex-direction: column; gap: 8px;
  mask-image: linear-gradient(180deg, transparent, #000 22px);
}
.msg { max-width: 86%; padding: 9px 12px; font-size: 15px; line-height: 1.38; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg--me { align-self: flex-end; background: var(--violet); color: #fff; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%); }
.msg--her { align-self: flex-start; background: var(--ink-2); border-left: 2px solid var(--red); color: var(--paper); }
.msg--pc { border-left-color: var(--blue); }
.msg__src { display: block; font: 600 9.5px var(--mono); letter-spacing: 0.12em; color: var(--paper-3); margin-bottom: 3px; }
.msg img { display: block; max-width: 160px; margin-bottom: 6px; }
.log__empty { margin: auto; color: var(--paper-3); font: 12px var(--mono); text-align: center; letter-spacing: 0.06em; }

/* ------------------------------------------------ input bar */
.bar {
  flex: none; padding: 8px 10px calc(var(--bottom) + 8px);
  background: linear-gradient(180deg, rgba(13, 9, 20, 0), rgba(13, 9, 20, 0.96) 30%);
}
.app.is-typing .bar { padding-bottom: 8px; }
.bar__row {
  display: flex; align-items: flex-end; gap: 4px; padding: 4px; background: var(--ink-2); border: 1px solid var(--ink-3);
  border-bottom: 2px solid var(--violet);
}
.bar textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: transparent; color: var(--paper);
  font: 500 16px/1.35 var(--font); padding: 9px 6px; max-height: 120px;
}
.bar textarea::placeholder { color: var(--paper-3); }
.icon--bar { width: 40px; height: 40px; }
.icon--bar.is-live { color: var(--red); animation: blink 0.9s steps(2) infinite; }
.send {
  flex: none; width: 44px; height: 40px; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--green); color: #07150c; clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%);
}
.send svg { width: 20px; height: 20px; fill: currentColor; }
.send:disabled { background: var(--ink-3); color: var(--paper-3); }
.bar__attach { display: flex; align-items: center; gap: 8px; margin: 0 0 6px 4px; }
.bar__attach img { height: 52px; border: 1px solid var(--violet); }
.bar__attach button { border: 0; background: var(--ink-3); color: var(--paper); width: 28px; height: 28px; cursor: pointer; }

/* ------------------------------------------------ she's on the PC */
.away {
  position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: calc(var(--top) + 40px) 30px calc(var(--bottom) + 40px);
  background: radial-gradient(80% 50% at 50% 40%, rgba(123, 60, 240, 0.25), transparent), rgba(10, 7, 15, 0.97);
  animation: fadein 0.3s ease-out;
}
.away__chip { position: relative; width: 132px; height: 132px; border: 1.5px solid var(--violet); clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px)); overflow: hidden; }
.away__chip img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(0.8) brightness(0.6) contrast(1.2); }
.away__scan { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.45) 0 2px, transparent 2px 4px); animation: scan 3s linear infinite; }
@keyframes scan { from { background-position: 0 0; } to { background-position: 0 40px; } }
.away__kicker { margin: 26px 0 6px; font: 600 11px var(--mono); letter-spacing: 0.2em; color: var(--violet-2); }
.away__title { margin: 0; font-size: 30px; line-height: 1.1; }
.away__sub { margin: 10px 0 30px; color: var(--paper-2); font-size: 15px; line-height: 1.4; max-width: 300px; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------------------------ her arrival (frames of her grabbing the screen) */
.arrive { position: absolute; inset: 0; z-index: 8; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; }
.arrive__frame { position: relative; width: 100%; height: 62%; overflow: hidden; }
.arrive__frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; transform: scale(1.04); }
.arrive.is-impact .arrive__frame img { filter: brightness(0) invert(1); }
.arrive.is-ink .arrive__frame img { filter: brightness(0); }
.arrive.is-split .arrive__frame img { filter: drop-shadow(-6px 0 var(--green)) drop-shadow(6px 0 var(--red)); }
.arrive.is-shake { animation: shake 0.24s steps(4) 2; }
@keyframes shake { 25% { transform: translate(5px, -3px); } 50% { transform: translate(-4px, 4px); } 75% { transform: translate(3px, 2px); } }
.arrive__tag {
  position: absolute; left: 58%; top: 26%; padding: 3px 12px; font: 700 26px var(--font); background: var(--red); color: #fff;
  transform: rotate(-6deg) scale(0); transition: transform 0.12s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.arrive__tag.is-on { transform: rotate(-6deg) scale(1); }
.arrive__cap { font: 600 12px var(--mono); letter-spacing: 0.3em; color: var(--paper-3); margin-top: 18px; }
.arrive.is-out { animation: out 0.4s steps(5) forwards; }
@keyframes out { 60% { transform: scaleY(0.04); opacity: 1; } 100% { transform: scaleY(0); opacity: 0; } }

/* ------------------------------------------------ menu sheet, toast */
.sheet { position: absolute; inset: 0; z-index: 7; background: rgba(5, 3, 8, 0.6); display: flex; align-items: flex-end; animation: fadein 0.2s; }
.sheet__panel { width: 100%; padding: 10px 14px calc(var(--bottom) + 14px); background: var(--ink-2); border-top: 1.5px solid var(--violet); display: flex; flex-direction: column; gap: 6px; }
.sheet__panel button { border: 0; background: var(--ink-3); padding: 16px; text-align: left; font-size: 16px; font-weight: 600; cursor: pointer; }
.sheet__panel button.is-dim { background: transparent; color: var(--paper-3); }
.toast {
  position: absolute; left: 50%; top: calc(var(--top) + 56px); transform: translateX(-50%); z-index: 9; max-width: 88%;
  padding: 9px 14px; background: var(--red); color: #fff; font: 600 13px var(--mono); animation: fadein 0.2s;
}

/* ------------------------------------------------ notifications sheet + nudge */
.sheet__panel--tall { gap: 4px; max-height: calc(var(--vh) * 88); overflow-y: auto; }
.nset__head { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 2px 8px; font: 600 11px var(--mono); letter-spacing: 0.14em; color: var(--paper-3); }
.nset__head b { color: var(--violet-2); font-size: 12px; }
.nset__head--small { margin-top: 10px; letter-spacing: 0.04em; }
.nset__head--small span { letter-spacing: 0; text-transform: none; }
.nset__row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--ink-3); font-size: 16px; font-weight: 600; }
.nset__row span { flex: 1; }
.nset__row--sub { padding-left: 28px; font-size: 14px; color: var(--paper-2); }
.nset__row input[type='time'] { background: var(--ink); color: var(--paper); border: 1px solid var(--violet); font: 600 15px var(--mono); padding: 5px 6px; border-radius: 0; }
.sw { appearance: none; -webkit-appearance: none; width: 46px; height: 26px; background: var(--ink); border: 1px solid var(--paper-3); position: relative; cursor: pointer; flex: none; margin: 0; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: var(--paper-3); transition: left 0.15s, background 0.15s; }
.sw:checked { border-color: var(--green); }
.sw:checked::after { left: 23px; background: var(--green); }
.nset__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nset__list li { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--ink); border-left: 2px solid var(--red); font-size: 14px; }
.nset__list li b { font: 600 11px var(--mono); color: var(--paper-3); flex: none; }
.nset__list li span { flex: 1; }
.nset__list li button { border: 0; background: transparent; color: var(--paper-3); font-size: 16px; padding: 2px 4px; cursor: pointer; }
.nset__list .nset__none { color: var(--paper-3); border-left-color: var(--ink-3); font: 12px var(--mono); }
.nset__btns { display: flex; gap: 6px; margin-top: 10px; }
.nset__btns button { flex: 1; }
.nudge {
  position: absolute; left: 12px; right: 12px; top: calc(var(--top) + 52px); z-index: 4; display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 10px 14px; background: var(--ink-2); border: 1px solid var(--violet); font-size: 14px; line-height: 1.3; animation: fadein 0.3s;
}
.nudge span { flex: 1; color: var(--paper-2); }
.nudge #nudgeOn { border: 0; background: var(--green); color: #07150c; font-weight: 700; padding: 8px 12px; cursor: pointer; }
.nudge #nudgeNo { border: 0; background: transparent; color: var(--paper-3); font-size: 16px; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  .capri img, .sat, .away__scan, .capri__ring { animation: none !important; }
}
.sheet__panel .btn--primary { background: var(--green); color: #07150c; text-align: center; letter-spacing: 0.12em; }
.sheet__panel button:disabled { opacity: 0.45; }
