/* ==========================================================
   AEROQUIZ - utseende
   ========================================================== */

:root {
  --lila:      #46178f;
  --lila-ljus: #5f27c4;
  --bg:        #f4f4f8;
  --text:      #21242c;
  --muted:     #6b7280;
  --kant:      #e2e4ec;
  --vit:       #ffffff;

  --rod:  #e21b3c;
  --bla:  #1368ce;
  --gul:  #d89e00;
  --gron: #26890c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body.student {
  background: linear-gradient(160deg, var(--lila) 0%, var(--lila-ljus) 100%);
  color: var(--vit);
  min-height: 100vh;
}

/* ---------- Topprad ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .75rem 1.25rem;
  background: var(--lila); color: var(--vit);
}
.topbar .brand { font-weight: 800; font-size: 1.1rem; letter-spacing: .02em; }
.topbar a { color: var(--vit); text-decoration: none; }
.topbar nav a { margin-left: 1rem; font-size: .9rem; opacity: .9; }
.topbar nav a:hover { opacity: 1; text-decoration: underline; }

/* ---------- Layout ---------- */
.wrap { max-width: 780px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.wrap.wide { max-width: 1000px; }
.center { text-align: center; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
body.student .muted { color: rgba(255,255,255,.75); }
.small { font-size: .85rem; }

h1 { font-size: 1.7rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 .6rem; }

.panel {
  background: var(--vit); border: 1px solid var(--kant); border-radius: 14px;
  padding: 1.25rem; margin-bottom: 1.25rem;
}
body.student .panel {
  background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2);
  backdrop-filter: blur(4px);
}
.panel.narrow { max-width: 420px; margin: 2rem auto; }

.page-head {
  display: flex; flex-wrap: wrap; gap: .75rem;
  align-items: center; justify-content: space-between; margin-bottom: 1rem;
}

/* ---------- Startsida ---------- */
.hero { text-align: center; padding: 1.5rem 0 .5rem; }
.hero h1 { font-size: 2.4rem; color: var(--lila); margin-bottom: .2rem; }
.lead { color: var(--muted); font-size: 1.05rem; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.5rem 0; }
.card {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: 2rem 1rem; border-radius: 16px; text-decoration: none;
  color: var(--vit); font-size: 1.15rem; transition: transform .12s;
}
.card:hover { transform: translateY(-3px); }
.card-icon { font-size: 2.2rem; }
.card-sub { font-size: .85rem; opacity: .85; font-weight: 400; }
.card-student { background: var(--bla); }
.card-teacher { background: var(--lila); }
@media (max-width: 520px) { .cards { grid-template-columns: 1fr; } }

/* ---------- Formulär ---------- */
label { display: block; margin-bottom: .9rem; font-weight: 600; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  display: block; width: 100%; margin-top: .3rem;
  padding: .7rem .8rem; font-size: 1rem; font-family: inherit;
  border: 2px solid var(--kant); border-radius: 10px; background: var(--vit); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--lila); }
textarea.autogrow { resize: none; overflow: hidden; line-height: 1.35; min-height: 2.9rem; }
.big-input { font-size: 1.4rem; text-align: center; letter-spacing: .06em; padding: .8rem; }
.title-input { font-size: 1.2rem; font-weight: 700; }

.inline-form { display: flex; gap: .5rem; align-items: stretch; flex-wrap: wrap; }
.inline-form input[type=text] { flex: 1 1 220px; margin-top: 0; }

.option-input { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.option-input input[type=radio] { width: 22px; height: 22px; flex: none; accent-color: var(--gron); }
.option-input input[type=text], .option-input textarea { margin-top: 0; }

/* ---------- Knappar ---------- */
.btn {
  display: inline-block; padding: .65rem 1.1rem; font-size: .95rem;
  font-family: inherit; font-weight: 600; border: 1px solid var(--kant);
  border-radius: 10px; background: var(--vit); color: var(--text);
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { background: #f7f7fb; }
.btn-primary { background: var(--lila); border-color: var(--lila); color: var(--vit); }
.btn-primary:hover { background: var(--lila-ljus); }
.btn-secondary { background: var(--bla); border-color: var(--bla); color: var(--vit); }
.btn-secondary:hover { filter: brightness(1.1); }
.btn-danger { color: var(--rod); border-color: #f3c9d1; background: var(--vit); }
.btn-danger:hover { background: #fdeef1; }
.btn-big { font-size: 1.15rem; padding: .9rem 1.6rem; }
.btn-block { width: 100%; }
.btn-small { padding: .38rem .7rem; font-size: .82rem; }
.btn-tiny { padding: .3rem .5rem; font-size: .8rem; line-height: 1; }
.btn:disabled { opacity: .35; cursor: default; }

.start-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.start-buttons form { display: flex; flex-direction: column; gap: .4rem; }
@media (max-width: 560px) { .start-buttons { grid-template-columns: 1fr; } }

/* ---------- Flikar ---------- */
.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.tab {
  padding: .5rem .9rem; font-family: inherit; font-size: .9rem; font-weight: 600;
  border: 1px solid var(--kant); background: var(--vit); border-radius: 10px; cursor: pointer;
}
.tab-active { background: var(--lila); border-color: var(--lila); color: var(--vit); }

/* ---------- Meddelanden ---------- */
.flash {
  padding: .7rem .95rem; border-radius: 10px; margin-bottom: 1rem;
  font-size: .92rem; border: 1px solid;
}
.flash-error   { background: #fdeef1; border-color: #f3c9d1; color: #9c1029; }
.flash-success { background: #eaf7e6; border-color: #c3e6b8; color: #1c6410; }
.flash-info    { background: #eaf1fd; border-color: #c4d8f6; color: #12447f; }

/* ---------- Listor ---------- */
.list { display: flex; flex-direction: column; gap: .6rem; }
.list-row {
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  background: var(--vit); border: 1px solid var(--kant);
  border-radius: 12px; padding: .85rem 1rem;
}
.list-main { min-width: 0; }
.list-title { display: block; font-weight: 700; color: var(--text); text-decoration: none; }
a.list-title:hover { color: var(--lila); }
.list-actions { display: flex; gap: .35rem; align-items: center; flex: none; }

.option-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0; }
.chip {
  font-size: .8rem; padding: .18rem .55rem; border-radius: 999px;
  background: #eef0f6; color: #4b5163;
}
.chip-correct { background: #d9f0d2; color: #1c6410; font-weight: 700; }

/* ---------- Spelkod ---------- */
.code-panel {
  display: flex; flex-wrap: wrap; gap: 1rem;
  align-items: center; justify-content: space-between;
}
.join-url { font-size: 1.05rem; font-weight: 700; word-break: break-all; }
.code-box { text-align: center; }
.code-digits {
  font-size: 2.6rem; font-weight: 800; letter-spacing: .12em;
  color: var(--lila); line-height: 1.1;
}
.mode-badge {
  background: var(--lila); color: var(--vit); font-size: .8rem; font-weight: 700;
  padding: .3rem .7rem; border-radius: 999px;
}
.quiz-name { font-size: 1.25rem; color: var(--muted); font-weight: 600; }

/* ---------- Fråga ---------- */
.q-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.q-foot { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; }
.q-text { font-size: 1.6rem; font-weight: 800; margin: .3rem 0 1rem; }
.timer {
  font-size: 1.3rem; font-weight: 800; color: var(--lila);
  background: var(--vit); border-radius: 999px; padding: .1rem .8rem; min-width: 3.2rem; text-align: center;
}
body.student .timer { color: var(--lila); }

/* ---------- Svarsalternativ ---------- */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 560px) { .options { grid-template-columns: 1fr; } }

.option {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: 1.4rem 1.1rem; border: none; border-radius: 14px;
  font-family: inherit; font-size: 1.15rem; font-weight: 700;
  color: var(--vit); text-align: left; min-height: 84px;
}
.option-clickable { cursor: pointer; transition: transform .1s; width: 100%; }
.option-clickable:active { transform: scale(.97); }
.option-0 { background: var(--rod); }
.option-1 { background: var(--bla); }
.option-2 { background: var(--gul); }
.option-3 { background: var(--gron); }
.option-correct { outline: 4px solid #fff; box-shadow: 0 0 0 3px var(--gron); }
.option-wrong { opacity: .35; }
.option-disabled { opacity: .4; pointer-events: none; }
.option-count { font-size: .85rem; font-weight: 600; opacity: .9; flex: none; }
.options-teacher .option { min-height: 70px; font-size: 1.05rem; }

/* ---------- Resultattavla ---------- */
.leaderboard { list-style: none; margin: 0; padding: 0; counter-reset: plats; }
.leaderboard li {
  counter-increment: plats;
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .8rem; border-bottom: 1px solid var(--kant);
}
body.student .leaderboard li { border-color: rgba(255,255,255,.2); }
.leaderboard li::before {
  content: counter(plats); font-weight: 800; color: var(--muted);
  min-width: 1.6rem; text-align: right;
}
body.student .leaderboard li::before { color: rgba(255,255,255,.7); }
.lb-name { flex: 1; font-weight: 600; }
.lb-score { font-weight: 800; color: var(--lila); }
body.student .lb-score { color: #ffd84d; }
.lb-me { background: rgba(255,255,255,.18); border-radius: 8px; }

.tag {
  font-size: .72rem; font-weight: 700; padding: .1rem .45rem;
  border-radius: 999px; background: #eef0f6; color: #4b5163;
}
.tag-done { background: #d9f0d2; color: #1c6410; }

/* ---------- Elevvy ---------- */
.student-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,.15); border-radius: 12px;
  padding: .6rem .9rem; margin-bottom: 1rem; font-weight: 700;
}
.points { font-size: 2.2rem; font-weight: 800; margin: .5rem 0; }

.pulse { font-size: 2rem; animation: puls 1.4s ease-in-out infinite; }
@keyframes puls { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* ---------- Frågor från dokument ---------- */
.panel-alt { margin: .8rem 0 0; }
.steps { margin: 0; padding-left: 1.2rem; line-height: 1.6; }
.chapter-tag {
  display: inline-block; font-size: .72rem; font-weight: 700; color: var(--lila);
  background: #efeafd; border-radius: 999px; padding: .1rem .55rem; margin-bottom: .25rem;
}
.chapter-tools { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }
.chapter-list { display: flex; flex-direction: column; gap: .3rem; max-height: 60vh; overflow-y: auto; }
.chapter-row {
  display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; align-items: start;
  margin: 0; padding: .5rem .6rem; border-radius: 8px; font-weight: 500; cursor: pointer;
}
.chapter-row:hover { background: #f7f7fb; }
.chapter-row input { width: 20px; height: 20px; margin-top: .1rem; accent-color: var(--lila); }
.chapter-meta { grid-column: 2; }
.warn { color: #9a6200; }
.field-label { font-weight: 600; font-size: .9rem; margin: 1rem 0 .4rem; }
.radio-row {
  display: flex; gap: .6rem; align-items: flex-start; font-weight: 400;
  padding: .5rem .6rem; border: 1px solid var(--kant); border-radius: 8px; margin-bottom: .4rem; cursor: pointer;
}
.radio-row input { width: 20px; height: 20px; margin-top: .1rem; flex: none; accent-color: var(--lila); }
.radio-extra { margin: 0 0 .8rem 2.2rem; }
.radio-extra input, .radio-extra select { margin-top: 0; }
.spinner {
  width: 42px; height: 42px; margin: .5rem auto 1rem; border-radius: 50%;
  border: 4px solid var(--kant); border-top-color: var(--lila); animation: snurra 1s linear infinite;
}
@keyframes snurra { to { transform: rotate(360deg); } }
.progress { height: 10px; background: var(--kant); border-radius: 999px; overflow: hidden; margin: .8rem 0; }
.progress-bar { height: 100%; background: var(--lila); transition: width .4s; }
.review-chapter { margin-top: 2rem; }
.review-card { padding-top: .8rem; }
.review-card .option-input input[type=radio] { accent-color: var(--gron); }
.keep-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; font-size: .85rem; }
.keep-row input { width: 18px; height: 18px; accent-color: var(--lila); }
.review-body > .q-text-input { font-weight: 700; margin-bottom: .5rem; }
.review-off .review-body { opacity: .35; }
.tf-choice { display: flex; gap: 1.2rem; }
.tf-choice label { display: flex; gap: .4rem; align-items: center; font-weight: 600; margin: 0; }
.save-bar {
  position: sticky; bottom: .5rem; box-shadow: 0 4px 18px rgba(0,0,0,.12);
  display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap; padding: .7rem 1rem;
}
.time-inline { display: flex; align-items: center; gap: .4rem; margin: 0; white-space: nowrap; }
.time-inline input[type=number] { width: 4.5rem; margin: 0; padding: .45rem .5rem; }
.save-where { flex: 1 1 160px; }
.review-card .option-input input[type=radio]:checked + textarea {
  border-color: var(--gron); background: #f1faee; font-weight: 600;
}
.tf-choice input[type=radio] { width: 20px; height: 20px; accent-color: var(--gron); }
