/* Faded Dependence — allotted screen time that fades */

:root {
  --bg: #0a0c10;
  --bg-elevated: #12151c;
  --bg-soft: #1a1e28;
  --text: #e8eaef;
  --text-muted: #8b93a7;
  --text-dim: #5c6478;
  --accent: #7eb8ff;
  --accent-soft: rgba(126, 184, 255, 0.18);
  --accent-glow: rgba(126, 184, 255, 0.45);
  --success: #8fd4a8;
  --danger-soft: #c9a0a8;
  --lock: #9aa4c7;
  --ring-track: rgba(255, 255, 255, 0.08);
  --ring-fill: #7eb8ff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius: 16px;
  --radius-lg: 24px;
  --tap: 48px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --fade-opacity: 1;
  --fade-blur: 0px;
  --fade-sat: 1;
  --vignette: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  max-width: 480px;
  margin: 0 auto;
  isolation: isolate;
}

.app[data-state="active"] .main,
.app[data-state="pattern"] .main,
.app[data-state="idle"] .main {
  opacity: var(--fade-opacity);
  filter: blur(var(--fade-blur)) saturate(var(--fade-sat));
  transition: none;
}

.app[data-state="sleep"],
.app[data-state="lock"] {
  --fade-opacity: 1;
  --fade-blur: 0px;
  --fade-sat: 1;
}

.app[data-state="lock"] {
  --vignette: 0.88;
}

.app[data-state="sleep"] {
  --vignette: 0.55;
}

.app[data-state="lock"] .header,
.app[data-state="lock"] #btn-settings {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.fade-layer {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 5;
  background: radial-gradient(
    ellipse at center,
    transparent 28%,
    rgba(0, 0, 0, calc(var(--vignette) * 0.92)) 100%
  );
  opacity: 1;
}

/* Soft aurora for lock / sleep */
.aurora {
  pointer-events: none;
  position: fixed;
  inset: -20%;
  z-index: 0;
  opacity: 0;
  background:
    radial-gradient(ellipse 50% 40% at 30% 40%, rgba(80, 110, 180, 0.18), transparent 60%),
    radial-gradient(ellipse 45% 35% at 70% 60%, rgba(100, 80, 160, 0.12), transparent 55%),
    radial-gradient(ellipse 40% 30% at 50% 80%, rgba(60, 140, 160, 0.1), transparent 50%);
  filter: blur(40px);
  transition: opacity 0.8s ease;
}

.app[data-state="lock"] .aurora,
.app[data-state="sleep"] .aurora {
  opacity: 1;
  animation: aurora-drift 18s ease-in-out infinite alternate;
}

@keyframes aurora-drift {
  from { transform: translate(-2%, -1%) scale(1); }
  to { transform: translate(3%, 2%) scale(1.05); }
}

.stars {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.app[data-state="lock"] .stars,
.app[data-state="sleep"] .stars {
  opacity: 0.7;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(145deg, #3a4a6a 0%, #1a2235 50%, #0d1018 100%);
  box-shadow: inset 0 0 0 1px rgba(126, 184, 255, 0.25),
    0 0 20px rgba(126, 184, 255, 0.15);
  flex-shrink: 0;
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: 0.55;
}

.brand-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  border: none;
  border-radius: 14px;
  background: var(--bg-soft);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:active {
  background: var(--accent-soft);
  color: var(--accent);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.view[hidden] {
  display: none !important;
}

.tagline {
  margin: 0 0 32px;
  color: var(--text-muted);
  font-size: 1.05rem;
  text-align: center;
  max-width: 22em;
  align-self: center;
}

.timer-setup {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 28px 22px 22px;
  margin-bottom: 28px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.setup-label {
  display: block;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.minutes-display {
  text-align: center;
  margin-bottom: 20px;
}

.minutes-display #minutes-value {
  font-size: 4rem;
  font-weight: 300;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.minutes-display .unit {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-left: 6px;
  font-weight: 500;
}

.slider {
  width: 100%;
  height: 44px;
  appearance: none;
  background: transparent;
  margin: 0 0 16px;
  cursor: pointer;
}

.slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--slider-pct, 44%),
    var(--bg-soft) var(--slider-pct, 44%),
    var(--bg-soft) 100%
  );
}

.slider::-webkit-slider-thumb {
  appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4), 0 0 0 4px var(--accent-soft);
  border: none;
}

.slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-soft);
}

.slider::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
}

.slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--text);
  border: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.chips {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.chip {
  min-height: 44px;
  min-width: 88px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}

.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.chip:active {
  transform: scale(0.97);
}

.btn {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  min-height: var(--tap);
  padding: 0 24px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #0a0c10;
}

.btn-primary:active {
  filter: brightness(0.92);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:active {
  background: var(--bg-soft);
}

.btn-lg {
  width: 100%;
  min-height: 56px;
  font-size: 1.15rem;
  border-radius: 16px;
}

.btn-sm {
  min-height: 40px;
  font-size: 0.95rem;
  padding: 0 16px;
}

.hint {
  margin: 16px 0 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.88rem;
  max-width: 28em;
  align-self: center;
}

/* Active — progress ring */
.view-active {
  align-items: center;
  justify-content: center;
  gap: 32px;
}

.ring-wrap {
  position: relative;
  width: min(280px, 72vw);
  aspect-ratio: 1;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 8;
}

.ring-progress {
  fill: none;
  stroke: var(--ring-fill);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 553;
  stroke-dashoffset: 0;
  transition: stroke 0.3s ease;
  filter: drop-shadow(0 0 6px rgba(126, 184, 255, 0.35));
}

.app[data-phase="fading"] .ring-progress {
  stroke: var(--danger-soft);
  filter: drop-shadow(0 0 8px rgba(201, 160, 168, 0.4));
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.countdown {
  font-size: 3.4rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

.phase-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.app[data-phase="fading"] .phase-label {
  color: var(--danger-soft);
}

/* Scripture — calm, muted; does not compete with countdown */
.verse {
  margin: 0;
  max-width: 22em;
  text-align: center;
  color: var(--text-dim);
}

.verse-text {
  margin: 0;
  font-size: 0.92rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}

.verse-cite {
  display: block;
  margin-top: 8px;
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--text-dim);
}

.verse-fading {
  margin-top: -8px;
  margin-bottom: 0;
  opacity: 0;
  transition: opacity 0.7s ease;
}

.verse-fading:not([hidden]) {
  opacity: 1;
}

.app[data-phase="fading"] .verse-fading:not([hidden]) {
  animation: verse-in 0.85s ease both;
}

.verse-lock {
  margin: 12px 0 4px;
  max-width: 20em;
}

.verse-sleep {
  margin: 4px 0 8px;
  max-width: 18em;
}

.verse-sleep .verse-text {
  font-size: 0.95rem;
}

@keyframes verse-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Pattern challenge */
.view-pattern {
  align-items: center;
  gap: 12px;
}

.pattern-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-align: center;
}

.pattern-sub {
  margin: 0 0 8px;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.95rem;
  max-width: 22em;
}

.pattern-canvas {
  position: relative;
  width: min(320px, 88vw);
  aspect-ratio: 1;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(126, 184, 255, 0.06), transparent 55%),
    var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.35);
  touch-action: none;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.pattern-node {
  position: absolute;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, transform 0.2s;
  pointer-events: none;
}

.pattern-node.is-next {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(126, 184, 255, 0.12);
  box-shadow:
    0 0 0 4px var(--accent-soft),
    0 0 28px var(--accent-glow),
    0 0 48px rgba(126, 184, 255, 0.25);
  animation: node-pulse 1.4s ease-in-out infinite;
}

.pattern-node.is-done {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 16px rgba(126, 184, 255, 0.35);
  animation: none;
}

.pattern-node.is-miss {
  border-color: var(--danger-soft);
  box-shadow: 0 0 0 4px rgba(201, 160, 168, 0.25);
}

.pattern-trail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@keyframes node-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 0 0 4px var(--accent-soft),
      0 0 22px var(--accent-glow),
      0 0 40px rgba(126, 184, 255, 0.2);
  }
  50% {
    transform: scale(1.08);
    box-shadow:
      0 0 0 10px rgba(126, 184, 255, 0.1),
      0 0 36px var(--accent-glow),
      0 0 60px rgba(126, 184, 255, 0.3);
  }
}

.pattern-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(320px, 88vw);
  margin-top: 8px;
}

.pattern-timer {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* Hard lock */
.view-lock {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding-bottom: 24px;
  user-select: none;
  -webkit-user-select: none;
}

.lock-eyebrow {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-dim);
}

.lock-title {
  margin: 0 0 8px;
  font-size: 2.4rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
  text-shadow: 0 0 40px rgba(154, 164, 199, 0.35);
  animation: lock-breathe 4s ease-in-out infinite;
}

.lock-ring-wrap {
  position: relative;
  width: min(260px, 70vw);
  aspect-ratio: 1;
  margin: 12px 0 20px;
}

.lock-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 0 12px rgba(154, 164, 199, 0.25));
}

.lock-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 6;
}

.lock-ring-progress {
  fill: none;
  stroke: var(--lock);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 553;
  stroke-dashoffset: 0;
  transition: none;
}

.lock-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lock-countdown {
  font-size: 3.6rem;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
  opacity: 0.95;
}

.lock-message {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  max-width: 18em;
}

.lock-sub {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
  max-width: 20em;
}

@keyframes lock-breathe {
  0%,
  100% {
    opacity: 0.85;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.02);
  }
}

/* Sleep / rest */
.view-sleep {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding-bottom: 24px;
}

.sleep-eyebrow {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
}

.sleep-clock {
  font-size: 4.5rem;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin: 8px 0 16px;
  color: var(--text);
  opacity: 0.9;
}

.sleep-message {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.sleep-sub {
  margin: 8px 0 36px;
  color: var(--text-muted);
  max-width: 18em;
}

.sleep-hint {
  margin-top: 12px;
}

/* Settings sheet */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.sheet[hidden] {
  display: none !important;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.sheet-panel {
  position: relative;
  background: var(--bg-elevated);
  border-radius: 20px 20px 0 0;
  padding: 12px 22px calc(28px + var(--safe-bottom));
  max-height: 85dvh;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: none;
  animation: sheet-up 0.28s ease;
}

@keyframes sheet-up {
  from {
    transform: translateY(40%);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  margin: 4px auto 16px;
}

.sheet-title {
  margin: 0 0 20px;
  font-size: 1.25rem;
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.field-toggle {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.field-label {
  font-size: 0.95rem;
  color: var(--text);
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.field-input {
  font-family: inherit;
  font-size: 1.1rem;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--bg);
  color: var(--text);
  min-height: var(--tap);
}

.toggle {
  width: 48px;
  height: 28px;
  appearance: none;
  background: var(--bg-soft);
  border-radius: 14px;
  position: relative;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s ease, background 0.2s ease;
}

.toggle:checked {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.toggle:checked::after {
  transform: translateX(20px);
  background: var(--accent);
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.sheet-actions .btn {
  flex: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 50;
  background: var(--bg-soft);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.95rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  max-width: calc(100% - 40px);
  text-align: center;
  animation: toast-in 0.25s ease;
}

.toast[hidden] {
  display: none !important;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pattern-node.is-next,
  .lock-title,
  .aurora,
  .verse-fading {
    animation: none !important;
  }
  .sheet-panel,
  .toast,
  .btn,
  .verse-fading {
    animation: none;
    transition: none;
  }
}

.app[data-reduced="1"] .pattern-node.is-next,
.app[data-reduced="1"] .lock-title,
.app[data-reduced="1"] .aurora,
.app[data-reduced="1"] .verse-fading {
  animation: none !important;
  transition: none;
}

.app[data-reduced="1"] .sheet-panel,
.app[data-reduced="1"] .toast {
  animation: none;
}

.app[data-reduced="1"] .stars {
  opacity: 0 !important;
}

.app.is-reviving .ring-progress {
  stroke: var(--success);
  filter: drop-shadow(0 0 10px rgba(143, 212, 168, 0.45));
}
