:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #0b1220;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --green: #16a34a;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --red: #dc2626;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ---------- Layout de dos paneles ---------- */
.app {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  height: 100vh;
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
}

.panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel h2 { margin: 0 0 12px; font-size: 1rem; color: var(--muted); font-weight: 600; }

/* ---------- Panel izquierdo (material / objetivo) ---------- */
.media-box {
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
}
.media-box .big { font-size: 2.5rem; margin-bottom: 12px; }
.objetivo-tag {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--text);
  font-weight: 600;
}

/* ---------- Panel derecho (chat) ---------- */
.chat-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: .85rem;
  background: var(--border); color: white; transition: background .2s;
}
.status-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: white; opacity: .9; }

.mic-meter { flex: 1; height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
#mic-bar { height: 100%; width: 0%; background: var(--green); transition: width .05s; }

#timeline {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  padding: 8px 4px;
}

.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; line-height: 1.45; }
.msg p { margin: 4px 0 0; }
.msg-rol { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; opacity: .7; }
.msg-user { align-self: flex-end; background: var(--blue); color: white; border-bottom-right-radius: 4px; }
.msg-ai { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-error { align-self: center; background: #3f1d1d; color: #fca5a5; border: 1px solid var(--red); font-size: .85rem; }

/* ---------- Controles ---------- */
.controls { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
button {
  font-size: .95rem; padding: 12px 18px; border: 0; border-radius: 10px;
  cursor: pointer; font-weight: 600; color: white; transition: transform .05s, opacity .2s;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .5; cursor: not-allowed; }
#btn-start { background: var(--green); flex: 1; }
#btn-mic { background: var(--border); }
#btn-finish { background: var(--red); }
#report-lang {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 12px; font-size: .9rem; font-weight: 600; cursor: pointer;
}

/* ---------- Debriefing ---------- */
.report-wrap { height: 100vh; height: 100dvh; overflow-y: auto; padding: 32px; }
.report { max-width: 820px; margin: 0 auto; }
.report h1 { font-size: 1.5rem; }
.center-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; height: 100dvh; gap: 16px; text-align: center; padding: 16px; }
.spinner {
  width: 44px; height: 44px; border: 4px solid var(--border); border-top-color: var(--blue);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--panel); border-radius: 14px; padding: 20px; margin: 16px 0; }
.card h3 { margin: 0 0 12px; }
.score { font-size: 3rem; font-weight: 800; color: var(--green); }
.strength { border-left: 3px solid var(--green); padding-left: 12px; margin: 12px 0; }
.strength .ej { color: var(--muted); font-style: italic; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: .9rem; }
th { color: var(--muted); font-weight: 600; }
.orig { color: #fca5a5; }
.corr { color: #86efac; }
.cat { font-size: .72rem; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }

.plan-item { margin: 12px 0; padding: 12px; background: var(--panel-2); border-radius: 10px; }
.plan-item .regla { font-weight: 700; }
.plan-item .rec { color: var(--muted); font-size: .85rem; margin-top: 4px; }

.btn-link { display: inline-block; margin-top: 8px; background: var(--blue); padding: 12px 20px; border-radius: 10px; color: white; text-decoration: none; font-weight: 600; }

/* ---------- Marca / logo (CLAUDLINGO) ---------- */
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; padding: 0; line-height: 0;
  text-decoration: none; color: var(--text); font-weight: 800; letter-spacing: .02em;
}
.brand img { height: 40px; width: auto; display: block; }
.brand .brand-fallback { font-size: 1.05rem; color: var(--text); }  /* respaldo si falta logo.png */
.brand img + .brand-fallback { display: none; }   /* si carga la imagen, ocultar texto */
.brand--lg img { height: 88px; }
.brand--lg .brand-fallback { font-size: 1.8rem; }
.brand-row { display: flex; justify-content: flex-start; margin-bottom: 16px; }
.brand-center { display: flex; justify-content: center; margin-bottom: 22px; }

/* ---------- Sesión a pantalla completa (P4) ---------- */
.session-screen { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 14px 18px; gap: 10px; }
.session-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.session-objetivo { color: var(--muted); font-size: .9rem; }
#ver-material { background: var(--blue); white-space: nowrap; }
.session-screen #timeline { flex: 1; min-height: 0; }

/* ---------- Auth / formularios (P1, P2, P3) ---------- */
body:has(.form-wrap), body:has(.auth-card) { overflow: auto; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.auth-card {
  background: var(--panel); border-radius: 16px; padding: 28px; width: min(420px, 92vw);
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab { flex: 1; background: var(--panel-2); color: var(--muted); }
.tab.active { background: var(--blue); color: #fff; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; text-align: left; }
.field span { font-size: .85rem; color: var(--muted); font-weight: 600; }
.field input, .field select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 12px; font-size: .95rem; width: 100%;
}
.auth-card form button[type=submit], .primary-btn { background: var(--green); width: 100%; margin-top: 6px; }
.auth-msg { margin-top: 14px; font-size: .88rem; min-height: 1.2em; }

.form-wrap { height: 100vh; height: 100dvh; overflow-y: auto; padding: 32px 20px; }
.form-card { max-width: 640px; margin: 0 auto; background: var(--panel); border-radius: 16px; padding: 28px; }
.form-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.form-head h1 { margin: 0; font-size: 1.4rem; }
.form-card h3 { margin: 22px 0 10px; font-size: 1rem; }
.link-btn { background: transparent; color: var(--muted); padding: 6px 8px; text-decoration: none; font-size: .85rem; }
.link-btn:hover { color: var(--text); }

/* idiomas con nivel */
.lang-grid { display: flex; flex-direction: column; gap: 8px; }
.lang-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
}
.lang-row.on { border-color: var(--green); }
.lang-row label { display: flex; align-items: center; gap: 10px; text-transform: capitalize; cursor: pointer; }
.lang-row select { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }

/* chips de intereses */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; font-size: .88rem; text-transform: capitalize;
}
.chip.on { border-color: var(--blue); background: rgba(59,130,246,.15); }
.chip input { accent-color: var(--blue); }

/* lista de contenidos (P3) */
.content-list { display: flex; flex-direction: column; gap: 10px; }
.content-item {
  text-align: left; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 4px; color: var(--text);
}
.content-item.on { border-color: var(--green); }
.content-item strong { font-size: 1rem; }
.badge { font-size: .72rem; color: var(--muted); }

.detalle { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 18px; }
.media-frame { width: 100%; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; background: #000; margin: 10px 0; }
.media-frame iframe { width: 100%; height: 100%; border: 0; }

/* fila de texto (fallback) en la sesión */
.text-row { display: flex; gap: 8px; margin-top: 10px; }
.text-row input { flex: 1; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.text-row button { background: var(--border); }
