@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,500;0,9..40,700;1,9..40,300&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg: #0F1117;
  --bg-card: #181B25;
  --bg-elevated: #1E2230;
  --bg-input: #252936;
  --border: #2A2E3B;
  --border-focus: #4B7BF5;
  --text: #E8EAF0;
  --text-muted: #8890A4;
  --text-dim: #565E75;

  --blue: #4B7BF5;
  --blue-glow: rgba(75, 123, 245, 0.2);
  --green: #34D399;
  --green-glow: rgba(52, 211, 153, 0.15);
  --amber: #F0B429;
  --orange: #F97316;
  --red: #EF4444;
  --red-glow: rgba(239, 68, 68, 0.15);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 9999px;

  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;

  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ===== LAYOUT ===== */
#app {
  
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 100px;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }

/* ===== AUTH SCREENS ===== */
.auth-container {
  /* display controlled by .screen.active */
  /* display is controlled by .screen.active */
  
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-box {
  width: 100%;
  max-width: 360px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 40px;
}
.auth-logo h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.auth-logo h1 span { color: var(--blue); }
.auth-logo p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 6px;
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus {
  border-color: var(--border-focus);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--blue);
  color: #fff;
  width: 100%;
}
.btn-primary:hover { background: #5A87F7; }

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 16px;
}
.btn-ghost:hover { color: var(--text); }

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.auth-switch {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-muted);
}
.auth-switch a {
  color: var(--blue);
  cursor: pointer;
  text-decoration: none;
}

.auth-error {
  background: var(--red-glow);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.auth-error.visible { display: block; }

/* ===== TOP BAR ===== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0;
  flex-shrink: 0;
}
.top-bar h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-elevated);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--amber);
}

/* ===== PROGRESS RING ===== */
.progress-section {
  
  flex-direction: column;
  align-items: center;
  padding: 28px 0 20px;
}

.progress-ring-container {
  position: relative;
  width: 200px;
  height: 200px;
}

.progress-ring {
  transform: rotate(-90deg);
  width: 200px;
  height: 200px;
}
.progress-ring-bg {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 8;
}
.progress-ring-fill {
  fill: none;
  stroke: var(--blue);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
  filter: drop-shadow(0 0 6px var(--blue-glow));
}
.progress-ring-fill.complete {
  stroke: var(--green);
  filter: drop-shadow(0 0 8px var(--green-glow));
}

.progress-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.progress-time {
  font-family: var(--mono);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -1px;
}
.progress-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.progress-target {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 12px;
}

/* ===== ACTION BUTTONS ===== */
.actions-row {
  display: flex;
  gap: 10px;
  padding: 0 4px;
  margin-bottom: 24px;
}

.action-btn {
  flex: 1;
  
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
  font-family: var(--font);
}
.action-btn:active { transform: scale(0.96); }
.action-btn:hover { border-color: var(--blue); }

.action-btn .icon {
  font-size: 24px;
  line-height: 1;
}
.action-btn .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.action-btn.start-focus {
  background: var(--blue);
  border-color: var(--blue);
}
.action-btn.start-focus .label { color: rgba(255,255,255,0.8); }
.action-btn.start-focus:hover { background: #5A87F7; }

/* ===== TIMER SCREEN ===== */
.timer-display {
  
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 20px;
}

.timer-status {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}
.timer-status.running { color: var(--green); }
.timer-status.paused { color: var(--amber); }

.timer-time {
  font-family: var(--mono);
  font-size: 72px;
  font-weight: 600;
  letter-spacing: -2px;
  line-height: 1;
  margin-bottom: 8px;
}

.timer-task {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
  max-width: 280px;
  text-align: center;
}

.timer-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.timer-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}
.timer-btn:active { transform: scale(0.92); }

.timer-btn-main {
  width: 80px;
  height: 80px;
  font-size: 28px;
}

.timer-btn.pause { background: var(--amber); color: #000; }
.timer-btn.resume { background: var(--green); color: #000; }
.timer-btn.stop { background: var(--bg-elevated); color: var(--red); border: 2px solid var(--red); }
.timer-btn.distraction { background: var(--bg-elevated); color: var(--orange); border: 2px solid var(--orange); }

.timer-session-info {
  margin-top: 32px;
  display: flex;
  gap: 24px;
  font-size: 13px;
  color: var(--text-muted);
}
.timer-session-info span strong {
  color: var(--text);
  font-family: var(--mono);
}

/* Start session form */
.start-session {
  
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}
.start-session input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  text-align: center;
  outline: none;
}
.start-session input::placeholder { color: var(--text-dim); }
.start-session input:focus { border-color: var(--border-focus); }

.start-session .btn-primary {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 0 40px var(--blue-glow);
  transition: all 0.3s;
}
.start-session .btn-primary:hover {
  box-shadow: 0 0 60px var(--blue-glow);
  transform: scale(1.03);
}

/* ===== DISTRACTION LOG ===== */
.distraction-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.distraction-modal.open { display: flex; }

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

.distraction-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 16px 40px;
  z-index: 1;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.distraction-sheet h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.category-btn {
  
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 4px;
  background: var(--bg-elevated);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  color: var(--text);
}
.category-btn:active { transform: scale(0.94); }
.category-btn.selected {
  border-color: var(--orange);
  background: rgba(249, 115, 22, 0.1);
}
.category-btn .cat-icon { font-size: 24px; }
.category-btn .cat-label { font-size: 11px; color: var(--text-muted); font-weight: 500; }

.distraction-note {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  resize: none;
  outline: none;
  margin-bottom: 16px;
}
.distraction-note:focus { border-color: var(--border-focus); }

.distraction-actions {
  display: flex;
  gap: 10px;
}
.distraction-actions .btn { flex: 1; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== TODAY'S SESSIONS LIST ===== */
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.session-item:last-child { border-bottom: none; }

.session-info {
  
  flex-direction: column;
  gap: 2px;
}
.session-task {
  font-size: 14px;
  font-weight: 500;
}
.session-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.session-duration {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
}

/* ===== DISTRACTIONS SUMMARY ===== */
.distraction-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.distraction-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  font-size: 13px;
}
.distraction-tag .count {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--orange);
}

/* ===== WEEKLY BAR CHART ===== */
.week-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  height: 120px;
  padding-top: 8px;
}

.week-bar {
  flex: 1;
  
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.week-bar-fill {
  width: 100%;
  min-height: 2px;
  background: var(--blue);
  border-radius: 4px 4px 0 0;
  transition: height 0.4s ease;
  position: relative;
}
.week-bar-fill.today { background: var(--green); }
.week-bar-fill.zero { background: var(--bg-elevated); min-height: 4px; }

.week-bar-label {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
}
.week-bar-label.today { color: var(--text); }

.week-bar-value {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-muted);
}

/* ===== DISTRACTION LIST SCREEN ===== */
.distraction-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.distraction-list-item:last-child { border-bottom: none; }

.distraction-list-icon { font-size: 20px; }
.distraction-list-info { flex: 1; }
.distraction-list-cat {
  font-size: 14px;
  font-weight: 500;
  text-transform: capitalize;
}
.distraction-list-note {
  font-size: 12px;
  color: var(--text-muted);
}
.distraction-list-time {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1;
  
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-item .nav-icon { font-size: 22px; }
.nav-item.active { color: var(--blue); }
.nav-item:hover { color: var(--text-muted); }

/* ===== SETTINGS SCREEN ===== */
.settings-group {
  margin-bottom: 24px;
}
.settings-group-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }

.setting-label {
  font-size: 15px;
}
.setting-value {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-input {
  width: 72px;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  text-align: center;
  outline: none;
}
.setting-input:focus { border-color: var(--border-focus); }

.setting-unit {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== EMPTY STATES ===== */
.empty-state {
  
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  text-align: center;
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { color: var(--text-muted); font-size: 14px; }

/* ===== UTILITIES ===== */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ===== DESKTOP ===== */
@media (min-width: 481px) {
  body { background: #080A0F; }
  #app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    background: var(--bg);
  }
}
