:root {
  --bg-main: #f4f7f6;
  --bg-panel: white;
  --bg-header: #0056b3;
  --bg-hover: #eef4f9;
  --bg-overlay: rgba(0, 0, 0, 0.58);
  --bg-modal: #f0f2f5;
  
  --text-main: #333;
  --text-header: white;
  --text-muted: #666;
  --text-light: #999;
  --text-secondary: #555;
  --text-dark: #444;
  --text-black: #222;
  
  --brand-primary: #0056b3;
  --brand-hover: #004494;
  
  --border-light: #eee;
  --border-med: #ccc;
  --border-dark: #ddd;
  
  --danger: #dc3545;
  --danger-hover: #b92d3a;
  --success: #28a745;
  
  --badge-bg: #e0f2fe;
  --badge-text: #0284c7;
  
  --shadow-color: rgba(0,0,0,0.1);
  --shadow-strong: rgba(0,0,0,0.2);
}

body.dark-mode {
  --bg-main: #121212;
  --bg-panel: #1e1e1e;
  --bg-header: #1a1a1a;
  --bg-hover: #2a2a2a;
  --bg-overlay: rgba(0, 0, 0, 0.75);
  --bg-modal: #252525;
  
  --text-main: #e0e0e0;
  --text-header: #e0e0e0;
  --text-muted: #a0a0a0;
  --text-light: #777;
  --text-secondary: #b0b0b0;
  --text-dark: #ccc;
  --text-black: #eee;
  
  --brand-primary: #4dabf7;
  --brand-hover: #3b8fd9;
  
  --border-light: #333;
  --border-med: #444;
  --border-dark: #444;
  
  --danger: #f87171;
  --danger-hover: #ef4444;
  --success: #4ade80;
  
  --badge-bg: #1e3a8a;
  --badge-text: #60a5fa;
  
  --shadow-color: rgba(0,0,0,0.5);
  --shadow-strong: rgba(0,0,0,0.7);
}

body {
  font-family: sans-serif;
  margin: 0;
  padding: clamp(10px, 2vw, 20px);
  background-color: var(--bg-main);
  color: var(--text-main);
  transition: background-color 0.3s, color 0.3s;
}

.main-header {
  background-color: var(--bg-header);
  color: var(--text-header);
  padding: 10px; 
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
  box-shadow: 0 4px 6px var(--shadow-color);
  min-height: 85px;
  height: auto;
  transition: background-color 0.3s;
}

.header-left-group {
  display: flex;
  flex-wrap: wrap; 
  align-items: center;
  gap: 15px; 
  flex: 1 1 auto;
}

.header-brand { 
  display: flex; 
  align-items: center; 
  gap: 15px; 
  flex: 1 1 auto;
  min-width: 250px;
  max-width: 420px; 
}

.header-logo {
  height: clamp(60px, 8vw, 80px);
  width: clamp(60px, 8vw, 80px);
  border-radius: 8px; 
  box-shadow: 0 0px 0px var(--shadow-strong);
  object-fit: cover; 
  flex-shrink: 0; 
}

.header-brand h1 { 
  margin: 0; 
  font-size: clamp(1.5rem, 4vw, 1.875rem);
  letter-spacing: 1px; 
  line-height: 1.1; 
}

.header-controls { 
  display: flex; 
  gap: 15px; 
}

.header-btn {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: background-color 0.2s;
}
.header-btn:hover { background-color: rgba(255, 255, 255, 0.3); }

.header-settings-btn {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0.85;
  transition: opacity 0.2s, transform 0.1s;
}
.header-settings-btn:hover { opacity: 1; transform: scale(1.05); }
.header-settings-btn svg { width: 24px; height: 24px; }
.header-settings-btn span { font-size: 11px; font-weight: bold; letter-spacing: 0.5px; }

.header-search {
  display: flex;
  align-items: center;
  background: var(--bg-panel);
  border-radius: 8px;
  padding: 5px 15px;
  box-shadow: inset 0 1px 3px var(--shadow-color);
  flex: 1 1 200px;
  max-width: 450px;
  min-height: 60px; 
}
.header-search input {
  border: none;
  outline: none;
  font-size: clamp(1rem, 3vw, 1.5rem) !important;
  line-height: 1.2 !important; 
  height: auto !important; 
  padding: 5px 10px;
  flex-grow: 1;
  background: transparent;
  color: var(--text-main);
  width: 100%;
}
.header-search button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 36px !important;
  color: var(--brand-primary);
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 20px;
  align-items: center;
  background: var(--bg-hover);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
}
.search-controls label { font-size: 18px; font-weight: bold; color: var(--text-dark); }
.search-controls input { width: 90px; padding: 10px; font-size: 18px; border-radius: 6px; border: 1px solid var(--border-med); background: var(--bg-panel); color: var(--text-main); }

.dashboard-container {
  display: flex;
  gap: clamp(10px, 2vw, 20px);
  height: calc(100vh - 125px); 
  min-height: 600px;
}
.left-panel {
  flex: 1;
  background: var(--bg-panel);
  border-radius: 8px;
  padding: clamp(10px, 2vw, 20px);
  box-shadow: 0 2px 4px var(--shadow-color);
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s;
}
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vw, 20px);
}
.messages-panel, .future-panel {
  flex: 1;
  background: var(--bg-panel);
  border-radius: 8px;
  padding: clamp(10px, 2vw, 20px);
  box-shadow: 0 2px 4px var(--shadow-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color 0.3s;
  min-height: 250px;
}

@media (max-width: 1024px) {
  .dashboard-container {
    flex-direction: column;
    height: auto;
  }
  .scroll-box {
    overflow-y: visible;
  }
}

@media (max-width: 768px) {
  .main-header {
    flex-direction: column;
    align-items: stretch;
  }
  .header-controls {
    flex-wrap: wrap;
    justify-content: center;
  }
  .header-search {
    max-width: 100%;
  }
  #fullscreen-btn {
    display: none;
  }
}

h2 {
  margin-top: 0;
  color: var(--brand-primary);
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 10px;
  margin-bottom: 10px;
  font-size: 22px;
}
.current-date-subheader {
  font-size: 18px;
  color: var(--text-secondary);
  font-weight: bold;
  margin-bottom: 15px;
}

.edit-btn {
  background: none;
  border: 1px solid var(--brand-primary);
  color: var(--brand-primary);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.edit-btn:hover { background: var(--bg-hover); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--brand-primary);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.1s;
}
.icon-btn:hover { opacity: 1; transform: scale(1.1); }

.day-group-header {
  background-color: var(--bg-hover);
  color: var(--brand-primary);
  padding: 8px 12px;
  font-weight: bold;
  border-radius: 4px;
  margin-top: 15px;
  margin-bottom: 10px;
  font-size: 22px;
}
.event-line-item {
  padding: 6px 12px;
  border-left: 3px solid var(--border-med);
  margin-left: 5px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.event-details { display: flex; flex-direction: column; gap: 2px; }
.event-time { font-size: 18px; color: var(--text-muted); }
.event-title { font-weight: bold; color: var(--text-main); font-size: 22px; }
.event-location, .event-notes { font-size: 18px; color: var(--text-secondary); margin-top: 4px; padding-left: 2px; }
.event-location { font-style: italic; }

.message-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 18px;
}
.message-item strong { color: var(--brand-primary); }

.future-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  table-layout: fixed;
}
.future-table td {
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-light);
  font-size: 20px;
  vertical-align: middle;
}
.col-date { width: 16%; font-weight: bold; color: var(--text-dark); white-space: nowrap; }
.col-edit { width: 8%; text-align: center; }
.col-title { width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-main); }
.col-days { width: 28%; color: var(--text-muted); text-align: right; white-space: nowrap; }

.carousel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 10px;
}
.carousel-title-wrapper { display: flex; align-items: baseline; gap: 8px; }
.carousel-header h2 { border: none; margin: 0; padding: 0; }
#carousel-timer { color: var(--text-muted); font-size: 14px; font-weight: normal; }
.nav-arrow {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--brand-primary);
  cursor: pointer;
}

.scroll-box { flex: 1; overflow-y: auto; overflow-x: hidden; }
.carousel-section { display: none; }
.carousel-section.active { display: block; }

.icon-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 15px;
  margin-top: 10px;
}
.icon-option {
  cursor: pointer;
  border: 3px solid transparent;
  border-radius: 8px;
  padding: 5px;
  transition: border-color 0.2s, transform 0.2s, background-color 0.2s;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
}
.icon-option img {
  width: 100%;
  height: auto;
  max-height: 60px;
  object-fit: contain;
  border-radius: 4px;
}
.icon-option input[type="radio"] { display: none; }
.icon-option:has(input[type="radio"]:checked) {
  border-color: var(--brand-primary);
  background-color: var(--bg-hover);
  transform: scale(1.08);
  box-shadow: 0 4px 8px var(--shadow-color);
}

#sleep-overlay {
  position: fixed;
  inset: 0;
  background-color: black;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease-in-out;
}
#sleep-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.theme-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}
.theme-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}
.theme-switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-med);
  transition: .4s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider { background-color: var(--brand-primary); }
input:checked + .slider:before { transform: translateX(22px); }

.overlay-backdrop {
  position: fixed;  
  inset: 0;
  background: var(--bg-overlay);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 2vw, 20px);
  box-sizing: border-box;
}
.overlay-backdrop.visible { display: flex; }

.overlay-panel {
  background: var(--bg-modal);
  width: 100%;
  max-width: 680px;
  max-height: 85dvh;
  overflow-y: auto;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  padding: clamp(15px, 4vw, 20px);
  box-sizing: border-box;
  transition: background-color 0.3s;
}
.form-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
  margin-bottom: 15px;
}
.app-header { color: var(--brand-primary); }
.app-header h1 { margin: 0; font-size: 2em; text-transform: uppercase; letter-spacing: 1px; }
.app-header p { margin: 5px 0 0 0; font-weight: bold; color: var(--text-muted); }

.close-form-btn {
  background-color: var(--danger);
  color: white;
  border: none;
  padding: 12px 18px;
  font-size: 1em;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.close-form-btn:hover { background-color: var(--danger-hover); }

.form-container {
  background: var(--bg-panel);
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 4px 12px var(--shadow-color);
  width: 100%;
  box-sizing: border-box;
  transition: background-color 0.3s;
}

.form-group { margin-bottom: 15px; }
.form-container label {
  display: block;
  font-weight: bold;
  margin-bottom: 5px;
  color: var(--text-dark);
  font-size: 1.2em;
}

input[type="text"], input[type="number"], select, textarea, input[type="datetime-local"], input[type="date"], input[type="time"] {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-med);
  border-radius: 6px;
  box-sizing: border-box;
  font-size: 1.2em; 
  font-family: inherit;
  background-color: var(--bg-panel);
  color: var(--text-main);
}

.hidden-file-input { display: none !important; }
.custom-file-upload {
  display: block;
  padding: 12px 20px;
  border-radius: 6px;
  border: 1px solid var(--brand-primary);
  background-color: var(--badge-bg);
  color: var(--brand-primary);
  font-weight: bold;
  font-size: 1.1em;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.2s;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 5px;
}
.custom-file-upload:hover { background-color: var(--bg-hover); }

.file-name-display {
  font-size: 0.95em;
  color: var(--text-muted);
  margin-bottom: 12px;
  word-wrap: break-word;
  display: block;
  text-align: center;
}

textarea { resize: vertical; min-height: 100px; }
.submit-message-btn {
  background-color: var(--brand-primary);
  color: white;
  border: none;
  padding: 14px 20px;
  font-size: 1.1em;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  margin-top: 10px;
  transition: background-color 0.2s;
}
.submit-message-btn:hover { background-color: var(--brand-hover); }
.submit-message-btn:disabled { background-color: var(--text-light); cursor: not-allowed; }

.status-message { text-align: center; margin-top: 15px; font-weight: bold; min-height: 20px; }
.success { color: var(--success); }
.error { color: var(--danger); }
.help-text { font-size: 1.05em; color: var(--text-muted); margin-top: 3px; }
.duration-container { display: flex; gap: 10px; }

.message-card {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-dark);
  padding: 15px;
  margin-bottom: 10px;
  border-radius: 6px;
  box-shadow: 0 1px 3px var(--shadow-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  transition: background-color 0.3s;
}
.message-content-left { flex-grow: 1; }
.message-sender { font-weight: bold; color: var(--brand-primary); margin-bottom: 5px; font-size: 1.1em; }
.recipient-badge {
  background-color: var(--badge-bg);
  color: var(--badge-text);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  margin-left: 8px;
}
.message-timestamp { font-weight: normal; color: var(--text-muted); font-size: 0.85em; }
.message-text { font-size: 1.3em; line-height: 1.4; white-space: pre-wrap; color: var(--text-black); }

.reaction-container { display: flex; gap: 12px; flex-shrink: 0; }
.reaction-btn {
  background: none;
  border: none;
  font-size: 1.8em;
  cursor: pointer;
  opacity: 0.3;
  transition: opacity 0.2s, transform 0.2s;
  padding: 0;
}
.reaction-btn:hover { opacity: 0.7; transform: scale(1.1); }
.reaction-btn.active { opacity: 1 !important; transform: scale(1.2); }
.reaction-btn.hidden { display: none; }

.header-brand h1, .header-logo { transition: opacity 0.3s ease-in-out; }
.loading .header-brand h1, .loading .header-logo { opacity: 0; }

#help-content-container {
  color: var(--text-main);
  line-height: 1.6;
  padding: 0 10px;
}
#help-content-container h1, #help-content-container h2, #help-content-container h3 {
  color: var(--brand-primary);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: bold;
}
#help-content-container h1 { 
  font-size: 2.2em; 
  border-bottom: 2px solid var(--border-light); 
  padding-bottom: 10px; 
}
#help-content-container h2 { 
  font-size: 1.6em; 
  margin-top: 2em;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 5px;
}
#help-content-container h3 { font-size: 1.3em; }
#help-content-container p { margin-bottom: 1.2em; }
#help-content-container ul, #help-content-container ol {
  margin-bottom: 1.5em;
  padding-left: 30px;
}
#help-content-container ul { list-style-type: disc; }
#help-content-container ol { list-style-type: decimal; }
#help-content-container li { margin-bottom: 0.5em; }
#help-content-container li p { margin-bottom: 0; }
#help-content-container strong { font-weight: 700; color: var(--text-main); }
#help-content-container em { font-style: italic; }
#help-content-container hr {
  border: none;
  border-top: 2px dashed var(--border-med);
  margin: 2.5em 0;
}
/* Modular Settings Menu Styles */
.settings-menu-container {
  padding: 10px 5px;
}

.settings-section {
  background-color: var(--bg-panel);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 12px var(--shadow-color);
  margin-bottom: 25px;
}

.settings-section-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 25px;
}

.settings-nav-link {
  display: flex;
  align-items: center;
  gap: 15px;
  background-color: var(--bg-panel);
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 4px 12px var(--shadow-color);
  text-decoration: none;
  color: var(--text-main);
  transition: transform 0.2s, box-shadow 0.2s;
}

.settings-nav-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px var(--shadow-strong);
}

.nav-link-icon {
  font-size: 1.8em;
}

.nav-link-text {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.nav-link-text strong {
  font-size: 1.1em;
  color: var(--text-dark);
}

.nav-link-text small {
  font-size: 0.9em;
  color: var(--text-muted);
}

.nav-link-arrow {
  font-size: 1.5em;
  font-weight: bold;
  color: var(--text-light);
}
