:root {
  --bg: #efe8da;
  --bg-2: #e5f0e8;
  --card: #fffdf8;
  --ink: #1c2822;
  --muted: #5e6a62;
  --line: #e3d6c4;
  --green: #1f6a45;
  --green-deep: #143d28;
  --today: #fbf6ea;
  --shadow: 0 18px 40px rgba(48, 42, 28, 0.08);
  --row: 48px;
  color-scheme: light;
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% -10%, #f7f3ea 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 320px);
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px 6px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 36px; height: 36px; flex: none; }
.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.045em;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

#range-label {
  margin: 0;
  min-width: 18ch;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.pager, .view-switch { display: flex; align-items: center; gap: 4px; }
.pager button, .view-switch button, .family-btn, .text-btn, .primary, .ghost {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
}
.pager button {
  width: 36px;
  height: 36px;
  font-size: 20px;
  line-height: 1;
}
#today { width: auto; padding: 0 12px; font-size: 14px; font-weight: 600; }
.view-switch button { padding: 8px 12px; font-weight: 600; }
.view-switch button[aria-selected="true"] {
  background: var(--green-deep);
  border-color: var(--green-deep);
  color: white;
}
.family-btn {
  background: var(--green);
  border-color: var(--green);
  color: white;
  font-weight: 700;
  padding: 10px 16px;
}

#calendar {
  margin: 12px 20px 28px;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px 16px 8px;
}

.chips, .filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.filters { flex: 1 1 100%; }
.person {
  display: flex;
  align-items: stretch;
  border-radius: 999px;
  background: color-mix(in srgb, var(--kid) 16%, white);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--kid) 42%, white);
}
.person .chip {
  border: 0;
  background: transparent;
  border-radius: 999px 0 0 999px;
  min-height: 44px;
}
.person .only {
  border: 0;
  border-left: 1px solid color-mix(in srgb, var(--kid) 28%, white);
  background: transparent;
  border-radius: 0 999px 999px 0;
  padding: 0 12px;
  min-height: 44px;
  font-size: 12px;
  font-weight: 700;
}
.person:has(.chip[aria-pressed="false"]) { opacity: 0.45; }
.chip.alle {
  min-height: 44px;
  padding: 0 16px;
  font-weight: 800;
}
.chip.alle[aria-pressed="true"] {
  background: var(--green-deep);
  border-color: var(--green-deep);
  color: white;
}
.next-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 1 0 100%;
  padding: 12px 14px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--kid) 16%, white);
  box-shadow: inset 4px 0 0 var(--kid);
}
.next-kicker {
  margin: 0;
  color: var(--kid);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.next-card strong { display: block; font-size: 16px; }
.next-card .meta { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.next-card .eta {
  margin: 0;
  color: var(--kid);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  font-weight: 650;
}
.chip i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--kid);
}
.chip[aria-pressed="false"] { opacity: 0.45; }
.chip[aria-pressed="false"] i {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--kid);
}

.demo-note, .quiet, .hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.dayheads, .allday {
  display: grid;
  grid-template-columns: 52px 1fr;
}
.cols {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.dayhead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dayhead .num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--ink);
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
}
.dayhead.today .num {
  background: var(--green);
  color: white;
  border-radius: 999px;
}
.dayhead.weekend { color: #8a8174; }

.grid {
  display: grid;
  grid-template-columns: 52px 1fr;
  height: calc(var(--rows) * var(--row));
  border-top: 1px solid var(--line);
}
.hours { position: relative; }
.hour {
  height: var(--row);
  transform: translateY(-7px);
  padding-right: 8px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-width: 0;
  height: 100%;
}
.daycol {
  position: relative;
  height: calc(var(--rows) * var(--row));
  border-left: 1px solid var(--line);
  background-color: transparent;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--row) - 1px),
    var(--line) calc(var(--row) - 1px),
    var(--line) var(--row)
  );
}
.daycol.today { background-color: var(--today); }
.lane {
  position: absolute;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--kid) 7%, transparent);
  pointer-events: none;
}
.event {
  position: absolute;
  z-index: 1;
  overflow: hidden;
  box-sizing: border-box;
  padding: 3px 5px 3px 7px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--kid) 12%, white);
  box-shadow: inset 3px 0 0 var(--kid);
  line-height: 1.15;
}
.event.aktivitet { background: color-mix(in srgb, var(--kid) 24%, white); }
.event.is-next,
.agenda li.is-next {
  outline: 2px solid var(--kid);
  outline-offset: 1px;
}
.event strong {
  display: block;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.event.full strong,
.event.roomy strong {
  display: -webkit-box;
  white-space: normal;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.kicker {
  display: block;
  color: var(--kid);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.time, .where {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.now {
  position: absolute;
  right: 0;
  left: 0;
  z-index: 3;
  height: 2px;
  background: #c23b2e;
  pointer-events: none;
}
.now::before {
  content: "";
  position: absolute;
  top: -3px;
  left: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c23b2e;
}

.allday { border-top: 1px solid var(--line); }
.allday-label {
  padding: 8px 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}
.allday-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 36px;
  padding: 6px;
  border-left: 1px solid var(--line);
}
.pill, .more {
  display: block;
  overflow: hidden;
  max-width: 100%;
  padding: 2px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--kid) 18%, white);
  box-shadow: inset 3px 0 0 var(--kid);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.more { background: transparent; box-shadow: none; color: var(--muted); font-weight: 600; }

.month { padding: 4px 8px 12px; }
.month-dow, .month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.month-dow span {
  padding: 8px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}
.cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  min-height: 92px;
  padding: 6px;
  border: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: transparent;
  text-align: left;
}
.cell:nth-child(7n + 1) { border-left: 0; }
.cell .num {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}
.cell.today .num {
  border-radius: 999px;
  background: var(--green);
  color: white;
}
.cell.outside { opacity: 0.45; }
.cell .pill { font-weight: 600; }

.agenda { display: none; padding: 4px 12px 16px; }
.agenda-day { padding: 8px 0 4px; border-top: 1px solid var(--line); }
.agenda-day h3 {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin: 0 0 8px;
  font-size: 15px;
}
.agenda-day h3 span { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.agenda-day.today h3 strong {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--green);
  color: white;
}
.agenda ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.agenda li {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--kid) 12%, white);
  box-shadow: inset 3px 0 0 var(--kid);
}
.agenda li.aktivitet { background: color-mix(in srgb, var(--kid) 22%, white); }
.when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.what { display: grid; }
.what strong { font-size: 14px; }
.what em { color: var(--muted); font-style: normal; font-size: 12px; }

.empty {
  padding: 48px 20px;
  text-align: center;
}
.empty h3 { margin-bottom: 4px; }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(28, 40, 34, 0.38);
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 21;
  width: min(440px, 100%);
  height: 100vh;
  overflow: auto;
  padding: 18px 18px 36px;
  background: var(--card);
  box-shadow: -16px 0 40px rgba(28, 40, 34, 0.16);
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.drawer-head h2 { margin: 0; font-size: 24px; letter-spacing: -0.03em; }
.drawer-head h2:focus { outline: none; }
.flash { min-height: 1.2em; margin: 10px 0; color: var(--green-deep); font-size: 14px; font-weight: 600; }
.help {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.kid-card {
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--kid);
  border-radius: 16px;
}
.kid-head { display: flex; gap: 8px; align-items: center; }
.kid-head input { flex: 1; min-width: 0; }
.swatches { display: flex; gap: 6px; margin: 8px 0; }
.swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--line);
}
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.section-label {
  margin: 10px 0 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.feeds, .slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.feeds li, .slots li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  background: #f7f3ea;
  font-size: 14px;
}
.feeds small, .slots small { color: var(--muted); }
.row-actions { display: flex; gap: 6px; }
.feed-form, .add-kid, .slot-form { display: grid; gap: 8px; margin-top: 8px; }
.slot-form { grid-template-columns: 1fr 1fr; }
.slot-form select, .slot-form input[name="subject"], .slot-form button { grid-column: 1 / -1; }
input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}
.primary, .ghost, .text-btn, .file {
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 700;
}
.primary { background: var(--green); border-color: var(--green); color: white; }
.ghost, .text-btn { background: white; }
.file {
  display: block;
  text-align: center;
  border: 1px dashed var(--line);
  background: white;
}
.file input { display: none; }
.drawer-actions { display: grid; gap: 8px; margin-top: 16px; }
.error { margin: 4px 0 0; color: #9d2c22; font-size: 13px; grid-column: 1 / -1; }

@media (max-width: 800px) {
  .top { flex-wrap: wrap; padding: 14px 14px 0; }
  .controls {
    order: 3;
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
    row-gap: 8px;
  }
  #range-label {
    order: -1;
    flex: 1 0 100%;
    min-width: 0;
    font-size: 16px;
    text-align: center;
  }
  .family-btn { margin-left: auto; }
  #calendar { margin: 10px 10px 20px; border-radius: 16px; }
  .week { display: none; }
  .agenda { display: block; }
  .cell { min-height: 64px; padding: 4px; }
  .cell .pill, .cell .more { display: none; }
  .cell .dotrow { display: flex; }
  .agenda li { grid-template-columns: 76px 1fr; }
}

.dotrow { display: none; gap: 3px; flex-wrap: wrap; }
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--kid);
}

@media (min-width: 801px) {
  .agenda { display: none; }
}
