:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1f2937;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #d35400;
  --accent-h: #e65c00;
  --weekend-tint: #161d28;
  --weeknum-bg: #161b22;
  --scroll-track: #111827;
  --scroll-thumb: #3b4556;
  --scroll-thumb-hover: #55627a;
}

@font-face {
  font-family: "Good Times";
  src: url("/good%20times%20rg.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; }
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}
.brand-logo { width: 188px; height: auto; display: block; }
.tagline { margin-top: 0.15rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }
.today-main { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.header-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid #2b3442;
  border-radius: 9px;
  background: linear-gradient(160deg, #141a23 0%, #10151d 100%);
  min-width: 138px;
}
.clock-main { font-family: "JetBrains Mono", monospace; font-size: 0.95rem; font-weight: 700; }
.clock-sub { font-size: 0.74rem; color: #718096; }
.user-info { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; color: var(--muted); }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); }

.btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
.btn-small { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

.login-wall { display: flex; align-items: center; justify-content: center; padding: 4rem 1rem; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  max-width: 460px;
  width: 100%;
  text-align: center;
}
.login-card h2 { font-size: 1.3rem; margin-bottom: 0.75rem; }
.login-card p { color: var(--muted); margin-bottom: 1.75rem; font-size: 0.95rem; }
.login-buttons { display: flex; flex-direction: column; gap: 0.75rem; }

#calendarApp { display: grid; grid-template-columns: 240px 1fr; min-height: 0; }
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem;
  overflow-y: auto;
}
.sidebar-create-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}
.sidebar-divider { height: 1px; background: var(--border); margin: 0.85rem 0; }
.sidebar-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.45rem; }
.decimal-link { display: inline-block; margin-top: 0.65rem; font-size: 0.83rem; color: #93c5fd; text-decoration: none; }

.calendar-list { display: flex; flex-direction: column; gap: 0.45rem; }
.calendar-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.36rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text);
}
.calendar-item.disabled { opacity: 0.45; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.main { display: flex; flex-direction: column; min-width: 0; }
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.toolbar-title { font-family: "Good Times", "Source Sans 3", sans-serif; font-size: 1.06rem; font-weight: 700; margin-left: 0.3rem; color: var(--accent); }
.load-status { font-size: 0.78rem; color: var(--muted); margin-left: 0.35rem; }

.nav-btn {
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  border-radius: 7px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}
.nav-btn:hover { border-color: #4b5563; }
.nav-today { background: var(--accent); border-color: var(--accent); color: #fff; }

.view-switcher { display: inline-flex; gap: 0.25rem; }
.view-btn {
  background: var(--panel2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.52rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.view-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.moon-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  border: none;
  background: transparent;
  color: #e5e7eb;
  border-radius: 0;
  width: 22px;
  height: 22px;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  z-index: 3;
}

.fc .fc-daygrid-day-top { padding-right: 28px; }
.fc .fc-daygrid-day-top { justify-content: flex-start; }
.fc .fc-daygrid-day-number { margin-right: auto; }

.moon-panel-inner { width: min(520px, 100%); }
.moon-top { display: flex; align-items: center; gap: 0.7rem; margin: 0.4rem 0 0.7rem; }
.moon-location { color: var(--muted); font-size: 0.82rem; margin-top: 0.35rem; }
.moon-glyph { font-size: 2rem; line-height: 1; }
.moon-name { font-size: 1.05rem; font-weight: 700; }
.moon-meta { color: var(--muted); font-size: 0.9rem; }
.moon-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 0.35rem 0.6rem;
  margin-bottom: 0.75rem;
}
.moon-k { color: var(--muted); }
.moon-list-title { color: var(--muted); font-size: 0.84rem; margin-bottom: 0.35rem; }
.moon-list { list-style: none; display: grid; gap: 0.25rem; max-height: 180px; overflow: auto; }
.moon-list li { font-size: 0.9rem; padding: 0.28rem 0.34rem; border: 1px solid #263244; border-radius: 6px; }

.month-logo-wrap {
  margin: 0.8rem 0.9rem 0;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  background: #121920;
}
.month-logo { width: min(320px, 100%); height: 66px; object-fit: contain; }

#calendar { flex: 1; min-height: 0; padding: 0.8rem 0.9rem 0.9rem; }

.nav-search {
  width: 100%;
  padding: 0.48rem 0.58rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f1722;
  color: var(--text);
}
.search-results {
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f1722;
  max-height: 220px;
  overflow: auto;
}
.search-item { padding: 0.44rem 0.55rem; border-bottom: 1px solid #1f2937; cursor: pointer; }
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: #1f2937; }

.event-panel {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 30;
}
.event-panel-inner {
  width: min(620px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  position: relative;
}
.close-btn {
  position: absolute;
  right: 0.65rem;
  top: 0.65rem;
  border: 1px solid var(--border);
  background: #111827;
  color: var(--text);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
}
.panel-actions { margin-top: 0.9rem; display: flex; gap: 0.45rem; }

.create-panel-inner { width: min(760px, 100%); }
.create-grid { display: grid; gap: 0.55rem; }
.create-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.create-wide { grid-column: 1 / -1; }
.create-field { display: grid; gap: 0.28rem; }
.create-field span { color: var(--muted); font-size: 0.78rem; }
.create-field input,
.create-field select,
.create-field textarea {
  background: #0f1722;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.48rem 0.56rem;
}
.create-check { display: inline-flex; align-items: center; gap: 0.42rem; }
.create-actions { margin-top: 0.7rem; display: flex; justify-content: space-between; align-items: center; }
.create-status { color: var(--muted); font-size: 0.83rem; }

.hidden { display: none !important; }

.fc {
  --fc-border-color: #30363d;
  --fc-page-bg-color: #0d1117;
  --fc-neutral-bg-color: #161b22;
  --fc-list-event-hover-bg-color: #1f2937;
  --fc-today-bg-color: rgba(211, 84, 0, 0.16);
  color: var(--text);
}
.fc .fc-scrollgrid,
.fc .fc-scrollgrid table { border-color: #30363d !important; }
.fc .fc-col-header-cell { background: #161b22; }
.fc .fc-timegrid-slot,
.fc .fc-daygrid-day { background: #111827; }
.fc .fc-day-other .fc-daygrid-day-top { opacity: 0.55; }
.fc .fc-col-header-cell.fc-day-sat .fc-col-header-cell-cushion,
.fc .fc-col-header-cell.fc-day-sun .fc-col-header-cell-cushion {
  color: #6273a3;
}
.fc .fc-daygrid-day.fc-day-sat,
.fc .fc-daygrid-day.fc-day-sun,
.fc .fc-timegrid-col.fc-day-sat,
.fc .fc-timegrid-col.fc-day-sun {
  background: var(--weekend-tint);
}
.fc .fc-daygrid-day.fc-day-sat.fc-day-today,
.fc .fc-daygrid-day.fc-day-sun.fc-day-today,
.fc .fc-timegrid-col.fc-day-sat.fc-day-today,
.fc .fc-timegrid-col.fc-day-sun.fc-day-today {
  background: #242437;
}
.fc .fc-timegrid-axis,
.fc .fc-timegrid-slot-label,
.fc .fc-list-day-text,
.fc .fc-list-day-side-text { color: #9ca3af; }
.fc .fc-timegrid-col:not(:last-child) {
  box-shadow: inset -1px 0 0 #30363d;
}
.fc .fc-timegrid-col-frame {
  border-right: 1px solid #30363d;
}
.fc .fc-timegrid-col:last-child .fc-timegrid-col-frame {
  border-right: none;
}
.fc .fc-button-primary {
  background: #1f2937;
  border-color: #30363d;
  color: #e6edf3;
}
.fc .fc-button-primary:hover,
.fc .fc-button-primary:active { background: #374151; border-color: #4b5563; }
.fc .fc-daygrid-week-number {
  color: #9ca3af;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.fc .fc-timegrid-axis-cushion {
  color: #9ca3af;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
}
.fc .fc-daygrid-week-number {
  background: var(--weeknum-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 1px 6px;
}

.trad-week-gutter-head {
  width: 34px;
  min-width: 34px;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.trad-week-gutter-cell {
  width: 34px;
  min-width: 34px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.74rem;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: none;
  text-align: center;
  vertical-align: middle;
  padding: 0;
}

.trad-week-gutter-inner {
  height: 100%;
  min-height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fc .fc-scrollgrid-section-header .fc-scroller,
.fc .fc-timegrid .fc-daygrid-body .fc-scroller {
  overflow: hidden !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.fc .fc-scrollgrid-section-header .fc-scroller::-webkit-scrollbar,
.fc .fc-timegrid .fc-daygrid-body .fc-scroller::-webkit-scrollbar {
  width: 0;
  height: 0;
}

body,
.sidebar,
.search-results,
.moon-list,
.fc .fc-scroller,
.fc .fc-list-table {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

body::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.search-results::-webkit-scrollbar,
.moon-list::-webkit-scrollbar,
.fc .fc-scroller::-webkit-scrollbar,
.fc .fc-list-table::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.search-results::-webkit-scrollbar-track,
.moon-list::-webkit-scrollbar-track,
.fc .fc-scroller::-webkit-scrollbar-track,
.fc .fc-list-table::-webkit-scrollbar-track {
  background: var(--scroll-track);
}

body::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb,
.moon-list::-webkit-scrollbar-thumb,
.fc .fc-scroller::-webkit-scrollbar-thumb,
.fc .fc-list-table::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 2px solid var(--scroll-track);
}

body::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.search-results::-webkit-scrollbar-thumb:hover,
.moon-list::-webkit-scrollbar-thumb:hover,
.fc .fc-scroller::-webkit-scrollbar-thumb:hover,
.fc .fc-list-table::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

@media (max-width: 1024px) {
  #calendarApp { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
}
