.elev-card, .elev-bar {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
}
.elev-card {
  max-width: 30rem;
  margin: 2rem auto;
  padding: clamp(1rem, 4vw, 2rem);
}
.elev-card h1 { margin: 0 0 1rem; }
.elev-entry-title { margin-bottom: .35rem; }
.elev-lead { margin: 0 0 1.2rem; color: var(--ink2); line-height: 1.5; }
.elev-card label { display: block; margin-bottom: .4rem; font-weight: 600; }
.elev-card input {
  width: 100%;
  padding: .65rem .8rem;
  font: inherit;
  border: 1px solid var(--muted);
  border-radius: .5rem;
  background: var(--input);
  color: var(--ink);
}
.elev-card :focus-visible, .elev-bar :focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.elev-card-links { display:grid; gap:.75rem; }
.elev-card-links button { min-height:3rem; overflow-wrap:anywhere; }
#elev-card-form button { margin-top:1rem; }
.elev-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; }
.elev-card [role="status"] { margin: .65rem 0; }
.elev-notice { margin-top: 1rem; color: var(--ink2); }
.elev-card form + form { margin-top: .9rem; }
.elev-choice {
  border: 1px solid var(--line);
  border-radius: .75rem;
  padding: .4rem 1rem 1rem;
  margin: 0;
}
.elev-choice legend { font-weight: 700; padding: 0 .4rem; }
.elev-choice .elev-actions { margin-top: .8rem; }
.elev-code {
  font-weight: 700;
  letter-spacing: .12em;
  font-size: 1.3em;
  padding: .1em .35em;
  border: 1px dashed var(--muted);
  border-radius: .4rem;
  background: var(--chip);
}
.elev-bar .elev-code { font-size: 1.05em; }
.elev-bar { margin-bottom: 1rem; padding: .65rem 1rem; }
.elev-bar strong { margin-inline-end: auto; }
.elev-bar ul { margin: .6rem 0 0; padding-inline-start: 1.4rem; }
.elev-prov {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  margin-bottom: 1rem;
  padding: .65rem 1rem;
}
.elev-prov > p { margin: .35rem 0; font-weight: 600; }
.elev-prov > p[role="alert"] { color: var(--bad); }
.elev-prov-answers { margin-top: .6rem; max-height: 60vh; overflow: auto; }
.elev-prov-answer {
  border: 1px solid var(--line);
  border-radius: .5rem;
  margin-bottom: .5rem;
  padding: .2rem .8rem .7rem;
}
.elev-prov-answer p { margin: .3rem 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#elev-reauth { margin-top: .6rem; }
#elev-reauth label { display: block; margin-bottom: .35rem; font-weight: 600; }
#elev-reauth input {
  padding: .5rem .7rem;
  font: inherit;
  border: 1px solid var(--muted);
  border-radius: .5rem;
  max-width: 12rem;
  background: var(--input);
  color: var(--ink);
}
#elev-reauth [role="status"] { margin: .4rem 0; }
.elev-ask {
  margin-top: .6rem;
  padding: .55rem .8rem;
  border: 1px solid var(--amber);
  border-radius: .5rem;
  background: var(--accent-soft);
}
.elev-ask > p { margin: .15rem 0 .5rem; font-weight: 600; }

/* Spåra bokstaven + Lyssna och välj (letter weeks) */
.tracebox { display:inline-block; margin:4px auto 10px; padding:10px; border:1px solid var(--line); border-radius:18px; background:var(--surface); }
.tracecv { display:block; width:min(78vw,320px); aspect-ratio:1; border-radius:12px; background:var(--soft); touch-action:none; cursor:crosshair; }
.listen-play { font-size:19px; padding:14px 30px; margin-bottom:14px; }
.listen-opts .opt { font:700 24px/1.5 var(--naskh); padding-bottom:14px; }

html body:not(.pupil) .elev-bar{display:none}
body.pupil .main:has(>.elev-card){min-height:calc(100dvh - 64px - 120px);display:grid;place-items:center;align-content:center;padding-top:24px}
.elev-bar{display:grid;gap:10px;margin:0 0 20px;padding:10px 14px;background:var(--surface);border:1px solid var(--border);border-radius:16px;direction:ltr}
.elev-bar:empty{display:none}
.elev-bar>*{min-width:0}
.elev-bar>.elev-actions{width:100%;gap:8px 10px;margin-top:0}
.elev-bar>.elev-actions strong{flex:0 1 auto;min-width:0;margin-inline-end:auto;overflow-wrap:anywhere;font-size:14px;line-height:1.45}
.elev-bar>.elev-actions .btn{flex:0 0 auto;min-height:44px;justify-content:center}
.elev-bar>.elev-actions .elev-code{flex:0 0 auto}
body.pupil .elev-bar .btn.ghost{background:transparent;border-color:transparent;color:var(--muted);box-shadow:none}
body.pupil .elev-bar .btn.ghost:hover{background:var(--hover);border-color:transparent;color:var(--fg)}
body.pupil .elev-bar .btn.ghost:focus-visible{background:var(--hover);color:var(--fg)}
.elev-bar>.elev-ask,.elev-bar>#elev-reauth,.elev-bar>[role="status"],.elev-bar>details{width:100%}
.elev-bar>[role="status"]:empty{display:none}
.elev-bar>[role="status"],.elev-bar>details{overflow-wrap:anywhere}
.elev-bar .btn:focus-visible,.elev-card button:focus-visible,.elev-card input:focus-visible,.elev-card a:focus-visible{outline:2px solid var(--primary);outline-offset:2px}
.elev-card{width:min(430px,100%);margin:0 auto;padding:30px 26px;background:var(--card);border:1px solid var(--border);border-radius:16px;box-shadow:var(--shadow-soft);color:var(--fg);text-align:center}
.elev-card h1{margin:0 0 8px;font-size:25px;line-height:1.25;font-weight:650;letter-spacing:-.01em;color:var(--fg)}
.elev-card h3{margin:22px 0 10px;font-size:17px;line-height:1.35;font-weight:650;color:var(--fg)}
.elev-card p{margin:8px 0;color:var(--muted);font-size:15px;line-height:1.55}
.elev-card form{text-align:start}
.elev-card fieldset{display:grid;gap:10px;margin:0;padding:0;border:0}
.elev-card legend{margin-bottom:2px;padding:0;font-size:15px;font-weight:650;color:var(--fg)}
.elev-card label{font-size:13px;font-weight:600;color:var(--fg)}
.elev-card small{color:var(--muted);font-size:12px;line-height:1.45}
.elev-card input:not([type="checkbox"]):not([type="radio"]){width:100%;min-height:48px;padding:10px 12px;border:1px solid var(--border-strong);border-radius:8px;background:var(--chip);color:var(--fg);font:500 16px/1.35 var(--font-ui)}
.elev-card input:not([type="checkbox"]):not([type="radio"])::placeholder{color:var(--muted);opacity:.65}
#elev-code-in{min-height:52px;font:600 20px/1.2 Consolas,Monaco,'Courier New',monospace;letter-spacing:.14em;text-align:center;text-transform:uppercase;direction:ltr;unicode-bidi:isolate}
.elev-card form+form{margin-top:18px;padding-top:18px;border-top:1px solid var(--border)}
#elev-new ~ #elev-code .elev-actions .btn{border:1px solid var(--border-strong);background:var(--surface);color:var(--fg);box-shadow:none}
#elev-new ~ #elev-code .elev-actions .btn:hover{background:var(--hover);border-color:var(--border-strong);color:var(--fg)}
.elev-actions{display:flex;gap:10px;margin-top:12px}
.elev-actions .btn{flex:1 1 auto;min-height:44px;justify-content:center}
.elev-notice{margin-top:14px;color:var(--muted);font-size:12px;line-height:1.5}
#elev-card-form{text-align:center}

#elev-card-form{display:grid;gap:14px;margin-top:16px}
#elev-card-code{display:block;width:100%;min-height:52px;padding:12px 16px;border:1px solid var(--border-strong);border-radius:10px;background:var(--chip);color:var(--fg);font:600 22px/1.2 Consolas,Monaco,'Courier New',monospace;letter-spacing:.16em;text-align:center;text-transform:uppercase;caret-color:var(--primary)}
#elev-card-code::placeholder{color:var(--muted);opacity:.62;letter-spacing:.16em}
#elev-card-form .btn{width:100%;min-height:48px;margin-top:0;justify-content:center;border-radius:8px;font-size:15px;font-weight:650}
.elev-card .btn{border-radius:8px}
.elev-card-links{display:grid;grid-template-columns:1fr;gap:10px;margin-top:18px}
.elev-card-links .btn{display:flex;width:100%;min-height:48px;align-items:center;justify-content:flex-start;gap:10px;padding:10px 14px;border:1px solid var(--border);background:var(--surface);color:var(--fg);text-align:start;border-radius:10px;unicode-bidi:plaintext}
.elev-card-links .btn:hover{background:var(--hover);border-color:var(--border-strong)}
.elev-card-links .btn small{display:block;margin-top:2px;color:var(--muted);font-size:12px;font-weight:400}
@media (max-width:640px){
  body.pupil .main:has(>.elev-card){min-height:calc(100dvh - 56px - 96px)}
  .elev-card{padding:24px 18px;border-radius:14px}
  .elev-card h1{font-size:22px}
}
/* RS-RDGAPPUPIL pupil bar fixes */
.elev-bar{direction:inherit}
.elev-bar>.elev-actions{row-gap:8px}
@media (max-width:640px){
  .elev-bar{padding:10px 12px}
  .elev-bar>.elev-actions{gap:8px}
  .elev-bar>.elev-actions strong{flex:1 1 100%;margin-inline-end:0}
  .elev-bar>.elev-actions .btn{flex:1 1 auto;min-width:0;padding-inline:10px;font-size:13px}
}

.gl-save{display:flex;width:100%;flex-wrap:wrap;align-items:center;justify-content:center;gap:6px 8px;margin-block-start:8px}
.gl-save-btn{min-height:44px;padding:8px 16px;border:1px solid var(--primary);border-radius:999px;background:var(--primary);color:var(--on-primary);font:700 14px/1.2 var(--font-ui);cursor:pointer}
.gl-save-btn:hover{filter:brightness(1.06)}
.gl-save-btn:disabled{opacity:.72;cursor:default}
.gl-save-btn.is-saved{background:var(--surface);color:var(--primary)}
.gl-save-status{color:var(--bad);font-size:12px;line-height:1.35}
.gl-save-status:empty{display:none}
.elev-words{width:100%;margin-top:14px;border:1px solid var(--border);border-radius:12px;background:var(--surface);color:var(--fg);text-align:start}
.elev-bar .elev-words{margin-top:0}
.elev-words>summary{display:flex;min-height:48px;align-items:center;gap:8px;padding:10px 12px;border-radius:12px;color:var(--fg);font-weight:650;cursor:pointer;list-style:none}
.elev-words>summary::-webkit-details-marker{display:none}
.elev-words>summary:hover{background:var(--hover)}
.elev-words>summary:focus-visible{outline:2px solid var(--primary);outline-offset:2px}
.elev-words>summary svg{flex:none;transition:transform .15s}
.elev-words[open]>summary>svg{transform:rotate(90deg)}
.elev-word-count{margin-inline-start:auto;padding:2px 8px;border:1px solid var(--border);border-radius:999px;background:var(--chip);color:var(--muted);font-size:12px;font-weight:650}
.elev-words-body{padding:10px;border-top:1px solid var(--border)}
.elev-words-status{margin:4px 0;color:var(--muted);font-size:14px;line-height:1.5}
.elev-words-error{margin:0 0 8px;color:var(--bad);font-size:13px;line-height:1.45}
.elev-word-list{display:grid;gap:8px;max-height:min(52vh,420px);margin:0;padding:0;overflow:auto;list-style:none}
.elev-word{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px 10px;align-items:center;padding:9px 10px;border:1px solid var(--border);border-radius:10px;background:var(--card)}
.elev-word-text{min-width:0}
.elev-word-text>b{display:block;font:700 23px/1.5 var(--naskh)}
.elev-word-meaning{display:block;margin-top:2px;color:var(--muted);font-size:13px;line-height:1.4;overflow-wrap:anywhere}
.elev-word-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:6px}
.elev-words .btn{min-height:44px;align-items:center;gap:6px;padding:6px 10px}
.elev-words .btn svg{flex:none}
.elev-word.is-known{border-color:var(--primary);background:var(--accent-soft)}
.elev-word.is-known .elev-word-text{opacity:.72}
.elev-word.is-known [data-elev-word-know]{border-color:var(--primary);color:var(--primary)}
.elev-card .elev-word{grid-template-columns:1fr}
.elev-card .elev-word-actions{justify-content:flex-start}
@media (max-width:640px){
  .elev-word{grid-template-columns:1fr}
  .elev-word-actions{justify-content:flex-start}
  .elev-words .btn{flex:1 1 auto;justify-content:center}
}
