:root {
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-muted: #f1f5f9;
  --bg-hover: #e2e8f0;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  
  --accent-journal: #10b981;
  --accent-journal-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* NAVBAR */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  z-index: 10;
  gap: 1rem;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
  font-weight: 700;
  font-size: 1.25rem;
}

.nav-date-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.current-date-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-left: 0.5rem;
  white-space: nowrap;
  min-width: 180px;
}

.nav-center {
  display: flex;
  justify-content: center;
}

.view-switcher {
  display: flex;
  background-color: var(--bg-muted);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.view-tab {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-tab:hover {
  color: var(--text-main);
}

.view-tab.active {
  background-color: var(--bg-surface);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* BUTTONS */
.btn {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

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

.btn-secondary {
  background-color: var(--bg-muted);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background-color: var(--bg-muted);
  color: var(--text-main);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 1.1rem;
}

.btn-icon:hover {
  background-color: var(--bg-muted);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

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

.btn-outline:hover {
  background-color: var(--bg-muted);
  color: var(--text-main);
}

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

.btn-danger:hover {
  background-color: #b91c1c;
}

/* MAIN LAYOUT */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.calendar-panel {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

/* JOURNAL SIDEBAR PANEL */
.journal-panel {
  width: 420px;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  overflow-y: auto;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.02);
  transition: transform 0.25s ease, width 0.25s ease;
}

.journal-panel.collapsed {
  display: none;
}

.journal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.journal-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent-journal);
  text-transform: uppercase;
}

.journal-date-heading {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0.15rem;
}

.journal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-indicator {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.close-journal-btn {
  width: 28px;
  height: 28px;
  font-size: 0.85rem;
}

/* DICTATION CARD */
.dictation-card {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.dictation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dictation-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #166534;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #22c55e;
}

.btn-mic {
  background-color: #059669;
  color: white;
  border: none;
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-mic:hover {
  background-color: #047857;
}

.btn-mic.listening {
  background-color: var(--danger);
  animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.live-speech-box {
  margin-top: 0.6rem;
  background-color: rgba(255, 255, 255, 0.85);
  border: 1px dashed #86efac;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}

.preview-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #15803d;
  display: block;
  margin-bottom: 0.2rem;
}

.interim-text {
  font-size: 0.85rem;
  font-style: italic;
  color: #166534;
  min-height: 1.2rem;
}

.speech-hints {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: #15803d;
}

/* JOURNAL METADATA */
.journal-meta-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.mood-selector {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mood-selector select {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.tags-input-container {
  flex: 1;
}

.tags-input-container input {
  width: 100%;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

/* JOURNAL TEXTAREA */
.journal-editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 240px;
}

#journal-textarea {
  width: 100%;
  flex: 1;
  font-family: inherit;
  font-size: 0.925rem;
  line-height: 1.6;
  color: var(--text-main);
  padding: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  resize: none;
  background-color: var(--bg-surface);
  transition: border-color 0.15s ease;
}

#journal-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

.journal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.stats-text {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.journal-actions {
  display: flex;
  gap: 0.5rem;
}

/* ========================================================================= */
/* MONTH VIEW                                                                */
/* ========================================================================= */
.month-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.month-weekday-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background-color: var(--bg-muted);
  border-bottom: 1px solid var(--border-color);
  text-align: center;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.6rem 0;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  flex: 1;
}

.month-cell {
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem;
  min-height: 95px;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  cursor: pointer;
  transition: background-color 0.1s ease;
  position: relative;
}

.month-cell:nth-child(7n) {
  border-right: none;
}

.month-cell:hover {
  background-color: #f8fafc;
}

.month-cell.pad-day {
  background-color: #fafbfc;
  color: var(--text-subtle);
}

.month-cell.selected {
  background-color: #eff6ff;
}

.month-cell.today .day-number {
  background-color: var(--primary);
  color: #ffffff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cell-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.day-number {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.month-cell.pad-day .day-number {
  color: var(--text-subtle);
}

.journal-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-journal);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.cell-events-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow: hidden;
}

.event-badge {
  font-size: 0.725rem;
  font-weight: 500;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: #ffffff;
  background-color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 3px solid rgba(0, 0, 0, 0.25);
}

.more-events-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0.1rem;
}

/* ========================================================================= */
/* WEEK VIEW                                                                 */
/* ========================================================================= */
.week-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.week-header-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  background-color: var(--bg-muted);
  border-bottom: 1px solid var(--border-color);
}

.week-col-header {
  padding: 0.75rem 0.5rem;
  text-align: center;
  border-left: 1px solid var(--border-color);
  cursor: pointer;
}

.week-col-header:hover {
  background-color: var(--bg-hover);
}

.week-col-header.selected {
  background-color: #eff6ff;
}

.week-day-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.week-day-number {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.week-body-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.week-hour-row {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  min-height: 52px;
  border-bottom: 1px solid var(--border-color);
}

.week-time-gutter {
  font-size: 0.72rem;
  color: var(--text-subtle);
  padding: 0.4rem 0.5rem;
  text-align: right;
  border-right: 1px solid var(--border-color);
}

.week-slot-cell {
  border-left: 1px solid var(--border-color);
  padding: 0.2rem;
  position: relative;
  transition: background-color 0.1s ease;
}

.week-slot-cell:hover {
  background-color: #f8fafc;
}

/* ========================================================================= */
/* DAY VIEW                                                                  */
/* ========================================================================= */
.day-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
  padding: 1.5rem;
}

.day-header-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.day-journal-preview-card {
  background-color: var(--bg-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.day-journal-preview-card h4 {
  font-size: 0.85rem;
  color: var(--accent-journal);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.day-timeline {
  display: flex;
  flex-direction: column;
}

.day-hour-slot {
  display: flex;
  min-height: 60px;
  border-bottom: 1px solid var(--border-color);
}

.day-time-label {
  width: 90px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  padding-top: 0.4rem;
}

.day-slot-content {
  flex: 1;
  border-left: 1px solid var(--border-color);
  padding: 0.4rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* ========================================================================= */
/* YEAR VIEW                                                                 */
/* ========================================================================= */
.year-container {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  padding: 0.5rem;
}

.mini-month-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.mini-month-title {
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
  color: var(--text-main);
  cursor: pointer;
}

.mini-month-title:hover {
  color: var(--primary);
}

.mini-weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-subtle);
  margin-bottom: 0.25rem;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mini-day-cell {
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  position: relative;
}

.mini-day-cell:hover {
  background-color: var(--bg-muted);
}

.mini-day-cell.today {
  background-color: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.mini-day-cell.has-journal::after {
  content: '';
  position: absolute;
  bottom: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: var(--accent-journal);
}

.mini-day-cell.today.has-journal::after {
  background-color: #ffffff;
}

/* ========================================================================= */
/* MODALS                                                                    */
/* ========================================================================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  animation: modal-appear 0.2s ease-out;
}

.modal-card.modal-lg {
  max-width: 680px;
}

@keyframes modal-appear {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.5rem;
  max-height: 75vh;
  overflow-y: auto;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

.form-group label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

.modal-footer {
  display: flex;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  gap: 0.75rem;
}

.footer-spacer {
  flex: 1;
}

/* SEARCH & BACKUP MODALS */
.search-input-box input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.search-result-item {
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  cursor: pointer;
  transition: all 0.15s ease;
}

.search-result-item:hover {
  border-color: var(--primary);
  background-color: #f8fafc;
}

.result-date-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.35rem;
  display: inline-block;
}

.result-snippet {
  font-size: 0.875rem;
  color: var(--text-main);
  line-height: 1.5;
}

.backup-action-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.25rem;
}

.action-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  background-color: var(--bg-muted);
}

.action-card h4 {
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.action-card p {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.hidden {
  display: none !important;
}

/* RESPONSIVENESS */
@media (max-width: 1024px) {
  .year-container {
    grid-template-columns: repeat(3, 1fr);
  }
  .journal-panel {
    width: 360px;
  }
}

@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
  }
  .year-container {
    grid-template-columns: repeat(2, 1fr);
  }
  .main-layout {
    flex-direction: column;
  }
  .journal-panel {
    position: absolute;
    right: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
  }
}
