/* =============================================================
   TQRV - Tranquillity Remote Viewing
   Design: military / parapsychological. Deep purple-charcoal,
   violet light, teal accent (from the logo). Modern, simple,
   mobile-first.
   ============================================================= */

:root {
  --bg:        #0e0a16;
  --bg-2:      #161122;
  --bg-3:      #1f1733;
  --bg-4:      #281e42;
  --line:      #322851;
  --line-2:    #463a6e;

  --purple:        #8b5cf6;
  --purple-bright: #a78bfa;
  --purple-deep:   #6d28d9;
  --teal:          #2bb3bd;
  --teal-bright:   #54d4dd;
  --danger:        #e0556b;
  --ok:            #3ecf8e;

  --text:      #ece9f5;
  --text-dim:  #9c93b8;
  --text-faint:#6c6388;

  --radius:    14px;
  --radius-sm: 9px;
  --maxw:      540px;

  --mono: 'Chakra Petch', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: 'Chakra Petch', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* faint psi-grid texture */
  background-image:
    radial-gradient(circle at 50% -10%, rgba(139,92,246,0.16), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(43,179,189,0.08), transparent 45%);
  background-attachment: fixed;
}

#app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

a { color: var(--purple-bright); text-decoration: none; }

/* ---- TOPBAR --------------------------------------------------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(14,10,22,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
#brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-family: var(--sans);
}
#brand img { width: 30px; height: 30px; object-fit: contain; flex: none; }
.brandtxt {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.2;
}
.iconbtn {
  width: 40px; height: 40px;
  flex: none;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.iconbtn:active { background: var(--bg-3); }

/* ---- SLIDE-OUT MENU ------------------------------------------ */
#menu { position: fixed; inset: 0; z-index: 50; }
.menu-scrim { position: absolute; inset: 0; background: rgba(6,4,12,0.7); z-index: 1; }
.menu-panel {
  position: absolute;
  z-index: 2;
  top: 0; right: 0; bottom: 0;
  width: min(78%, 320px);
  background: var(--bg-2);
  border-left: 1px solid var(--line-2);
  padding: calc(20px + env(safe-area-inset-top)) 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.menu-acct {
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 8px;
  word-break: break-all;
}
.menu-panel a, .menu-panel button {
  display: block;
  text-align: left;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: var(--sans);
  letter-spacing: 0.03em;
  background: none;
  border: none;
  cursor: pointer;
}
.menu-panel a:active, .menu-panel button:active { background: var(--bg-3); }
#signout { color: var(--danger); margin-top: 6px; border-top: 1px solid var(--line); }
.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 10px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 15px;
  letter-spacing: 0.03em;
}

/* ---- VIEW / LAYOUT ------------------------------------------- */
#view {
  flex: 1;
  padding: 18px 16px 28px;
}
.stack > * + * { margin-top: 14px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--teal-bright);
}
h1.page {
  font-family: var(--sans);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 4px 0 2px;
}
.lead { color: var(--text-dim); font-size: 14.5px; }

/* ---- CARDS ---------------------------------------------------- */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card.glow {
  border-color: var(--line-2);
  box-shadow: 0 0 0 1px rgba(139,92,246,0.08), 0 14px 34px -20px rgba(139,92,246,0.5);
}
.tile {
  display: block;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text);
  position: relative;
  overflow: hidden;
}
.tile:active { background: var(--bg-3); }
.tile .tile-k {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.24em;
  color: var(--teal-bright);
  text-transform: uppercase;
}
.tile .tile-t {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  margin-top: 3px;
}
.tile .tile-d { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.tile.live::after {
  content: 'LIVE';
  position: absolute; top: 12px; right: 12px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.18em;
  color: var(--ok);
  border: 1px solid rgba(62,207,142,0.4);
  border-radius: 5px; padding: 2px 6px;
}
.tile.soon::after {
  content: 'SOON';
  position: absolute; top: 12px; right: 12px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.18em;
  color: var(--text-faint);
  border: 1px solid var(--line-2);
  border-radius: 5px; padding: 2px 6px;
}
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr 1fr; }

/* ---- BUTTONS -------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
  border-color: var(--purple-bright);
}
.btn-primary:active { filter: brightness(0.92); }
.btn-ghost {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--line-2);
}
.btn-ghost:active { background: var(--bg-3); }
.btn-danger { background: var(--bg-2); color: var(--danger); border-color: rgba(224,85,107,0.4); }
.btn-subtle { background: var(--bg); color: var(--text-faint); border-color: var(--line); font-weight: 500; }
.btn-subtle:active { background: var(--bg-2); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---- LANDING -------------------------------------------------- */
.landing {
  text-align: center;
  padding-top: 8px;
}
.landing .banner {
  width: 100%;
  display: block;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  margin: 0 auto 6px;
}
.landing .crest { width: 132px; height: 64px; object-fit: contain; margin: 8px auto 0; display: block; }

/* Remote Viewing course page: the cosmic-eye image as a faded,
   full-bleed background. Scoped to this view, an asset specific
   to the remote viewing area of the Academy. */
.course-bg::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url('../img/banner.jpg') center top / cover no-repeat;
  opacity: 0.16;
  z-index: -1;
  pointer-events: none;
}
:root[data-theme="light"] .course-bg::before { opacity: 0.2; }
.landing h1 {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.16em;
}
.landing .tagline {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.34em;
  color: var(--teal-bright);
  text-transform: uppercase;
  margin-top: 4px;
}
.portal {
  text-align: left;
  display: block;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
  margin-top: 14px;
  position: relative;
}
.portal:active { background: var(--bg-3); }
.portal .p-k {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.24em;
  color: var(--teal-bright); text-transform: uppercase;
}
.portal .p-t { font-family: var(--sans); font-size: 20px; font-weight: 600; margin-top: 4px; }
.portal .p-d { color: var(--text-dim); font-size: 13.5px; margin-top: 5px; }
.portal .p-go { color: var(--purple-bright); font-size: 22px; position: absolute; right: 18px; top: 50%; transform: translateY(-50%); }
.portal.soon { opacity: 0.6; }
.portal.soon:active { background: var(--bg-2); }
.course-badge {
  position: absolute; right: 16px; top: 16px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-faint);
  border: 1px solid var(--line-2); border-radius: 5px; padding: 3px 7px;
}

/* ---- FORMS ---------------------------------------------------- */
label.fld { display: block; }
label.fld .lbl {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-dim);
}
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%;
  margin-top: 6px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  padding: 12px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--purple); }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.hint { font-size: 12.5px; color: var(--text-faint); margin-top: 6px; }

/* range */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 30px; background: transparent;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px; background: var(--line-2);
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line-2); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--purple-bright); margin-top: -7px;
  border: 2px solid var(--bg);
}
input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--purple-bright); border: 2px solid var(--bg);
}

/* toggle */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { position: relative; width: 50px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--bg-4); border: 1px solid var(--line-2); transition: background .15s;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-dim); transition: transform .15s, background .15s;
}
.switch input:checked + .track { background: var(--purple-deep); border-color: var(--purple); }
.switch input:checked + .track::after { transform: translateX(22px); background: #fff; }

/* ---- BATCH CARDS --------------------------------------------- */
.batch {
  display: block;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text);
}
.batch:active { background: var(--bg-3); }
.batch .b-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.batch .b-name { font-family: var(--sans); font-size: 18px; font-weight: 600; }
.batch .b-count { font-family: var(--mono); font-size: 12px; color: var(--teal-bright); }
.batch .b-desc { color: var(--text-dim); font-size: 13px; margin-top: 5px; }
.progress {
  height: 6px; border-radius: 6px; background: var(--bg-4);
  margin-top: 12px; overflow: hidden;
}
.progress > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--purple));
}
.progress-label { font-family: var(--mono); font-size: 11px; color: var(--text-faint); margin-top: 6px; }

/* ---- TAG / SLOT MACHINE -------------------------------------- */
.viewer { text-align: center; }
.tag-frame {
  display: inline-flex;
  gap: 8px;
  padding: 18px 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  box-shadow: inset 0 0 32px -14px rgba(139,92,246,0.7);
  position: relative;
}
.tag-frame::before, .tag-frame::after {
  content: ''; position: absolute; width: 12px; height: 12px;
  border: 2px solid var(--teal); top: -1px;
}
.tag-frame::before { left: -1px; border-right: none; border-bottom: none; }
.tag-frame::after  { right: -1px; border-left: none; border-bottom: none; }
.reel {
  width: 52px; height: 76px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  position: relative;
}
.reel-strip {
  display: flex;
  flex-direction: column;
  will-change: transform;
}
.reel-strip span {
  height: 76px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 44px;
  font-weight: 700;
  color: var(--purple-bright);
  text-shadow: 0 0 16px rgba(167,139,250,0.55);
}
.reel.locked .reel-strip span { color: var(--text); }
.tag-caption {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.24em;
  color: var(--text-dim); text-transform: uppercase; margin-top: 10px;
}

/* concealed target panel */
.conceal {
  margin-top: 16px;
  aspect-ratio: 4 / 3;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(45deg, var(--bg-2) 0 14px, var(--bg-3) 14px 28px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: var(--text-faint);
}
.conceal .lock-ico { font-size: 30px; }
.conceal .lock-tx { font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; }

/* timer */
.timer {
  font-family: var(--mono);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}
.timer.warn { color: var(--teal-bright); }
.timer.done { color: var(--danger); }
.timer-sub { font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; color: var(--text-faint); text-transform: uppercase; }

/* hold to reveal */
.hold-btn {
  position: relative;
  width: 100%;
  padding: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--purple-bright);
  background: var(--bg-3);
  color: #fff;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}
.hold-btn .fill {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  transform: scaleX(0); transform-origin: left;
  z-index: 0;
}
.hold-btn .fill.armed { transition: transform linear; }
.hold-btn span { position: relative; z-index: 1; }

/* reveal image */
.reveal-img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  display: block;
}
.reveal-cap {
  font-family: var(--sans); font-size: 21px; font-weight: 600; margin-top: 12px;
}
.reveal-cat {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.22em;
  color: var(--teal-bright); text-transform: uppercase;
}
.reveal-desc { color: var(--text-dim); font-size: 14.5px; margin-top: 6px; }

/* confidence */
.conf-row { display: flex; gap: 8px; }
.conf-row button {
  flex: 1;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}
.conf-row button[aria-pressed=true] {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff; border-color: var(--purple-bright);
}
.conf-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-faint); font-family: var(--mono); letter-spacing: 0.08em; }

/* ---- NOTEBOOK / LISTS ---------------------------------------- */
.note-entry {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.note-entry .ne-top { display: flex; justify-content: space-between; gap: 10px; }
.note-entry .ne-tag { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--purple-bright); }
.note-entry .ne-date { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.note-entry .ne-cap { font-size: 13.5px; color: var(--text-dim); margin-top: 2px; }
.note-entry .ne-body { font-size: 14px; margin-top: 8px; white-space: pre-wrap; }
.note-entry .ne-conf { font-family: var(--mono); font-size: 11px; color: var(--teal-bright); margin-top: 8px; letter-spacing: 0.08em; }

/* ---- SCAFFOLD (under development) ---------------------------- */
.scaffold {
  text-align: center;
  padding: 30px 18px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--bg-2);
}
.scaffold .s-ico {
  font-size: 30px;
  margin-bottom: 6px;
}
.scaffold .s-badge {
  display: inline-block;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em;
  color: var(--teal-bright); text-transform: uppercase;
  border: 1px solid var(--line-2); border-radius: 5px;
  padding: 3px 8px; margin-bottom: 10px;
}
.scaffold h2 { font-family: var(--sans); font-size: 19px; font-weight: 600; }
.scaffold p { color: var(--text-dim); font-size: 14px; margin-top: 6px; }

/* ---- EMPTY STATE --------------------------------------------- */
.empty { text-align: center; color: var(--text-faint); padding: 30px 12px; }
.empty .e-ico { font-size: 28px; }

/* ---- THETA BAR ----------------------------------------------- */
#theta-bar {
  position: sticky;
  bottom: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: rgba(22,17,34,0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line-2);
}
.theta-btn {
  width: 44px; height: 44px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--purple-bright);
  background: var(--bg-3);
  color: #fff;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theta-btn svg { width: 15px; height: 15px; display: block; }
.theta-btn.playing { background: linear-gradient(135deg, var(--purple), var(--purple-deep)); }
.theta-meta { flex: 1; min-width: 0; }
.theta-title { display: block; font-family: var(--sans); font-size: 13px; font-weight: 600; }
.theta-sub { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--text-faint); text-transform: uppercase; }
#thetaVol { width: 92px; flex: none; }

/* ---- TOAST ---------------------------------------------------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-4);
  border: 1px solid var(--purple-bright);
  color: var(--text);
  font-size: 14px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  max-width: 88%;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 80;
  box-shadow: 0 16px 40px -16px rgba(0,0,0,0.8);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- MISC ----------------------------------------------------- */
.divider { height: 1px; background: var(--line); margin: 4px 0; }
.center { text-align: center; }
.muted { color: var(--text-dim); }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 360px) {
  .reel { width: 46px; height: 68px; }
  .reel-strip span { height: 68px; font-size: 38px; }
}

/* ===============================================================
   LIGHT THEME  (set via data-theme="light" on <html>)
   Bright ground with a strong purple ambiance and glow.
   =============================================================== */
:root[data-theme="light"] {
  --bg:        #f2eefb;
  --bg-2:      #ffffff;
  --bg-3:      #efe8fb;
  --bg-4:      #e4d8f6;
  --line:      #e7dff4;
  --line-2:    #d2c5ec;

  --purple:        #7c3aed;
  --purple-bright: #6d28d9;
  --purple-deep:   #5b21b6;
  --teal:          #0f8e98;
  --teal-bright:   #0b727c;
  --danger:        #c0354b;
  --ok:            #1f9d6b;

  --text:      #271f3e;
  --text-dim:  #645a82;
  --text-faint:#9389ad;
}
:root[data-theme="light"] body {
  background-image:
    radial-gradient(circle at 50% -8%, rgba(124,58,237,0.26), transparent 60%),
    radial-gradient(circle at 108% 6%, rgba(139,92,246,0.20), transparent 46%),
    radial-gradient(circle at -8% 92%, rgba(124,58,237,0.16), transparent 52%),
    radial-gradient(circle at 100% 100%, rgba(43,179,189,0.10), transparent 45%);
}
:root[data-theme="light"] #topbar  { background: rgba(255,255,255,0.90); }
:root[data-theme="light"] #theta-bar { background: rgba(255,255,255,0.94); }
:root[data-theme="light"] .theta-btn { background: var(--bg-4); color: var(--purple-deep); }
:root[data-theme="light"] .theta-btn.playing {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
}
:root[data-theme="light"] .hold-btn { background: var(--purple); color: #fff; }
:root[data-theme="light"] .card.glow {
  box-shadow: 0 0 0 1px rgba(124,58,237,0.12), 0 18px 40px -20px rgba(124,58,237,0.55);
}
:root[data-theme="light"] .tag-frame {
  box-shadow: inset 0 0 34px -12px rgba(124,58,237,0.45);
}
