/* Catppuccin Latte — light */
:root {
  --bg:             #eff1f5;  /* Base */
  --surface:        #e6e9ef;  /* Mantle */
  --fg:             #4c4f69;  /* Text */
  --muted:          #9ca0b0;  /* Overlay0 */
  --line:           #ccd0da;  /* Surface0 */
  --accent:         #8839ef;  /* Mauve */
  --accent-shadow:  rgba(136, 57, 239, .20);
  --empty:          #dce0e8;  /* Crust */
  --err-bg:         #fce4ec;
  --err-fg:         #d20f39;  /* Red */
  --mood-1:         #c8d5f5;  /* pale periwinkle */
  --mood-2:         #9db4ee;
  --mood-3:         #6b8fe5;
  --mood-4:         #3f68d0;
  --mood-5:         #1e46a8;  /* deep navy */
  --brand-log:      #209fb5;  /* Sapphire */
  --brand-mood:     #8839ef;  /* Mauve */
  --cell:           12px;
  --cell-gap:       3px;
  --wdays-w:        28px;
}

/* Catppuccin Mocha — dark */
[data-theme="dark"] {
  --bg:             #1e1e2e;  /* Base */
  --surface:        #313244;  /* Surface0 */
  --fg:             #cdd6f4;  /* Text */
  --muted:          #6c7086;  /* Overlay0 */
  --line:           #45475a;  /* Surface1 */
  --accent:         #cba6f7;  /* Mauve */
  --accent-shadow:  rgba(203, 166, 247, .20);
  --empty:          #181825;  /* Mantle */
  --brand-log:      #74c7ec;  /* Sapphire */
  --brand-mood:     #cba6f7;  /* Mauve */
  --err-bg:         #4a1524;
  --err-fg:         #f38ba8;  /* Red */
  --mood-1:         #3b4a7a;  /* muted dark blue */
  --mood-2:         #5068a8;
  --mood-3:         #6a88d8;
  --mood-4:         #8aaae8;
  --mood-5:         #adc4f5;  /* bright periwinkle */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1rem; font-weight: 600; color: var(--muted); margin: 0 0 12px; }
.sub { color: var(--muted); margin-top: -8px; }

/* --- nav --- */
.nav {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  max-width: 960px;
  margin: 0 auto;
}
.brand { font-weight: 700; letter-spacing: -0.02em; }
.brand-log { color: var(--brand-log); }
.brand-mood { color: var(--brand-mood); }
.tabs { display: flex; gap: 16px; }
.tabs a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
.tabs a.active { color: var(--fg); border-bottom-color: var(--accent); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.account-link {
  text-decoration: none; color: var(--muted); font-weight: 500;
}
.account-link:hover, .account-link.active { color: var(--fg); }
.logout button {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font: inherit; padding: 0;
}
.logout button:hover { color: var(--fg); }

/* --- theme toggle --- */
.theme-toggle {
  background: none; border: none;
  cursor: pointer; padding: 2px 4px;
  font-size: 1rem; line-height: 1;
  color: var(--muted);
  border-radius: 6px;
  transition: color .15s ease;
}
.theme-toggle:hover { color: var(--fg); }

/* --- today picker --- */
.today { margin-bottom: 28px; }
.picker { display: flex; flex-direction: column; gap: 10px; }
.faces { display: flex; gap: 10px; }
.face {
  font-size: 30px;
  line-height: 1;
  width: 56px; height: 56px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  cursor: pointer;
  transition: transform .05s ease, border-color .1s ease, box-shadow .1s ease;
}
.face:hover { transform: translateY(-2px); border-color: var(--accent); }
.face.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-shadow);
}
.note-input {
  font: inherit; font-size: .9rem;
  padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  color: var(--fg); background: var(--surface);
  max-width: 300px;
}
.note-input:focus { outline: none; border-color: var(--accent); }
.note-input::placeholder { color: var(--muted); }
.loggednote { color: var(--muted); font-size: .9rem; margin: 10px 2px 0; }
.today-count { color: var(--muted); font-size: .9rem; margin-top: -4px; }

/* --- streaks --- */
.stats { margin-bottom: 28px; }
.streaks { display: flex; gap: 32px; }
.streak { display: flex; flex-direction: column; }
.streak .num { font-size: 1.8rem; font-weight: 700; }
.streak .lbl { color: var(--muted); font-size: .85rem; }

/* --- insights --- */
.insights { margin-bottom: 28px; }
.dow-chart {
  display: flex; gap: 8px; align-items: flex-end;
  height: 80px; padding-bottom: 20px; position: relative;
}
.dow-bar {
  display: flex; flex-direction: column; align-items: center;
  width: 32px; height: 100%; justify-content: flex-end; position: relative;
}
.dow-fill {
  width: 20px; border-radius: 4px 4px 0 0;
  background: var(--accent); opacity: 0.6;
  min-height: 2px;
  transition: height .2s ease;
}
.dow-label {
  font-size: .7rem; color: var(--muted); margin-top: 2px;
}
.dow-name {
  font-size: .7rem; color: var(--muted); font-weight: 600;
  position: absolute; bottom: -16px;
}
.dow-summary {
  color: var(--muted); font-size: .85rem; margin: 8px 0 0;
}
.dow-summary strong { color: var(--fg); }

/* --- grid --- */
.gridsection {
  margin-top: 8px;
}
.gridwrap { overflow-x: auto; padding-bottom: 6px; }
.months {
  display: flex;
  gap: var(--cell-gap);
  margin-left: calc(var(--wdays-w) + 8px);
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 4px;
}
.mlabel { width: var(--cell); white-space: nowrap; flex-shrink: 0; }
.gridbody { display: flex; gap: 8px; }
.week { flex-shrink: 0; }
.wdays {
  display: grid;
  grid-template-rows: repeat(7, var(--cell));
  gap: var(--cell-gap);
  width: var(--wdays-w);
  font-size: 9px;
  color: var(--muted);
}
.wdays span { line-height: var(--cell); height: var(--cell); }
.grid { display: flex; gap: var(--cell-gap); }
.week { display: grid; grid-template-rows: repeat(7, var(--cell)); gap: var(--cell-gap); }
.cell {
  width: var(--cell); height: var(--cell);
  border-radius: 2px;
  background: var(--empty);
}
.cell.future { background: transparent; }
.month-gap { margin-left: 5px; }
.cell[data-tip] { cursor: pointer; }

/* --- legend --- */
.legend {
  display: flex; align-items: center; gap: 4px;
  margin-top: 14px; color: var(--muted); font-size: .8rem;
}
.legend .swatch {
  width: var(--cell); height: var(--cell);
  border-radius: 2px; display: inline-block;
}
.legend .lo { margin-right: 4px; }
.legend .hi { margin-left: 4px; }

/* --- tooltip --- */
.tip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--fg);
  color: var(--bg);
  font-size: .75rem;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
}
.tip[hidden] { display: none; }

/* --- auth --- */
.auth { max-width: 360px; margin: 40px auto; }
.authform { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.authform label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.authform input {
  font: inherit; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  color: var(--fg); background: var(--surface);
}
.authform input:focus { outline: none; border-color: var(--accent); }
.authform button {
  font: inherit; font-weight: 600;
  padding: 11px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.authform button:hover { filter: brightness(1.1); }
.hint { color: var(--muted); font-size: .8rem; margin: -4px 0 0; }
.alt { color: var(--muted); margin-top: 18px; }
.alt a { color: var(--accent); }
.err {
  background: var(--err-bg); color: var(--err-fg);
  padding: 10px 12px; border-radius: 10px; font-size: .9rem;
}
.success {
  background: #e8f5e9; color: #2e7d32;
  padding: 10px 12px; border-radius: 10px; font-size: .9rem;
}
[data-theme="dark"] .success {
  background: #1b3a1f; color: #81c784;
}
.pw-heading { margin-top: 28px; }

/* --- version footer --- */
.version {
  text-align: center;
  color: var(--muted);
  font-size: .7rem;
  padding: 0 20px 20px;
  opacity: 0.6;
}
.version a {
  color: var(--muted);
  text-decoration: none;
}
.version a:hover {
  color: var(--fg);
  text-decoration: underline;
}

/* --- changelog --- */
.changelog-release { margin-bottom: 28px; }
.changelog-version {
  font-size: 1rem; font-weight: 700; color: var(--fg); margin: 0 0 8px;
}
.changelog-date { font-weight: 400; color: var(--muted); }
.changelog-list {
  margin: 0; padding-left: 20px;
  color: var(--fg); font-size: .9rem; line-height: 1.8;
}

/* --- empty state --- */
.empty-state { color: var(--muted); font-size: .95rem; margin: 18px 0; }

/* --- responsive --- */
@media (max-width: 600px) {
  .nav { flex-wrap: wrap; gap: 10px; }
  .face { width: 48px; height: 48px; font-size: 26px; }
  .streak .num { font-size: 1.4rem; }
  .streaks { gap: 20px; flex-wrap: wrap; }
  :root { --cell: 10px; }
  .note-input { max-width: 100%; }
}
@media (max-width: 400px) {
  :root { --cell: 8px; }
  .face { width: 42px; height: 42px; font-size: 22px; }
}
