/* ── VARIABLES ───────────────────────────────────────────────────────────────── */
:root {
  --bg:        #07030f;
  --surface:   #110522;
  --surface2:  #1b0a35;
  --border:    rgba(192,132,252,0.30);
  --text:      #f0eafa;
  --text-dim:  rgba(226,217,243,0.78);
  --primary:   #d09aff;
  --primary-d: #9333ea;
  --glow:      rgba(192,132,252,0.70);
  --font-head: 'Cinzel', Georgia, serif;
  --font-body: 'Raleway', system-ui, sans-serif;

  /* Category colors – overridden by JS */
  --cat-primary:   #d09aff;
  --cat-secondary: #9333ea;
  --cat-glow:      rgba(192,132,252,0.70);
}

/* ── RESET ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
}

/* ── STAR CANVAS ─────────────────────────────────────────────────────────────── */
.star-canvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ── SCREENS ─────────────────────────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ── SCREEN HEADER ───────────────────────────────────────────────────────────── */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.screen-header h2 {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--primary);
  text-transform: uppercase;
  flex: 1;
}
.mode-tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

/* ── SCREEN BODY ─────────────────────────────────────────────────────────────── */
.screen-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}
.screen-body::-webkit-scrollbar { width: 4px; }
.screen-body::-webkit-scrollbar-track { background: transparent; }
.screen-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── BUTTONS ─────────────────────────────────────────────────────────────────── */
.btn-primary {
  padding: 13px 28px;
  background: linear-gradient(135deg, var(--cat-secondary, var(--primary-d)), var(--cat-primary, var(--primary)));
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: var(--font-head);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow: 0 0 20px var(--cat-glow, var(--glow));
  transition: box-shadow 0.25s, transform 0.15s, opacity 0.2s;
  align-self: stretch;
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 0 35px var(--cat-glow, var(--glow));
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-secondary {
  padding: 11px 22px;
  background: transparent;
  color: var(--cat-primary, var(--primary));
  border: 1px solid var(--cat-primary, var(--primary));
  border-radius: 6px;
  font-family: var(--font-head);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}
.btn-secondary:hover {
  background: rgba(192,132,252,0.1);
  box-shadow: 0 0 14px var(--cat-glow, var(--glow));
}

.btn-ghost {
  padding: 10px 20px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.btn-ghost:hover { color: var(--text); border-color: rgba(192,132,252,0.4); }

.btn-back {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.btn-back:hover { color: var(--primary); border-color: var(--primary); }

.btn-sm {
  padding: 7px 14px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, box-shadow 0.2s;
}
.btn-sm:hover:not(:disabled) { color: #fff; background: rgba(192,132,252,0.18); box-shadow: 0 0 10px rgba(192,132,252,0.25); }
.btn-sm:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-ritual {
  padding: 14px 30px;
  background: linear-gradient(135deg, var(--cat-secondary, #9333ea), var(--cat-primary, #c084fc));
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: var(--font-head);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow: 0 0 24px var(--cat-glow, rgba(192,132,252,0.5));
  transition: box-shadow 0.25s, transform 0.15s;
  align-self: center;
}
.btn-ritual:hover {
  box-shadow: 0 0 40px var(--cat-glow, rgba(192,132,252,0.7));
  transform: translateY(-1px);
}

.btn-sm-ghost {
  padding: 8px 16px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.8rem;
  cursor: pointer;
  align-self: center;
  transition: color 0.2s;
}
.btn-sm-ghost:hover { color: var(--text); }

.hidden { display: none !important; }

/* ── WELCOME SCREEN ──────────────────────────────────────────────────────────── */
#s-welcome {
  justify-content: center;
  align-items: center;
  background: radial-gradient(ellipse at center, #1a0535 0%, var(--bg) 70%);
}

.center-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  max-width: 420px;
}

.welcome-hex-icon {
  font-size: 3.5rem;
  color: var(--primary);
  text-shadow: 0 0 30px var(--glow), 0 0 60px rgba(192,132,252,0.3);
  animation: hex-float 4s ease-in-out infinite;
  line-height: 1;
}
@keyframes hex-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.app-title {
  font-family: var(--font-head);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  color: var(--primary);
  text-shadow: 0 0 30px var(--glow), 0 0 60px rgba(192,132,252,0.2);
  line-height: 1;
}

.app-tagline {
  font-family: var(--font-head);
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.app-desc {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.9;
  margin: 4px 0;
}

/* ── INTENTION SCREEN ────────────────────────────────────────────────────────── */
.guide-text {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.example-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.example-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primary);
  font-family: var(--font-head);
}
.example-box em { color: var(--text-dim); font-style: italic; }

textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  padding: 14px;
  resize: none;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
textarea:focus {
  border-color: var(--cat-primary, var(--primary));
  box-shadow: 0 0 0 2px rgba(192,132,252,0.18);
}
textarea::placeholder { color: var(--text-dim); }

.char-counter {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: -8px;
}

.category-display {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  transition: border-color 0.3s;
}
.category-icon { font-size: 1.3rem; }
.category-name {
  font-family: var(--font-head);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--cat-primary, var(--primary));
}

/* ── EXTRACT SCREEN ──────────────────────────────────────────────────────────── */
.extract-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.extract-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  font-family: var(--font-head);
}
.active-label { color: var(--cat-primary, var(--primary)); }

.extract-arrow {
  text-align: center;
  font-size: 1.3rem;
  color: var(--text-dim);
  line-height: 1;
}

.letter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 40px;
  padding: 4px 0;
}
.letter-tile {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px;
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.unique-row .letter-tile {
  border-color: var(--cat-primary, var(--primary));
  color: var(--cat-primary, var(--primary));
  box-shadow: 0 0 8px var(--cat-glow, var(--glow));
  animation: tile-appear 0.35s ease both;
}
@keyframes tile-appear {
  from { transform: scale(0.5) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);     opacity: 1; }
}

.extract-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}
.toggle-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-dim);
  user-select: none;
}
.toggle-opt input[type=checkbox] { display: none; }
.toggle-track {
  width: 40px; height: 22px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 11px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.25s, border-color 0.25s;
}
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 14px; height: 14px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.25s, background 0.25s;
}
.toggle-opt input:checked ~ .toggle-track,
.merge-toggle-opt input:checked ~ .toggle-track,
.symm-toggle-opt input:checked ~ .toggle-track {
  background: rgba(192,132,252,0.2);
  border-color: var(--cat-primary, var(--primary));
}
.toggle-opt input:checked ~ .toggle-track .toggle-thumb,
.merge-toggle-opt input:checked ~ .toggle-track .toggle-thumb,
.symm-toggle-opt input:checked ~ .toggle-track .toggle-thumb {
  transform: translateX(18px);
  background: var(--cat-primary, var(--primary));
}

.letter-count-info {
  font-size: 0.8rem;
  color: var(--text-dim);
}
.letter-count-info span {
  color: var(--cat-primary, var(--primary));
  font-weight: 600;
}

/* ── DRAW SCREEN ─────────────────────────────────────────────────────────────── */
.mode-tab {
  padding: 5px 12px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
}
.mode-tab.active {
  background: rgba(192,132,252,0.15);
  color: var(--primary);
  border-color: var(--primary);
}

.draw-body { align-items: center; }

.canvas-wrapper {
  position: relative;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(192,132,252,0.08);
  flex-shrink: 0;
}
#sigil-canvas {
  display: block;
  background: var(--surface);
  border-radius: 50%;
  cursor: crosshair;
}

.mode-hint {
  font-size: 0.8rem;
  color: var(--text);
  text-align: center;
  opacity: 0.82;
}

.draw-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── LETTER PALETTE ──────────────────────────────────────────────────────────── */
.letter-palette {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 320px;
  padding: 4px 0;
}
.palette-tile {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(192,132,252,0.07);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.05rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.18s;
  user-select: none;
  -webkit-user-select: none;
}
.palette-tile:hover { background: rgba(192,132,252,0.14); color: var(--text); }
.palette-tile.active {
  background: rgba(192,132,252,0.28);
  border-color: var(--cat-primary, var(--primary));
  color: var(--cat-primary, var(--primary));
  box-shadow: 0 0 12px rgba(192,132,252,0.35);
}

/* ── ARRANGE CONTROLS ────────────────────────────────────────────────────────── */
.arrange-controls {
  width: 100%; max-width: 320px;
  background: rgba(17,5,34,0.85);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex; flex-direction: column; gap: 9px;
}
.arrange-ctrl-row {
  display: flex; align-items: center; gap: 8px;
}
.ctrl-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  width: 46px; flex-shrink: 0;
  letter-spacing: 0.04em;
}
.ctrl-val {
  font-size: 0.72rem;
  color: var(--text-dim);
  width: 30px; text-align: right; flex-shrink: 0;
}
input[type=range]#arrange-scale {
  flex: 1; height: 4px;
  accent-color: var(--cat-primary, var(--primary));
  cursor: pointer;
}
.btn-danger-sm {
  margin-left: auto;
  padding: 4px 10px;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.35);
  color: #f87171;
  border-radius: 5px; font-size: 0.8rem; cursor: pointer;
  transition: all 0.18s;
}
.btn-danger-sm:hover { background: rgba(239,68,68,0.25); }

/* ── HEXAGON / RENDER SCREEN ─────────────────────────────────────────────────── */
.render-body { align-items: center; }

.hex-wrapper {
  width: min(320px, 100%);
  animation: hex-appear 0.7s ease both;
}
@keyframes hex-appear {
  from { transform: scale(0.8) rotate(-5deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);    opacity: 1; }
}
#hex-svg { width: 100%; height: auto; overflow: visible; }

.sigil-name-display {
  font-family: var(--font-head);
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  color: var(--cat-primary, var(--primary));
  text-shadow: 0 0 16px var(--cat-glow, var(--glow));
  text-align: center;
  text-transform: uppercase;
}

.sigil-intention-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
  max-width: 280px;
}

.render-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}
.render-actions .btn-secondary { flex: 1; }
.render-actions .btn-primary   { flex: 2; }

/* ── RITUAL SCREEN ───────────────────────────────────────────────────────────── */
.ritual-screen {
  background: radial-gradient(ellipse at center, #160435 0%, var(--bg) 75%);
  overflow-y: auto;
}

.ritual-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px 10px;
  gap: 4px;
  flex-shrink: 0;
}
.rp-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.rp-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  transition: all 0.4s;
}
.rp-step.active .rp-dot {
  background: var(--cat-primary, var(--primary));
  border-color: var(--cat-primary, var(--primary));
  box-shadow: 0 0 10px var(--cat-glow, var(--glow));
}
.rp-step.done .rp-dot {
  background: var(--cat-secondary, var(--primary-d));
  border-color: var(--cat-secondary, var(--primary-d));
}
.rp-step span {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-family: var(--font-head);
  text-transform: uppercase;
  white-space: nowrap;
}
.rp-step.active span { color: var(--cat-primary, var(--primary)); }
.rp-line {
  flex: 1;
  height: 1px;
  background: var(--border);
  max-width: 40px;
  margin-bottom: 18px;
}

.ritual-phase {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 16px 20px 24px;
  flex: 1;
}
.ritual-phase.active { display: flex; }

.phase-hex-container,
.activation-hex-wrap {
  width: min(200px, 75vw);
  flex-shrink: 0;
}
.phase-hex-container svg,
.activation-hex-wrap svg { width: 100%; height: auto; overflow: visible; }

#prep-hex-poly  { stroke: var(--cat-primary, var(--primary)); }
#activ-hex-poly { stroke: var(--cat-primary, var(--primary)); }

.phase-text {
  text-align: center;
  max-width: 340px;
}
.phase-text h3 {
  font-family: var(--font-head);
  font-size: 1rem;
  letter-spacing: 0.12em;
  color: var(--cat-primary, var(--primary));
  text-transform: uppercase;
  margin-bottom: 8px;
}
.phase-text p {
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.7;
}

.intention-echo {
  font-style: italic;
  color: var(--text);
  font-size: 0.85rem;
  margin-top: 10px;
  padding: 8px 14px;
  border-left: 2px solid var(--cat-primary, var(--primary));
  text-align: left;
}

.pulse-hex   { animation: pulse-hex 2.5s ease-in-out infinite; }
.pulse-sigil { animation: pulse-hex 2.5s ease-in-out infinite 0.5s; }
@keyframes pulse-hex {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 1;   }
}

/* ── BREATHING ANIMATION ─────────────────────────────────────────────────────── */
.breath-area {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0 4px;
}

.breath-rings {
  position: relative;
  width: 190px; height: 190px;
  display: flex; align-items: center; justify-content: center;
}

.breath-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--cat-primary, var(--primary));
  transition: transform 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
  opacity: 0.25;
}
.b-ring-3 { width: 100%; height: 100%; }
.b-ring-2 { width: 72%;  height: 72%;  }
.b-ring-1 { width: 46%;  height: 46%;  border-width: 1.5px; opacity: 0.45; }

/* inhale */
.breath-rings.inhale .b-ring-3 {
  transform: scale(1.1); opacity: 0.35;
  transition-duration: 4s; transition-timing-function: ease-in;
}
.breath-rings.inhale .b-ring-2 {
  transform: scale(1.14); opacity: 0.5;
  transition-duration: 4s; transition-timing-function: ease-in;
}
.breath-rings.inhale .b-ring-1 {
  transform: scale(1.2); opacity: 0.85;
  transition-duration: 4s; transition-timing-function: ease-in;
}

/* hold */
.breath-rings.hold .b-ring-3  { transform: scale(1.1);  opacity: 0.45; transition-duration: 0.4s; }
.breath-rings.hold .b-ring-2  { transform: scale(1.14); opacity: 0.55; transition-duration: 0.4s; }
.breath-rings.hold .b-ring-1  {
  transform: scale(1.2); opacity: 1; transition-duration: 0.4s;
  box-shadow: 0 0 20px var(--cat-glow, var(--glow));
}

/* exhale */
.breath-rings.exhale .b-ring-3 {
  transform: scale(0.88); opacity: 0.18;
  transition-duration: 8s; transition-timing-function: ease-out;
}
.breath-rings.exhale .b-ring-2 {
  transform: scale(0.82); opacity: 0.22;
  transition-duration: 8s; transition-timing-function: ease-out;
}
.breath-rings.exhale .b-ring-1 {
  transform: scale(0.75); opacity: 0.35;
  transition-duration: 8s; transition-timing-function: ease-out;
}

.breath-core {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.breath-word {
  font-family: var(--font-head);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  color: var(--cat-primary, var(--primary));
  text-transform: uppercase;
}
.breath-num {
  font-family: var(--font-head);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  min-width: 2ch;
  text-align: center;
}

.breath-cycle-info {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-align: center;
}
.breath-cycle-info span { color: var(--cat-primary, var(--primary)); }

.breath-pattern-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  font-family: var(--font-head);
  text-align: center;
}

/* ── ACTIVATION TIMER ────────────────────────────────────────────────────────── */
.activation-area {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.timer-wrap {
  position: relative;
  width: 68px; height: 68px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.timer-svg { width: 100%; height: 100%; }
.timer-track { stroke: var(--surface2); }
.timer-arc {
  stroke: var(--cat-primary, var(--primary));
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
.activation-countdown {
  position: absolute;
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cat-primary, var(--primary));
}

/* ── DESTRUCTION CANVAS ──────────────────────────────────────────────────────── */
.destruction-wrap {
  width: min(220px, 80vw);
  aspect-ratio: 1;
  flex-shrink: 0;
}
#destruct-canvas {
  width: 100%; height: 100%;
  background: var(--surface);
  border-radius: 50%;
  display: block;
}

/* ── COMPLETE SCREEN ─────────────────────────────────────────────────────────── */
#s-complete {
  background: radial-gradient(ellipse at center, #1a0535 0%, var(--bg) 70%);
  justify-content: center;
  align-items: center;
}
.complete-star {
  font-size: 3rem;
  color: var(--cat-primary, var(--primary));
  text-shadow: 0 0 30px var(--cat-glow, var(--glow));
  animation: complete-pulse 2.2s ease-in-out infinite;
}
@keyframes complete-pulse {
  0%, 100% { transform: scale(1);   }
  50%       { transform: scale(1.1); }
}
.complete-title {
  font-family: var(--font-head);
  font-size: 1.3rem;
  letter-spacing: 0.1em;
  color: var(--cat-primary, var(--primary));
  text-align: center;
}
.complete-msg {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  line-height: 1.8;
}
.complete-divider {
  color: var(--border);
  letter-spacing: 0.3em;
}
.complete-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

/* ── COLLECTION ──────────────────────────────────────────────────────────────── */
.collection-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  align-content: start;
}
.collection-grid::-webkit-scrollbar { width: 4px; }
.collection-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.coll-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  animation: tile-appear 0.4s ease both;
}
.coll-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 16px rgba(192,132,252,0.18);
}
.coll-card svg { width: 80px; height: 80px; overflow: visible; }
.coll-card-name {
  font-family: var(--font-head);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--primary);
  text-align: center;
  text-transform: uppercase;
}
.coll-card-date {
  font-size: 0.65rem;
  color: var(--text-dim);
}

.coll-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  color: var(--text-dim);
  padding: 40px;
}
.empty-hex { font-size: 3rem; color: var(--border); }

/* ── ACTIVATION PHASE ────────────────────────────────────────────────────────── */
.activ-phase {
  justify-content: space-between;
  padding: 8px 16px 16px;
}
.activ-sigil-wrap {
  width: min(340px, 88vw);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.activ-sigil-wrap svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

/* Stronger breathing pulse for activation sigil */
@keyframes pulse-activ {
  0%, 100% {
    opacity: 0.65;
    filter: drop-shadow(0 0 4px var(--cat-primary, var(--primary)))
            drop-shadow(0 0 1px var(--cat-glow, var(--glow)));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 28px var(--cat-primary, var(--primary)))
            drop-shadow(0 0 56px var(--cat-glow, var(--glow)))
            drop-shadow(0 0 10px #fff5);
  }
}
/* Override the existing pulse-hex/pulse-sigil for the activation phase */
.activ-phase .pulse-hex,
.activ-phase .pulse-sigil {
  animation: pulse-activ 4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.activ-phase .pulse-sigil { animation-delay: 0.6s; }

@keyframes release-glow {
  0%, 100% {
    box-shadow: 0 0 6px var(--cat-primary, var(--primary)),
                0 0 2px var(--cat-glow, var(--glow));
    border-color: var(--cat-primary, var(--primary));
    color: var(--cat-primary, var(--primary));
  }
  50% {
    box-shadow: 0 0 18px var(--cat-primary, var(--primary)),
                0 0 36px var(--cat-glow, var(--glow)),
                0 0 6px #fff4;
    border-color: var(--cat-glow, var(--glow));
    color: #fff;
  }
}

/* Subtle footer: timer + hint + release button */
.activ-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  padding-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.activ-focus-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-style: italic;
  opacity: 0.7;
  flex: 1;
  min-width: 100px;
}

/* Subtle release button — fades in slowly via JS adding .visible */
.btn-release {
  background: transparent;
  border: 1px solid rgba(192,132,252,0.18);
  color: rgba(192,132,252,0.45);
  padding: 9px 20px;
  border-radius: 6px;
  font-family: var(--font-head);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 5s ease, color 0.3s, border-color 0.3s, box-shadow 0.3s;
  white-space: nowrap;
}
.btn-release.visible {
  opacity: 1;
  pointer-events: auto;
  animation: release-glow 2.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  animation-delay: 5s;
}
.btn-release:hover {
  animation: none;
  color: #fff;
  border-color: var(--cat-glow, var(--glow));
  box-shadow: 0 0 18px var(--cat-primary, var(--primary)),
              0 0 36px var(--cat-glow, var(--glow));
}
[data-theme="light"] .btn-release { border-color: rgba(109,40,217,0.2); color: rgba(109,40,217,0.4); }

/* ── THEORY SCREEN ───────────────────────────────────────────────────────────── */
.theory-screen {
  background: radial-gradient(ellipse at center, #1a0535 0%, var(--bg) 75%);
}

.theory-cards-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.theory-cards {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: scroll;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.theory-cards::-webkit-scrollbar { display: none; }

.theory-card {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px 28px;
  text-align: center;
  box-sizing: border-box;
}

.theory-card-icon {
  font-size: 3rem;
  color: var(--primary);
  text-shadow: 0 0 24px var(--glow), 0 0 48px rgba(192,132,252,0.25);
  line-height: 1;
}

.theory-card-title {
  font-family: var(--font-head);
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  color: var(--primary);
  text-transform: uppercase;
  text-shadow: 0 0 16px var(--glow);
}

.theory-card-body {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.8;
  max-width: 340px;
}
.theory-card-body em {
  color: var(--primary);
  font-style: normal;
}

.theory-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
  text-align: left;
}
.theory-steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.5;
}
.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(192,132,252,0.15);
  border: 1px solid var(--primary);
  color: var(--primary);
  font-family: var(--font-head);
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.theory-card-last .theory-cta {
  margin-top: 8px;
  align-self: stretch;
  max-width: 260px;
}

/* Navigation dots + prev/next */
.theory-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 20px 20px;
  flex-shrink: 0;
}
.theory-nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.theory-nav-btn:hover { color: var(--primary); border-color: var(--primary); }
.theory-nav-btn:disabled { opacity: 0.3; cursor: default; }
.theory-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}
.theory-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s, transform 0.3s;
  display: block;
}
.theory-dot.active {
  background: var(--primary);
  transform: scale(1.3);
  box-shadow: 0 0 8px var(--glow);
}

/* ── BRIGHTNESS TWEAKS ───────────────────────────────────────────────────────── */
/* Make descriptive text brighter across the app */
.guide-text { color: var(--text); opacity: 0.88; }
.toggle-opt { color: var(--text); opacity: 0.85; }
.extract-label { color: var(--text); opacity: 0.7; }
.letter-count-info { color: var(--text); opacity: 0.82; }
.phase-text p { color: var(--text); opacity: 0.88; }
.sigil-intention-label { color: var(--text); opacity: 0.78; }
.app-tagline { color: var(--text); opacity: 0.72; }
.app-desc { color: var(--text); opacity: 0.78; }

/* ── THEME TOGGLE BUTTON (always visible, fixed) ─────────────────────────────── */
.btn-theme-toggle {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 9999;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(17,5,34,0.85);
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 14px rgba(192,132,252,0.12);
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s, background 0.3s;
  backdrop-filter: blur(6px);
}
.btn-theme-toggle:hover {
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--glow);
}

/* ── LIGHT MODE ──────────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:        #f0ebff;
  --surface:   #e6dffa;
  --surface2:  #dbd2f5;
  --border:    rgba(100, 50, 200, 0.22);
  --text:      #14062a;
  --text-dim:  rgba(20, 6, 42, 0.65);
  --primary:   #6d28d9;
  --primary-d: #4c1d95;
  --glow:      rgba(109, 40, 217, 0.38);
  --cat-primary:   #6d28d9;
  --cat-secondary: #4c1d95;
  --cat-glow:      rgba(109, 40, 217, 0.38);
}

/* Light mode: screen backgrounds */
[data-theme="light"] #s-welcome {
  background: radial-gradient(ellipse at center, #dbd2f5 0%, var(--bg) 70%);
}
[data-theme="light"] .ritual-screen {
  background: radial-gradient(ellipse at center, #dbd2f5 0%, var(--bg) 75%);
}
[data-theme="light"] #s-complete {
  background: radial-gradient(ellipse at center, #dbd2f5 0%, var(--bg) 70%);
}
[data-theme="light"] .theory-screen {
  background: radial-gradient(ellipse at center, #dbd2f5 0%, var(--bg) 75%);
}

/* Starfield invisible in light mode */
[data-theme="light"] .star-canvas { opacity: 0; pointer-events: none; }

/* Theme toggle icon changes */
[data-theme="light"] .btn-theme-toggle {
  background: rgba(230, 223, 250, 0.92);
}

/* Sigil/destruct canvas always dark */
#sigil-canvas,
#destruct-canvas { background: #0a0118 !important; }

/* ── ARRANGE TOGGLES (merge + symmetry) ──────────────────────────────────────── */
.merge-toggle-opt,
.symm-toggle-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  opacity: 0.88;
  user-select: none;
  -webkit-user-select: none;
  padding: 2px 0;
}
.merge-toggle-opt input[type=checkbox],
.symm-toggle-opt  input[type=checkbox] { display: none; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────────── */
@media (max-height: 640px) {
  .screen-body  { padding: 12px; gap: 10px; }
  .ritual-phase { padding: 8px 14px 14px; gap: 10px; }
  .breath-rings { width: 150px; height: 150px; }
  .welcome-hex-icon { font-size: 2.5rem; }
  .app-title    { font-size: 2.2rem; }
}

/* ── MOBILE TOUCH TARGET IMPROVEMENTS ───────────────────────────────────────── */
@media (max-width: 420px) {
  .btn-primary, .btn-secondary, .btn-ritual {
    min-height: 48px;
    font-size: 0.88rem;
  }
  .btn-sm {
    min-height: 40px;
    padding: 8px 16px;
    font-size: 0.82rem;
  }
  .palette-tile {
    width: 42px; height: 42px;
    font-size: 1.1rem;
  }
  .mode-tab {
    padding: 7px 14px;
    font-size: 0.78rem;
  }
  .app-title { font-size: 2.6rem; }
  .screen-body { padding: 16px; gap: 16px; }
  textarea { font-size: 1rem; }
  .arrange-ctrl-row { gap: 10px; }
}
