:root {
  --bg-dark: #0F0F1B;
  --bg-radial-inner: #1A1A2E;
  --bg-setup: #0F172A;
  --primary: #7C3AED;
  --primary-light: #A78BFA;
  --setup-primary: #6366F1;
  --text-lavender: #E0E0FF;
  --text-light: #F0F0F5;
  --surface-card: rgba(255, 255, 255, 0.05);
  --border-subtle: rgba(255, 255, 255, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-dark);
  color: #FFFFFF;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  user-select: none;
}

button, input, select {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

.ico {
  display: block;
  fill: currentColor;
  flex-shrink: 0;
}

.view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.spacer-1 {
  flex: 1 1 0;
}

.spacer-2 {
  flex: 2 1 0;
}

/* ==================== SETUP SCREEN ==================== */
#view-setup {
  background: var(--bg-setup);
}

.setup-shell {
  width: 100%;
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  padding: 48px 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.setup-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--setup-primary);
}

.setup-tagline {
  margin-top: 8px;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.72);
}

.setup-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.setup-prompt {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.3;
  color: #FFFFFF;
}

.setup-input {
  width: 100%;
  margin-top: 24px;
  background: transparent;
  border: none;
  outline: none;
  font-size: 24px;
  font-weight: 400;
  color: #FFFFFF;
}

.setup-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.setup-reminder-label {
  margin-top: 48px;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.72);
}

.setup-time-pill {
  margin-top: 12px;
  padding: 12px 20px;
  border: none;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
  font-size: 24px;
  font-weight: 600;
  cursor: pointer;
}

.setup-start-btn {
  width: 100%;
  padding: 20px;
  border: none;
  border-radius: 24px;
  background: var(--setup-primary);
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}

.setup-start-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.setup-start-btn:active:not(:disabled) {
  transform: scale(0.98);
}

/* ==================== HOME SCREEN ==================== */
#view-home {
  background: radial-gradient(circle at center, var(--bg-radial-inner) 0%, var(--bg-dark) 100%);
}

.home-shell {
  width: 100%;
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 16px;
}

.home-header {
  position: relative;
  width: 100%;
  padding: 10px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 82px;
}

.reset-circle-btn {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

[dir="rtl"] .reset-circle-btn {
  left: auto;
  right: 20px;
}

.home-title-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: calc(100% - 116px);
}

.day-chip {
  padding: 6px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-lavender);
  font-size: 14px;
  font-weight: 500;
}

.habit-title {
  margin-top: 8px;
  font-size: 32px;
  font-weight: 700;
  color: var(--text-lavender);
  letter-spacing: -0.5px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Multi-habit selector */
.habit-selector {
  width: 90%;
  padding: 10px 0;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.habit-pill {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.habit-pill.selected {
  width: 56px;
  height: 56px;
  background: rgba(124, 58, 237, 0.15);
  border-color: var(--primary);
  color: #FFFFFF;
}

.habit-pill.plus {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Central check-in circle */
.central-circle {
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3A3A55 0%, #2A2A40 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 30px 5px rgba(124, 58, 237, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s, box-shadow 0.3s;
}

.central-circle.completed {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2) 0%, rgba(91, 33, 182, 0.1) 100%);
  border: 2.5px solid var(--primary);
  box-shadow: 0 0 40px 8px rgba(124, 58, 237, 0.25);
  cursor: default;
}

.central-circle.checking-in {
  transform: scale(1.1);
}

.central-circle.dimmed {
  opacity: 0.6;
  cursor: default;
}

.central-check-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.central-name {
  margin-top: 16px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-light);
  text-align: center;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.central-circle.completed .central-name {
  color: var(--primary-light);
}

.central-reminder {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: rgba(124, 58, 237, 0.7);
}

.central-circle.completed .central-reminder {
  color: rgba(167, 139, 250, 0.7);
}

.central-status {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
}

.central-circle.completed .central-status {
  color: var(--primary);
  font-weight: 700;
}

/* Weekly bar */
.weekly-bar {
  width: 85%;
  display: flex;
  flex-direction: column;
}

.week-days {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
}

.day-col {
  background: transparent;
  border: none;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.day-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, box-shadow 0.2s;
}

.day-dot.done {
  background: var(--primary);
  box-shadow: 0 0 4px rgba(124, 58, 237, 0.4);
}

.day-dot.selected-empty {
  background: #FFFFFF;
}

.day-dot.today {
  border: 2px solid var(--primary);
}

.day-lbl {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 400;
}

.day-lbl.today {
  color: #FFFFFF;
  font-weight: 700;
}

.progress-track {
  margin-top: 16px;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.settings-link-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
  padding: 8px 16px;
  cursor: pointer;
}

/* ==================== SETTINGS SCREEN ==================== */
#view-settings {
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
}

.settings-topbar {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  height: 56px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-back-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

[dir="rtl"] .topbar-back-btn svg {
  transform: scaleX(-1);
}

.topbar-title {
  font-size: 20px;
  font-weight: 700;
  color: #FFFFFF;
}

.settings-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
}

.settings-scroll {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.settings-section-title {
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  margin-bottom: 16px;
}

.settings-section-title:not(:first-child) {
  margin-top: 32px;
}

.settings-card {
  padding: 8px 16px;
  background: var(--surface-card);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.settings-field {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}

.settings-field-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 4px;
}

.settings-name-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #FFFFFF;
  font-size: 16px;
  padding: 4px 0;
}

.settings-icon-block {
  padding: 12px 0;
}

.settings-field-sub {
  display: block;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 12px;
}

.settings-tile {
  width: 100%;
  min-height: 48px;
  padding: 10px 0;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: start;
  cursor: pointer;
}

.tile-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile-title {
  font-size: 14px;
  color: #FFFFFF;
}

.tile-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
}

.tile-trailing {
  display: flex;
  align-items: center;
}

.settings-row {
  min-height: 48px;
  padding: 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.settings-select {
  appearance: none;
  background: transparent;
  border: none;
  outline: none;
  color: #FFFFFF;
  font-size: 14px;
  padding-inline-end: 4px;
  cursor: pointer;
}

.settings-select option {
  background: #1A1A2E;
  color: #FFFFFF;
}

.time-value-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.time-value {
  color: var(--primary);
  font-weight: 700;
  font-size: 16px;
}

.settings-version {
  margin: 48px 0 16px;
  text-align: center;
  color: rgba(255, 255, 255, 0.15);
  font-size: 12px;
}

/* ==================== ALARM SCREEN ==================== */
#view-alarm {
  background: var(--bg-dark);
}

.alarm-glow-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(124, 58, 237, 0.12) 0%, rgba(26, 26, 46, 0.8) 50%, var(--bg-dark) 100%);
  animation: alarmGlowBg 2s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes alarmGlowBg {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

.alarm-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 48px;
}

.alarm-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.7);
}

.alarm-brand {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 4px;
  color: rgba(255, 255, 255, 0.5);
}

.alarm-title {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #FFFFFF;
}

.alarm-pulse-circle {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3A2B6E 0%, #2A1B5E 100%);
  border: 2.5px solid rgba(124, 58, 237, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: alarmPulse 1.5s ease-in-out infinite alternate, alarmCircleGlow 2s ease-in-out infinite alternate;
}

@keyframes alarmPulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

@keyframes alarmCircleGlow {
  from {
    box-shadow: 0 0 60px 15px rgba(124, 58, 237, 0.15), 0 0 100px 30px rgba(167, 139, 250, 0.06);
  }
  to {
    box-shadow: 0 0 60px 15px rgba(124, 58, 237, 0.4), 0 0 100px 30px rgba(167, 139, 250, 0.16);
  }
}

.alarm-habit-name {
  margin-top: 16px;
  color: #FFFFFF;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.alarm-clock {
  font-size: 48px;
  font-weight: 200;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 2px;
}

.alarm-actions {
  width: 100%;
  padding: 0 32px;
  display: flex;
  gap: 20px;
  animation: slideUpElastic 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUpElastic {
  from {
    transform: translateY(150%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.alarm-btn {
  border-radius: 20px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
}

.alarm-btn.snooze {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
  font-size: 15px;
  font-weight: 500;
}

.alarm-btn.checkin {
  flex: 2;
  padding: 20px 16px;
  background: var(--primary);
  border: 1.5px solid #9333EA;
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 0 20px 2px rgba(124, 58, 237, 0.4);
}

.alarm-checked-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.alarm-done-label {
  color: var(--primary-light);
  font-size: 24px;
  font-weight: 700;
}

/* ==================== DIALOGS, ICON GRID, TOAST, CONFETTI ==================== */
.icon-grid {
  display: grid;
  width: 100%;
}

.icon-tile {
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-tile.selected {
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--primary);
  color: #FFFFFF;
}

.dlg-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.dlg {
  width: 100%;
  max-width: 340px;
  background: #1A1A2E;
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.dlg-title {
  font-size: 20px;
  font-weight: 600;
  color: #FFFFFF;
  margin-bottom: 16px;
}

.dlg-message {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  line-height: 1.5;
}

.dlg-message.center {
  text-align: center;
}

.dlg-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.dlg-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.dlg-btn.text {
  background: transparent;
}

.dlg-btn.filled {
  background: var(--primary);
  color: #FFFFFF;
}

.dlg-btn:disabled {
  background: rgba(156, 163, 175, 0.15);
  color: rgba(255, 255, 255, 0.35);
  cursor: not-allowed;
}

.dlg-text-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  outline: none;
  color: #FFFFFF;
  font-size: 16px;
  padding: 8px 0;
}

.dlg-text-input:focus {
  border-bottom-color: var(--primary);
}

.dlg-text-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.add-habit-label {
  margin: 24px 0 12px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
}

.premium-modal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* Time picker */
.tp-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 0;
}

.tp-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.tp-step {
  width: 56px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
}

.tp-input {
  width: 68px;
  height: 56px;
  border: 2px solid var(--primary);
  border-radius: 14px;
  background: rgba(124, 58, 237, 0.15);
  color: #FFFFFF;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  outline: none;
}

.tp-colon {
  font-size: 28px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
}

/* Confetti & Toast */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 300;
}

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--primary);
  color: #FFFFFF;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: opacity 0.25s, transform 0.25s;
}

.toast.out {
  opacity: 0;
  transform: translateY(8px);
}
