/* ------------------------------------------------------------------
   CEEU - Bootstrap-based soft theme (primary #D3DAD9)
   Mobile first. Custom CSS only complements Bootstrap components.
------------------------------------------------------------------- */
:root {
  --blue: #D3DAD9;
  --blue-soft: #B9C5C2;
  --blue-mist: #E1E7E6;
  --blue-pale: #F1F4F3;
  --bg: #ECF0EF;
  --card: #FFFFFF;
  --ink: #2A2B33;
  --ink-soft: #6C6D79;
  --line: #DCDFDE;
  --ok-ink: #2E8B57;
  --ok-bg: #DFF5E9;
  --warn-ink: #A06A15;
  --warn-bg: #FBEED6;
  --danger-ink: #B6513C;
  --danger-bg: #FBE3DC;
  --shadow: 0 8px 24px rgba(45, 50, 49, 0.12);
  --radius: 16px;
}

html, body { height: 100%; }

body.ceeu-body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------ flat ambient background motion */
.bgfx {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.bgfx i {
  position: absolute;
  bottom: -32px;
  display: block;
  border-radius: var(--b-shape, 50%);
  background: var(--b-sub, rgba(169, 211, 242, 0.5));
  opacity: 0;
  animation: bgFloat var(--b-dur, 26s) linear infinite;
  animation-delay: var(--b-del, 0s);
}
@keyframes bgFloat {
  0%   { transform: translate3d(0, 0, 0); opacity: 0; }
  8%   { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translate3d(var(--b-drift, 30px), -120vh, 0); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .bgfx i { animation: none; opacity: 0; }
}

/* ------------------------------------------------------------ Bootstrap theme overrides */
.btn-primary {
  --bs-btn-color: #26272E;
  --bs-btn-hover-color: #26272E;
  --bs-btn-active-color: #1F2026;
  --bs-btn-bg: var(--blue);
  --bs-btn-border-color: var(--blue);
  --bs-btn-hover-bg: #C2CDCA;
  --bs-btn-hover-border-color: #C2CDCA;
  --bs-btn-active-bg: #B4C0BD;
  --bs-btn-active-border-color: #B4C0BD;
  --bs-btn-focus-shadow-rgb: 211, 218, 217;
}
.btn-outline-primary {
  --bs-btn-color: #56576B;
  --bs-btn-border-color: var(--blue-soft);
  --bs-btn-hover-bg: var(--blue-pale);
  --bs-btn-hover-color: var(--ink);
  --bs-btn-hover-border-color: var(--blue);
  --bs-btn-active-bg: var(--blue-mist);
  --bs-btn-active-color: var(--ink);
  --bs-btn-active-border-color: var(--blue);
}
.btn-soft {
  background: var(--blue-pale);
  color: #56576B;
  border: 1px solid var(--blue-mist);
}
.btn-soft:hover, .btn-soft:focus {
  background: var(--blue-mist);
  color: #4A4B5C;
}
.btn-danger-soft {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border: 1px solid #F3CBC3;
}
.btn-danger-soft:hover, .btn-danger-soft:focus {
  background: #F6CDC4;
  color: var(--danger-ink);
}

.form-control, .form-select {
  border-color: var(--line);
  background-color: #FBFDFF;
  color: var(--ink);
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 0.25rem rgba(57, 54, 70, 0.18);
}
.form-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(57, 54, 70, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  background: var(--card);
}
.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.badge-soft {
  background: var(--blue-pale);
  color: #56576B;
  font-weight: 600;
}
.badge-ok    { background: var(--ok-bg);   color: var(--ok-ink); }
.badge-warn  { background: var(--warn-bg); color: var(--warn-ink); }
.badge-bad   { background: var(--danger-bg); color: var(--danger-ink); }

.text-muted { color: var(--ink-soft) !important; }

/* ------------------------------------------------------------ layout / nav */
.wrap {
  max-width: 1020px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 64px max(14px, env(safe-area-inset-left));
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  cursor: pointer;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--blue);
  color: #26272E;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 10px rgba(57, 54, 70, 0.35);
}
.brand-mark-admin { background: #55586B; color: #fff; }
.brand-text {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1;
}
.brand-text small {
  display: block;
  font-size: 0.56rem;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 1.6px;
  margin-top: 3px;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--blue-pale);
  color: #56576B;
  border: 1px solid var(--blue-mist);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
}
.pill .pdot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
}

/* ------------------------------------------------------------ hero & role cards */
.hero { text-align: center; padding: 28px 6px 30px; }
.hero h1 { font-weight: 800; font-size: clamp(1.7rem, 6vw, 2.6rem); letter-spacing: 0.3px; }
.hero .hl {
  background: #56576B;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { color: var(--ink-soft); font-size: 1rem; margin: 10px auto 0; max-width: 560px; line-height: 1.6; }

.role-card { cursor: pointer; padding: 1.5rem; height: 100%; }
.role-card .role-ico {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  color: #56576B;
  background: var(--blue-pale);
  border: 1px solid var(--blue-mist);
}
.role-card h3 { font-size: 1.2rem; font-weight: 700; }
.role-card p { color: var(--ink-soft); font-size: 0.9rem; line-height: 1.55; margin: 0; }

/* ------------------------------------------------------------ components */
.banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--blue-mist);
  border: 1px solid var(--blue-soft);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  margin: 0.6rem 0;
  font-size: 0.9rem;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}
.section-sub { color: var(--ink-soft); font-size: 0.85rem; margin-bottom: 1rem; }

.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
  background: var(--blue-pale);
  border-radius: 8px;
  padding: 2px 8px;
  font-weight: 700;
  color: #56576B;
  letter-spacing: 1px;
}
.token-big {
  font-family: "Cascadia Mono", Consolas, monospace;
  letter-spacing: 3px;
  font-size: 1.3rem;
  font-weight: 700;
  color: #56576B;
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid var(--blue-mist);
  border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--ink-soft);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
}
.empty .big { font-size: 1.6rem; margin-bottom: 0.4rem; display: block; }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin: 1.25rem 0 1rem; overflow-x: auto; }
.tabs button {
  border: none;
  background: none;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.tabs button.active { color: #56576B; border-color: var(--blue); }

.stat-badge {
  text-align: center;
  background: var(--blue-pale);
  border: 1px solid var(--blue-mist);
  border-radius: var(--radius);
  padding: 1.1rem 0.8rem;
  height: 100%;
}
.stat-badge .n { font-size: 1.7rem; font-weight: 800; color: #56576B; line-height: 1.15; }
.stat-badge .l { font-size: 0.72rem; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

.track-bar { height: 8px; background: var(--blue-pale); border-radius: 999px; overflow: hidden; }
.track-bar > span { display: block; height: 100%; background: var(--blue); border-radius: 999px; transition: width 0.6s cubic-bezier(0.2, 0.9, 0.3, 1); }

code.block {
  display: block;
  background: var(--blue-pale);
  border: 1px dashed var(--blue-soft);
  padding: 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  color: var(--ink);
}

/* switch (checkbox emulation) */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--line);
  transition: 0.25s;
  cursor: pointer;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  left: 3px; top: 3px;
  transition: 0.25s;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}
.switch input:checked + .slider { background: var(--blue); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ------------------------------------------------------------ modals & toasts */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(46, 64, 83, 0.45);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 14px;
  z-index: 1050;
  animation: fadeIn 0.2s ease both;
}
.ce-modal {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow: auto;
  padding: 1.3rem;
  animation: popIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.ce-close {
  border: none;
  background: var(--blue-pale);
  color: #56576B;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s, transform 0.2s;
}
.ce-close:hover { background: var(--blue-mist); transform: rotate(90deg); }

#toasts {
  position: fixed;
  top: 14px;
  right: 14px;
  left: 14px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 360px;
  margin-left: auto;
}
.toast {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  box-shadow: var(--shadow);
  animation: fadeUp 0.35s ease both;
  font-size: 0.9rem;
  color: var(--ink);
}
.toast.err { border-left-color: var(--danger-ink); }
.toast.ok  { border-left-color: var(--ok-ink); }
.toast.warn { border-left-color: var(--warn-ink); }
.toast i { font-size: 1.05rem; margin-top: 1px; }

/* ------------------------------------------------------------ pin pad */
.pin-dots { display: flex; gap: 1rem; justify-content: center; margin: 1.1rem 0 0.3rem; }
.pin-dots i {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--blue-soft);
  background: transparent;
  transition: background 0.15s, transform 0.15s;
  font-style: normal;
}
.pin-dots i.filled { background: var(--blue); border-color: var(--blue); transform: scale(1.15); }
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  max-width: 240px;
  margin: 1rem auto 0;
}
.pin-pad button {
  height: 62px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(57, 54, 70, 0.12);
}
.pin-pad button:active { transform: scale(0.92); background: var(--blue-pale); border-color: var(--blue-soft); }
.pin-pad button.pin-action { background: var(--blue-pale); color: #56576B; }

/* ------------------------------------------------------------ answer tracking zone */
.answer-area {
  border: 1.5px dashed var(--blue-soft);
  border-radius: 14px;
  padding: 1rem;
  background: var(--blue-pale);
  margin: 0.75rem 0;
}
.answer-area .lock-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: #56576B;
  margin-bottom: 0.65rem;
  font-weight: 600;
}
.answer-track {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  border-top: 1px dashed var(--blue-soft);
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.rich-answer { font-size: 12px; line-height: 1.55; color: var(--ink); }
.rich-answer p:last-child, .rich-answer ul:last-child, .rich-answer ol:last-child { margin-bottom: 0; }
.note-editor { border-color: rgba(57, 54, 70, 0.4) !important; border-radius: 12px !important; }
.note-editor .note-toolbar { border-radius: 12px 12px 0 0 !important; background: var(--blue-pale) !important; }
.note-editor .note-editing-area .note-editable {
  background: #fff !important;
  border-radius: 0 0 12px 12px;
  font-size: 12px !important;
  padding: 0.7rem 0.8rem;
}
.note-editor .note-editable p { margin-bottom: 0.4rem; }

/* ------------------------------------------------------------ maintenance */
.maintenance-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 20px;
}
.maintenance-overlay .box {
  background: #fff;
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 2.4rem;
  max-width: 460px;
  width: 100%;
  animation: popIn 0.4s ease both;
}
.maintenance-overlay .box .ico {
  width: 74px;
  height: 74px;
  border-radius: 22px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  display: grid;
  place-items: center;
  font-size: 2rem;
  margin: 0 auto 1rem;
}

/* ------------------------------------------------------------ animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes popIn {
  0%   { opacity: 0; transform: scale(0.94); }
  60%  { transform: scale(1.01); }
  100% { opacity: 1; transform: scale(1); }
}
.anim-fadeUp { animation: fadeUp 0.45s ease both; }
.anim-fadeIn { animation: fadeIn 0.35s ease both; }
.anim-popIn  { animation: popIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
.d1 { animation-delay: 0.05s; }
.d2 { animation-delay: 0.1s; }
.d3 { animation-delay: 0.16s; }
.d4 { animation-delay: 0.22s; }
.d5 { animation-delay: 0.28s; }

.space { margin-top: 1rem; }

.hidden { display: none !important; }

@media (min-width: 768px) {
  .wrap { padding: 22px 26px 70px; }
  #toasts { left: auto; }
}

/* ------------------------------------------------------------ PWA install gate */
.install-gate {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 22px;
}
.install-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 1.6rem;
  text-align: center;
  animation: popIn 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.install-ico {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  background: var(--blue);
  color: #26272E;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: 1px;
  margin: 0 auto 1rem;
  box-shadow: 0 6px 18px rgba(57, 54, 70, 0.18);
}
.install-steps {
  text-align: left;
  background: var(--blue-pale);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  font-size: 0.85rem;
  color: var(--ink);
}
.install-steps li { margin-left: 0.25rem; padding: 0.2rem 0; }

/* ------------------------------------------------------------ PWA / device polish */
html { scroll-behavior: smooth; }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button:not(.note-btn), a, input, select, textarea { touch-action: manipulation; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }