/* ─── Reset & Base ──────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-hover: #111111;
  --border: #1a1a1a;
  --text: #d0d0d0;
  --text-secondary: #707070;
  --text-dim: #404040;
  --accent: #6C9CFC;
  --accent-dim: #3a5a9c;
  --green: #4CAF50;
  --green-dim: #2e6830;
  --red: #ef5350;
  --red-dim: #8b2e2d;
  --orange: #FF9800;
  --purple: #AB47BC;
  --teal: #4DB6AC;
  --nav-height: 64px;
  --header-height: 48px;
  --radius: 12px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ─── Header ────────────────────────────────────────── */
#app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.user-badge {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
}

/* ─── Main Content ──────────────────────────────────── */
#page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 24px);
  -webkit-overflow-scrolling: touch;
}

/* ─── Bottom Navigation ─────────────────────────────── */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 11px;
  cursor: pointer;
  border: none;
  background: none;
  min-width: 56px;
  transition: color 0.15s;
}

.nav-item.active {
  color: var(--accent);
}

.nav-item svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* ─── Cards ─────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  font-weight: 600;
}

/* ─── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border-radius: var(--radius);
  border: none;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  min-height: 56px;
  color: #fff;
}

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

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

.btn-primary:active {
  background: var(--accent-dim);
}

.btn-success {
  background: var(--green);
}

.btn-success:active {
  background: var(--green-dim);
}

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

.btn-danger:active {
  background: var(--red-dim);
}

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

.btn-ghost.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(108, 156, 252, 0.1);
}

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

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

.btn.secondary.outline {
  border-color: var(--text-secondary);
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.btn.secondary.outline:active {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text);
}

.full-width {
  width: 100%;
}

.btn-full {
  width: 100%;
}

.btn-large {
  min-height: 80px;
  font-size: 20px;
  font-weight: 600;
  border-radius: 16px;
}

/* ─── Timer ─────────────────────────────────────────── */
.timer-display {
  font-size: 48px;
  font-weight: 300;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding: 16px 0;
}

.timer-display.active {
  color: var(--green);
}

.timer-btn {
  width: 100%;
  min-height: 88px;
  font-size: 22px;
  font-weight: 600;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  color: #fff;
}

.timer-btn:active {
  transform: scale(0.97);
}

.timer-btn.start {
  background: var(--green);
}

.timer-btn.stop {
  background: var(--red);
}

/* ─── Toggle Group ──────────────────────────────────── */
.toggle-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.toggle-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  min-height: 48px;
}

.toggle-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(108, 156, 252, 0.1);
}

/* ─── Chips (multi-select) ──────────────────────────── */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  padding: 10px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.chip.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(108, 156, 252, 0.12);
}

/* ─── Mood Grid ─────────────────────────────────────── */
.mood-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.mood-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 64px;
}

.mood-card .mood-emoji {
  font-size: 28px;
}

.mood-card.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(108, 156, 252, 0.1);
}

/* ─── Forms ─────────────────────────────────────────── */
.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}

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

.form-input::placeholder {
  color: var(--text-dim);
}

textarea.form-input {
  resize: vertical;
  min-height: 60px;
}

/* ─── Log List ──────────────────────────────────────── */
.log-list {
  margin-top: 16px;
}

.log-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.log-item:last-child {
  border-bottom: none;
}

.log-main {
  flex: 1;
}

.log-time {
  font-size: 13px;
  color: var(--text-secondary);
}

.log-detail {
  font-size: 15px;
  color: var(--text);
  margin-top: 2px;
}

.log-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.log-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.log-duration {
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  margin-left: 12px;
}

.log-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 18px;
  margin-left: 8px;
}

.log-delete:active {
  color: var(--red);
}

/* ─── User Selection ────────────────────────────────── */
.user-select-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 20px;
  padding: 32px;
}

.user-select-title {
  font-size: 32px;
  font-weight: 300;
  color: var(--text);
  margin-bottom: 16px;
}

.user-select-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.user-btn {
  width: 100%;
  max-width: 280px;
  min-height: 88px;
  font-size: 22px;
  font-weight: 500;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.user-btn:active {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Section titles ────────────────────────────────── */
.section-title {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 20px 0 8px;
}

/* ─── Stats ─────────────────────────────────────────── */
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 14px;
}

.stat-value {
  font-weight: 500;
  font-size: 15px;
}

.chart-container {
  position: relative;
  height: 200px;
  margin: 16px 0;
}

/* ─── Calendar ──────────────────────────────────────── */
.week-view {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 16px;
}

.week-day {
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}

.week-day .day-name {
  color: var(--text-secondary);
  font-size: 11px;
}

.week-day .day-num {
  font-size: 16px;
  font-weight: 500;
  margin-top: 2px;
}

.week-day.today {
  background: rgba(108, 156, 252, 0.15);
  color: var(--accent);
}

.week-day.today .day-name {
  color: var(--accent);
}

.week-day.has-events .day-num::after {
  content: '';
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  margin: 4px auto 0;
}

.event-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.event-time {
  font-size: 13px;
  color: var(--accent);
  white-space: nowrap;
  min-width: 55px;
}

.event-title {
  font-size: 15px;
  color: var(--text);
}

.event-location {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ─── Empty states ──────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-dim);
  font-size: 14px;
}

/* ─── Active indicator ──────────────────────────────── */
.active-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
  margin-right: 6px;
}

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

/* ─── Dashboard specific ────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.dash-card .card-title {
  margin-bottom: 4px;
}

.dash-card .card-value {
  font-size: 22px;
}

/* ─── Utilities ─────────────────────────────────────── */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* ─── Edit Modal ────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

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

/* ─── Log item tap target ───────────────────────────── */
.log-main {
  cursor: pointer;
}

.log-main:active {
  opacity: 0.7;
}

/* ─── Time Group (edit modal) ───────────────────────── */
.time-row {
  display: flex;
  gap: 10px;
}

.time-col {
  flex: 1;
}

.dur-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dur-input {
  width: 60px !important;
  text-align: center;
  -moz-appearance: textfield;
}

.dur-input::-webkit-inner-spin-button,
.dur-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.dur-sep {
  color: var(--text-secondary);
  font-size: 14px;
  min-width: 14px;
}

.time-hint {
  font-size: 12px;
  color: var(--teal);
  margin-top: 6px;
  min-height: 18px;
}
