:root {
  --bg: #0a0a0a;
  --bg-secondary: #141414;
  --text: #f5f5f5;
  --text-muted: rgba(245, 245, 245, 0.5);
  --accent: #4ade80;
  --accent-dim: rgba(74, 222, 128, 0.2);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.2);
  --warning: #fbbf24;
  --border: rgba(255, 255, 255, 0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Layout */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Screens */
.screen {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Home Screen */
.home-header {
  text-align: center;
  padding: 40px 0;
}

.wake-time-display {
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -2px;
  margin-bottom: 8px;
}

.lock-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 8px 16px;
  border-radius: 20px;
}

.lock-status.locked {
  color: var(--accent);
  background: var(--accent-dim);
}

.streak-display {
  text-align: center;
  padding: 32px 0;
}

.streak-number {
  font-size: 64px;
  font-weight: 700;
  color: var(--warning);
}

.streak-label {
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 4px;
}

.streak-fire {
  font-size: 32px;
  margin-left: 8px;
}

.countdown-section {
  text-align: center;
  padding: 24px;
  background: var(--bg-secondary);
  border-radius: 16px;
  margin: 24px 0;
}

.countdown-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.countdown-time {
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 24px 0;
}

.stat-card {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: 12px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--accent);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 52px;
}

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

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

/* Navigation */
.nav-tabs {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 12px;
  margin-bottom: 24px;
}

.nav-tab {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-tab.active {
  background: var(--bg);
  color: var(--text);
}

/* Alarm Screen */
.alarm-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  text-align: center;
  padding: 24px;
}

.alarm-time {
  font-size: 96px;
  font-weight: 700;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.alarm-message {
  font-size: 20px;
  color: var(--text-muted);
  margin: 24px 0;
}

.scan-btn {
  padding: 24px 48px;
  font-size: 20px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 16px;
  font-weight: 600;
  cursor: pointer;
}

/* QR Scanner */
.scanner-container {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

#qr-reader {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
}

#qr-reader video {
  border-radius: 16px;
}

/* Morning Check-In */
.checkin-section {
  padding: 24px 0;
}

.checkin-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
}

.task-preview {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: 12px;
  border-left: 4px solid var(--accent);
  margin-bottom: 24px;
}

.task-preview-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.task-preview-name {
  font-size: 18px;
  font-weight: 500;
}

/* Mood Slider */
.mood-slider-container {
  padding: 24px 0;
}

.mood-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.mood-slider {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-secondary);
  border-radius: 4px;
  outline: none;
}

.mood-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.mood-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Signature */
.signature-area {
  margin: 24px 0;
}

.signature-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

#signature-canvas {
  width: 100%;
  height: 150px;
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: 12px;
  touch-action: none;
}

/* Settings */
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.setting-label {
  font-size: 16px;
}

.setting-value {
  font-size: 16px;
  color: var(--accent);
}

/* Time Picker */
.time-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin: 24px 0;
}

.time-picker select {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 24px;
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.time-picker-separator {
  font-size: 24px;
  font-weight: 600;
}

/* Lock Duration */
.lock-options {
  display: flex;
  gap: 12px;
  margin: 24px 0;
}

.lock-option {
  flex: 1;
  padding: 16px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lock-option.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.lock-option-days {
  font-size: 24px;
  font-weight: 600;
}

.lock-option-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* QR Setup */
.qr-display {
  text-align: center;
  padding: 24px;
}

.qr-image {
  max-width: 280px;
  margin: 24px auto;
  background: #fff;
  padding: 16px;
  border-radius: 12px;
}

.qr-image img {
  width: 100%;
}

.qr-instructions {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Mobile Signature Screen */
.sign-section {
  padding: 24px 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.sign-title {
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 24px;
  color: var(--accent);
}

.commitment-card {
  background: var(--bg-secondary);
  border: 1px solid var(--accent-dim);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.commitment-text {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  font-style: italic;
}

#sign-signature-canvas {
  width: 100%;
  height: 180px;
  background: var(--bg-secondary);
  border: 2px dashed var(--border);
  border-radius: 12px;
  touch-action: none;
}

.sign-status {
  text-align: center;
  padding: 32px;
  margin-top: 24px;
}

.sign-success {
  font-size: 48px;
  color: var(--accent);
  margin-bottom: 16px;
}

.sign-hint {
  font-size: 14px;
  color: var(--text-muted);
}

/* Checkin signature canvas */
#checkin-signature-canvas {
  width: 100%;
  height: 150px;
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: 12px;
  touch-action: none;
}

/* Streak Hero */
.streak-hero {
  text-align: center;
  padding: 24px 0;
}

.streak-number-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.streak-flames {
  font-size: 28px;
}

/* Level Badge */
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.level-badge.rookie { border-color: #666; }
.level-badge.iron { border-color: #f97316; background: rgba(249, 115, 22, 0.1); }
.level-badge.bronze { border-color: #cd7f32; background: rgba(205, 127, 50, 0.1); }
.level-badge.silver { border-color: #c0c0c0; background: rgba(192, 192, 192, 0.1); }
.level-badge.gold { border-color: #fbbf24; background: rgba(251, 191, 36, 0.1); }
.level-badge.diamond { border-color: #60a5fa; background: rgba(96, 165, 250, 0.1); }
.level-badge.conqueror { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

/* Level Progress */
.level-progress {
  margin-top: 16px;
}

.level-progress-bar-bg {
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.level-progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.level-progress-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Alarm Screen Elements */
.alarm-bg-anim {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.alarm-pulse-ring {
  position: absolute;
  width: 200px;
  height: 200px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
  animation: alarmPulse 2s ease-out infinite;
}

.alarm-pulse-ring:nth-child(2) { animation-delay: 0.6s; }
.alarm-pulse-ring:nth-child(3) { animation-delay: 1.2s; }

@keyframes alarmPulse {
  0% { transform: scale(0.5); opacity: 0.6; }
  100% { transform: scale(2.5); opacity: 0; }
}

.alarm-content {
  position: relative;
  z-index: 1;
  width: 100%;
}

.alarm-emoji {
  font-size: 64px;
  margin-bottom: 16px;
}

.alarm-time-big {
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -2px;
  animation: pulse 1s ease-in-out infinite;
}

.alarm-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 8px;
  letter-spacing: 4px;
}

.alarm-commitment-card {
  background: var(--bg-secondary);
  border: 1px solid var(--accent-dim);
  border-radius: 12px;
  padding: 16px;
  margin: 24px 0;
  text-align: left;
}

.alarm-commitment-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.alarm-commitment-text {
  font-size: 14px;
  font-style: italic;
  line-height: 1.5;
}

.alarm-first-task {
  font-size: 14px;
  color: var(--accent);
  margin-top: 8px;
  font-weight: 500;
}

.alarm-signature-preview {
  margin-top: 12px;
}

.alarm-signature-preview img {
  max-width: 100%;
  border-radius: 8px;
  opacity: 0.6;
}

.alarm-confirm-section {
  margin-top: 32px;
}

.alarm-confirm-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.alarm-name-input {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  text-align: center;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.2s ease;
}

.alarm-name-input:focus {
  border-color: var(--accent);
}

.alarm-name-input.valid {
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* Phase Badge */
.phase-badge {
  display: inline-block;
  padding: 8px 24px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  margin-top: 12px;
}

.phase-badge.on-time {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.phase-badge.late {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* Alarm Window Timer */
.alarm-window-timer {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Check-In Screen */
.checkin-header {
  text-align: center;
  padding: 24px 0;
}

.checkin-emoji {
  font-size: 48px;
  margin-bottom: 12px;
}

.checkin-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Commitment Reminder */
.commitment-reminder {
  background: var(--bg-secondary);
  border: 1px solid var(--accent-dim);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.commitment-reminder-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.commitment-reminder-text {
  font-size: 14px;
  font-style: italic;
  line-height: 1.5;
}

.commitment-signature-preview {
  margin-top: 12px;
}

.commitment-signature-preview img {
  max-width: 100%;
  border-radius: 8px;
  opacity: 0.6;
}

/* Mood Emojis */
.mood-emojis {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.mood-emoji-btn {
  width: 52px;
  height: 52px;
  font-size: 24px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.mood-emoji-btn.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* Mood Dots */
.mood-history {
  margin: 24px 0;
}

.mood-history-title {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.mood-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.mood-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* Planned Day */
.planned-day {
  margin-bottom: 24px;
}

/* Nav Tab Icon */
.nav-tab-icon {
  display: block;
  font-size: 16px;
  margin-bottom: 2px;
}

/* Settings Section */
.settings-section {
  padding: 24px 0;
}

.settings-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
}

/* QR Section */
.qr-section {
  padding: 24px 0;
  text-align: center;
}

.qr-section h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Utility Classes */
.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

/* Window Selector */
.window-selector {
  display: flex;
  gap: 8px;
  margin: 12px 0 24px;
}

.window-option {
  flex: 1;
  padding: 12px 8px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.window-option.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

/* Hybrid Info Card */
.hybrid-info-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
}

.hybrid-info-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--accent);
}

.hybrid-info-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Onboarding */
.onboarding-section {
  padding: 24px 0;
}

.onboarding-header {
  text-align: center;
  padding: 32px 0;
}

.onboarding-emoji {
  font-size: 48px;
  margin-bottom: 16px;
}

.onboarding-title {
  font-size: 28px;
  font-weight: 700;
}

.onboarding-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
}

.onboarding-steps {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 24px 0;
}

.onboarding-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step-number {
  width: 32px;
  height: 32px;
  min-width: 32px;
  background: var(--accent);
  color: #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.step-content {
  flex: 1;
}

.step-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.step-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.onboarding-time-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.onboarding-time-picker select {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 20px;
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
}

.onboarding-info {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--accent);
  text-align: center;
}

/* Hidden */
.hidden {
  display: none !important;
}
