:root {
  --purple: #524594; --purple-dark: #3d3470; --lilac: #f0edfa; --lilac-2: #e7e3f3;
  --cream: #faf2e0; --yellow: #ece552; --ink: #2b2750; --muted: #6b678a; --line: #e2def0;
  --danger: #b3261e; --ok: #2e7d4f; --warn: #b26a00; --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--ink); background: #faf9fe; min-height: 100vh; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--purple); }
.hidden { display: none !important; }
.print-only { display: none; }

/* Layout */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--purple); text-decoration: none; font-size: 18px; }
.brand img { width: 34px; height: 34px; }
.nav { display: flex; gap: 4px; margin-left: 12px; flex: 1; }
.nav a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a.active { background: var(--lilac); color: var(--purple); }
.user { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 12px; }
main { max-width: 980px; margin: 0 auto; padding: 24px 20px 80px; }
h1 { font-size: 26px; margin-bottom: 4px; color: var(--ink); }
h2 { font-size: 18px; margin: 0 0 8px; }
.sub { color: var(--muted); margin-bottom: 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 12px; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }

/* Controls */
.btn { border: 0; border-radius: 999px; padding: 10px 20px; font-weight: 600; cursor: pointer; background: var(--purple); color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: var(--purple-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--lilac); color: var(--purple); }
.btn.secondary:hover { background: var(--lilac-2); }
.btn.ghost { background: transparent; color: var(--purple); padding: 8px 12px; }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #f0c4c0; }
.btn.big { padding: 14px 28px; font-size: 17px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type=text], input[type=date], input[type=password], input[type=search], select, textarea { width: 100%; padding: 11px 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--purple); }
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--purple); }
.field-error, .error { color: var(--danger); font-size: 14px; min-height: 20px; }
.notice { background: var(--cream); border-radius: 10px; padding: 12px 14px; font-size: 14px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--purple) 0%, var(--purple-dark) 100%); padding: 20px; }
.login-card { background: #fff; border-radius: 18px; padding: 36px 32px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card img { width: 72px; display: block; margin: 0 auto 8px; }
.login-card h1 { text-align: center; font-size: 24px; }
.login-card .sub { text-align: center; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; gap: 14px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit; }
.item:hover { border-color: var(--purple); }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .meta { font-size: 13px; color: var(--muted); }
.badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--lilac); color: var(--purple); white-space: nowrap; }
.badge.ready { background: #e3f4ea; color: var(--ok); }
.badge.failed { background: #fbe4e2; color: var(--danger); }
.badge.work { background: #fff2d9; color: var(--warn); }

/* Recorder */
.rec { text-align: center; padding: 40px 20px; }
.timer { font-size: 56px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.rec-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--danger); margin-right: 8px; animation: pulse 1.2s infinite; }
.rec-dot.paused { animation: none; background: var(--muted); }
@keyframes pulse { 50% { opacity: .25; } }
.meter { height: 10px; background: var(--lilac); border-radius: 99px; overflow: hidden; max-width: 360px; margin: 16px auto; }
.meter > div { height: 100%; width: 0; background: var(--purple); transition: width .1s; }
.progress { height: 10px; background: var(--lilac); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: var(--purple); transition: width .2s; }

/* Report */
.tabs { display: flex; gap: 6px; margin: 16px 0; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 10px 16px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs button.active { color: var(--purple); border-color: var(--purple); }
.section { margin-bottom: 18px; }
.section h3 { font-size: 15px; color: var(--purple); margin-bottom: 6px; }
.section textarea { min-height: 70px; border-color: transparent; background: #fff; padding: 8px 10px; }
.section textarea:hover { border-color: var(--line); }
.section textarea:focus { border-color: var(--purple); }
.turn { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f2f0fa; }
.turn .who { width: 96px; flex: none; font-weight: 600; font-size: 13px; color: var(--purple); }
.turn .at { width: 44px; flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.steps { display: flex; gap: 8px; margin: 14px 0; }
.step { flex: 1; text-align: center; font-size: 13px; padding: 8px; border-radius: 10px; background: var(--lilac); color: var(--muted); }
.step.on { background: var(--purple); color: #fff; font-weight: 600; }
.step.done { background: #e3f4ea; color: var(--ok); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 20; }
.sec-edit { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #fff; }

@media (max-width: 640px) {
  .nav a { padding: 8px 10px; font-size: 14px; }
  .user span { display: none; }
  .timer { font-size: 44px; }
  .turn .who { width: 70px; }
}
@media print {
  .print-only { display: block !important; }
  textarea { display: none !important; }
  .topbar, .tabs, .no-print, .toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .section textarea { border: 0; padding: 0; resize: none; overflow: visible; }
}

/* Brand: the IA in CavevIA stands out */
.ia { background: var(--yellow); color: var(--purple-dark); padding: 0 .12em 0 .08em; border-radius: .22em; }
