:root {
  --bg: #0A0D12;
  --surface: #141922;
  --surface-2: #1C232F;
  --border: #2A3341;
  --text: #EDF0F5;
  --text-dim: #8A93A3;
  --green: #34C759;
  --green-dim: #1E4A2A;
  --red: #FF4D4D;
  --red-dim: #4A1E1E;
  --yellow: #F5C518;
  --yellow-dim: #4A3F1E;
  --blue: #3E8EFF;
  --orange: #FF8A1F;
  --shadow: rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
}

*, input, select, textarea, button { font-style: normal !important; }

.hidden { display: none !important; }

.app-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 18px 60px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 18px;
  border-bottom: 1px solid var(--border);
}
.brand {
  font-size: 20px;
  letter-spacing: 1.5px;
  margin: 0;
  color: var(--text);
}
.user-badge { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--text-dim); }

.text-btn {
  background: none;
  border: none;
  color: var(--blue);
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
}
.text-btn:hover { color: #79B0FF; }

/* Buttons */
.btn {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  font-size: 13px;
  letter-spacing: 0.5px;
  border-radius: 6px;
  padding: 12px 16px;
  border: 1.5px solid transparent;
  cursor: pointer;
  color: var(--text);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #5A9EFF; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }
.btn-small { padding: 8px 12px; font-size: 12px; }
.full-width { width: 100%; }

.btn-status { flex: 1; padding: 12px 8px; font-size: 12px; }
.btn-green { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.btn-green.selected { background: var(--green); color: #06210F; }
.btn-red { background: var(--red-dim); color: var(--red); border-color: var(--red); }
.btn-red.selected { background: var(--red); color: #2A0A0A; }
.btn-yellow { background: var(--yellow-dim); color: var(--yellow); border-color: var(--yellow); }
.btn-yellow.selected { background: var(--yellow); color: #2A2306; }

/* Auth */
.auth-card {
  max-width: 380px;
  margin: 48px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 26px 22px;
  box-shadow: 0 10px 30px var(--shadow);
}
.tabs { display: flex; gap: 6px; margin-bottom: 20px; }
.tab {
  flex: 1;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  font-size: 12px;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-dim); letter-spacing: 0.4px; }
.auth-form input, select, .modal input, .modal textarea {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  font-size: 14px;
  padding: 11px 12px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.modal textarea { resize: vertical; min-height: 90px; }
.auth-form input:focus, select:focus, .modal textarea:focus { outline: 2px solid var(--blue); border-color: var(--blue); }

.error { color: var(--red); font-size: 13px; margin-top: 14px; }
.note { color: var(--text-dim); font-size: 11px; margin-top: 16px; line-height: 1.5; }

/* Calendar + upcoming events layout */
.app-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-top: 22px;
  flex-wrap: wrap;
}
.calendar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 18px 22px;
  box-shadow: 0 10px 30px var(--shadow);
  flex: 2 1 440px;
}
.upcoming-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px 20px 22px;
  box-shadow: 0 10px 30px var(--shadow);
  flex: 1 1 260px;
  max-height: 560px;
  overflow-y: auto;
}
.panel-heading { font-size: 15px; letter-spacing: 1.5px; margin: 0 0 16px; color: var(--text); }
.upcoming-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.upcoming-list .empty-msg { color: var(--text-dim); font-size: 13px; }
.upcoming-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.upcoming-item.upcoming-extracurricular { border-left-color: var(--red); }
.upcoming-date { display: block; font-size: 10px; letter-spacing: 0.5px; color: var(--text-dim); margin-bottom: 4px; }
.upcoming-label { display: block; }

.month-nav { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 14px; }
.month-nav h2 { font-size: 15px; letter-spacing: 1.5px; margin: 0; }
.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 10px;
  color: var(--text-dim);
  padding-bottom: 8px;
  letter-spacing: 0.5px;
}
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day-cell {
  aspect-ratio: 1 / 0.9;
  min-height: 54px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
}
.day-cell:hover { border-color: var(--blue); }
.day-cell.empty { visibility: hidden; cursor: default; }
.day-cell.today { border-color: var(--blue); border-width: 2px; }
.day-num { font-size: 13px; }
.day-dots { display: flex; gap: 3px; align-self: flex-end; flex-wrap: wrap; justify-content: flex-end; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); }
.dot-red { background: var(--red); }
.dot-yellow { background: var(--yellow); }
.dot-event-glow {
  width: 8px;
  height: 8px;
  background: var(--orange);
  box-shadow: 0 0 6px 2px rgba(255, 138, 31, 0.85), 0 0 2px 1px var(--orange);
}
.event-dot-cross { position: relative; width: 10px; height: 10px; }
.event-dot-cross::before,
.event-dot-cross::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 1.6px;
  border-radius: 1px;
  background: var(--red);
}
.event-dot-cross::before { transform: translate(-50%, -50%) rotate(45deg); }
.event-dot-cross::after { transform: translate(-50%, -50%) rotate(-45deg); }
.legend { font-size: 10px; color: var(--text-dim); margin: 16px 2px 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; letter-spacing: 0.4px; }
.legend .dot { margin-left: 6px; }

/* Bottom sheet */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 20;
}
.day-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 86vh;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 30px var(--shadow);
  padding: 10px 20px 34px;
  overflow-y: auto;
  z-index: 21;
}
.sheet-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 6px auto 10px;
}
.close-sheet-btn { position: absolute; top: 14px; right: 16px; font-size: 12px; }
.sheet-title { font-size: 16px; letter-spacing: 1px; margin: 4px 0 20px; }
.sheet-block { margin-bottom: 24px; }
.sheet-block h4 { font-size: 11px; letter-spacing: 1px; color: var(--text-dim); margin: 0 0 10px; }
.sheet-block-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-block-header h4 { margin: 0; }

.events-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.events-list .empty-msg { color: var(--text-dim); font-size: 13px; }
.event-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
}
.event-item .event-meta { display: block; margin-top: 4px; font-size: 11px; color: var(--text-dim); }

.status-buttons { display: flex; gap: 8px; }

.status-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.status-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; min-height: 60px; }
.status-col-header { font-size: 10px; letter-spacing: 0.5px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.col-green { color: var(--green); }
.col-red { color: var(--red); }
.col-yellow { color: var(--yellow); }
.status-name-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }

/* Daily notes (photo uploads) */
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }
.note-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.note-tab {
  flex: 1;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  font-size: 11px;
  letter-spacing: 0.4px;
  cursor: pointer;
}
.note-tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.notes-photo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.notes-photo-grid .empty-msg { grid-column: 1 / -1; color: var(--text-dim); font-size: 13px; }
.note-photo-item {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 1 / 1;
  background: #fff;
  padding: 0;
  cursor: pointer;
  font: inherit;
  display: block;
}
.note-photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.note-photo-item .photo-meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 9px;
  padding: 3px 5px;
  letter-spacing: 0.3px;
}
.upload-status { font-size: 12px; color: var(--text-dim); margin-top: 10px; }

/* Photo lightbox */
.photo-lightbox {
  width: min(480px, 92vw);
  text-align: center;
  padding: 20px;
}
.photo-lightbox .close-sheet-btn { top: 12px; right: 14px; }
.photo-lightbox img {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  margin: 18px 0 18px;
  display: block;
}
.photo-lightbox .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }

/* Syllabus viewer */
.syllabus-modal {
  width: min(480px, 92vw);
  max-height: 72vh;
  overflow-y: auto;
  text-align: left;
  padding: 24px 22px;
}
.syllabus-modal h3 { margin: 0 28px 14px 0; font-size: 15px; letter-spacing: 1px; }
.syllabus-text { white-space: pre-wrap; font-size: 13px; line-height: 1.6; color: var(--text); margin: 0; }
.view-syllabus-btn { margin-left: 6px; font-size: 11px; }

/* Add-event modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 30;
}
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, 90vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 22px;
  z-index: 31;
  box-shadow: 0 10px 30px var(--shadow);
}
.modal h3 { margin: 0 0 18px; font-size: 15px; letter-spacing: 1px; }
#event-form { display: flex; flex-direction: column; gap: 14px; }
#event-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-dim); }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn { flex: 1; }

@media (max-width: 480px) {
  .brand { font-size: 16px; }
  .day-cell { min-height: 44px; }
  .status-columns { gap: 6px; }
}

@media (max-width: 760px) {
  .app-layout { flex-direction: column; }
  .calendar-card, .upcoming-card { flex-basis: auto; width: 100%; }
  .upcoming-card { max-height: 320px; }
}
