
:root{
  --bg:#0b0f17;
  --panel:#11182a;
  --panel2:#0f1526;
  --text:#e7eefc;
  --muted:#9fb0d0;
  --accent:#6aa6ff;
  --danger:#ff4d4d;
  --shadow:0 16px 40px rgba(0,0,0,.45);
  --radius:18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:var(--sans);
  background: radial-gradient(1000px 700px at 20% 10%, rgba(106,166,255,.18), transparent 55%),
              radial-gradient(900px 650px at 70% 20%, rgba(68,209,139,.12), transparent 55%),
              var(--bg);
  color:var(--text);
}

.topbar{
  display:flex;
  gap:16px;
  align-items:flex-start;
  justify-content:space-between;
  padding:18px 18px 12px;
  border-bottom:1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(10px);
  position: sticky;
  top:0;
  z-index:10;
  background: linear-gradient(to bottom, rgba(11,15,23,.95), rgba(11,15,23,.7));
}

.brand__title{
  font-weight:800;
  letter-spacing:.2px;
  font-size:18px;
}
.brand__subtitle{
  font-size:12.5px;
  color:var(--muted);
  max-width:560px;
  margin-top:4px;
}

.controls{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  align-items:flex-end;
  justify-content:flex-end;
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width: 180px;
}
.field--slider{min-width: 230px;}
.field__label{
  font-size:12px;
  color:var(--muted);
}

.select{
  background: rgba(17,24,42,.9);
  color:var(--text);
  border:1px solid rgba(255,255,255,.10);
  border-radius:12px;
  padding:10px 12px;
  outline:none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
}
.select:focus{border-color: rgba(106,166,255,.55);}

.btnRow{display:flex; gap:10px; flex-wrap:wrap; align-items:center}
.btnRow--right{justify-content:flex-end;}

.btn{
  background: rgba(255,255,255,.08);
  border:1px solid rgba(255,255,255,.10);
  color:var(--text);
  border-radius:999px;
  padding:10px 14px;
  cursor:pointer;
  transition: transform .08s ease, background .2s ease, border-color .2s ease;
  user-select:none;
}
.btn:hover{background: rgba(255,255,255,.12);}
.btn:active{transform: translateY(1px);}
.btn--primary{
  background: rgba(106,166,255,.18);
  border-color: rgba(106,166,255,.45);
}
.btn--danger{
  background: rgba(255,77,77,.16);
  border-color: rgba(255,77,77,.45);
}

.iconBtn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:40px; height:40px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color:var(--text);
  cursor:pointer;
}
.iconBtn:hover{background: rgba(255,255,255,.10);}
.icon{font-size:18px; line-height:1;}

.sliderWrap{
  display:flex;
  gap:10px;
  align-items:center;
  padding:8px 10px;
  border-radius:999px;
  background: rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.10);
}
#opacityRange{ width: 140px; }

.main{
  padding: 14px 18px 30px;
  display:flex;
  flex-direction:column;
  gap:14px;
  max-width: 1150px;
  margin: 0 auto;
}

.scoreCard{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:12px;
}
.scoreCard__item{
  background: linear-gradient(to bottom right, rgba(17,24,42,.9), rgba(15,21,38,.9));
  border:1px solid rgba(255,255,255,.10);
  border-radius: var(--radius);
  padding: 14px 14px;
  box-shadow: var(--shadow);
}
.scoreCard__label{font-size:12px; color:var(--muted);}
.scoreCard__value{font-size:18px; font-weight:800; margin-top:6px;}

.worksheet{
  background: linear-gradient(to bottom right, rgba(17,24,42,.92), rgba(15,21,38,.92));
  border:1px solid rgba(255,255,255,.10);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.worksheet__head{display:flex; flex-direction:column; gap:6px; padding: 6px 6px 10px;}
.worksheet__title{margin:0; font-size:18px; letter-spacing:.1px;}
.worksheet__help{margin:0; color:var(--muted); font-size:12.5px; line-height:1.35; max-width: 920px;}

.traceWrap{
  position:relative;
  border-radius: 16px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
}

.guide{
  padding: 14px 14px;
  min-height: 420px;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(231,238,252,.18);
}

.writer{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  padding: 14px 14px;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.65;
  border:0;
  outline:none;
  resize:none;
  background: transparent;
  color: var(--text);
  caret-color: var(--accent);
}

.wrongOverlay{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  z-index:9999;
  background: rgba(0,0,0,.20);
}
.wrongOverlay.show{display:flex;}
.wrongOverlay__x{
  font-size: 110px;
  font-weight: 900;
  color: var(--danger);
  text-shadow: 0 12px 40px rgba(0,0,0,.55);
  transform: rotate(-6deg);
}

.modal{
  position:fixed;
  inset:0;
  display:none;
  z-index:9998;
}
.modal.show{display:block;}
.modal__backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.55);
}
.modal__card{
  position:relative;
  max-width: 560px;
  margin: 8vh auto;
  background: linear-gradient(to bottom right, rgba(17,24,42,.96), rgba(15,21,38,.96));
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow:hidden;
}
.modal__card--wide{ max-width: 960px; }
.modal__header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 12px 12px;
  border-bottom:1px solid rgba(255,255,255,.08);
}
.modal__title{font-weight:900;}
.modal__body{padding: 12px 12px 14px;}

.mcqPrompt{
  padding:10px 10px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
  color: var(--text);
  font-size: 13.5px;
  margin-bottom: 10px;
}
.mcqGrid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mcqOpt{
  text-align:left;
  padding: 12px 12px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  cursor:pointer;
  transition: background .2s ease, border-color .2s ease, transform .08s ease;
  color: var(--text);
}
.mcqOpt:hover{background: rgba(255,255,255,.10);}
.mcqOpt:active{transform: translateY(1px);}
.mcqOpt small{display:block; color: var(--muted); font-size: 11px; margin-top: 2px;}

.mcqHint{margin-top:10px; color:var(--muted); font-size:12px; line-height:1.35;}

.small{color:var(--muted); font-size:12.5px; margin: 0 0 10px; line-height:1.35;}
.jsonBox{
  width:100%;
  min-height: 340px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
  color: var(--text);
  padding: 12px 12px;
  outline:none;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
}
.error{margin-top:10px; color: var(--danger); font-size:12.5px;}

@media (max-width: 820px){
  .scoreCard{grid-template-columns:1fr; }
  .field{min-width: 150px;}
  .field--slider{min-width: 200px;}
  .brand__subtitle{max-width: 320px;}
  .modal__card{margin: 10vh 12px;}
  .modal__card--wide{margin: 8vh 12px;}
}

/* === ADD DIALOGUE MODAL STYLES (SCOPED) === */
/* These styles ONLY affect the Add Dialogue modal (#addModal) and mobile layout. */

/* Add Dialogue overlay */
#addModal{
  position: fixed;
  inset: 0;
  display: none;               /* openModal() adds .show */
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9998;
}
#addModal.show{ display:flex; }

/* Reuse existing backdrop class but keep it behind the card */
#addModal .modal__backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(10px);
  z-index: 1;
}

/* The card */
#addModal .dialogueModal{
  position: relative;
  z-index: 2;
  width: min(920px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: 28px;
  border: 1px solid rgba(255,255,255,.10);
  background: linear-gradient(180deg, rgba(18,22,52,.90), rgba(0,0,0,.62));
  box-shadow: 0 32px 110px rgba(0,0,0,.60);
}

/* Header */
#addModal .dialogueHead{
  padding: 18px 18px 10px;
}
#addModal .dialogueHead h3{
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.02em;
}
#addModal .dialogueHead p{
  margin: 0;
  color: rgba(231,238,252,.75);
  font-size: 14px;
  line-height: 1.45;
}

/* Form spacing */
#addModal .dialogueForm{
  padding: 0 18px 18px;
  display: grid;
  gap: 14px;
}

/* Labels */
#addModal .fieldLabel{
  color: rgba(231,238,252,.72);
  font-size: 13px;
}

/* Inputs */
#addModal .fieldInput,
#addModal .fieldText{
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.05);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.22);
}
#addModal .fieldInput:focus,
#addModal .fieldText:focus{
  border-color: rgba(106,166,255,.55);
  box-shadow: 0 0 0 3px rgba(106,166,255,.18);
}
#addModal .fieldText{
  min-height: 260px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 14.5px;
  line-height: 1.55;
}
#addModal .fieldInput::placeholder,
#addModal .fieldText::placeholder{
  color: rgba(231,238,252,.40);
}

/* Auto blanks panel */
#addModal .autoBlanks{
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.22);
  padding: 14px;
  display: grid;
  gap: 12px;
}

#addModal .autoRow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
#addModal .autoTitle{
  font-weight: 900;
  font-size: 18px;
  letter-spacing: -0.01em;
}

#addModal .densityRow{
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
#addModal .densityLeft{ flex: 1 1 240px; }
#addModal .densityTitle{ font-weight: 900; font-size: 16px; margin-bottom: 2px; }
#addModal .densitySub{ color: rgba(231,238,252,.72); font-size: 13px; }

#addModal #densitySlider{
  flex: 2 1 320px;
  height: 24px;
  accent-color: var(--accent);
}

/* Tip text */
#addModal .autoTip{
  color: rgba(231,238,252,.72);
  font-size: 12.5px;
  line-height: 1.35;
}

/* Toggle switch (scoped) */
#addModal .switch{
  position: relative;
  width: 56px;
  height: 32px;
  display: inline-block;
}
#addModal .switch input{ opacity: 0; width: 0; height: 0; }
#addModal .switch .slider{
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.18);
  transition: .18s;
  cursor: pointer;
}
#addModal .switch .slider:before{
  content: "";
  position: absolute;
  width: 24px; height: 24px;
  left: 4px; top: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,.70));
  transition: .18s;
}
#addModal .switch input:checked + .slider{
  background: rgba(106,166,255,.45);
  border-color: rgba(106,166,255,.55);
}
#addModal .switch input:checked + .slider:before{
  transform: translateX(24px);
}

/* Error line */
#addModal .errorText{
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

/* Action buttons (ONLY inside Add Modal) */
#addModal .dialogueActions{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 6px;
}
#addModal .btn.secondary{
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
}
#addModal .btn.primary{
  background: rgba(106,166,255,.22);
  border: 1px solid rgba(106,166,255,.50);
}

/* Mobile layout: keep EVERYTHING inside the phone width (no sideways scrolling) */
@media (max-width: 560px){
  .topbar{
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .controls{
    justify-content: flex-start;
  }
  .controls .field,
  .controls .field--slider{
    min-width: 0;
    width: 100%;
  }
  .select{ width: 100%; }

  .btnRow{
    width: 100%;
  }
  .btnRow .btn{
    flex: 1 1 auto;
    width: 100%;
    text-align: center;
  }

  .main{ padding: 12px 12px 26px; }
  .guide, .writer{ font-size: 14px; }
  .traceWrap{ border-radius: 14px; }
  .guide{ min-height: 380px; }
  #opacityRange{ width: 100%; }
  .sliderWrap{ width: 100%; justify-content: space-between; }
  .modal__card{ margin: 10vh 12px; }
  /* Add modal tighter spacing on phones */
  #addModal{ padding: 12px; }
  #addModal .dialogueHead h3{ font-size: 22px; }
  #addModal .dialogueModal{ border-radius: 22px; }
  #addModal .dialogueHead,
  #addModal .dialogueForm{ padding-left: 14px; padding-right: 14px; }
  #addModal .fieldText{ min-height: 210px; }
}
/* === END ADD DIALOGUE MODAL STYLES === */


/* === On-screen language keyboard (French/Spanish) === */
.vkWrap{
  background: linear-gradient(to bottom right, rgba(17,24,42,.92), rgba(15,21,38,.92));
  border:1px solid rgba(255,255,255,.10);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.vkHead{display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;}
.vkTitle{font-weight:900; font-size:13px;}
.vkHint{font-size:12px; color: var(--muted);}
.vkRows{display:flex; flex-direction:column; gap:8px;}
.vkRow{display:flex; flex-wrap:wrap; gap:8px;}
.vkKey{
  background: rgba(255,255,255,.07);
  border:1px solid rgba(255,255,255,.12);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  cursor:pointer;
  user-select:none;
  min-width: 44px;
  text-align:center;
  font-family: var(--mono);
  font-size: 14px;
}
.vkKey:hover{background: rgba(255,255,255,.12);}
.vkKey:active{transform: translateY(1px);}
.vkKey--wide{min-width: 92px;}
.vkKey--xl{min-width: 160px;}
@media (max-width: 520px){
  .vkKey{padding: 10px 10px; min-width: 40px;}
  .vkKey--xl{min-width: 130px;}
}


/* === Dictation modal textarea === */
.dictBox{
  width:100%;
  min-height: 140px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
  color: var(--text);
  padding: 12px 12px;
  outline:none;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
}
