﻿/* ===== CSS VARIABLES ===== */
:root {
  --bg: #0F172A;
  --bg2: #080E1A;
  --card-bg: #1E293B;
  --card-bg2: #253347;
  --accent: #38BDF8;
  --accent2: #A78BFA;
  --accent-hover: #60CDFF;
  --text-primary: #E2E8F0;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --good: #22C55E;
  --neutral: #FACC15;
  --bad: #EF4444;
  --orange: #F97316;
  --border: rgba(255,255,255,0.06);
  --shadow: 0 4px 32px rgba(0,0,0,0.35);
  --radius-card: 20px;
  --radius-btn: 12px;
  --radius-sm: 8px;
  --mood1: #EF4444;
  --mood2: #F97316;
  --mood3: #FACC15;
  --mood4: #4ADE80;
  --mood5: #22C55E;
}

body.light {
  --bg: #F0F4F8;
  --bg2: #E2E8F0;
  --card-bg: #FFFFFF;
  --card-bg2: #F8FAFC;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --border: rgba(0,0,0,0.08);
  --shadow: 0 4px 24px rgba(0,0,0,0.10);
  --accent: #0284C7;
  --accent-hover: #0369A1;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ===== HEADER ===== */
header {
  height: 66px;
  background: rgba(15,23,42,0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  transition: background 0.3s;
}
body.light header { background: rgba(255,255,255,0.88); }

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
}

.header-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.app-title {
  font-family: 'Poppins', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}
.brain-icon { -webkit-text-fill-color: initial; }

.header-streak {
  background: linear-gradient(135deg,rgba(56,189,248,0.15),rgba(167,139,250,0.15));
  border: 1px solid var(--accent2);
  border-radius: 50px;
  padding: 3px 10px;
  font-size: 0.75rem;
  color: var(--accent2);
  font-weight: 600;
  white-space: nowrap;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: center;
}
.nav-link {
  color: var(--text-secondary);
  font-size: 0.88rem;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}
.nav-link:hover { color: var(--text-primary); background: var(--border); }

.btn-insights {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-btn);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn-insights:hover { filter: brightness(1.1); transform: translateY(-1px); }

.theme-toggle {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.25s;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { transform: rotate(20deg) scale(1.1); }

/* ===== MAIN ===== */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 16px 80px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ===== CARD ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 26px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: background 0.3s, border-color 0.3s;
}

.card-title {
  font-family: 'Poppins', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 18px;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.card-header-row .card-title { margin-bottom: 0; }

/* ===== STATS BAR ===== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
@media (max-width: 700px) { .stats-bar { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 440px) { .stats-bar { grid-template-columns: repeat(2, 1fr); } }

.stat-chip {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-chip:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.stat-chip.accent2 { border-color: rgba(167,139,250,0.3); }

.stat-value {
  display: block;
  font-family: 'Poppins', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}
.stat-chip.accent2 .stat-value { color: var(--accent2); }

.stat-label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-secondary);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== QUOTE CARD ===== */
.quote-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: linear-gradient(135deg, rgba(56,189,248,0.07), rgba(167,139,250,0.07));
  border-color: rgba(56,189,248,0.18);
  padding: 20px 22px;
  flex-wrap: wrap;
}
.quote-icon { font-size: 1.6rem; flex-shrink: 0; margin-top: 2px; }
.quote-text {
  flex: 1;
  font-size: 0.98rem;
  color: var(--text-primary);
  font-style: italic;
  line-height: 1.65;
  min-width: 200px;
}
.quote-author {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-style: normal;
}
.btn-new-quote {
  align-self: center;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.btn-new-quote:hover { background: var(--accent); color: #0F172A; }

/* ===== INPUT CARD ===== */
.today-date {
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 8px;
}

/* Mood Selector */
.mood-selector {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
}
.mood-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 2rem;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 10px 4px 8px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s, background 0.2s;
  line-height: 1;
}
.mood-btn span {
  font-size: 0.6rem;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mood-btn:hover { transform: scale(1.14); background: var(--card-bg2); }
.mood-btn.selected {
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(56,189,248,0.45);
  transform: scale(1.1);
  background: rgba(56,189,248,0.08);
}

/* Intensity Slider */
.intensity-wrap { margin-bottom: 18px; }
.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.optional-label { font-weight: 400; text-transform: none; letter-spacing: 0; }
.intensity-slider {
  width: 100%;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 50px;
  background: linear-gradient(90deg, var(--bad), var(--neutral), var(--good));
  outline: none;
  cursor: pointer;
  margin-bottom: 6px;
}
.intensity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--card-bg);
  box-shadow: 0 0 8px rgba(56,189,248,0.5);
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.intensity-slider::-webkit-slider-thumb:hover { box-shadow: 0 0 14px rgba(56,189,248,0.7); }
.intensity-markers {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Tags */
.tags-section { margin-bottom: 18px; }
.tags-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.tag-btn {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 50px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.18s;
  font-family: 'Inter', sans-serif;
}
.tag-btn:hover { border-color: var(--accent); color: var(--accent); }
.tag-btn.active {
  background: rgba(56,189,248,0.12);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Field Row */
.field-row {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}
.field-group { flex: 1; }

.styled-select {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394A3B8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  transition: border-color 0.2s;
}
.styled-select:focus { border-color: var(--accent); }
.small-select { font-size: 0.82rem; padding: 6px 28px 6px 10px; }

/* Textarea */
textarea {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.93rem;
  resize: vertical;
  min-height: 100px;
  outline: none;
  margin-bottom: 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.6;
}
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,189,248,0.12); }
textarea::placeholder { color: var(--text-muted); }

.char-count { font-size: 0.72rem; color: var(--text-muted); text-align: right; margin-bottom: 16px; }

/* Save Button */
.btn-save {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #0EA5E9);
  color: #0F172A;
  border: none;
  border-radius: var(--radius-btn);
  padding: 13px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: filter 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(56,189,248,0.3);
}
.btn-save:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 8px 24px rgba(56,189,248,0.4); }
.btn-save:active { transform: scale(0.98); }

/* Save Feedback */
.save-feedback {
  margin-top: 12px;
  font-size: 0.88rem;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
}
.save-feedback.success { background: rgba(34,197,94,0.12); color: var(--good); border: 1px solid rgba(34,197,94,0.25); }
.save-feedback.error   { background: rgba(239,68,68,0.12); color: var(--bad); border: 1px solid rgba(239,68,68,0.25); }

/* Streak Banner */
.streak-banner {
  margin-top: 14px;
  background: linear-gradient(135deg,rgba(167,139,250,0.12),rgba(56,189,248,0.12));
  border: 1px solid rgba(167,139,250,0.35);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--accent2);
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Today Entry Preview */
.today-entry-preview {
  margin-top: 16px;
  background: rgba(56,189,248,0.06);
  border: 1px solid rgba(56,189,248,0.2);
  border-radius: 14px;
  padding: 14px 16px;
}
.tep-label { font-size: 0.82rem; font-weight: 600; color: var(--good); margin-bottom: 6px; }
.tep-details { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 10px; }
.tep-edit {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.tep-edit:hover { background: var(--accent); color: #0F172A; }

/* ===== CHART SECTION ===== */
.chart-filters { display: flex; gap: 6px; }
.filter-btn {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}
.filter-btn.active, .filter-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(56,189,248,0.08); }

.chart-wrapper { position: relative; height: 260px; }
.short-chart { height: 200px; }

.chart-legend {
  display: flex;
  gap: 18px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-secondary); }
.legend-dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.mood-line-dot { background: var(--accent); }
.avg-dot { background: var(--accent2); }

.chart-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 10px; }

/* ===== TWO COLUMN ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
@media (max-width: 680px) { .two-col { grid-template-columns: 1fr; } }

/* ===== DOUGHNUT ===== */
.doughnut-wrapper {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 16px;
}
.doughnut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  text-align: center;
  pointer-events: none;
}
.doughnut-center span {
  font-family: 'Poppins', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}
.doughnut-center small { font-size: 0.7rem; color: var(--text-secondary); }

.dist-legend {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.dist-swatch {
  width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0;
}
.dist-bar-wrap { flex: 1; height: 5px; background: var(--border); border-radius: 50px; overflow: hidden; }
.dist-bar { height: 100%; border-radius: 50px; transition: width 0.5s ease; }
.dist-count { font-size: 0.75rem; color: var(--text-muted); min-width: 20px; text-align: right; }

/* ===== CALENDAR ===== */
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav-btn {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-primary);
  width: 28px; height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.2s;
}
.cal-nav-btn:hover { background: var(--card-bg2); }
#cal-month-label { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; }

.cal-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 6px;
}
.cal-dow-row span {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: default;
  transition: transform 0.15s;
  position: relative;
}
.cal-day.has-entry { cursor: pointer; color: #fff; }
.cal-day.has-entry:hover { transform: scale(1.15); z-index: 2; }
.cal-day.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-day.mood-0 { background: rgba(255,255,255,0.04); }
.cal-day.mood-1 { background: var(--mood1); }
.cal-day.mood-2 { background: var(--mood2); }
.cal-day.mood-3 { background: var(--mood3); color: #0F172A; }
.cal-day.mood-4 { background: var(--mood4); }
.cal-day.mood-5 { background: var(--mood5); }
.cal-day.empty  { background: transparent; }

.cal-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 0.68rem;
  color: var(--text-muted);
}
.cal-swatch {
  width: 10px; height: 10px; border-radius: 3px; display: inline-block;
}
.cal-swatch.mood-1 { background: var(--mood1); }
.cal-swatch.mood-2 { background: var(--mood2); }
.cal-swatch.mood-3 { background: var(--mood3); }
.cal-swatch.mood-4 { background: var(--mood4); }
.cal-swatch.mood-5 { background: var(--mood5); }

/* ===== TAG ANALYSIS ===== */
.tag-analysis-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.tag-row {
  display: grid;
  grid-template-columns: 110px 1fr 50px 50px;
  align-items: center;
  gap: 10px;
}
.tag-row-name { font-size: 0.82rem; color: var(--text-secondary); }
.tag-row-bar-wrap { height: 8px; background: var(--border); border-radius: 50px; overflow: hidden; }
.tag-row-bar { height: 100%; border-radius: 50px; transition: width 0.5s ease; }
.tag-row-avg { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); text-align: right; }
.tag-row-count { font-size: 0.72rem; color: var(--text-muted); text-align: right; }

/* ===== INSIGHTS ===== */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
@media (max-width: 640px) { .insights-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 400px) { .insights-grid { grid-template-columns: 1fr; } }

.insight-chip {
  background: var(--bg);
  border-radius: 14px;
  padding: 14px 14px 12px;
  border-left: 3px solid var(--accent);
  transition: transform 0.15s, box-shadow 0.15s;
}
.insight-chip:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.2); }
.insight-chip.purple { border-left-color: var(--accent2); }
.insight-chip.green  { border-left-color: var(--good); }
.insight-chip.yellow { border-left-color: var(--neutral); }
.insight-chip.red    { border-left-color: var(--bad); }
.insight-chip.orange { border-left-color: var(--orange); }

.insight-chip-val {
  display: block;
  font-family: 'Poppins', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 3px;
  color: var(--text-primary);
}
.insight-chip-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* Goal Box */
.goal-box {
  background: var(--bg);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
}
.goal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.goal-label { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); }
.goal-pct { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 1.1rem; color: var(--accent); }
.goal-bar-wrap { height: 9px; background: rgba(255,255,255,0.07); border-radius: 50px; overflow: hidden; margin-bottom: 8px; }
.goal-bar { height: 100%; border-radius: 50px; background: linear-gradient(90deg,var(--bad),var(--neutral),var(--good)); transition: width 0.7s ease; width: 0%; }
.goal-hint { font-size: 0.78rem; color: var(--text-muted); }

/* Weekly Report */
.weekly-report { margin-bottom: 20px; }
.wr-title { font-family: 'Poppins', sans-serif; font-size: 0.92rem; font-weight: 700; margin-bottom: 12px; color: var(--text-primary); }
.wr-grid { display: flex; gap: 6px; flex-wrap: wrap; }
.wr-day {
  flex: 1;
  min-width: 36px;
  background: var(--bg);
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
}
.wr-day-name { font-size: 0.62rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.wr-day-emoji { font-size: 1.3rem; display: block; margin: 4px 0 2px; }
.wr-day-val { font-size: 0.72rem; font-weight: 600; color: var(--text-secondary); }
.wr-day.today-wr { border: 1.5px solid var(--accent); }

/* Recommendations */
.recommendations { }
.rec-title { font-family: 'Poppins', sans-serif; font-size: 0.92rem; font-weight: 700; margin-bottom: 12px; color: var(--text-primary); }
.rec-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.rec-item {
  background: var(--bg);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.88rem;
  color: var(--text-primary);
  border-left: 3px solid var(--accent2);
  line-height: 1.5;
}
.rec-item.rec-placeholder { color: var(--text-muted); border-left-color: var(--border); font-style: italic; }

/* ===== HISTORY / JOURNAL ===== */
.history-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.history-search {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 7px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  outline: none;
  width: 180px;
  transition: border-color 0.2s;
}
.history-search:focus { border-color: var(--accent); }
.history-search::placeholder { color: var(--text-muted); }

.history-list { display: flex; flex-direction: column; gap: 10px; }

.h-entry {
  background: var(--bg);
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
  border: 1px solid transparent;
}
.h-entry:hover { transform: translateX(3px); box-shadow: 0 4px 16px rgba(0,0,0,0.2); border-color: var(--border); }
.h-entry-emoji { font-size: 1.8rem; line-height: 1; flex-shrink: 0; }
.h-entry-body { min-width: 0; }
.h-entry-date { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.h-entry-label { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.h-entry-note { font-size: 0.82rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 400px; }
.h-entry-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.h-tag { background: rgba(56,189,248,0.1); color: var(--accent); padding: 2px 8px; border-radius: 50px; font-size: 0.68rem; font-weight: 600; }
.h-entry-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.btn-h-delete {
  background: transparent;
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--bad);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-h-delete:hover { background: rgba(239,68,68,0.1); border-color: var(--bad); }
.h-entry-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }

.history-pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.page-btn {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  width: 34px; height: 34px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.page-btn.active, .page-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(56,189,248,0.08); }

/* ===== EXPORT ===== */
.export-desc { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.6; }
.export-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-export {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-btn);
  font-size: 0.87rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
}
.btn-export:hover { border-color: var(--accent); color: var(--accent); background: rgba(56,189,248,0.06); }
.btn-danger { border-color: rgba(239,68,68,0.3); color: var(--bad); }
.btn-danger:hover { background: rgba(239,68,68,0.08); border-color: var(--bad); color: var(--bad); }

/* ===== FOOTER ===== */
.site-footer {
  text-align: center;
  padding: 32px 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  line-height: 1.8;
}
.footer-link { color: var(--accent); }
.footer-link:hover { text-decoration: underline; }
.footer-sub { margin-top: 4px; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  position: relative;
  animation: modal-in 0.2s ease;
}
@keyframes modal-in { from { opacity:0; transform:scale(0.94) translateY(10px); } to { opacity:1; transform:none; } }
.modal h3 { font-family: 'Poppins', sans-serif; font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.modal p { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 20px; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; }
.btn-modal-cancel {
  background: var(--bg); border: 1.5px solid var(--border);
  color: var(--text-secondary); padding: 9px 18px;
  border-radius: var(--radius-btn); cursor: pointer; font-size: 0.88rem;
  transition: border-color 0.2s;
}
.btn-modal-cancel:hover { border-color: var(--text-secondary); }
.btn-modal-danger {
  background: var(--bad); color: #fff; border: none;
  padding: 9px 18px; border-radius: var(--radius-btn);
  cursor: pointer; font-size: 0.88rem; font-weight: 600;
  transition: filter 0.2s;
}
.btn-modal-danger:hover { filter: brightness(1.1); }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: transparent; border: none; color: var(--text-secondary);
  font-size: 1.1rem; cursor: pointer; padding: 4px 8px; border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}
.modal-close:hover { background: var(--border); color: var(--text-primary); }

/* Detail Modal */
.detail-modal { max-width: 480px; }
.detail-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; padding-right: 30px; }
.detail-emoji { font-size: 2.5rem; }
.detail-date { font-size: 0.78rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.detail-mood-label { font-family: 'Poppins', sans-serif; font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.detail-meta { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 12px; display: flex; gap: 14px; flex-wrap: wrap; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.detail-note {
  background: var(--bg); border-radius: 10px;
  padding: 12px; font-size: 0.9rem;
  color: var(--text-primary); line-height: 1.65;
  white-space: pre-wrap; font-style: italic;
}

/* ===== CONFETTI ===== */
.confetti-canvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 999;
  width: 100%; height: 100%;
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.no-data {
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 24px 0;
  grid-column: 1 / -1;
  font-style: italic;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--card-bg2); border-radius: 50px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .header-nav .nav-link { display: none; }
  .mood-btn span { display: none; }
  .mood-btn { font-size: 1.7rem; }
  .field-row { flex-direction: column; }
  .tag-row { grid-template-columns: 90px 1fr 42px; }
  .tag-row-count { display: none; }
  .h-entry { grid-template-columns: auto 1fr; }
  .h-entry-actions { display: none; }
}
