: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-small {
  padding: 10px 16px;
  font-size: 14px;
  min-height: auto;
  width: auto;
  display: inline-block;
}

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

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

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.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-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

#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;
}

/* Fullscreen Signature Overlay */
.fullscreen-signature-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

.fullscreen-signature-overlay.hidden {
  display: none !important;
}

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

.fullscreen-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

.btn-close-fullscreen {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  width: auto;
  min-height: auto;
}

#fullscreen-signature-canvas {
  flex: 1;
  width: 100%;
  background: var(--bg-secondary);
  touch-action: none;
  cursor: crosshair;
}

.fullscreen-actions {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

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

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