:root {
  --bg:          #0b1020;
  --bg-soft:     #121a33;
  --surface:     #161f3d;
  --surface-2:   #1e2949;
  --line:        #2a3760;
  --text:        #e8ecf8;
  --text-dim:    #97a3c4;
  --accent:      #5b8cff;
  --accent-2:    #34d3a6;
  --danger:      #ff6b6b;
  --warn:        #ffc94d;
  --radius:      14px;
  --shadow:      0 8px 30px rgba(0,0,0,.35);
  --font:        system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  background-image:
    radial-gradient(900px 500px at 15% -5%, rgba(91,140,255,.16), transparent 60%),
    radial-gradient(700px 500px at 95% 5%, rgba(52,211,166,.10), transparent 55%);
  background-attachment: fixed;
}

/* ------------------------------------------------------------- estrutura */

.screen { display: none; }
.screen.active { display: block; }

#screen-login, #screen-setup, #screen-report {
  max-width: 680px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}

#screen-login { display: none; }
#screen-login.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card--narrow { width: 100%; max-width: 380px; }

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; letter-spacing: -.01em; }
.card__head h2 { margin: 0; }

.brand { text-align: center; margin-bottom: 22px; }
.brand__icon { font-size: 2.6rem; display: block; margin-bottom: 6px; }
.brand__sub { color: var(--text-dim); font-size: .9rem; margin: 4px 0 0; }

/* ------------------------------------------------------------- controles */

.field { display: block; margin-bottom: 18px; }
.field > span {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

input[type=text], input[type=password], select, textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,140,255,.18);
}
textarea { resize: vertical; line-height: 1.5; font-size: .92rem; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 38px; }

.checkbox { display: flex; align-items: center; gap: 10px; margin: 14px 0 18px; font-size: .9rem; color: var(--text-dim); }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }

.hint { font-size: .8rem; color: var(--text-dim); line-height: 1.5; margin: 8px 0 0; }
.hint--center { text-align: center; }
.hint b { color: #c3cee9; }
.meta { font-size: .78rem; color: var(--text-dim); margin: 12px 0 0; text-align: center; }
.error { color: var(--danger); font-size: .85rem; margin: 12px 0 0; line-height: 1.5; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 18px;
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  transition: filter .15s, transform .05s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: linear-gradient(180deg, #6c98ff, #4a7bf0); }
.btn--danger  { background: #7a2b34; border-color: #a13b46; }
.btn--ghost   { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn--block   { width: 100%; }
.btn--lg      { padding: 16px; font-size: 1.05rem; }
.btn--sm      { padding: 8px 12px; font-size: .82rem; }
.btn--icon    { padding: 12px 14px; line-height: 1; }

.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.row--end { justify-content: flex-end; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  flex: 1 1 auto;
  min-width: 88px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 8px;
  color: var(--text-dim);
  cursor: pointer;
  text-align: center;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.chip b { display: block; font-size: 1rem; color: var(--text); }
.chip small { display: block; font-size: .68rem; margin-top: 2px; }
.chip.is-active { border-color: var(--accent); background: rgba(91,140,255,.14); color: var(--text); }
.chip.is-active b { color: #9dbaff; }

.details {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  margin-bottom: 16px;
  background: var(--bg-soft);
}
.details > summary {
  cursor: pointer;
  padding: 14px 0;
  font-weight: 600;
  font-size: .9rem;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.details > summary::-webkit-details-marker { display: none; }
.details > summary::after { content: "▾"; color: var(--text-dim); transition: transform .2s; }
.details[open] > summary::after { transform: rotate(180deg); }
.details[open] { padding-bottom: 14px; }
.details .field:last-child { margin-bottom: 0; }

.badge {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  margin-left: auto;
  margin-right: 8px;
}
.badge.is-ok { background: rgba(52,211,166,.16); color: var(--accent-2); }

/* -------------------------------------------------------------- sessão */

#screen-session.active {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 680px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(11,16,32,.75);
  backdrop-filter: blur(12px);
}
.topbar__stat { display: flex; flex-direction: column; line-height: 1.15; }
.topbar__stat b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.topbar__stat small { font-size: .68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.topbar .btn { margin-left: auto; }

.stage { padding: 20px 16px 12px; text-align: center; flex-shrink: 0; }

.orb { position: relative; width: 108px; height: 108px; margin: 0 auto; }
.orb__core {
  position: absolute; inset: 26px;
  border-radius: 50%;
  background: linear-gradient(160deg, #6c98ff, #3f6ae0);
  box-shadow: 0 0 30px rgba(91,140,255,.5);
  transition: background .3s, box-shadow .3s;
}
.orb__ring {
  position: absolute; inset: 8px;
  border-radius: 50%;
  border: 2px solid rgba(91,140,255,.35);
  opacity: 0;
}
.orb__ring--2 { inset: 0; }

.orb[data-state="listening"] .orb__core { background: linear-gradient(160deg, #3ee0ad, #22a882); box-shadow: 0 0 34px rgba(52,211,166,.55); }
.orb[data-state="listening"] .orb__ring { border-color: rgba(52,211,166,.45); animation: pulse 1.6s ease-out infinite; opacity: 1; }
.orb[data-state="listening"] .orb__ring--2 { animation-delay: .5s; }
.orb[data-state="speaking"] .orb__ring { animation: pulse 1.1s ease-out infinite; opacity: 1; }
.orb[data-state="speaking"] .orb__ring--2 { animation-delay: .35s; }
.orb[data-state="idle"] .orb__core,
.orb[data-state="muted"] .orb__core { background: linear-gradient(160deg, #4a5678, #333d5c); box-shadow: none; }

@keyframes pulse {
  0%   { transform: scale(.9);  opacity: .8; }
  100% { transform: scale(1.5); opacity: 0; }
}

.orb__label { font-size: .9rem; color: var(--text-dim); margin: 12px 0 0; min-height: 1.2em; }

.ratio { margin-top: 18px; }
.ratio__bar {
  height: 8px;
  border-radius: 999px;
  background: #8a6bff;
  overflow: hidden;
}
.ratio__you { height: 100%; background: var(--accent-2); transition: width .5s ease; }
.ratio__legend {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--text-dim);
  margin-top: 8px;
}
.ratio__legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; }
.dot--you { background: var(--accent-2); }
.dot--teacher { background: #8a6bff; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.tab {
  flex: 1;
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 600;
  padding: 10px 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.count {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: .7rem;
  vertical-align: 1px;
}
.tab.is-active .count { background: var(--accent); color: #fff; }

.panels { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px; }
.panel { display: none; }
.panel.is-active { display: block; }
.empty { color: var(--text-dim); font-size: .85rem; text-align: center; padding: 28px 12px; line-height: 1.6; }

.bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  margin-bottom: 10px;
  font-size: .95rem;
  line-height: 1.5;
  word-wrap: break-word;
}
.bubble--teacher { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble--you { background: rgba(52,211,166,.14); border: 1px solid rgba(52,211,166,.3); margin-left: auto; border-bottom-right-radius: 4px; }
.bubble--pending { opacity: .55; font-style: italic; }
.bubble__who { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin-bottom: 3px; }

.item {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: .9rem;
  line-height: 1.5;
  animation: slide-in .3s ease;
}
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.item__tag {
  display: inline-block;
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255,201,77,.16);
  color: var(--warn);
  margin-bottom: 8px;
}
.item__wrong { color: var(--danger); text-decoration: line-through; text-decoration-color: rgba(255,107,107,.5); }
.item__right { color: var(--accent-2); font-weight: 600; }
.item__tip { color: var(--text-dim); font-size: .82rem; margin-top: 6px; }
.item__term { font-weight: 700; color: #9dbaff; font-size: 1rem; }
.item__ex { color: var(--text-dim); font-style: italic; font-size: .84rem; margin-top: 6px; }

.composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(11,16,32,.85);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}
.composer input { flex: 1; padding: 11px 14px; font-size: 16px; }
.btn--muted { background: #7a2b34 !important; }

/* ------------------------------------------------------------ relatório */

.report { font-size: .95rem; line-height: 1.65; }
.report h3 { font-size: .95rem; color: #9dbaff; margin: 20px 0 8px; letter-spacing: -.01em; }
.report h3:first-child { margin-top: 0; }
.report p { margin: 0 0 10px; }
.report ol, .report ul { margin: 0 0 12px; padding-left: 22px; }
.report li { margin-bottom: 6px; }
.report strong { color: #fff; }
.report code { background: var(--bg-soft); padding: 1px 6px; border-radius: 5px; font-size: .88em; }

.history__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: .88rem;
}
.history__item:last-child { border-bottom: none; }
.history__date { color: var(--text-dim); font-size: .8rem; min-width: 82px; }
.history__level { font-weight: 700; color: #9dbaff; }
.history__stats { margin-left: auto; color: var(--text-dim); font-size: .78rem; text-align: right; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: .87rem;
  box-shadow: var(--shadow);
  z-index: 99;
  animation: slide-in .25s ease;
}

@media (min-width: 720px) {
  .stage { padding-top: 28px; }
  .orb { width: 128px; height: 128px; }
}
