:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1d2330;
  --muted: #667085;
  --line: #d9dde3;
  --accent: #2f6fde;
  --accent-ink: #fff;
  --ok: #e8f5ec;
  --ok-line: #6cbf84;
  --danger: #c4372b;
  --flash: #e8f0fd;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }

.top { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }
.top nav { margin-left: auto; display: flex; gap: 1rem; align-items: center; }
.top nav a { text-decoration: none; }
main { max-width: 900px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem; margin: 0 0 1rem; }
.narrow { max-width: 380px; margin: 3rem auto; }
.empty { text-align: center; padding: 2.5rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

label { display: block; font-weight: 600; margin: 0 0 .9rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .9em; }
input[type=text], input[type=password], input[type=number], textarea, select {
  font: inherit; color: inherit; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; width: 100%; margin-top: .25rem;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

button, .button {
  font: inherit; display: inline-block; padding: .4rem .8rem; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; text-decoration: none; line-height: 1.4;
}
button:hover, .button:hover { border-color: #aab1bd; }
button:disabled { opacity: .4; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.primary:hover { background: #255fc4; }
.danger { color: var(--danger); }
button.link { border: 0; padding: 0; background: none; color: var(--accent); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); border-color: var(--line); }
form.inline { display: inline; }

.flash { background: var(--flash); border: 1px solid #bcd0f5; border-radius: 8px; padding: .6rem 1rem; margin-bottom: 1rem; }
.error { color: var(--danger); font-weight: 600; }
.errors { background: #fdecea; border: 1px solid #f1b3ab; border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; }
.errors ul { margin: .4rem 0 0; padding-left: 1.2rem; }

table.quizzes { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.quizzes th, .quizzes td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.quizzes th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.quizzes tr:last-child td { border-bottom: 0; }
.quizzes td:first-child a { font-weight: 600; text-decoration: none; }
.quizzes .actions { text-align: right; white-space: nowrap; }
.quizzes .actions .button, .quizzes .actions button { padding: .25rem .55rem; font-size: .9rem; }

/* Editor */
fieldset.question { min-width: 0; }
.q-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.q-head select { width: auto; margin: 0; }
.q-head .points { display: flex; align-items: center; margin: 0; font-weight: 400; }
.q-head .points input { width: 4.5rem; margin: 0; }
.q-head .spacer { flex: 1; }
.q-head button { padding: .2rem .55rem; }
.answers { list-style: none; padding: 0; margin: .6rem 0 .3rem; }
.answers li { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; border-radius: 6px; padding: .1rem .3rem; }
.answers li.correct { background: var(--ok); }
.answers li.correct input[type=text] { border-color: var(--ok-line); }
.answers .mark { display: flex; align-items: center; gap: .3rem; margin: 0; font-weight: 600; width: 2.6rem; cursor: pointer; }
.answers .mark input { width: 1.1rem; height: 1.1rem; margin: 0; cursor: pointer; }
.answers input[type=text] { margin: 0; flex: 1; }
.q-foot { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.q-foot .hint { margin: 0; }
.add-row { display: flex; align-items: center; gap: 1rem; }
.savebar { position: sticky; bottom: 0; display: flex; gap: .75rem; align-items: center; padding: .75rem 1rem; margin: 1rem -1rem 0; background: rgba(244, 245, 247, .95); border-top: 1px solid var(--line); }

@media (max-width: 600px) {
  .quizzes thead { display: none; }
  .quizzes tr { display: block; border-bottom: 1px solid var(--line); padding: .4rem 0; }
  .quizzes td { display: inline-block; border: 0; padding: .2rem .75rem; }
  .quizzes td:first-child { display: block; }
  .quizzes .actions { display: block; text-align: left; white-space: normal; }
}

/* Login */
.login { text-align: center; }
.login .google { display: inline-flex; align-items: center; gap: .6rem; padding: .6rem 1.2rem; font-weight: 600; }
.login .dev { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
.login .dev button { font-size: .85rem; color: var(--muted); }
code { font-size: .85em; background: #eef0f3; padding: .1em .35em; border-radius: 4px; word-break: break-all; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .05rem .45rem; border-radius: 99px; background: var(--ok); color: #1e6b35; border: 1px solid var(--ok-line); vertical-align: middle; }
label.check { font-weight: 600; }
label.check input { margin: 0 .4rem 0 0; vertical-align: -1px; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .5rem 1rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.badge.blocked { background: #fdecea; color: var(--danger); border-color: #f1b3ab; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
button.star { font-size: 1.1rem; line-height: 1; padding: .3rem .5rem; color: #b8860b; }
button.star.on { background: #fff7d6; border-color: #e6c35c; }
h2.section { margin-top: 2rem; }
.badge.protected { background: #ede7fb; color: #5b3fb0; border-color: #b9a7ea; }
.flash .undo { margin-left: .5rem; font-weight: 600; text-decoration: underline; }
details.deleted { margin-top: 2rem; }
details.deleted summary { cursor: pointer; color: var(--muted); font-weight: 600; margin-bottom: .5rem; }
.flash.toast { position: fixed; left: 50%; bottom: 5rem; transform: translateX(-50%); z-index: 10; box-shadow: 0 4px 16px rgba(0,0,0,.15); margin: 0; }

[x-cloak] { display: none !important; }

/* Bottom-left corner of the screen. On narrower screens it would cover the editor's save bar,
   so there it stays at the end of the page. */
footer.bottom { color: #98a2b3; font-size: .85rem; font-weight: 700; padding: 1.5rem 1rem 2rem; text-align: center; }
footer.bottom .heart { font-size: .75em; }
@media (min-width: 1300px) {
  footer.bottom { position: fixed; left: 1rem; bottom: .75rem; padding: 0; text-align: left; pointer-events: none; }
}
