:root {
  --bg: #f8f3ea;
  --ink: #231f20;
  --muted: #6d6260;
  --panel: rgba(255,255,255,.86);
  --line: rgba(35,31,32,.12);
  --shadow: 0 20px 60px rgba(56, 35, 16, .12);
  --accent: #ff8c42;
  --accent-2: #6c63ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 196, 87, .45), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(108, 99, 255, .25), transparent 34rem),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
}

.brand {
  font-size: 1.25rem;
  font-weight: 900;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar nav a,
.user-pill,
.month-button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.65);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 24px;
  backdrop-filter: blur(8px);
}

.flash-zone {
  display: grid;
  gap: 10px;
  margin: 8px 0 16px;
}

.flash {
  padding: 12px 16px;
  border-radius: 18px;
  font-weight: 800;
  background: white;
  border: 1px solid var(--line);
}

.flash.success {
  border-color: rgba(44, 155, 77, .35);
}

.flash.error {
  border-color: rgba(210, 55, 55, .35);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(460px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 34px;
  padding: 34px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-emoji {
  font-size: 3rem;
}

h1,
h2 {
  margin: 0 0 10px;
  line-height: 1.05;
}

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

.stack-form,
.add-form {
  display: grid;
  gap: 14px;
  text-align: left;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  background: white;
  color: var(--ink);
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 16px;
  padding: 13px 16px;
  font: inherit;
  font-weight: 900;
  background: var(--ink);
  color: white;
}

button:hover,
.month-button:hover,
.topbar nav a:hover {
  transform: translateY(-1px);
}

.dashboard {
  display: grid;
  gap: 18px;
  padding-bottom: 30px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  overflow: hidden;
}

.kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .75rem;
  font-weight: 900;
  color: var(--accent-2);
}

.hero-badge {
  min-width: 142px;
  aspect-ratio: 1;
  border-radius: 32px;
  background: linear-gradient(135deg, #ffe39d, #ff8c42);
  display: grid;
  place-items: center;
  font-size: 3rem;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.55);
}

.hero-badge span {
  display: block;
  font-size: .85rem;
  margin-top: -20px;
}

.quick-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, .8fr);
  gap: 18px;
  align-items: start;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.upcoming-list {
  display: grid;
  gap: 10px;
}

.mini-event {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 12px;
  background: white;
}

.emoji {
  font-size: 1.5rem;
}

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

.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  text-align: center;
  margin-bottom: 18px;
}

.filter-form {
  margin-top: 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.day-names {
  margin-bottom: 10px;
  font-weight: 900;
  color: var(--muted);
  text-align: center;
}

.day-cell {
  min-height: 138px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 10px;
  background: rgba(255,255,255,.72);
}

.day-cell.outside {
  opacity: .45;
}

.day-cell.today {
  outline: 3px solid rgba(255, 140, 66, .45);
  background: white;
}

.day-number {
  font-weight: 950;
  margin-bottom: 8px;
}

.event-chip {
  display: grid;
  gap: 5px;
  border-radius: 16px;
  padding: 9px;
  margin-top: 7px;
  background: #fff8e7;
  border: 1px solid rgba(0,0,0,.08);
}

.event-chip.ecole,
.mini-event.ecole {
  background: #eef6ff;
}

.event-chip.rdv,
.mini-event.rdv {
  background: #f0fff5;
}

.event-chip.loisir,
.mini-event.loisir {
  background: #fff0f6;
}

.event-chip.maison,
.mini-event.maison {
  background: #f4f1ff;
}

.event-chip.important,
.mini-event.important {
  background: #ffecec;
}

.event-head {
  display: flex;
  gap: 6px;
  align-items: center;
}

.event-head strong {
  overflow-wrap: anywhere;
}

.event-chip p {
  margin: 0;
  font-size: .88rem;
}

.delete {
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: .8rem;
  text-align: left;
}

.empty {
  margin-bottom: 0;
}

.narrow {
  width: min(560px, 100%);
  margin: 30px auto;
}

@media (max-width: 900px) {
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .calendar-toolbar,
  .hero {
    align-items: stretch;
    flex-direction: column;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .day-names {
    display: none;
  }

  .day-cell {
    min-height: auto;
  }
}

/* === DARK MODE FOUR FAMILY START === */

:root {
  --bg: #0d1117;
  --ink: #f4f7fb;
  --muted: #aeb7c8;
  --panel: rgba(22, 27, 38, .94);
  --line: rgba(255, 255, 255, .12);
  --shadow: 0 20px 70px rgba(0, 0, 0, .55);
  --accent: #ff9f43;
  --accent-2: #8c83ff;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 159, 67, .18), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(108, 99, 255, .20), transparent 34rem),
    linear-gradient(135deg, #0d1117 0%, #111827 45%, #0b1020 100%);
}

.panel,
.login-card {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.topbar nav a,
.user-pill,
.month-button {
  background: rgba(22, 27, 38, .88);
  border-color: var(--line);
  color: var(--ink);
}

.brand {
  color: var(--ink);
}

p,
small,
.delete,
.day-names {
  color: var(--muted);
}

.flash {
  background: #161b26;
  color: var(--ink);
  border-color: var(--line);
}

.flash.success {
  background: rgba(35, 134, 54, .18);
  border-color: rgba(63, 185, 80, .45);
}

.flash.error {
  background: rgba(248, 81, 73, .15);
  border-color: rgba(248, 81, 73, .45);
}

input,
select,
textarea {
  background: #0f1623;
  color: var(--ink);
  border-color: var(--line);
}

input::placeholder,
textarea::placeholder {
  color: #788397;
}

button {
  background: linear-gradient(135deg, #ff9f43, #ff6b35);
  color: #111827;
}

button.delete {
  background: transparent;
  color: #c6cfdd;
}

.hero-badge {
  background: linear-gradient(135deg, #ffbf69, #ff7a45);
  color: #111827;
}

.day-cell {
  background: rgba(15, 22, 35, .78);
  border-color: var(--line);
}

.day-cell.today {
  background: rgba(255, 159, 67, .13);
  outline: 3px solid rgba(255, 159, 67, .50);
}

.day-cell.outside {
  opacity: .38;
}

.mini-event,
.event-chip {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .12);
  color: var(--ink);
}

.event-chip.famille,
.mini-event.famille {
  background: rgba(255, 159, 67, .14);
}

.event-chip.ecole,
.mini-event.ecole {
  background: rgba(56, 139, 253, .15);
}

.event-chip.rdv,
.mini-event.rdv {
  background: rgba(46, 160, 67, .16);
}

.event-chip.loisir,
.mini-event.loisir {
  background: rgba(218, 54, 255, .14);
}

.event-chip.maison,
.mini-event.maison {
  background: rgba(140, 131, 255, .16);
}

.event-chip.important,
.mini-event.important {
  background: rgba(248, 81, 73, .17);
}

.event-head strong,
.mini-event strong,
.day-number,
h1,
h2,
label {
  color: var(--ink);
}

.login-screen {
  background:
    radial-gradient(circle at top, rgba(255, 159, 67, .14), transparent 30rem),
    radial-gradient(circle at bottom, rgba(108, 99, 255, .18), transparent 30rem);
}

/* === DARK MODE FOUR FAMILY END === */

/* === RECURRENCE FOUR FAMILY START === */

.recurrence-box {
  border: 1px dashed var(--line);
  border-radius: 22px;
  padding: 16px;
  background: rgba(255, 255, 255, .05);
}

.recurrence-box h3 {
  margin: 0 0 12px;
}

.helper {
  margin: 10px 0 0;
  font-size: .9rem;
  line-height: 1.45;
}

.recurrence-badge {
  display: inline-block;
  margin-top: 4px;
  font-weight: 800;
  color: var(--accent);
}

/* === RECURRENCE FOUR FAMILY END === */

/* === NATIVE DATE TIME DARK START === */
input[type="date"],
input[type="time"] {
  color-scheme: dark;
  background: #0f1623;
  color: var(--ink);
  border-color: var(--line);
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: .85;
  cursor: pointer;
}
/* === NATIVE DATE TIME DARK END === */
