/* Visual language of dashboard.dobosevych.com: Inter, APPS purple header, white cards on light grey. */
:root {
  --bg: #f7f7f8; --card: #fff; --fg: #2b2c2e; --muted: #6b6d70; --border: #e4e4e7;
  --primary: #662d91; --primary-fg: #fff; --primary-soft: #f1eaf7; --header: #662d91;
  --error-bg: #fdecec; --error-fg: #a12626;
  --ok-bg: #e8f5ec; --ok-fg: #1f6b3a; --warn-bg: #fff4e0; --warn-fg: #8a5300;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16121b; --card: #1f1a26; --fg: #ecebef; --muted: #a7a3ae; --border: #342d3d;
    --primary: #a57bd0; --primary-fg: #16121b; --primary-soft: #2c2236; --header: #3d1b57;
    --error-bg: #3a1d22; --error-fg: #f2a7a7;
    --ok-bg: #173022; --ok-fg: #8fd6a8; --warn-bg: #352a14; --warn-fg: #f0c674;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif; background: var(--bg); color: var(--fg);
  font-size: 15px; line-height: 1.5; overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--primary); }
.icon { flex: none; vertical-align: -0.15em; }

/* ---------- header ---------- */
header.top { background: var(--header); color: #fff; }
header.top .bar {
  max-width: 72rem; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  font-size: 12px; line-height: 1.3; color: rgb(255 255 255 / .8);
}
header.top img { width: 44px; height: 44px; flex: none; }
header.top .brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; }
header.top .user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; min-width: 0; }
header.top .who { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
header.top .who .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.top .user button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px;
  background: transparent; color: #fff; border: 1px solid rgb(255 255 255 / .35); border-radius: 8px;
  padding: 6px 10px; font: 500 13px/1 inherit; cursor: pointer;
}
header.top .user button:hover { border-color: #fff; }

/* ---------- layout & type ---------- */
main { flex: 1; width: 100%; max-width: 72rem; margin: 0 auto; padding: 32px 16px 48px; }
main.center { display: grid; place-items: center; }
h1 { margin: 0 0 6px; font-size: 24px; color: var(--primary); letter-spacing: -.01em; line-height: 1.25; }
h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -.005em; line-height: 1.3; display: flex; align-items: center; gap: 8px; }
h2 > .icon { color: var(--primary); }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack > * + * { margin-top: 16px; }
.with-icon { display: inline-flex; align-items: center; gap: 8px; }
.back { margin-bottom: 16px; }
.back a { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; text-decoration: none; padding: 4px 0; }
.back a:hover { text-decoration: underline; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: 0 1px 2px rgb(0 0 0 / .04); min-width: 0;
}
.card.login { width: 100%; max-width: 400px; padding: 32px 24px; text-align: center; }
.card.login > img { width: 64px; height: 64px; }
.card.login h1 { margin-top: 16px; font-size: 22px; }
.card.login p { font-size: 14px; color: var(--muted); }
#google-button { margin-top: 24px; display: flex; justify-content: center; min-height: 44px; }
.dev-login { display: flex; gap: 8px; }
.dev-login .btn { flex: none; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.challenge { display: flex; flex-direction: column; gap: 10px; }
.challenge[aria-disabled="true"] { opacity: .75; }
.challenge-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.challenge-head h2 { margin: 0; }
.challenge .meta { margin-top: auto; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }

.countdown { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.countdown b { color: var(--fg); font-weight: 600; }
.countdown.soon, .countdown.soon b { color: var(--warn-fg); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.4;
  background: var(--primary-soft); color: var(--primary); white-space: nowrap; flex: none;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.off { background: var(--border); color: var(--muted); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid var(--primary);
  background: var(--primary); color: var(--primary-fg); font: 600 15px/1.2 inherit; cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--card); color: var(--fg); border-color: var(--border); }
.btn.secondary:hover { border-color: var(--primary); filter: none; }
.btn.danger { background: var(--error-fg); border-color: var(--error-fg); color: #fff; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13px; gap: 6px; }
.btn.small .icon { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn:focus-visible, input:focus-visible, .back a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

input[type="email"], input[type="search"] {
  width: 100%; min-height: 42px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--fg); font: 16px/1.2 inherit; /* 16px: no zoom-on-focus in iOS */
}
.search { position: relative; display: block; width: 100%; max-width: 340px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 36px; }

/* ---------- alerts ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 8px; font-size: 14px; line-height: 1.45; text-align: left;
}
.alert > .icon { margin-top: 1px; }
.alert.error { background: var(--error-bg); color: var(--error-fg); }
.alert.ok { background: var(--ok-bg); color: var(--ok-fg); }
.alert.warn { background: var(--warn-bg); color: var(--warn-fg); }

/* ---------- challenge flow ---------- */
.steps { display: flex; gap: 6px; margin-bottom: 20px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.steps span.done { background: var(--primary); }

ul.rules { margin: 0; padding-left: 20px; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.45; cursor: pointer; }
.consent input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--primary); }
.policy section h2 { font-size: 16px; margin-bottom: 6px; }
ul.rules li + li { margin-top: 6px; }

.level { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.level .meter { flex: 1; }
.meter { height: 10px; border-radius: 5px; background: var(--border); overflow: hidden; }
.meter > div { height: 100%; width: 0; background: var(--primary); transition: width .08s linear; }

.timer { text-align: center; padding: 8px 0; }
.timer .clock { font-size: 64px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--primary); line-height: 1.2; }
.timer.ending .clock { color: var(--error-fg); }
.progress { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); }
.timer.ending .progress > div { background: var(--error-fg); }

.rec-dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--error-fg); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.wave { display: flex; justify-content: center; align-items: center; gap: 5px; height: 48px; }
.wave span { width: 6px; height: 12px; border-radius: 3px; background: var(--primary); animation: wave 1s ease-in-out infinite; }
.wave span:nth-child(2) { animation-delay: .1s; } .wave span:nth-child(3) { animation-delay: .2s; }
.wave span:nth-child(4) { animation-delay: .3s; } .wave span:nth-child(5) { animation-delay: .4s; }
@keyframes wave { 50% { height: 44px; } }
@media (prefers-reduced-motion: reduce) { .wave span, .rec-dot, .spin { animation: none; } }

audio { width: 100%; max-width: 100%; }
.question-image { display: block; width: 100%; max-height: 320px; object-fit: contain; border-radius: 8px; background: var(--bg); }
.question-thumb { display: block; width: 160px; max-width: 100%; border-radius: 6px; margin-bottom: 6px; }

/* ---------- results table ---------- */
.table-card { padding: 8px 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td:first-child { min-width: 190px; overflow-wrap: normal; word-break: normal; }
td.cell-actions { width: 1%; }
.btn { white-space: nowrap; }
td audio { min-width: 220px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 16px 0; }

/* ---------- phones ---------- */
@media (max-width: 639px) {
  header.top .bar { padding: 10px 16px; }
  header.top img { width: 36px; height: 36px; }
  header.top .faculty, header.top .who, header.top .user .label { display: none; }
  header.top .user button { min-width: 40px; min-height: 40px; justify-content: center; padding: 8px; }

  main { padding: 20px 16px 40px; }
  h1 { font-size: 21px; }
  h2 { font-size: 17px; }
  .card { padding: 18px 16px; }
  .card.login { padding: 28px 18px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }

  /* Primary actions span the width and are easy to hit with a thumb. */
  .actions { flex-direction: column; align-items: stretch; }
  .actions > .btn { width: 100%; min-height: 46px; }
  .actions > .btn.small { min-height: 42px; font-size: 14px; }
  .challenge .meta { flex-direction: column; align-items: stretch; }
  .challenge .meta .actions { flex-direction: row; }
  .challenge .meta .actions > .btn { flex: 1; width: auto; }

  .timer .clock { font-size: 56px; }
  .steps { margin-bottom: 14px; }
  .search { max-width: none; }

  /* Results table becomes one card per attempt, each cell labelled from its column header. */
  .table-card { padding: 4px 16px; }
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { padding: 14px 0; border-bottom: 1px solid var(--border); }
  table.responsive tr:last-child { border-bottom: 0; }
  table.responsive td { border: 0; padding: 4px 0; }
  table.responsive td[data-label]:not([data-label=""])::before {
    content: attr(data-label); display: block; margin-bottom: 2px;
    color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  }
  table.responsive td.cell-actions { padding-top: 8px; }
  table.responsive td.cell-actions .btn { width: 100%; min-height: 42px; }
  td audio { min-width: 0; }
  td:first-child { min-width: 0; overflow-wrap: anywhere; }
  td.cell-actions { width: 100%; }
}
