:root {
  --bg: #fff;
  --bg-elev: #f5f5f7;
  --bg-tile: #fafafa;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #e0e0e0;
  --accent: #0a84ff;
  --blue: #4a90e2;
  --yellow: #f5d142;
  --green: #4caf50;
  --red: #e57373;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --radius: 12px;
  --bottom-nav-h: 64px;
}

[data-theme="dark"] {
  --bg: #15151a;
  --bg-elev: #1f1f25;
  --bg-tile: #25252c;
  --text: #eee;
  --text-muted: #aaa;
  --border: #333;
  --accent: #4a9eff;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-size: 1.2rem;
  margin: 0;
  font-weight: 600;
}

.btn-icon {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text);
  border-radius: 8px;
  min-height: 44px;
  min-width: 44px;
  font-family: inherit;
}

.btn-icon:active {
  background: var(--bg-tile);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.day-nav, .week-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.day-nav h2, .week-nav h3 {
  margin: 0;
  font-size: 1.1rem;
  text-align: center;
  flex: 1;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  margin-bottom: 12px;
  color: var(--text-muted);
  align-items: center;
}

.legend-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.legend-dot.blue { background: var(--blue); }
.legend-dot.yellow { background: var(--yellow); }
.legend-dot.green { background: var(--green); }
.legend-dot.red { background: var(--red); }

.quick-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.quick-btn {
  flex: 1;
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}

.quick-btn:active {
  opacity: 0.7;
}

.time-blocks {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.time-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background: var(--bg-tile);
  border-radius: var(--radius);
  transition: background 0.15s;
}

.time-row[data-color="blue"] { background: rgba(74,144,226,0.12); }
.time-row[data-color="yellow"] { background: rgba(245,209,66,0.15); }
.time-row[data-color="green"] { background: rgba(76,175,80,0.12); }
.time-row[data-color="red"] { background: rgba(229,115,115,0.15); }

.time-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 50px;
  font-variant-numeric: tabular-nums;
}

.color-pill {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.1s, border-color 0.1s, background 0.1s;
  font-family: inherit;
}

.color-pill[data-color="blue"] { background: var(--blue); border-color: var(--blue); }
.color-pill[data-color="yellow"] { background: var(--yellow); border-color: var(--yellow); }
.color-pill[data-color="green"] { background: var(--green); border-color: var(--green); }
.color-pill[data-color="red"] { background: var(--red); border-color: var(--red); }

.color-pill:active {
  transform: scale(0.9);
}

.activity-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  padding: 8px;
  outline: none;
  min-width: 0;
  font-family: inherit;
}

.activity-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.notes {
  margin-top: 24px;
}

.notes label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--bg-tile);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  min-height: 60px;
}

.list-section {
  margin-bottom: 24px;
}

.list-section h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  display: flex;
  align-items: center;
}

.tag-input {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.tag-input input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--bg-tile);
  color: var(--text);
  font-size: 1rem;
  min-width: 0;
  font-family: inherit;
}

.btn-add {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  width: 44px;
  font-size: 1.4rem;
  cursor: pointer;
  font-family: inherit;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tag-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  font-size: 1rem;
  line-height: 1;
  font-family: inherit;
}

.reflections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.reflections label {
  display: block;
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: normal;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 12px;
  text-align: left;
  font-family: inherit;
  border: 1px solid var(--border);
}

.btn-large {
  padding: 16px;
  font-size: 1.05rem;
}

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

.btn:active {
  opacity: 0.8;
}

.status {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-tile);
  font-size: 0.9rem;
  display: none;
}

.status.show {
  display: block;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  height: var(--bottom-nav-h);
  z-index: 10;
}

.nav-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: inherit;
  font-size: 0.75rem;
}

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

.nav-icon {
  font-size: 1.4rem;
}

@media (min-width: 720px) {
  main {
    padding: 24px;
  }
}

/* Print styles for PDF export */
@media print {
  .topbar, .bottom-nav, .quick-actions, .no-print {
    display: none !important;
  }
  
  body {
    padding: 0;
    background: white;
    color: black;
    font-size: 11pt;
  }
  
  main {
    max-width: 100%;
    padding: 0;
  }
  
  .view {
    display: block !important;
    page-break-after: always;
    margin-bottom: 24px;
  }
  
  .view:last-child {
    page-break-after: auto;
  }
  
  .time-row {
    page-break-inside: avoid;
    background: white !important;
    border: 1px solid #ddd;
  }
  
  .color-pill, .legend-dot {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  
  .btn {
    display: none;
  }
  
  h2 {
    margin-top: 0;
  }
}
