#al-root {
  --card: #fffdf8;
  --paper: #ffffff;
  --ink: #33302a;
  --soft: #5a5346;
  --line: #e3d8c4;
  --line2: #ece0c2;
  --teal: #0e5a48;
  --teal-d: #0c4a3b;
  --gold: #c0843c;
  --muted: #7a7163;
  --heart: #b8503a;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background: transparent;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px;
  -webkit-text-size-adjust: 100%;
  position: relative;
  box-sizing: border-box;
}
#al-root * {
  box-sizing: border-box;
}
#al-root .sys {
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
}
#al-root .wordmark {
  font: 500 11px system-ui;
  letter-spacing: 0.16em;
  color: #b8923c;
}
#al-root .gtag {
  font: 600 12px system-ui;
  letter-spacing: 0.05em;
  color: #b8923c;
}
#al-root .gtag .sub {
  color: #a08a5c;
  font-weight: 500;
}
#al-root h1 {
  font-size: 30px;
  margin: 8px 0 4px;
  font-weight: bold;
}
#al-root .lede {
  font-size: 16px;
  line-height: 1.55;
  color: var(--soft);
}
#al-root button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  background: none;
}

/* primary / secondary buttons */
#al-root .btn {
  display: inline-block;
  text-align: center;
  background: #157f73;
  color: #fffdf8;
  font: 600 15px system-ui;
  padding: 12px 22px;
  border-radius: 10px;
  border: 1px solid #0e5a48;
}
#al-root .btn:active {
  transform: scale(0.98);
}
#al-root .btn.ghost {
  background: var(--card);
  color: var(--soft);
  border: 1px solid #cdbf9a;
}
#al-root .btn.wide {
  display: block;
  width: 100%;
}
#al-root .btn[disabled] {
  background: #cdbf9a;
  border-color: #cdbf9a;
  color: #fff;
  cursor: default;
}

/* HUD */
#al-root .hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font: 500 12px system-ui;
  color: #7a6f5e;
  margin-bottom: 10px;
}
#al-root .hearts {
  color: var(--heart);
  letter-spacing: 2px;
}
#al-root .hearts .gone {
  color: #d9cdb2;
}
#al-root .hudright {
  display: flex;
  align-items: center;
  gap: 8px;
}
#al-root .streak {
  font: 500 11px system-ui;
  background: #faeeda;
  color: #854f0b;
  border: 1px solid #e9d4ad;
  border-radius: 20px;
  padding: 2px 9px;
  white-space: nowrap;
}
#al-root .hudleft {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}
#al-root .score-sep {
  color: #cdbf9a;
}
#al-root .scorewrap {
  font: 500 12px system-ui;
  color: #5a5346;
  white-space: nowrap;
}
#al-root .score-n {
  font: 600 13px system-ui;
  color: #33302a;
  font-variant-numeric: tabular-nums;
}
#al-root .ptfly {
  position: absolute;
  z-index: 40;
  pointer-events: none;
  font: 700 18px system-ui;
  color: #0e5a48;
  opacity: 1;
  transition:
    transform 0.7s ease-out,
    opacity 0.7s ease-out;
}
#al-root .dots {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
#al-root .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #efe6d0;
  border: 1.5px solid #e3d8c4;
  flex: none;
}
#al-root .dot-ok {
  background: #2f7d57;
  border-color: #2f7d57;
}
#al-root .dot-miss {
  background: #b8503a;
  border-color: #b8503a;
}
#al-root .dot-cur {
  background: var(--card);
  border-color: var(--teal);
}
#al-root .dotgap {
  width: 5px;
  flex: none;
}
#al-root .spark {
  position: absolute;
  bottom: 12px;
  opacity: 1;
  pointer-events: none;
  font-family: system-ui;
  transition:
    transform 1s ease-out,
    opacity 1s;
}
#al-root .endbtn {
  font: 500 11px system-ui;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3px 10px;
  cursor: pointer;
}
#al-root .endbtn:active {
  transform: scale(0.97);
}
#al-root .endconfirm {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(30, 24, 16, 0.34);
}
#al-root .endcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(50, 40, 20, 0.24);
  padding: 20px 18px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}
#al-root .endcard h2 {
  font-size: 20px;
  margin: 10px 0 6px;
}
#al-root .endcard p {
  font: 400 14px/1.5 system-ui;
  color: var(--soft);
  margin: 0 0 16px;
}
#al-root .menucorner {
  display: flex;
  justify-content: flex-end;
  min-height: 32px;
  margin-bottom: 8px;
}
#al-root .modebtns {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-top: 4px;
}
#al-root .modebtns > div {
  flex: 1;
  min-width: 0;
}
#al-root .startlbl {
  font: 600 10px system-ui;
  letter-spacing: 0.08em;
  color: var(--teal);
  margin-bottom: 6px;
  text-align: center;
}
#al-root .btn.chal {
  background: #7a2e35;
  border-color: #5e232a;
  color: #fffdf8;
}

/* layout container (frameless) + warm card surface for focal screens */
#al-root .panel {
  padding: 0;
}
#al-root .sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(60, 50, 30, 0.08);
}
#al-root .prompt {
  font: 500 13px system-ui;
  color: var(--muted);
  margin: 4px 0 10px;
}
#al-root .prompt:empty {
  margin: 0;
}

/* the top instruction leads the eye; the reference below it stays subordinate */
#al-root .prompt.lead {
  color: #4c4638;
  font-weight: 600;
}

/* reference pane (Learn only): quiet text toggle at rest, a soft panel only when opened */
#al-root .reftoggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 0;
  margin: -2px 0 12px;
  font: 500 12px system-ui;
  color: #9a8f7c;
  cursor: pointer;
}
#al-root .reftoggle:active {
  transform: scale(0.98);
}
#al-root .reftoggle .chev {
  font-size: 9px;
  color: #bcae90;
}
#al-root .reftoggle .ul {
  border-bottom: 1px dotted #cdbf9a;
  padding-bottom: 1px;
}
#al-root .refpanel {
  margin: 0 0 12px;
  border: 1px solid #ecdfc4;
  border-radius: 10px;
  background: #fdfaf1;
  padding: 9px 12px 11px;
  max-height: 44vh;
  overflow-y: auto;
}
#al-root .refph {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 0;
  margin: 0 0 4px;
  font: 500 12px system-ui;
  color: #9a8f7c;
  cursor: pointer;
}
#al-root .refph .chev {
  font-size: 9px;
  color: #bcae90;
  transform: rotate(90deg);
}
#al-root .refitem {
  display: flex;
  gap: 9px;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid #f0e7d3;
}
#al-root .refitem:first-of-type {
  border-top: 0;
}
#al-root .refitem .sw {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex: none;
  position: relative;
  top: 2px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
#al-root .refitem .rname {
  font: 600 12.5px system-ui;
  color: #33302a;
}
#al-root .refitem .rdef {
  font: 400 12.5px/1.45 system-ui;
  color: #6b6153;
}

/* stimulus: warm card surface on a transparent ground (matches Train of Thought) */
#al-root .stim {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 14px 16px;
  font-size: 17px;
  line-height: 2.35;
  position: relative;
  overflow: hidden;
  transition:
    background-color 0.35s,
    border-color 0.35s;
}
#al-root .scanband {
  position: absolute;
  left: 0;
  right: 0;
  height: 12px;
  pointer-events: none;
  background: rgba(14, 90, 72, 0.1);
  border-bottom: 2px solid var(--teal);
}
/* the develop: at Scan the card flips to film until the item ends */
#al-root .stim.filmed {
  background: #201e18;
  border-color: #3a362c;
}
#al-root .stim.filmed .scanband {
  background: rgba(47, 169, 138, 0.14);
  border-bottom-color: #2fa98a;
}
#al-root .stim.filmed .flab:not(.filmy) {
  opacity: 0;
}
#al-root .stim.filmed .al-chunk {
  color: rgba(240, 232, 214, 0.5);
}
#al-root .stim.filmed .al-chunk.lit {
  color: #f0e8d6;
}
#al-root .stim.filmed .lead {
  color: rgba(240, 232, 214, 0.45);
}
#al-root .stim.filmed .lead.show {
  color: rgba(240, 232, 214, 0.7);
  font-style: italic;
}
#al-root .stim.filmed .lead.shown {
  color: rgba(240, 232, 214, 0.75);
}
#al-root .stim.filmed .lead.ind {
  font-style: italic;
}
#al-root .stim.filmed .mk.ok {
  color: #6fcf97;
}
#al-root .stim.filmed .mk.bad {
  color: #e0654f;
}
#al-root .seg {
  border-radius: 3px;
}
#al-root .al-stim.arming .seg {
  cursor: pointer;
}
#al-root .al-stim.arming .al-chunk:not(.placed) {
  background: #eef5ff;
}
#al-root .al-chunk {
  border-radius: 3px;
  padding: 0 1px;
  transition:
    background 0.12s,
    color 0.35s;
}
#al-root .al-chunk.drop {
  background: #eaf4ff;
  outline: 1.5px dashed #378add;
  outline-offset: 1px;
}
#al-root .al-chunk.placed {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
  text-decoration-color: var(--ulc, #cfccc1);
}
/* floating labels: absolutely positioned, so the text never reflows */
#al-root .flab {
  position: absolute;
  font: 600 9px system-ui;
  border-radius: 4px;
  padding: 0 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 3;
  transform-origin: left bottom;
}
#al-root .flab.filmy {
  background: none;
  border: 0;
  padding: 0;
  letter-spacing: 0.03em;
}
#al-root .lead {
  color: inherit;
  transition: color 0.3s;
}
#al-root .lead.show {
  color: #5a5346;
  font-style: italic;
}

/* inline front tag: a quiet raised annotation (clearing is by tapping the sentence) */
#al-root .tag {
  font: 600 9.5px system-ui;
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 2px;
  white-space: nowrap;
  vertical-align: 2px;
  user-select: none;
  transition: opacity 0.3s;
}
#al-root .mk {
  font: 600 10px system-ui;
  vertical-align: 2px;
  margin-right: 1px;
}
#al-root .mk.ok {
  color: #2f7d57;
}
#al-root .mk.bad {
  color: #b8503a;
}

/* role colors */
#al-root .r-ctx {
  background: #eceae3;
  color: #5f5e5a;
  border-color: #cfccc1;
}
#al-root .r-prem {
  background: #f6ecd9;
  color: #8a5618;
  border-color: #c0843c;
}
#al-root .r-interm {
  background: #e6f1fb;
  color: #185fa5;
  border-color: #85b7eb;
}
#al-root .r-main {
  background: #e8f3ee;
  color: #0e5a48;
  border-color: #9cc9b9;
}
#al-root .r-otherp,
#al-root .r-otherc,
#al-root .r-otherv {
  background: #faece7;
  color: #993c1d;
  border-color: #f0997b;
}

/* tray */
#al-root .tray {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 14px;
}
#al-root .tray-h {
  font: 500 11px system-ui;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
#al-root .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
#al-root .chip {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid;
  border-radius: 10px;
  min-height: 44px;
  padding: 0 14px;
  font: 500 14px system-ui;
  touch-action: none;
  user-select: none;
  cursor: pointer;
}
#al-root .chip .grip {
  letter-spacing: 1px;
  opacity: 0.45;
}
#al-root .chip.dim {
  opacity: 0.4;
}
#al-root .chip.armed {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(60, 50, 30, 0.18);
}

/* tap-to-label: each sentence is the control; a popover carries the roles */
#al-root .stim.labeling .seg {
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.12s;
}
#al-root .stim.labeling:not(.filmed) .seg:hover {
  background: #f4eede;
}
#al-root .stim.labeling:not(.filmed) .seg.picking {
  background: #eef5ff;
}
#al-root .rolemenu {
  position: absolute;
  z-index: 30;
  background: #fffdf8;
  border: 1px solid #d9cdb2;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(50, 40, 20, 0.24);
  padding: 5px;
  min-width: 180px;
  max-width: min(280px, 88vw);
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 0.12s,
    transform 0.12s;
}
#al-root .rolemenu.on {
  opacity: 1;
  transform: none;
}
#al-root .rolemenu .opt {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  border-radius: 8px;
  font: 500 14px system-ui;
  color: var(--ink);
  cursor: pointer;
  min-height: 44px;
}
#al-root .rolemenu .opt:active {
  background: #efe6d0;
}
@media (hover: hover) {
  #al-root .rolemenu .opt:hover {
    background: #f1ead9;
  }
}
#al-root .rolemenu .opt .dot {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
#al-root .rolemenu .opt.clear {
  color: #9a3b2c;
  border-top: 1px solid #efe6d0;
  border-radius: 0 0 8px 8px;
  margin-top: 2px;
}
#al-root .rolemenu .opt.clear .dot {
  background: none;
  border: 1px dashed #c9b48c;
}

/* gate */
#al-root .gate {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
#al-root .gate .btn {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 12px 8px;
}

/* feedback */
#al-root .fb {
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.5;
}
#al-root .fb.good {
  background: #e7f5ee;
  border: 1px solid #9fe1cb;
  color: #0a4d3c;
}
#al-root .fb.bad {
  background: #faf1e2;
  border: 1px solid #e9d4ad;
  color: #5a5346;
}
#al-root .fb.bad b {
  color: #8a5618;
}
#al-root .cue {
  font-weight: 600;
  color: #2a4d40;
}
#al-root .cue::before {
  content: "\201C";
}
#al-root .cue::after {
  content: "\201D";
}
#al-root .nudge {
  margin-top: 10px;
  font-size: 14px;
  color: #9e3a2f;
}

/* drag ghost */
#al-root .al-ghost {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid;
  border-radius: 8px;
  padding: 8px 11px;
  font: 500 12.5px system-ui;
  box-shadow: 0 8px 16px rgba(40, 30, 15, 0.28);
  transform: rotate(-3deg);
}

/* intro / results */
#al-root .center {
  text-align: center;
}
#al-root .badge {
  display: inline-block;
  font: 500 12px system-ui;
  color: var(--teal);
  background: #e7f5ee;
  border: 1px solid #bfe6d6;
  border-radius: 20px;
  padding: 4px 12px;
}
#al-root .film {
  background: #201e18;
  border-radius: 8px;
  padding: 14px 11px 12px;
  margin-top: 10px;
  text-align: left;
  font-size: 14px;
  line-height: 2.3;
  position: relative;
  overflow: hidden;
}
#al-root .film .fsent {
  color: rgba(240, 232, 214, 0.5);
  transition: color 0.3s;
}
#al-root .film .fsent.on {
  color: #f0e8d6;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}
#al-root .film .fsent.fp.on {
  text-decoration-color: #d2a24a;
}
#al-root .film .fsent.fc.on {
  text-decoration-color: #7fd8bf;
}
#al-root .ftag {
  position: absolute;
  font: 600 9px system-ui;
  letter-spacing: 0.03em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 3;
}
#al-root .ftag.fprem {
  color: #d2a24a;
}
#al-root .ftag.fconcl {
  color: #7fd8bf;
}
#al-root .ftag .fmk {
  color: #6fcf97;
  font-size: 10px;
}
#al-root .filmline {
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  height: 2px;
  background: #2fa98a;
  opacity: 0.85;
  pointer-events: none;
}
#al-root .big-score {
  font-size: 46px;
  font-weight: bold;
  line-height: 1;
}
#al-root .review {
  text-align: left;
  font-size: 14px;
  line-height: 1.5;
  margin-top: 6px;
}
#al-root .review .row {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
#al-root .revrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  padding: 0;
}
#al-root .revbody {
  padding: 8px 0 4px;
}
#al-root .stim.revstim {
  font-size: 14px;
  line-height: 2;
  margin-bottom: 8px;
}
#al-root .resbtns {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
#al-root .resbtns .btn {
  flex: 1;
  min-width: 0;
  padding: 12px 8px;
}
#al-root .sharebtns {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}
#al-root .sharebtns .btn {
  flex: 1;
  min-width: 120px;
  padding: 12px 8px;
}
#al-root .shareimg {
  display: block;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  margin-top: 4px;
}
/* staged results reveal */
#al-root .ph {
  opacity: 0;
  transition: opacity 0.35s;
  pointer-events: none;
}
#al-root .ph.on {
  opacity: 1;
  pointer-events: auto;
}
#al-root .rstrip {
  background: #201e18;
  border-radius: 10px;
  padding: 10px 6px 8px;
  margin-top: 10px;
}
#al-root .lvlgrp {
  display: inline-block;
  margin: 0 5px;
  opacity: 0;
  transition: opacity 0.25s;
}
#al-root .lvlgrp.on {
  opacity: 1;
}
#al-root .lvlgrp .sq {
  display: block;
  font-size: 15px;
  letter-spacing: 1px;
  white-space: nowrap;
}
#al-root .lvlgrp .lb {
  display: block;
  font: 500 9px system-ui;
  color: rgba(240, 232, 214, 0.6);
  margin-top: 2px;
  letter-spacing: 0.08em;
}
#al-root .rankstamp {
  transform: scale(1.5);
  transition: transform 0.18s;
}
#al-root .rdots {
  margin-top: 8px;
  font-size: 13px;
  letter-spacing: 4px;
  color: #cdbf9a;
}
#al-root .rdots .lit {
  color: #157f73;
}
#al-root .rbarw {
  height: 6px;
  background: #eee3cb;
  border-radius: 3px;
  margin: 10px 24px 0;
  overflow: hidden;
}
#al-root .rbar {
  height: 100%;
  width: 0;
  background: #157f73;
  border-radius: 3px;
  transition: width 0.8s ease-out;
}
#al-root .rladder {
  font: 500 10px system-ui;
  color: #b4a98e;
  line-height: 1.8;
  margin-top: 8px;
}
#al-root .rladder .cur {
  color: #0e5a48;
  font-weight: 600;
  border-bottom: 2px solid #157f73;
}
#al-root textarea {
  width: 100%;
  font: 13px/1.5 system-ui;
  border: 1px solid #cdbf9a;
  border-radius: 8px;
  padding: 8px;
  background: #fffdf6;
  color: var(--ink);
  resize: none;
}
#al-root .mut {
  color: var(--muted);
  font-size: 13px;
}
#al-root .spacer {
  height: 14px;
}

@media (max-width: 380px) {
  #al-root {
    padding: 10px;
  }
  #al-root h1 {
    font-size: 25px;
  }
  #al-root .stim {
    font-size: 18px;
    line-height: 2.45;
  }
  #al-root .gate {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  #al-root .stim {
    transition: none;
  }
  #al-root .al-chunk {
    transition: none;
  }
  #al-root .tag {
    transition: none;
  }
  #al-root .ph {
    transition: none;
  }
  #al-root .lvlgrp {
    transition: none;
  }
  #al-root .rankstamp {
    transition: none;
  }
  #al-root .rbar {
    transition: none;
  }
}
