/* === RESET & BASE === */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--kimi-font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  background: var(--kimi-color-surface, #fafafa);
  color: var(--kimi-color-text-primary, #111);
  -webkit-tap-highlight-color: transparent;
}
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--kimi-color-surface, #fafafa);
  position: relative;
}

/* === HEADER === */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--kimi-color-border, #e5e5e5);
  background: var(--kimi-color-surface, #fafafa);
  flex-shrink: 0;
}
.app-header h1 {
  font-size: 20px;
  font-weight: 500;
  color: var(--kimi-color-text-primary, #111);
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--kimi-color-text-secondary, #666);
}
.icon-btn:hover { background: var(--kimi-color-surface-muted, #f0f0f0); }
.icon-btn svg { width: 20px; height: 20px; }

/* === SCREENS === */
.screens { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; }
.screen {
  display: none;
  padding: 12px 16px 80px;
  animation: fadeIn 0.2s ease-out;
}
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* === BOTTOM NAV === */
.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 6px 0 10px;
  border-top: 1px solid var(--kimi-color-border, #e5e5e5);
  background: var(--kimi-color-surface, #fafafa);
  flex-shrink: 0;
  position: relative;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 10px;
  color: var(--kimi-color-text-tertiary, #999);
  cursor: pointer;
  transition: color 0.15s;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--kimi-color-text-primary, #111); }
.nav-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--kimi-color-text-primary, #111);
  color: var(--kimi-color-surface, #fff);
  margin-top: -20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  flex: none;
}
.nav-fab svg { width: 24px; height: 24px; }

/* === CARDS & INPUTS === */
.card {
  background: var(--kimi-color-surface-raised, #fff);
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}
.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  background: var(--kimi-color-surface-raised, #fff);
  color: var(--kimi-color-text-primary, #111);
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--kimi-color-text-primary, #111); }
.input::placeholder { color: var(--kimi-color-text-quaternary, #bbb); }
.textarea { min-height: 80px; resize: vertical; }
.btn {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--kimi-color-text-primary, #111);
  color: var(--kimi-color-surface, #fff);
  margin-top: 12px;
}
.btn-secondary {
  background: var(--kimi-color-surface-muted, #f0f0f0);
  color: var(--kimi-color-text-primary, #111);
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  margin-bottom: 8px;
}
.btn-danger {
  background: color-mix(in srgb, var(--kimi-color-danger, #e74c3c) 10%, transparent);
  color: var(--kimi-color-danger, #e74c3c);
  border: 1px solid color-mix(in srgb, var(--kimi-color-danger, #e74c3c) 30%, transparent);
}

/* === DAY SCREEN === */
.day-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.summary-pill {
  text-align: center;
  padding: 10px 4px;
  border-radius: 10px;
  background: var(--kimi-color-surface-raised, #fff);
  border: 1px solid var(--kimi-color-border, #e5e5e5);
}
.summary-num {
  font-size: 20px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--kimi-color-text-primary, #111);
}
.summary-label {
  font-size: 11px;
  color: var(--kimi-color-text-tertiary, #999);
  margin-top: 2px;
}
.water-tracker {
  margin-bottom: 16px;
}
.water-bar-bg {
  height: 8px;
  background: var(--kimi-color-surface-muted, #f0f0f0);
  border-radius: 4px;
  overflow: hidden;
}
.water-bar {
  height: 100%;
  width: 0%;
  background: var(--kimi-chart-3, #2ecc71);
  border-radius: 4px;
  transition: width 0.4s ease-out;
}
.water-text {
  text-align: right;
  font-size: 12px;
  color: var(--kimi-color-text-tertiary, #999);
  margin-top: 4px;
}
.section-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--kimi-color-text-secondary, #666);
  margin-bottom: 10px;
}
.timeline {
  position: relative;
  padding-left: 22px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--kimi-color-border, #e5e5e5);
}
.t-item {
  position: relative;
  margin-bottom: 14px;
}
.t-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--kimi-color-surface, #fafafa);
  border: 2.5px solid var(--kimi-color-border, #e5e5e5);
}
.t-time {
  font-size: 12px;
  color: var(--kimi-color-text-quaternary, #bbb);
  margin-bottom: 3px;
}
.t-content {
  background: var(--kimi-color-surface-raised, #fff);
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  border-radius: 10px;
  padding: 10px 12px;
}
.t-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--kimi-color-text-primary, #111);
}
.t-meta {
  font-size: 13px;
  color: var(--kimi-color-text-secondary, #666);
  margin-top: 2px;
}
.t-tags {
  margin-top: 6px;
}
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  margin-right: 5px;
  font-weight: 500;
}
.tag-food { background: color-mix(in srgb, var(--kimi-chart-1, #3498db) 12%, transparent); color: var(--kimi-chart-1, #3498db); }
.tag-water { background: color-mix(in srgb, var(--kimi-chart-3, #2ecc71) 12%, transparent); color: var(--kimi-chart-3, #2ecc71); }
.tag-toilet { background: color-mix(in srgb, var(--kimi-chart-5, #95a5a6) 15%, transparent); color: var(--kimi-chart-5, #7f8c8d); }
.tag-symptom { background: color-mix(in srgb, var(--kimi-chart-2, #e74c3c) 12%, transparent); color: var(--kimi-chart-2, #e74c3c); }
.tag-mood { background: color-mix(in srgb, var(--kimi-chart-4, #9b59b6) 12%, transparent); color: var(--kimi-chart-4, #9b59b6); }
.tag-sleep { background: color-mix(in srgb, var(--kimi-chart-5, #95a5a6) 15%, transparent); color: var(--kimi-chart-5, #7f8c8d); }
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--kimi-color-text-quaternary, #bbb);
}
.empty-icon { font-size: 40px; margin-bottom: 8px; }
.empty-text { font-size: 15px; color: var(--kimi-color-text-secondary, #666); }
.empty-sub { font-size: 13px; margin-top: 4px; }

/* === ADD SCREEN === */
.add-types {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.add-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 4px;
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  border-radius: 10px;
  background: var(--kimi-color-surface-raised, #fff);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  color: var(--kimi-color-text-secondary, #666);
  transition: all 0.15s;
}
.add-type-btn.active {
  border-color: var(--kimi-color-text-primary, #111);
  color: var(--kimi-color-text-primary, #111);
  font-weight: 500;
}
.add-type-icon { font-size: 22px; }
.add-form { display: none; }
.add-form.active { display: block; }

.input-methods {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.method-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  border-radius: 8px;
  background: var(--kimi-color-surface-raised, #fff);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--kimi-color-text-secondary, #666);
}
.method-btn.active {
  border-color: var(--kimi-color-text-primary, #111);
  color: var(--kimi-color-text-primary, #111);
  font-weight: 500;
}
.photo-dropzone {
  border: 2px dashed var(--kimi-color-border, #e5e5e5);
  border-radius: 12px;
  padding: 32px 16px;
  text-align: center;
  color: var(--kimi-color-text-tertiary, #bbb);
  cursor: pointer;
  transition: border-color 0.15s;
  margin-bottom: 12px;
}
.photo-dropzone:hover { border-color: var(--kimi-color-text-secondary, #666); }
.photo-dropzone svg { margin-bottom: 8px; color: var(--kimi-color-text-quaternary, #bbb); }
.photo-sub { font-size: 12px; margin-top: 4px; }
.ai-result {
  background: var(--kimi-color-surface-muted, #f0f0f0);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}
.ai-status { font-size: 13px; color: var(--kimi-color-text-secondary, #666); }
.ai-detected { font-size: 14px; color: var(--kimi-color-text-primary, #111); margin-top: 6px; font-weight: 500; }
.voice-btn {
  width: 100%;
  padding: 24px;
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  border-radius: 12px;
  background: var(--kimi-color-surface-raised, #fff);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--kimi-color-text-secondary, #666);
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 12px;
}
.voice-btn.recording {
  background: color-mix(in srgb, var(--kimi-color-danger, #e74c3c) 8%, transparent);
  border-color: color-mix(in srgb, var(--kimi-color-danger, #e74c3c) 30%, transparent);
  color: var(--kimi-color-danger, #e74c3c);
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
.voice-result {
  background: var(--kimi-color-surface-muted, #f0f0f0);
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  color: var(--kimi-color-text-primary, #111);
  margin-bottom: 12px;
  display: none;
}
.kbju-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.kbju-input { text-align: center; }

.water-presets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.water-preset {
  padding: 14px;
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  border-radius: 10px;
  background: var(--kimi-color-surface-raised, #fff);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--kimi-color-text-secondary, #666);
}
.water-preset:hover { border-color: var(--kimi-color-text-primary, #111); }

.toilet-types {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.toilet-type {
  flex: 1;
  padding: 14px 8px;
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  border-radius: 10px;
  background: var(--kimi-color-surface-raised, #fff);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--kimi-color-text-secondary, #666);
}
.toilet-type.active {
  border-color: var(--kimi-color-text-primary, #111);
  color: var(--kimi-color-text-primary, #111);
  font-weight: 500;
}

.intensity-label {
  font-size: 14px;
  color: var(--kimi-color-text-secondary, #666);
  margin-bottom: 6px;
}
.intensity-slider {
  width: 100%;
  margin-bottom: 12px;
  accent-color: var(--kimi-color-text-primary, #111);
}

.mood-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.mood-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 2px;
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  border-radius: 10px;
  background: var(--kimi-color-surface-raised, #fff);
  cursor: pointer;
  font-size: 20px;
}
.mood-btn span { font-size: 11px; color: var(--kimi-color-text-tertiary, #999); }
.mood-btn.active {
  border-color: var(--kimi-color-text-primary, #111);
  background: var(--kimi-color-surface-muted, #f0f0f0);
}
.mood-selected {
  text-align: center;
  font-size: 14px;
  color: var(--kimi-color-text-secondary, #666);
  margin-bottom: 12px;
}

.sleep-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.sleep-field label {
  display: block;
  font-size: 13px;
  color: var(--kimi-color-text-secondary, #666);
  margin-bottom: 4px;
}

/* === CALENDAR === */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-nav {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  background: var(--kimi-color-surface-raised, #fff);
  cursor: pointer;
  font-size: 18px;
  color: var(--kimi-color-text-primary, #111);
}
.cal-title {
  font-size: 17px;
  font-weight: 500;
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
  font-size: 12px;
  color: var(--kimi-color-text-tertiary, #999);
  margin-bottom: 4px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 14px;
  color: var(--kimi-color-text-secondary, #666);
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}
.cal-day:hover { background: var(--kimi-color-surface-muted, #f0f0f0); }
.cal-day.today {
  background: var(--kimi-color-text-primary, #111);
  color: var(--kimi-color-surface, #fff);
  font-weight: 500;
}
.cal-day.selected {
  outline: 2px solid var(--kimi-color-text-primary, #111);
  outline-offset: -2px;
}
.cal-day.has-data::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--kimi-chart-1, #3498db);
}
.cal-day.other-month { color: var(--kimi-color-text-quaternary, #bbb); }
.cal-day-details {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--kimi-color-border, #e5e5e5);
}
.cal-day-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 10px;
}
.cal-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.cal-stat {
  background: var(--kimi-color-surface-raised, #fff);
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cal-stat-label { font-size: 13px; color: var(--kimi-color-text-secondary, #666); }
.cal-stat-value { font-weight: 500; font-variant-numeric: tabular-nums; }

/* === STATS === */
.segmented {
  display: flex;
  background: var(--kimi-color-surface-muted, #f0f0f0);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 16px;
}
.seg-btn {
  flex: 1;
  padding: 8px;
  border: none;
  background: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--kimi-color-text-secondary, #666);
  cursor: pointer;
  transition: all 0.15s;
}
.seg-btn.active {
  background: var(--kimi-color-surface-raised, #fff);
  color: var(--kimi-color-text-primary, #111);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.stat-section { margin-bottom: 20px; }
.stat-section-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--kimi-color-text-secondary, #666);
  margin-bottom: 8px;
}
.chart-canvas {
  width: 100%;
  height: 140px;
  background: var(--kimi-color-surface-raised, #fff);
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  border-radius: 10px;
}
.macro-bars { display: flex; flex-direction: column; gap: 8px; }
.macro-bar { display: flex; align-items: center; gap: 10px; }
.macro-label { width: 50px; font-size: 13px; color: var(--kimi-color-text-secondary, #666); }
.macro-track { flex: 1; height: 10px; background: var(--kimi-color-surface-muted, #f0f0f0); border-radius: 5px; overflow: hidden; }
.macro-fill { height: 100%; border-radius: 5px; transition: width 0.4s ease-out; }
.macro-value { width: 50px; text-align: right; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.symptom-list { display: flex; flex-direction: column; gap: 6px; }
.symptom-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--kimi-color-surface-raised, #fff);
  border: 1px solid var(--kimi-color-border, #e5e5e5);
  border-radius: 10px;
}
.symptom-name { font-size: 14px; }
.symptom-count { font-size: 12px; color: var(--kimi-color-text-tertiary, #999); background: var(--kimi-color-surface-muted, #f0f0f0); padding: 2px 8px; border-radius: 10px; }

/* === SETTINGS === */
.settings-group { margin-bottom: 20px; }
.settings-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--kimi-color-text-tertiary, #999);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.setting-label {
  display: block;
  font-size: 14px;
  color: var(--kimi-color-text-secondary, #666);
  margin-bottom: 4px;
  margin-top: 8px;
}
.about-text {
  font-size: 13px;
  color: var(--kimi-color-text-secondary, #666);
  line-height: 1.6;
}

/* === TOAST === */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--kimi-color-text-primary, #111);
  color: var(--kimi-color-surface, #fff);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* === SCROLLBAR === */
.screens::-webkit-scrollbar { width: 4px; }
.screens::-webkit-scrollbar-track { background: transparent; }
.screens::-webkit-scrollbar-thumb { background: var(--kimi-color-border, #e5e5e5); border-radius: 2px; }

/* === RESPONSIVE === */
@media (max-width: 360px) {
  .day-summary { gap: 6px; }
  .summary-pill { padding: 8px 2px; }
  .summary-num { font-size: 16px; }
  .add-types { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .add-type-btn { padding: 10px 2px; font-size: 11px; }
}
