html {
  color-scheme: dark light;
}

/*
  Default theme: dark.
  Light mode is applied only when the device explicitly prefers light mode.
*/
:root {
  --brand: #ff383c;
  --brand-hover: #ff5054;
  --brand-soft: rgba(255, 56, 60, 0.14);
  --brand-softer: rgba(255, 56, 60, 0.08);

  --bg: #121212;
  --card: #1e1e1e;
  --card-strong: #242424;
  --surface: #2b2b2b;
  --surface-hover: #333333;

  --text: #f4f4f4;
  --muted: #b0b0b0;
  --border: #3a3a3a;

  --danger: #ff6b6f;
  --danger-bg: rgba(255, 56, 60, 0.10);
  --danger-border: rgba(255, 56, 60, 0.35);

  --shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
  --dialog-shadow: 0 24px 70px rgba(0, 0, 0, 0.50);

  --radius-lg: 18px;
  --radius-md: 12px;
  --page-pad: 24px;
}

@media (prefers-color-scheme: light) {
  :root {
    --brand-soft: rgba(255, 56, 60, 0.12);
    --brand-softer: rgba(255, 56, 60, 0.06);

    --bg: #f6f6f6;
    --card: #ffffff;
    --card-strong: #f1f1f1;
    --surface: #e9e9e9;
    --surface-hover: #dddddd;

    --text: #222222;
    --muted: #666666;
    --border: #dddddd;

    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --danger-border: #fecaca;

    --shadow: 0 14px 34px rgba(0, 0, 0, 0.08);
    --dialog-shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: var(--page-pad);
  background:
    radial-gradient(circle at top, var(--brand-softer), transparent 340px),
    var(--bg);
  font-size: 20px;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background-color 220ms ease, color 220ms ease;
}

a,
button,
input,
textarea {
  font: inherit;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
}

/* Header / hero */

.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 18px;
  text-align: center;
}

.title {
  margin: 0 0 4px;
  color: var(--text);
  font-family: 'Morl', system-ui, sans-serif;
  font-size: 2.2em;
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-family: 'Morl', system-ui, sans-serif;
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 200;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
}

h1 {
  margin: 0;
  font-size: 2.2em;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.top-actions,
.links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.links {
  justify-content: center;
  margin: 0 0 18px;
}

/* Buttons */

.button-link,
button,
.links button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: 0.8em;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.15;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.button-link:hover,
button:hover,
.links button:hover {
  background: var(--surface);
  border-color: var(--surface-hover);
}

.button-primary,
.button-link.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 700;
}

.button-primary:hover,
.button-link.primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.button-link:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.fc .fc-button:focus-visible {
  outline: 3px solid var(--brand-soft);
  outline-offset: 2px;
}

/* Cards */

.calendar-card,
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition:
    background-color 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease;
}

.calendar-card {
  overflow: hidden;
  padding: 16px;
  border-radius: var(--radius-lg);
}

#calendar {
  width: 100%;
}

/* Login */

body.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top left, var(--brand-softer), transparent 34rem),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  border-radius: 22px;
  padding: 28px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  margin-bottom: 18px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.05em;
  box-shadow: 0 10px 22px rgba(255, 56, 60, 0.28);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: clamp(1.55rem, 5vw, 2.05rem);
}

.login-card .subtitle {
  margin: 0 0 24px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.98rem;
  font-weight: 400;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  background: var(--card-strong);
  color: var(--text);
  outline: none;
}

input {
  min-height: 46px;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

textarea {
  resize: vertical;
}

.error {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  font-weight: 600;
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

/* Admin modal */

dialog {
  width: min(520px, calc(100vw - 24px));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--dialog-shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(4px);
}

dialog form {
  display: grid;
  gap: 12px;
  padding: 20px;
}

dialog h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

input[type="color"] {
  width: 72px;
  height: 44px;
  padding: 4px;
  cursor: pointer;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

menu {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 0;
  margin: 8px 0 0;
  flex-wrap: wrap;
}

#deleteBtn {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

/* FullCalendar */

.fc,
.fc a {
  color: var(--text);
}

.fc {
  font-size: 0.95rem;
}

.fc .fc-toolbar-title {
  color: var(--text);
  font-size: clamp(1.1rem, 4vw, 1.65rem);
}

.fc-theme-standard td,
.fc-theme-standard th,
.fc-theme-standard .fc-scrollgrid {
  border-color: var(--border);
}

.fc .fc-col-header-cell,
.fc .fc-list-day-cushion {
  background: var(--surface);
}

.fc .fc-col-header-cell-cushion,
.fc .fc-list-day-text,
.fc .fc-list-day-side-text,
.fc .fc-daygrid-day-number,
.fc .fc-timegrid-axis-cushion,
.fc .fc-timegrid-slot-label-cushion {
  color: var(--text);
}

.fc .fc-daygrid-day,
.fc .fc-timegrid-slot,
.fc .fc-list-empty {
  background: var(--card);
}

.fc .fc-daygrid-event {
  white-space: normal;
}

.fc .fc-list-event-title a {
  color: inherit;
}

.fc .fc-list-event:hover td {
  background: var(--surface-hover);
}

.fc .fc-day-today,
.fc .fc-timegrid-col.fc-day-today,
.fc .fc-daygrid-day.fc-day-today {
  background: var(--brand-softer) !important;
}

.fc .fc-col-header-cell.fc-day-today,
.fc-theme-standard th.fc-day-today {
  background: var(--brand) !important;
}

.fc .fc-col-header-cell.fc-day-today a,
.fc .fc-col-header-cell.fc-day-today .fc-col-header-cell-cushion,
.fc-theme-standard th.fc-day-today a {
  color: #fff !important;
}

.fc .fc-now-indicator-line {
  border-color: var(--brand);
}

.fc .fc-now-indicator-arrow {
  border-color: var(--brand);
}

.fc .fc-button {
  min-height: 38px;
  border-radius: 999px;
  box-shadow: none !important;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.fc .fc-button-primary,
.fc .fc-button-primary:not(:disabled) {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}

.fc .fc-button-primary:hover,
.fc .fc-button-primary:not(:disabled):hover {
  background: var(--surface);
  border-color: var(--surface-hover);
  color: var(--text);
}

.fc .fc-button-primary:focus,
.fc .fc-button-primary:not(:disabled):focus {
  box-shadow: none;
}

.fc .fc-button-primary:active,
.fc .fc-button-primary.fc-button-active,
.fc .fc-button-primary:not(:disabled):active,
.fc .fc-button-primary:not(:disabled).fc-button-active {
  background: var(--brand) !important;
  border-color: var(--brand) !important;
  color: #fff !important;
}

.fc .fc-button-primary:disabled {
  background: var(--card);
  border-color: var(--border);
  color: var(--muted);
  opacity: 0.7;
}

/* Responsive */

@media (max-width: 700px) {
  :root {
    --page-pad: 12px;
  }

  .back-button{
    display: none;
  }

  .back-arrow{
    display: inline;
  }

  .hero {
    display: block;
    margin-bottom: 14px;
  }

  .title {
    font-size: clamp(2.8rem, 14vw, 4.2rem);
  }

  .top {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .links {
    display: grid;
    grid-template-columns: 1fr;
  }

  .button-link,
  button,
  .links button {
    width: 100%;
    border-radius: var(--radius-md);
  }

  .calendar-card {
    padding: 8px;
    border-radius: 14px;
  }

  .fc {
    font-size: 0.88rem;
  }

  .fc .fc-toolbar.fc-header-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }

  .fc .fc-toolbar-chunk {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
  }

  .fc .fc-toolbar-title {
    text-align: center;
  }

  .fc .fc-button {
    padding: 0.35em 0.55em;
    border-radius: 10px;
  }

  .fc .fc-daygrid-day-number {
    padding: 4px;
  }

  .fc .fc-list-event-time {
    width: 80px;
  }

  .fc .fc-timegrid-slot {
    height: 2.4em;
  }

  dialog {
    width: 100vw;
    max-width: none;
    min-height: 100dvh;
    border-radius: 0;
  }

  dialog form {
    min-height: 100dvh;
    padding: 16px;
  }

  menu {
    display: grid;
    grid-template-columns: 1fr;
    margin-top: auto;
  }
}

@media (max-width: 520px) {
  body.login-page {
    align-items: stretch;
  }

  .login-card {
    align-self: center;
    padding: 22px;
    border-radius: 18px;
  }
}