/* ==========================================================
   Erpli Wave — Maths suite
   App shell (exam maker) + printable paper + maths hub.
   Brand: coral #f28482, navy #3d405b, cream #fffbf5.
   ========================================================== */

:root {
  --coral: #e8615c;
  --coral-soft: #fdeceb;
  --navy: #1f2438;
  --cream: #faf7f0;
  --ink: #1f2438;
  --muted: #7a7f95;
  --line: #ece6df;
  --line-soft: #f4efe9;
  --surface: #ffffff;
  --stage: #ece7e1;
  --accent: #e8615c;
  --ring: 0 0 0 3px rgba(232, 97, 92, 0.28);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* scoped for erpli.com */
.ex-app, .ex-app *, .ex-modal, .ex-modal * { box-sizing: border-box; }
.ex-app { font-family: var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; }
.ex-app button { font: inherit; cursor: pointer; }
.ex-app :focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ==========================================================
   App shell
   ========================================================== */
.ex-app { display: flex; flex-direction: column; height: calc(100vh - 96px); min-height: 640px; background: var(--cream); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; box-shadow: 0 1px 2px rgba(31,36,56,.05), 0 16px 40px rgba(31,36,56,.08); }

.ex-appbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  z-index: 5;
}

.ex-home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  color: var(--navy);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid var(--line);
  transition: background 0.18s, border-color 0.18s;
}
.ex-home:hover { background: var(--coral-soft); border-color: var(--coral); }
.ex-home img { height: 20px; width: auto; display: block; }

.ex-appbar-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.ex-appbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ex-count { font-size: 12.5px; color: var(--muted); font-weight: 600; }

.ex-ghost, .ex-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.ex-ghost { background: var(--surface); color: var(--navy); border: 1px solid var(--line); }
.ex-ghost:hover { border-color: var(--coral); color: var(--coral); }
.ex-primary {
  background: var(--coral);
  color: #fff;
  border: 1px solid var(--coral);
  box-shadow: 0 4px 14px rgba(242, 132, 130, 0.36);
}
.ex-primary:hover { background: #e97472; border-color: #e97472; }

.ex-body { flex: 1 1 auto; display: flex; min-height: 0; }

/* ---------- sidebar ---------- */
.ex-side {
  flex: 0 0 320px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ex-tabs {
  display: flex;
  padding: 8px 8px 0;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.ex-tab {
  flex: 1;
  padding: 10px 6px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  transition: color 0.18s, border-color 0.18s;
}
.ex-tab:hover { color: var(--navy); }
.ex-tab[aria-selected="true"] { color: var(--coral); border-bottom-color: var(--coral); }

.ex-pane { padding: 4px 16px 28px; overflow-y: auto; flex: 1 1 auto; }

.ex-block { padding: 14px 0; border-bottom: 1px dashed var(--line); }
.ex-block:last-child { border-bottom: none; }

.ex-label {
  display: block;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
.ex-block .ex-label + .ex-row + .ex-label { margin-top: 14px; }
.ex-note { font-size: 12px; line-height: 1.5; color: var(--muted); margin: 8px 0 0; }

/* segmented control */
.ex-seg {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--line-soft);
  border-radius: 11px;
}
.seg {
  padding: 9px 6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.seg:hover { color: var(--navy); }
.seg[aria-pressed="true"] {
  background: var(--surface);
  color: var(--coral);
  box-shadow: 0 1px 4px rgba(61, 64, 91, 0.12);
}

/* chips */
.ex-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 8px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.chip:hover { border-color: var(--coral); }
.chip[aria-pressed="true"] { background: var(--coral); border-color: var(--coral); color: #fff; }

/* inputs */
.ex-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ex-row label, .ex-field {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.ex-field { margin-bottom: 12px; }

.ex-side input[type="text"],
.ex-side input[type="number"],
.ex-side select {
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 9px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.ex-side input:focus, .ex-side select:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: var(--ring);
}

.ex-switch {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
}
.ex-switch input { width: 17px; height: 17px; margin: 0; accent-color: var(--coral); }

/* templates */
.ex-templates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tpl {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy);
  transition: border-color 0.18s, background 0.18s;
}
.tpl:hover { border-color: var(--coral); }
.tpl[aria-pressed="true"] { border-color: var(--coral); background: var(--coral-soft); }
.tpl-art {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  height: 42px;
  padding: 4px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line-soft);
}
.tpl-art i { display: block; border-radius: 2px; }
.tpl-art-classic i { border: 1px solid var(--navy); }
.tpl-art-minimal i { border-bottom: 1.5px solid var(--navy); }
.tpl-art-grid i { border: 1px solid var(--navy); background: repeating-linear-gradient(to bottom, transparent 0 4px, var(--line) 4px 5px); }
.tpl-art-cards i { background: var(--coral-soft); border: 1px solid var(--coral); }

/* logo + swatches */
.ex-logo { display: flex; align-items: center; gap: 10px; }
.ex-file {
  display: inline-block;
  padding: 9px 14px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s;
}
.ex-file:hover { border-color: var(--coral); color: var(--coral); }
.ex-file input { display: none; }
#logoThumb { max-height: 36px; max-width: 90px; object-fit: contain; }
.ex-linkbtn {
  border: none;
  background: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: underline;
}

.ex-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--sw);
  border: 2px solid transparent;
  box-shadow: 0 0 0 1.5px var(--line);
  transition: box-shadow 0.18s, transform 0.18s;
}
.sw:hover { transform: scale(1.08); }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--sw); }

/* ---------- stage ---------- */
.ex-stage {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  background: var(--stage);
  padding: 24px;
}
.ex-paper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

@media (max-width: 900px) {
  .ex-app { height: auto; }
  .ex-body { flex-direction: column; }
  .ex-side { flex: 0 0 auto; border-right: none; border-bottom: 1px solid var(--line); }
  .ex-pane { max-height: none; }
  .ex-stage { padding: 16px; }
}


/* ---------- question type selector + generated option fields ---------- */
.ex-typebar { display: grid; gap: 8px; }
.ex-typebar select { width: 100%; }
.ex-browse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 12px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy);
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.ex-browse:hover { border-color: var(--coral); color: var(--coral); background: var(--coral-soft); }

.ex-blurb { font-size: 12.5px; line-height: 1.5; color: var(--muted); margin: 8px 0 0; }

.ex-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ex-fieldrow { display: block; margin-bottom: 8px; }
.ex-fieldrow > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}
.ex-fieldrow input, .ex-fieldrow select { width: 100%; margin-top: 0; }

body.ex-locked { overflow: hidden; }

/* dropdowns sit in half-width columns — never let a long option clip */
.ex-fieldrow select { text-overflow: ellipsis; }
.ex-grid2 > .ex-fieldrow { min-width: 0; }
