:root {
  --bg: #14151c;
  --panel: #1c1e29;
  --accent: #5865f2;
  --accent-glow: #8b7cf6;
  --accent-warm: #ffb454;
  --text: #eef0fa;
  --muted: #8b8fa3;
  --danger: #ed4245;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid #383a4a;
}

h1 { font-size: 1.25rem; margin: 0; }

main { padding: 1.5rem; max-width: 1000px; margin: 0 auto; }

#login-gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, #2a2c3a 1px, transparent 1.5px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(circle at 50% 40%, black 0%, transparent 70%);
  mask-image: radial-gradient(circle at 50% 40%, black 0%, transparent 70%);
  z-index: 0;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: hero-in 0.5s ease-out;
}

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

@media (prefers-reduced-motion: reduce) {
  .hero { animation: none; }
}

.hero-title {
  font-size: 1.85rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}

.hero-sub {
  color: var(--muted);
  margin: 0 0 1.75rem;
  font-size: 1rem;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.pill-btn {
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.pill-btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 16px rgba(88, 101, 242, 0.35);
}
.pill-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(88, 101, 242, 0.45); }
.pill-btn-primary:active { transform: translateY(0) scale(0.98); }

.pill-btn-secondary { background: var(--panel); color: var(--text); border: 1px solid #383a4a; }
.pill-btn-secondary:hover { transform: translateY(-2px); border-color: var(--accent); }
.pill-btn-secondary:active { transform: translateY(0) scale(0.98); }

.btn, button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.95rem;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.12s ease, background 0.15s ease;
}

button.danger { background: var(--danger); }
button#cancel-btn { background: #454858; }
button:active { transform: scale(0.97); }

#calendar {
  background: var(--panel);
  padding: 1rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.muted { color: var(--muted); }

#guild-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.guild-card {
  background: var(--panel);
  border: 1px solid #383a4a;
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.guild-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-soft); }

.guild-card img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1e1f27;
}

.guild-card .fallback-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.calendar-toolbar h2 {
  margin: 0;
  flex: 1;
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  background: var(--panel);
  border: 1px solid #383a4a;
  color: var(--text);
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 8px;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

#drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}

#drawer-overlay.open { opacity: 1; pointer-events: auto; }

#side-drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: min(80vw, 280px);
  background: var(--panel);
  border-right: 1px solid #383a4a;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 50;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#side-drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.drawer-item {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-radius: 8px;
  font-size: 0.95rem;
  width: 100%;
}

.drawer-item:hover { background: var(--bg); }

.recurring-panel {
  padding: 1.5rem;
  width: min(90vw, 480px);
}

.recurring-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid #383a4a;
}

.recurring-item:last-child { border-bottom: none; }

.recurring-item .info { display: flex; flex-direction: column; }
.recurring-item .freq { color: var(--muted); font-size: 0.85rem; }

.recurring-item button { background: var(--danger); padding: 0.4rem 0.8rem; }

#current-guild-name { margin-top: 0; }

dialog {
  border: none;
  border-radius: 10px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  width: min(90vw, 480px);
}

dialog::backdrop { background: rgba(0,0,0,0.6); }

#event-form { padding: 1.5rem; display: flex; flex-direction: column; gap: 0.9rem; }

label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }

label.checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }

input, textarea, select {
  background: #1e1f27;
  border: 1px solid #383a4a;
  color: var(--text);
  padding: 0.5rem;
  border-radius: 6px;
  font-size: 0.95rem;
}

fieldset { border: 1px solid #383a4a; border-radius: 8px; padding: 0.75rem; }
legend { color: var(--muted); padding: 0 0.4rem; }

.reminder-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; align-items: center; }
.reminder-row input { flex: 1; }
.reminder-row button { background: var(--danger); padding: 0.3rem 0.6rem; }

.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }

.fc-event { cursor: pointer; }

/* --- FullCalendar dark theme (it ships styled for a light page by default) --- */
.fc {
  --fc-border-color: #383a4a;
  --fc-page-bg-color: transparent;
  --fc-neutral-bg-color: #20222e;
  --fc-neutral-text-color: var(--muted);
  --fc-today-bg-color: rgba(88, 101, 242, 0.15);
  --fc-button-text-color: #fff;
  --fc-button-bg-color: var(--accent);
  --fc-button-border-color: var(--accent);
  --fc-button-hover-bg-color: #4752c4;
  --fc-button-hover-border-color: #4752c4;
  --fc-button-active-bg-color: #3c45a5;
  --fc-button-active-border-color: #3c45a5;
  --fc-event-bg-color: var(--accent);
  --fc-event-border-color: var(--accent);
  --fc-event-text-color: #fff;
  --fc-list-event-hover-bg-color: #262838;
  --fc-highlight-color: rgba(88, 101, 242, 0.2);
  color: var(--text);
}

.fc .fc-toolbar-title { color: var(--text); font-size: 1.05rem; }
.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number,
.fc .fc-list-day-text,
.fc .fc-list-day-side-text {
  color: var(--text);
  text-decoration: none;
}
.fc .fc-daygrid-day.fc-day-other .fc-daygrid-day-number { color: var(--muted); }
.fc .fc-list-empty { background: transparent; color: var(--muted); }
.fc .fc-button { border-radius: 6px; box-shadow: none; text-transform: capitalize; }
.fc .fc-button:focus { box-shadow: none; }
.fc .fc-toolbar.fc-header-toolbar { flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }

.fc-daygrid-day-frame { overflow: hidden; }
.fc-daygrid-day-events { overflow: hidden; }
.fc-daygrid-event {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
  font-size: 0.78rem;
}
.fc-daygrid-event .fc-event-title { overflow: hidden; text-overflow: ellipsis; }
.fc-daygrid-more-link { color: var(--muted); font-size: 0.78rem; }

/* --- Mobile (phone-width) adjustments --- */
@media (max-width: 640px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.9rem 1rem;
  }

  main { padding: 0.75rem; }

  #calendar { padding: 0.5rem; }

  .calendar-toolbar { flex-wrap: wrap; gap: 0.5rem; }

  dialog, .recurring-panel { width: 94vw; max-height: 88vh; overflow-y: auto; }

  #event-form { padding: 1rem; }

  .reminder-row { flex-wrap: wrap; }
  .reminder-row input { min-width: 0; flex: 1 1 100%; }
  .reminder-row span { flex: 1 1 100%; font-size: 0.8rem; }

  .modal-actions { justify-content: stretch; }
  .modal-actions button { flex: 1 1 auto; }

  #guild-list { grid-template-columns: 1fr; }

  .recurring-item { flex-direction: column; align-items: flex-start; gap: 0.4rem; }

  .hero-actions { flex-direction: column; align-items: stretch; width: 100%; }
  .pill-btn { width: 100%; }
}
