:root {
  --bg: #0f1020; --bg2: #16172e; --card: #1c1d38; --card2: #23254a;
  --txt: #eef0ff; --muted: #9aa0c7; --line: #2c2e54;
  --me: #5b6cff; --them: #2a2c52;
  --accent: #ff5d8f; --accent2: #5b6cff; --ok: #34d39a; --warn: #ffce5b; --bad: #ff5b6e;
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box }
html, body { margin: 0; padding: 0 }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #27264f 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--txt); min-height: 100vh; line-height: 1.45;
}
a { color: var(--accent2) }
.wrap { max-width: 880px; margin: 0 auto; padding: 18px 16px 60px }

/* ── Header ─────────────────────────────── */
header.app { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 18px }
.brand { display: flex; align-items: center; gap: 12px }
.logo { width: 42px; height: 42px; border-radius: 8px; background: var(--accent2); display: grid; place-items: center; font-size: 22px }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: .3px }
.brand p { margin: 0; font-size: 12.5px; color: var(--muted) }
.gear { background: var(--card); border: 1px solid var(--line); color: var(--muted); border-radius: 10px; padding: 8px 10px; cursor: pointer; font-size: 13px }
.gear:hover { color: var(--txt) }

/* ── Card ───────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 28px 24px; box-shadow: var(--shadow) }
.card + .card { margin-top: 20px }

/* ── Form ───────────────────────────────── */
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 600 }
input[type=text], textarea, select {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 8px; padding: 12px 13px; font-size: 16px; font-family: inherit; outline: none
}
input:focus, textarea:focus, select:focus { border-color: var(--accent2) }
textarea { resize: vertical; min-height: 70px }
.chips { display: flex; flex-wrap: wrap; gap: 8px }
.chip {
  background: var(--bg2); border: 1px solid var(--line); color: var(--muted); border-radius: 999px;
  padding: 8px 13px; font-size: 13.5px; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent
}
.chip.on { background: var(--accent2); border-color: transparent; color: #fff }
.chip[data-v="facil"].on { background: var(--ok); color: #0f1020 }
.chip[data-v="pesadelo"].on { background: var(--bad) }
.row { display: flex; gap: 12px; flex-wrap: wrap }
.row > * { flex: 1; min-width: 220px }

/* ── Buttons ────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; cursor: pointer;
  border-radius: 8px; padding: 13px 18px; font-size: 15px; font-weight: 700; font-family: inherit;
  -webkit-tap-highlight-color: transparent; transition: background .15s, color .15s, border-color .15s
}
.btn.primary { background: var(--accent); color: #fff; border: 1.5px solid transparent }
.btn.primary:hover { background: var(--accent2) }
.btn.ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line) }
.btn.ghost:hover { color: var(--txt); border-color: var(--muted) }
.btn.block { width: 100% }
.btn:disabled { opacity: .5; cursor: not-allowed }
.btns { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px }

.hint { font-size: 12.5px; color: var(--muted); margin-top: 10px }

/* ── Simulator ──────────────────────────── */
.scenebar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px }
.scene-back { margin-left: auto; font-size: 13px; padding: 6px 12px; color: var(--txt) !important; border-color: var(--muted) !important; flex-shrink: 0 }
.who { font-weight: 700 }
.tag { font-size: 12px; color: var(--muted); background: var(--bg2); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px }
.mood { display: flex; align-items: center; gap: 10px; margin: 8px 0 20px }
.mood .emoji { font-size: 26px }
.meter { flex: 1; height: 12px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); overflow: hidden }
.meter > i { display: block; height: 100%; width: 50%; border-radius: 999px; background: linear-gradient(90deg, var(--bad), var(--warn) 50%, var(--ok)); transition: width .6s ease }
.moodlabel { font-size: 12.5px; color: var(--muted); min-width: 96px; text-align: right }

.chat { display: flex; flex-direction: column; gap: 12px; max-height: 48vh; max-height: 48dvh; overflow-y: auto; padding: 6px 2px; -webkit-overflow-scrolling: touch }
.msg { max-width: 80%; padding: 11px 14px; border-radius: 16px; font-size: 15px; white-space: pre-wrap; word-wrap: break-word }
.msg.them { background: var(--them); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 5px }
.msg.me { background: var(--me); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px }
.think { align-self: flex-start; max-width: 80%; font-size: 13px; color: var(--muted); font-style: italic; background: rgba(255,255,255,.03); border: 1px dashed var(--line); border-radius: 12px; padding: 8px 12px; margin-top: -4px }
.think b { color: var(--accent); font-style: normal }
.typing { align-self: flex-start; color: var(--muted); font-size: 14px; padding: 6px 4px }
.msg.streaming::after { content: "▊"; animation: blink .7s step-end infinite }
@keyframes blink { 50% { opacity: 0 } }

.composer { display: flex; gap: 10px; margin-top: 20px }
.composer textarea { min-height: 48px; max-height: 120px }
.tools { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; align-items: center }
.tools .btn { padding: 10px 14px; font-size: 13.5px }
#resetBtn { background: transparent; border-color: transparent; color: var(--muted); font-size: 13px; font-weight: 600; padding: 10px 8px }
#resetBtn:hover { color: var(--txt); border-color: transparent; background: transparent }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none }
.toggle input { width: auto }

/* ── Coach ──────────────────────────────── */
.coach { margin-top: 20px; border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: var(--bg2) }
.coach h3 { margin: 0 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--accent) }
.coach p { margin: 6px 0; font-size: 14px; line-height: 1.55 }
.coach .sug { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-top: 10px }
.coach .sug b { color: var(--ok) }

/* ── Modal ──────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(5,6,16,.75); display: none; place-items: center; padding: 18px; z-index: 50 }
.modal.on { display: grid }
.modal .card { max-width: 460px; width: 100%; position: relative }
.modal h2 { margin: 0 0 6px; font-size: 18px }
.x { position: absolute; top: 14px; right: 16px; color: var(--muted); cursor: pointer; font-size: 20px }

/* ── Badge ──────────────────────────────── */
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  color: #ffd9a0; background: rgba(255,160,80,.12); border: 1px solid rgba(255,160,80,.3);
  padding: 3px 9px; border-radius: 999px
}
.hide { display: none !important }

/* ── Footer ─────────────────────────────── */
footer { margin-top: 26px; text-align: center; color: var(--muted); font-size: 12px }
footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px }

/* ── Scene gallery ──────────────────────── */
.scenes-hint { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; margin: 14px 0 8px }
.scenes-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; -webkit-overflow-scrolling: touch }
.scenes-row::-webkit-scrollbar { height: 4px }
.scenes-row::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px }
.scene-card { flex: 0 0 142px; background: var(--bg2); border: 1.5px solid var(--line); border-radius: 8px; padding: 11px 13px; cursor: pointer; transition: border-color .15s, background .15s; user-select: none; -webkit-tap-highlight-color: transparent }
.scene-card:hover { border-color: var(--accent2) }
.scene-card.on { border-color: var(--accent2); background: rgba(91,108,255,.09) }
.scene-emoji { font-size: 20px; margin-bottom: 6px }
.scene-title { font-size: 13px; font-weight: 700; margin-bottom: 3px }
.scene-sub { font-size: 11px; color: var(--muted); line-height: 1.35 }
.scenes-or { display: flex; align-items: center; gap: 14px; margin: 22px 0 6px }
.scenes-or::before, .scenes-or::after { content: ''; flex: 1; height: 1px; background: var(--line) }
.scenes-or span { font-size: 11px; color: var(--muted); white-space: nowrap; font-weight: 700; letter-spacing: .5px; text-transform: uppercase }

/* ── Mood chart ─────────────────────────── */
.mood-chart { margin-top: 14px; padding: 10px 12px 6px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px }
.mood-chart-label { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .4px; text-transform: uppercase; margin: 0 0 6px }

/* ── Report modal ───────────────────────── */
.report-loading { text-align: center; padding: 48px 0; color: var(--muted); font-size: 15px; animation: pulse 1.4s ease-in-out infinite }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .45 } }
.report-card { max-width: 560px; width: 100%; max-height: 90vh; max-height: 90dvh; overflow-y: auto }
.report-score { display: flex; align-items: center; gap: 18px; margin-bottom: 20px }
.score-circle { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 800; flex-shrink: 0; border: 3px solid }
.score-title { font-size: 16px; font-weight: 700; line-height: 1.35 }
.report-section { margin-top: 16px }
.report-section h4 { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); margin: 0 0 8px }
.report-item { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 7px; font-size: 14px; line-height: 1.4 }
.report-item span { flex-shrink: 0; margin-top: 1px }
.report-best { background: rgba(91,108,255,.1); border: 1px solid rgba(91,108,255,.22); border-radius: 6px; padding: 10px 13px; font-size: 14px; font-style: italic; margin-top: 6px }
.report-next { background: rgba(52,211,154,.07); border: 1px solid rgba(52,211,154,.2); border-radius: 6px; padding: 10px 13px; font-size: 14px; margin-top: 6px }
.report-arc { font-size: 13.5px; color: var(--muted); margin: 6px 0 0; line-height: 1.5 }

/* ── Mobile ─────────────────────────────── */
@media (max-width: 580px) {
  .wrap { padding: 12px 12px 40px }
  .card { padding: 16px 14px }
  .brand p { display: none }
  .gear { padding: 10px 14px }
  .row > * { min-width: 0 }
  textarea { resize: none }
  .btns { flex-direction: column }
  .btns .btn { width: 100% }
  .msg { max-width: 90% }
  .composer textarea { min-height: 52px }
  .tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px }
  #resetBtn { grid-column: span 2 }
  .modal { padding: 12px }
  footer { font-size: 11px }
}
