/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg1:          #1e1f22;
  --bg2:          #2b2d31;
  --bg3:          #313338;
  --surface:      #383a40;
  --surface-hi:   #404249;
  --border:       #1e1f22;
  --accent:       #5865F2;
  --accent-hover: #4752c4;
  --accent-low:   rgba(88,101,242,.15);
  --danger:       #ed4245;
  --danger-hover: #c03537;
  --success:      #57f287;
  --text:         #dbdee1;
  --text-muted:   #949ba4;
  --text-head:    #f2f3f5;
  --interactive:  #b5bac1;
  --shadow:       0 8px 32px rgba(0,0,0,.45);
  --radius:       12px;
  --radius-sm:    8px;
}

[data-theme="light"] {
  --bg1:          #e3e5e8;
  --bg2:          #f2f3f5;
  --bg3:          #ffffff;
  --surface:      #ffffff;
  --surface-hi:   #f2f3f5;
  --border:       #d5d8dc;
  --accent:       #5865F2;
  --accent-hover: #4752c4;
  --accent-low:   rgba(88,101,242,.12);
  --danger:       #d83c3e;
  --danger-hover: #a02e30;
  --success:      #2d7d46;
  --text:         #2e3338;
  --text-muted:   #747f8d;
  --text-head:    #060607;
  --interactive:  #4e5058;
  --shadow:       0 8px 32px rgba(0,0,0,.12);
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg1); }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg2);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  transition: background .2s, color .2s;
  -webkit-font-smoothing: antialiased;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(.96); }

.btn-discord {
  background: var(--accent);
  color: #fff;
  padding: .8rem 1.6rem;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(88,101,242,.4);
}
.btn-discord:hover { background: var(--accent-hover); box-shadow: 0 4px 20px rgba(88,101,242,.5); }

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

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-hi); color: var(--text); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hi); }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: .45rem;
  border-radius: 6px;
  line-height: 1;
  font-size: 1.15rem;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface-hi); color: var(--text); }

.btn-sm { padding: .35rem .75rem; font-size: .8rem; }

/* ── Theme switch ───────────────────────────────────────────────────────────── */
.theme-switch {
  position: relative;
  display: inline-block;
  cursor: pointer;
  user-select: none;
}
.theme-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Track: 68×28px pill — icons baked in as pseudo-elements */
.ts-track {
  display: block;
  width: 68px;
  height: 28px;
  background: #23263c;        /* night sky */
  border-radius: 14px;
  position: relative;
  transition: background .3s cubic-bezier(.4,0,.2,1);
  box-shadow: inset 0 1px 4px rgba(0,0,0,.45);
  overflow: hidden;
}

/* ☀️ left side — visible when light mode (thumb moves right) */
.ts-track::before {
  content: '☀️';
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .8rem;
  line-height: 1;
  z-index: 0;
}

/* 🌙 right side — visible when dark mode (thumb stays left) */
.ts-track::after {
  content: '🌙';
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .8rem;
  line-height: 1;
  z-index: 0;
}

/* Light mode: warm amber track */
.theme-switch input:checked + .ts-track {
  background: #e8a800;
}

/* Thumb: white circle with drop shadow, bouncy spring animation */
.ts-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
  transition: transform .28s cubic-bezier(.34,1.2,.64,1);
  z-index: 1;
  pointer-events: none;
}
/* Dark→Light: slide right by (68 - 3 - 3 - 22) = 40px */
.theme-switch input:checked + .ts-track .ts-thumb {
  transform: translateX(40px);
}

/* Page-level toggle: fixed top-right corner */
.page-theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
}

/* ── Floating Action Button ──────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(88,101,242,.5);
  z-index: 100;
  transition: background .15s, transform .12s, box-shadow .15s;
}
.fab:hover  { background: var(--accent-hover); box-shadow: 0 6px 24px rgba(88,101,242,.6); }
.fab:active { transform: scale(.9); }

/* ── Center pages (login / failed) ─────────────────────────────────────────── */
.center-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: var(--bg1);
}

.login-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: card-in .25s ease;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo { margin-bottom: 1.25rem; }
.login-logo svg { filter: drop-shadow(0 4px 12px rgba(88,101,242,.3)); }

.login-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-head);
  margin-bottom: .5rem;
  letter-spacing: -.02em;
}

.login-sub {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 1.75rem;
  line-height: 1.6;
}

.fail-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(237,66,69,.15);
  color: var(--danger);
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  font-weight: 800;
}

/* ── Schedule page layout ───────────────────────────────────────────────────── */
.schedule-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Navbar ─────────────────────────────────────────────────────────────────── */
.navbar {
  flex-shrink: 0;
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: .75rem;
  z-index: 50;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-head);
  letter-spacing: -.01em;
  margin-right: auto;
}

.brand-logo {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
}

.user-name {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── All-days area ──────────────────────────────────────────────────────────── */
.days-outer {
  flex: 1;
  overflow: auto;
  padding: .85rem;
  background: var(--bg2);
}

.all-days-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .75rem;
  align-items: start;
}

/* ── Day columns ────────────────────────────────────────────────────────────── */
.day-col {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.day-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem .85rem;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.day-col-header:hover { background: var(--surface-hi); }

.day-col-header h3 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-head);
}

.day-col-events {
  padding: .55rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  min-height: 80px;
}

.col-empty {
  font-size: .78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1.25rem .4rem;
  line-height: 1.6;
}

/* ── Day column header: clickable in overview ───────────────────────────────── */
.day-col-arrow {
  font-size: 1rem;
  color: var(--text-muted);
  transition: color .12s, transform .12s;
  flex-shrink: 0;
}
.day-col-header:hover .day-col-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* ── Compact event cards ────────────────────────────────────────────────────── */
.event-card-compact {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: .55rem .65rem;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s, border-color .15s;
  min-width: 0;
  animation: card-in .18s ease;
}
.event-card-compact:hover {
  box-shadow: 0 2px 10px rgba(88,101,242,.2);
  transform: translateY(-1px);
  border-color: var(--accent);
}
.event-card-compact:active { transform: scale(.98); }

.compact-time {
  font-size: .68rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .04em;
  line-height: 1.3;
}

.compact-title {
  font-size: .83rem;
  font-weight: 600;
  color: var(--text-head);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: .1rem;
}

.compact-img-badge {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: .2rem;
  display: block;
}

.compact-desc {
  font-size: .75rem;
  color: var(--text-muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: .2rem;
  line-height: 1.4;
  word-break: break-word;
}

/* ── Full event cards (day detail page) ─────────────────────────────────────── */
.event-list {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.event-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
  animation: card-in .2s ease;
}
.event-card:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-low); }

.event-bar { width: 4px; flex-shrink: 0; background: var(--accent); }

.event-body { padding: .9rem 1rem; flex: 1; min-width: 0; }

.event-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .25rem;
}

.event-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-head);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.event-thumb {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: .65rem;
  cursor: zoom-in;
  display: block;
}

.event-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .65rem;
  gap: .5rem;
}

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
  text-align: center;
}
.empty-state .empty-icon { font-size: 2.5rem; opacity: .5; }
.empty-state p { font-size: .9rem; }

/* ── Day detail layout ──────────────────────────────────────────────────────── */
.day-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  justify-content: center;
}

.day-main-inner {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: .2rem .5rem;
  border-radius: var(--radius-sm);
  transition: background .12s, color .12s;
  margin-right: .15rem;
}
.back-link:hover { background: var(--surface-hi); color: var(--text); }

/* ── Detail modal body ──────────────────────────────────────────────────────── */
.detail-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.detail-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-head);
  word-break: break-word;
}

.detail-image {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  cursor: zoom-in;
  display: block;
}

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

/* ── Event meta elements (time badge, desc, by-line) ───────────────────────── */
.event-time {
  font-size: .72rem;
  font-weight: 700;
  background: var(--accent-low);
  color: var(--accent);
  padding: .15rem .45rem;
  border-radius: 4px;
  letter-spacing: .03em;
}

.event-desc {
  font-size: .875rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.event-by {
  font-size: .75rem;
  color: var(--text-muted);
}

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  backdrop-filter: blur(3px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modal-in .18s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg3);
  z-index: 1;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--text-head); }

.modal form { padding: 1.25rem; display: flex; flex-direction: column; gap: .9rem; }

/* ── Form controls ──────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .4rem; }

.form-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}
.required { color: var(--danger); }

.form-input, .form-textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .9rem;
  padding: .6rem .85rem;
  width: 100%;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88,101,242,.2);
}
.form-textarea { resize: vertical; min-height: 80px; }

.file-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color .15s, background .15s;
}
.file-zone:hover, .file-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-low);
}
.file-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-zone-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  pointer-events: none;
}
.file-zone-icon { font-size: 1.75rem; }
.file-zone-text { font-size: .8rem; color: var(--text-muted); }
#previewImg {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: .5rem;
  display: none;
}

.form-actions { display: flex; gap: .6rem; justify-content: flex-end; padding-top: .25rem; }

/* ── Lightbox ───────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.lightbox.hidden { display: none; }
.lightbox-bg {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.88);
  cursor: zoom-out;
}
.lightbox img {
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 16px 64px rgba(0,0,0,.6);
}
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0,0,0,.5);
  border: none;
  color: #fff;
  font-size: 1.2rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.lightbox-close:hover { background: rgba(0,0,0,.8); }

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface); border-radius: 3px; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .all-days-grid { grid-template-columns: repeat(5, 210px); }
}

@media (max-width: 700px) {
  .all-days-grid { grid-template-columns: repeat(5, 170px); }
  .user-name { display: none; }
  .day-main { padding: .85rem .75rem 5rem; }

  .modal { max-height: 95vh; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: var(--radius) var(--radius) 0 0; max-width: 100%; }
  @keyframes modal-in {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .login-card { padding: 2rem 1.25rem; }
  .login-title { font-size: 1.35rem; }
}

@media (max-width: 480px) {
  .all-days-grid { grid-template-columns: repeat(5, 148px); }
  .navbar-brand { font-size: .875rem; }
  .day-col-header { padding: .5rem .65rem; }
}
