:root {
  --bg: #07070c;
  --surface: rgba(14, 14, 24, 0.72);
  --surface-strong: rgba(12, 12, 22, 0.88);
  --border: rgba(255, 255, 255, 0.11);
  --border-hover: rgba(255, 255, 255, 0.24);
  --text: #f8fafc;
  --text-muted: rgba(248, 250, 252, 0.64);
  --accent: #a78bfa;
  --accent-glow: rgba(167, 139, 250, 0.35);
  --accent-strong: #c084fc;
  --success: #34d399;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-pill: 999px;
  --blur: 18px;
  --transition-img: 600ms;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, Inter, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ===== Palco Visual (Mandala) ===== */
.stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at center, #121224 0%, #07070c 75%);
}

.stage-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--transition-img) ease-in-out;
  will-change: opacity, transform;
  pointer-events: none;
}

.stage-layer.is-active {
  opacity: 1;
}

.stage.fit-contain .stage-layer {
  object-fit: contain;
  padding: 4vmin;
}

.stage.is-breathing .stage-layer.is-active {
  animation: breathe 8s ease-in-out infinite;
}

.stage.is-rotating .stage-layer.is-active {
  animation: slowSpin 120s linear infinite;
}

.stage.is-breathing.is-rotating .stage-layer.is-active {
  animation: breatheSpin 60s linear infinite;
}

.stage-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    circle at center,
    transparent 42%,
    rgba(5, 5, 10, 0.35) 78%,
    rgba(5, 5, 10, 0.72) 100%
  );
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes slowSpin {
  from { transform: rotate(0deg) scale(1.05); }
  to { transform: rotate(360deg) scale(1.05); }
}

@keyframes breatheSpin {
  0% { transform: rotate(0deg) scale(1.02); }
  25% { transform: rotate(90deg) scale(1.08); }
  50% { transform: rotate(180deg) scale(1.02); }
  75% { transform: rotate(270deg) scale(1.08); }
  100% { transform: rotate(360deg) scale(1.02); }
}

/* ===== Overlay de Intenção & Códigos ===== */
.intention-overlay {
  position: fixed;
  top: clamp(16px, 3vh, 32px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: min(90vw, 680px);
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  background: rgba(7, 7, 14, 0.48);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  transition: opacity 0.45s ease, transform 0.45s ease;
  pointer-events: none;
}

.intention-overlay.is-hidden {
  opacity: 0;
  transform: translate(-50%, -12px);
}

.intention-text {
  font-size: clamp(0.72rem, 1.3vw, 0.85rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-strong);
  font-weight: 500;
}

.intention-text:empty {
  display: none;
}

.code-display {
  font-family: var(--font-mono);
  font-size: clamp(0.95rem, 2.2vw, 1.35rem);
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--text);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85);
  transition: opacity 0.35s ease;
}

.code-display.is-fading {
  opacity: 0.15;
}

/* ===== Timer Badge ===== */
.timer-badge {
  position: fixed;
  top: clamp(16px, 3vh, 28px);
  right: clamp(16px, 3vw, 28px);
  z-index: 20;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--text);
  transition: opacity 0.35s ease;
}

.timer-badge[hidden] {
  display: none;
}

/* ===== Dock Inferior Flutuante ===== */
.dock {
  position: fixed;
  bottom: clamp(16px, 3.2vh, 32px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

body.ui-idle .dock,
body.zen-mode .dock {
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
}

body.zen-mode .timer-badge {
  opacity: 0;
  pointer-events: none;
}

.dock-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  min-width: 40px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn.is-active {
  background: rgba(167, 139, 250, 0.2);
  border-color: rgba(167, 139, 250, 0.5);
  color: var(--accent-strong);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.freq-pill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.sound-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.icon-btn.is-active .sound-dot {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

/* ===== Drawer Lateral de Configurações ===== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(3, 3, 8, 0.52);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: min(92vw, 390px);
  display: flex;
  flex-direction: column;
  background: var(--surface-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.65);
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drawer-symbol {
  font-size: 1.35rem;
  color: var(--accent-strong);
}

.drawer-title h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.drawer-title p {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.section-value {
  font-family: var(--font-mono);
  color: var(--accent-strong);
  text-transform: none;
  letter-spacing: 0.03em;
}

/* Chips / Grids */
.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.chip-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.chip.compact {
  align-items: center;
  text-align: center;
  padding: 8px 6px;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
}

.chip.is-active {
  background: rgba(167, 139, 250, 0.18);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.25);
}

.chip-title {
  font-size: 0.84rem;
  font-weight: 600;
}

.chip-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Sliders & Inputs */
.range-input {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 6px;
}

.text-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.88rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.text-input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.text-input::placeholder {
  color: rgba(248, 250, 252, 0.35);
}

/* Toggle rows */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  font-size: 0.84rem;
  cursor: pointer;
}

.toggle-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Shortcuts */
.shortcuts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 12px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.shortcuts kbd {
  display: inline-block;
  padding: 2px 6px;
  margin-right: 4px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translate(-50%, 10px);
  z-index: 60;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  background: var(--surface-strong);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 0.84rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 600px) {
  .dock {
    width: calc(100vw - 24px);
    justify-content: space-between;
    padding: 6px 10px;
    gap: 2px;
  }

  .freq-pill {
    display: none;
  }

  .dock-divider {
    display: none;
  }
}
