:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --border: #deded8;
  --accent: #2563eb;
  --ok: #15803d;
  --bad: #b91c1c;
  --warn-bg: #fff6db;
  --warn-border: #f0d68a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --card: #20201e;
    --text: #ececea;
    --muted: #9a9a94;
    --border: #34342f;
    --accent: #60a5fa;
    --ok: #4ade80;
    --bad: #f87171;
    --warn-bg: #3a3112;
    --warn-border: #6b5a1f;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 20px/1.5 system-ui, sans-serif;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}
.brand { font-size: 24px; font-weight: 700; color: var(--text); text-decoration: none; }
main { max-width: 960px; margin: 0 auto; padding: 32px 16px; }
h2 { font-size: 18px; color: var(--muted); font-weight: 600; margin: 32px 0 8px; }

button, .btn {
  font: inherit;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .5; cursor: default; }

input[type=text], input[type=password], textarea {
  font: inherit;
  width: 100%;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}

.add { display: flex; gap: 12px; }
.form-error { color: var(--bad); margin: 8px 0 0; }

.library { display: flex; flex-direction: column; gap: 12px; }
.video {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.video .info { flex: 1; min-width: 0; }
.video .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video .sub { color: var(--muted); font-size: 17px; }
.video.rate_limited { background: var(--warn-bg); border-color: var(--warn-border); }
.video .err { color: var(--bad); font-size: 17px; overflow-wrap: anywhere; }
.empty { color: var(--muted); }

.spinner {
  width: 22px; height: 22px; flex: none;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Exercise */
.ex-head { display: flex; gap: 16px; align-items: baseline; margin-bottom: 20px; min-width: 0; }
.ex-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.nav, .opts, .row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
input.counter-input { width: 4.5em; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); text-align: right; }
input[type=checkbox] { width: 1.2em; height: 1.2em; vertical-align: -0.2em; }
.clock { color: var(--muted); font-size: 17px; margin-left: 4px; }
select { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--text); }
textarea { resize: vertical; font-size: 26px; }
.feedback { font-size: 26px; padding: 14px 18px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 6px; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.feedback .ok, .message .ok { color: var(--ok); }
.feedback .bad { color: var(--bad); }
.hint-mask { color: var(--muted); letter-spacing: 1px; }
.message { min-height: 1.5em; }
.done-mark { color: var(--ok); font-weight: 700; }
.hint { color: var(--muted); font-size: 16px; margin: 0; }
#user { color: var(--muted); font-size: 17px; }
.login { max-width: 420px; margin: 64px auto; display: flex; flex-direction: column; gap: 10px; }
.login h1 { font-size: 30px; margin: 0 0 6px; }
