/* ── Reset & base ────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0906;
  --bg2:       #111009;
  --surface:   #161410;
  --surface2:  #1e1b14;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.13);
  --text:      #e8e0d0;
  --text2:     #9a9080;
  --text3:     #5a5248;
  --gold:      #c9a96e;
  --gold2:     #8a6e3e;
  --crack:     rgba(201,169,110,0.15);
  --font-disp: 'Cormorant Garamond', Georgia, serif;
  --font-mono: 'DM Mono', 'Courier New', monospace;
  --radius:    6px;
  --radius-lg: 12px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-disp);
  font-weight: 300;
  font-size: 18px;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Grain overlay ───────────────────────────── */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  opacity: 0.6;
}

/* ── Crack lines SVG bg ──────────────────────── */
.crack-lines {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
}
.crack-lines svg { width: 100%; height: 100%; }

/* ── App container ───────────────────────────── */
#app {
  position: relative; z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 6rem;
}

/* ── Header ──────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 0.5px solid var(--border);
}

.mirror-mark {
  flex-shrink: 0;
  width: 44px; height: 50px;
  color: var(--gold);
  transition: color .4s;
}
.mirror-mark svg { width: 100%; height: 100%; }

.header-text { flex: 1; }

.header-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 3px;
}

.site-title {
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text);
  font-style: italic;
}

/* ── Voice toggle in header ──────────────────── */
.voice-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.vtog {
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: 99px;
  padding: 3px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
  cursor: pointer;
  transition: all .2s;
  letter-spacing: 0.05em;
}
.vtog.on {
  border-color: var(--gold2);
  color: var(--gold);
}
.vtog-sep { color: var(--text3); font-size: 12px; }

.mic-pill {
  display: none;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: 99px;
  padding: 3px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
  cursor: pointer;
  transition: all .2s;
  letter-spacing: 0.05em;
}
.mic-pill.live { border-color: #c04a1a; color: #e05a2a; }
.mic-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 1.5s ease-in-out infinite;
}
.mic-pill:not(.live) .mic-dot { animation: none; }
@keyframes pulse-dot { 0%,100%{opacity:.4;transform:scale(.8)} 50%{opacity:1;transform:scale(1.1)} }

/* ── Progress bar ────────────────────────────── */
.progress-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2.5rem;
}
.progress-track {
  flex: 1;
  height: 1px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--gold2);
  border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
  width: 0%;
}
.progress-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.1em;
  white-space: nowrap;
}

/* ── Stage / conversation area ───────────────── */
.stage { min-height: 300px; }

/* ── Message blocks ──────────────────────────── */
.msg {
  display: flex;
  gap: 14px;
  margin-bottom: 1.25rem;
  animation: msgIn .4s cubic-bezier(.2,.8,.4,1) both;
}
@keyframes msgIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

.msg-avatar { flex-shrink: 0; width: 30px; height: 30px; margin-top: 3px; }

.msg-body { flex: 1; min-width: 0; }

.msg-who {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 5px;
}

.msg-text {
  font-size: 1.1rem;
  line-height: 1.75;
  color: var(--text);
  font-weight: 300;
}
.msg-text.ente-comment {
  font-style: italic;
  color: var(--text2);
  font-size: 1rem;
  line-height: 1.8;
}
.msg-text.user-ans {
  font-size: .95rem;
  color: var(--text2);
  font-style: italic;
}

/* ── Typing dots ─────────────────────────────── */
.dp { display: inline-flex; gap: 4px; align-items: center; vertical-align: middle; }
.dp span {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--text3);
  animation: dp 1.4s ease-in-out infinite;
}
.dp span:nth-child(2){animation-delay:.2s}
.dp span:nth-child(3){animation-delay:.4s}
@keyframes dp { 0%,80%,100%{transform:scale(.5);opacity:.3} 40%{transform:scale(1);opacity:.8} }

/* ── Blinking cursor ─────────────────────────── */
.cursor {
  display: inline-block;
  width: 1px; height: 1em;
  background: var(--gold2);
  vertical-align: text-bottom;
  animation: blink .9s step-end infinite;
  margin-left: 1px;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── Divider ─────────────────────────────────── */
.divider {
  height: 0.5px;
  background: var(--border);
  margin: 2rem 0;
  position: relative;
}
.divider::after {
  content: '◆';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  font-size: 8px;
  color: var(--text3);
  background: var(--bg);
  padding: 0 8px;
  letter-spacing: 0;
}

/* ── Options list ────────────────────────────── */
.opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 1.25rem;
  margin-left: 44px;
}

.opt {
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1.1rem;
  font-family: var(--font-disp);
  font-size: .95rem;
  font-weight: 300;
  color: var(--text2);
  cursor: pointer;
  text-align: left;
  line-height: 1.5;
  transition: all .2s;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.opt::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  background: var(--crack);
  transition: width .25s;
}
.opt:hover { border-color: var(--border2); color: var(--text); }
.opt:hover::before { width: 3px; }
.opt:disabled { opacity: .25; cursor: default; }
.opt:disabled::before { display: none; }
.opt.sel { border-color: var(--gold2); color: var(--text); }
.opt.sel::before { width: 3px; background: var(--gold2); }
.opt.reading { border-color: var(--border2); color: var(--text); }
.opt.reading::before { width: 3px; background: rgba(255,255,255,0.15); }

.opt-k {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text3);
  min-width: 14px;
  margin-top: 2px;
  flex-shrink: 0;
  letter-spacing: 0.05em;
}
.opt.sel .opt-k,
.opt:hover .opt-k { color: var(--gold2); }

/* ── Hint line ───────────────────────────────── */
.hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  margin-top: 1rem;
  min-height: 18px;
  letter-spacing: 0.05em;
  transition: all .3s;
}

/* ── Start screen ────────────────────────────── */
.start-screen {
  animation: msgIn .5s ease both;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 1.5rem;
  margin-left: 44px;
  margin-bottom: 1.25rem;
}

.mode-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  cursor: pointer;
  transition: all .2s;
  text-align: left;
}
.mode-card:hover { border-color: var(--border2); }
.mode-card.picked { border-color: var(--gold2); background: var(--surface2); }

.mode-icon { margin-bottom: 10px; color: var(--text3); }
.mode-card.picked .mode-icon { color: var(--gold); }

.mode-name {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 4px;
  font-style: italic;
}
.mode-desc {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text3);
  line-height: 1.6;
  letter-spacing: 0.02em;
}

.start-btn {
  margin-left: 44px;
  background: transparent;
  border: 0.5px solid var(--border2);
  border-radius: var(--radius);
  padding: .85rem 2rem;
  font-family: var(--font-disp);
  font-size: 1rem;
  font-style: italic;
  font-weight: 300;
  color: var(--text2);
  cursor: pointer;
  transition: all .25s;
  letter-spacing: 0.04em;
}
.start-btn:hover {
  border-color: var(--gold2);
  color: var(--gold);
}

/* ── Result card ─────────────────────────────── */
.result-wrap {
  margin-left: 44px;
  margin-top: 1rem;
  animation: msgIn .5s ease both;
}

.frag-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}
.frag-title {
  font-size: 2rem;
  font-weight: 400;
  font-style: italic;
  color: var(--text);
  line-height: 1.15;
  margin-bottom: 4px;
  letter-spacing: 0.01em;
}
.frag-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold2);
  letter-spacing: 0.08em;
  margin-bottom: 1.5rem;
}
.frag-desc {
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text2);
  margin-bottom: 1.75rem;
  font-style: italic;
}
.frag-rule {
  height: 0.5px;
  background: var(--border);
  margin-bottom: 1.25rem;
}

.traits {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 2rem;
}
.tr {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.tr-l {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 4px;
}
.tr-v {
  font-size: .9rem;
  font-style: italic;
  color: var(--text);
  font-weight: 300;
}

.restart-btn {
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.5rem;
  font-family: var(--font-disp);
  font-size: .95rem;
  font-style: italic;
  font-weight: 300;
  color: var(--text3);
  cursor: pointer;
  transition: all .25s;
  letter-spacing: 0.03em;
}
.restart-btn:hover { border-color: var(--border2); color: var(--text2); }

/* ── Avatars ─────────────────────────────────── */
.av-ente { color: var(--gold); }
.av-user { color: var(--text3); }

/* ── Fragment glow animation ─────────────────── */
@keyframes fragGlow {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Mobile ──────────────────────────────────── */
@media (max-width: 520px) {
  #app { padding: 1.5rem 1rem 5rem; }
  .site-title { font-size: 1.1rem; }
  .mode-grid { grid-template-columns: 1fr; }
  .opts { margin-left: 0; }
  .mode-grid,
  .start-btn,
  .result-wrap { margin-left: 0; }
  .frag-title { font-size: 1.5rem; }
  .traits { grid-template-columns: 1fr; }
}
