/* ============================================================
   Familjeplaneraren – v1
   Varmt, lugnt designsystem byggt på "stone"-palett med
   personfärger som accent. Allt i systemtypsnitt, inga bundlar.
   ============================================================ */

:root {
  --bg: #f3f0ea;
  --card: #fffefc;
  --ink: #211d1a;
  --muted: #7d746c;
  --faint: #a39a91;
  --line: rgba(33, 29, 26, 0.09);
  --line-strong: rgba(33, 29, 26, 0.16);
  --soft: rgba(33, 29, 26, 0.055);
  --hover: rgba(33, 29, 26, 0.03);
  --topbar-bg: rgba(243, 240, 234, 0.82);
  --ev-mix: #ffffff;
  --evtag-bg: rgba(255, 255, 255, 0.75);
  --ok: #15803d;

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;

  --shadow-card: 0 1px 2px rgba(33, 29, 26, 0.04), 0 14px 34px -22px rgba(33, 29, 26, 0.28);
  --shadow-pop: 0 2px 4px rgba(33, 29, 26, 0.06), 0 18px 40px -20px rgba(33, 29, 26, 0.35);

  /* Sätts även i app.js så kalendern och JS håller isär seenigheten */
  --hour: 50px;

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #161311;
  --card: #201c19;
  --ink: #ede8e2;
  --muted: #a2978b;
  --faint: #786e63;
  --line: rgba(237, 232, 226, 0.10);
  --line-strong: rgba(237, 232, 226, 0.22);
  --soft: rgba(237, 232, 226, 0.065);
  --hover: rgba(237, 232, 226, 0.04);
  --topbar-bg: rgba(22, 19, 17, 0.82);
  --ev-mix: #2b2622;
  --evtag-bg: rgba(0, 0, 0, 0.3);
  --ok: #22c55e;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 14px 34px -20px rgba(0, 0, 0, 0.55);
  --shadow-pop: 0 2px 6px rgba(0, 0, 0, 0.4), 0 18px 40px -18px rgba(0, 0, 0, 0.65);

  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Subtila färgklick i bakgrunden */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(520px 380px at 8% -4%, rgba(225, 29, 72, 0.05), transparent 65%),
    radial-gradient(620px 420px at 96% 0%, rgba(2, 132, 199, 0.055), transparent 65%),
    radial-gradient(540px 460px at 50% 110%, rgba(217, 119, 6, 0.05), transparent 60%);
}

[data-theme="dark"] body::before {
  background:
    radial-gradient(520px 380px at 8% -4%, rgba(244, 63, 94, 0.07), transparent 65%),
    radial-gradient(620px 420px at 96% 0%, rgba(14, 165, 233, 0.07), transparent 65%),
    radial-gradient(540px 460px at 50% 110%, rgba(245, 158, 11, 0.06), transparent 60%);
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.012em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }

::selection { background: rgba(225, 29, 72, 0.16); }

:focus-visible {
  outline: 2.5px solid #0284c7;
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 11px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-card); }

.topbar-right { display: flex; align-items: center; gap: 13px; }

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.brand-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #f43f5e, #e11d48 55%, #be123c);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 14px -6px rgba(225, 29, 72, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-logo svg { width: 21px; height: 21px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.16; min-width: 0; }
.brand-text strong { font-size: 16.5px; letter-spacing: -0.015em; }
.brand-text small { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-date { text-align: right; line-height: 1.25; }
.topbar-date strong { display: block; font-size: 14px; font-weight: 650; }
.topbar-date small { display: block; color: var(--muted); font-size: 11.5px; }

/* ---------- Layout ---------- */

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.side-pane { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card h2 { font-size: 16.5px; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- View-switch (mobiltabbar) ---------- */

.view-switch { display: none; }

/* ---------- Medlemmar / filter ---------- */

.members { padding: 16px 18px 14px; }

.members-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.members-head h2 { font-size: 15.5px; }
.members-head .hint { color: var(--faint); font-size: 12px; }

.chip-reset {
  margin-left: auto;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px 4px 7px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.chip-reset svg { width: 11px; height: 11px; }
.chip-reset:hover { color: var(--ink); border-color: var(--faint); }

.members-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 13px 6px 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.2s ease;
}

.chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-card); }
.chip:active { transform: translateY(0); }

.chip .av {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  flex: 0 0 auto;
}

.chip .who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.chip .who strong { font-size: 12.5px; font-weight: 650; }
.chip .who small { font-size: 10.5px; color: var(--muted); }

.chip[aria-pressed="true"] {
  background: var(--c-tint);
  border-color: var(--c);
  box-shadow: 0 0 0 1px var(--c) inset;
}

/* ---------- Kalender ---------- */

.week { padding: 18px 0 4px; overflow: hidden; }

.week .card-head { padding: 0 18px; margin-bottom: 14px; }

.pill {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  padding: 5px 11px;
  white-space: nowrap;
}
.pill-soft { background: var(--soft); color: var(--muted); }

.cal-scroll {
  overflow-x: auto;
  padding-bottom: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(33, 29, 26, 0.22) transparent;
  scroll-snap-type: x proximity;
}

.cal-grid {
  display: grid;
  grid-template-columns: 46px repeat(7, minmax(148px, 1fr));
  min-width: 1082px; /* 46 + 7×148 – tvingar westlig horisontell scroll på smala skärmar */
}

.cal-cell { border-top: 1px solid var(--line); position: relative; }

/* Rad 1: daghuvud */
.cal-dayhead {
  padding: 8px 10px 9px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.cal-dayhead .dh-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.cal-dayhead .dh-date {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
}
.cal-dayhead.is-weekend .dh-name { color: var(--faint); }

.cal-dayhead.is-today .dh-date { background: var(--ink); color: var(--card); }
.cal-dayhead.is-today .dh-name { color: #e11d48; }

/* Rad 2: tidslinje */
.cal-gutter { position: sticky; left: 0; z-index: 5; background: var(--card); }
.cal-gutter::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 8px;
  background: linear-gradient(90deg, transparent, rgba(33, 29, 26, 0.05));
  pointer-events: none;
}

.cal-hours { position: relative; }
.cal-hours span {
  position: absolute;
  right: 8px;
  transform: translateY(-45%);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.cal-col { border-left: 1px solid var(--line); }

.cal-col.is-today { background: linear-gradient(180deg, rgba(225, 29, 72, 0.035), rgba(225, 29, 72, 0.015) 60%, transparent); }
.cal-col.is-weekend { background: rgba(33, 29, 26, 0.014); }
.cal-col.is-today.is-weekend { background: linear-gradient(180deg, rgba(225, 29, 72, 0.035), rgba(225, 29, 72, 0.015) 60%, transparent); }

/* Timlinjer ritas som upprepande gradient */
.cal-body {
  position: relative;
  height: calc(var(--hour) * var(--rows, 14));
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--hour) - 1px),
    var(--line) calc(var(--hour) - 1px),
    var(--line) var(--hour)
  );
}

.cal-scroll::-webkit-scrollbar { height: 8px; }
.cal-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
.cal-scroll::-webkit-scrollbar-track { background: transparent; }

/* Nu-linjen */
.now-line {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  pointer-events: none;
}
.now-line::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  border-top: 2px solid #e11d48;
}
.now-line::after {
  content: "";
  position: absolute;
  left: -3px;
  top: -5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e11d48;
}
.now-line .now-label {
  position: absolute;
  left: 6px;
  top: -17px;
  background: #e11d48;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

/* Events */
.ev {
  position: absolute;
  z-index: 1;
  margin: 1px;
  padding: 4px 7px 5px;
  border-radius: 9px;
  border-left: 3px solid var(--c);
  background: var(--c-tint);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 13%, var(--ev-mix)), color-mix(in srgb, var(--c) 7%, var(--ev-mix)));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
  transition: opacity 0.25s ease, filter 0.25s ease, box-shadow 0.15s ease;
}

.ev:hover { box-shadow: var(--shadow-pop); z-index: 2; }

.ev-time {
  font-size: 10px;
  font-weight: 700;
  color: var(--c);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
  line-height: 1.3;
}

.ev-title {
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.22;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ev-foot { display: flex; align-items: center; gap: 5px; margin-top: auto; }
.ev-tag {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--evtag-bg);
  border-radius: 5px;
  padding: 1px 5px;
  white-space: nowrap;
}
.ev-place {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.ev-avs { display: flex; margin-left: auto; }
.ev-avs .av {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--card);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-left: -5px;
}
.ev-avs .av:first-child { margin-left: 0; }

.ev.slim .ev-foot { display: none; }
.ev.slim { padding: 3px 7px 4px; }
.ev.slim .ev-title { font-size: 12px; line-height: 1.2; }
.ev.xslim .ev-title { display: none; }

/* Heldagsband: jobb & skola renderas som slanka chips i kolumntoppen */
.ev.heldag {
  flex-direction: row;
  align-items: center;
  gap: 5px;
  height: 25px;
  min-height: 0;
  padding: 2px 7px;
  z-index: 0;
  opacity: 0.94;
}
.ev.heldag .ev-time { flex: 0 0 auto; }
.ev.heldag .ev-title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: unset;
  -webkit-box-orient: unset;
}

/* Filtrering: andra personers events tonas ner */
body[data-filter] .ev.dim { opacity: 0.16; filter: saturate(0.25); }

/* ---------- Dagens uppgifter ---------- */

.today { padding: 18px 18px 8px; }

.ring { position: relative; width: 46px; height: 46px; flex: 0 0 auto; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--soft); stroke-width: 3.4; }
.ring-fg {
  fill: none;
  stroke: var(--ok);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-dasharray: 97.4;
  stroke-dashoffset: 97.4;
  transition: stroke-dashoffset 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--soft);
  margin: 12px 0 4px;
  overflow: hidden;
}
.progress-bar {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, var(--ok));
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.tasks { margin-top: 6px; }

.task {
  position: relative;
  border-top: 1px solid var(--line);
}
.task:first-child { border-top: 0; }

.task label {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 2px;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background 0.15s ease;
}
.task label:hover { background: var(--hover); }

.task input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.task .box {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  margin-top: 1px;
  border-radius: 7px;
  border: 2px solid var(--line-strong);
  display: grid;
  place-items: center;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.task .box svg {
  width: 12px;
  height: 12px;
  stroke: #fff;
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  transition: stroke-dashoffset 0.22s ease 0.05s;
}
.task label:hover .box { border-color: var(--c); }
.task input:checked + .box {
  background: var(--c);
  border-color: var(--c);
  transform: scale(1.04);
}
.task input:checked + .box svg { stroke-dashoffset: 0; }
.task input:focus-visible + .box { outline: 2.5px solid #0284c7; outline-offset: 2px; }

.task-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.task-text { font-size: 13.5px; font-weight: 550; transition: color 0.2s ease; }
.task-meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.task-meta .t { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--faint); }
.task-meta .w { display: inline-flex; align-items: center; gap: 5px; }
.task-meta .w .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--wc, var(--faint)); }

.task input:checked ~ .task-main .task-text {
  color: var(--faint);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.task.dim { display: none; }

.tasks-empty { padding: 22px 4px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- Översikt ---------- */

.overview, .dinners { padding: 17px 18px; }
.overview h2, .din-title { font-size: 15.5px; margin-bottom: 12px; }

.ov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.ov-cell {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--r-md);
  padding: 10px 12px;
  min-width: 0;
}
.ov-cell .k { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); }
.ov-cell .v { margin-top: 3px; font-size: 13px; font-weight: 650; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-cell .v.nowrap-clip { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ov-cell.accent { background: linear-gradient(135deg, rgba(225, 29, 72, 0.06), rgba(225, 29, 72, 0.02)); border-color: rgba(225, 29, 72, 0.22); }
.ov-cell.accent .k { color: #be123c; }

/* ---------- Middagar ---------- */

.din-today { display: flex; align-items: center; gap: 10px; }
.din-today .av {
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
}
.din-today .dish { font-size: 14px; font-weight: 650; line-height: 1.25; }
.din-today .who { color: var(--muted); font-size: 11.5px; }

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

.din-cell {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--r-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.din-cell:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }

.din-cell .day { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.din-cell .day .today-pill {
  background: #e11d48;
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 5px;
  letter-spacing: 0.03em;
}
.din-cell .dish { font-size: 12.8px; font-weight: 620; line-height: 1.3; }
.din-cell .who { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10.5px; }
.din-cell .who .av { width: 15px; height: 15px; font-size: 8px; color: #fff; border-radius: 50%; display: grid; place-items: center; font-weight: 700; }

.din-cell.is-today {
  border-color: rgba(225, 29, 72, 0.4);
  background: linear-gradient(160deg, rgba(225, 29, 72, 0.055), rgba(225, 29, 72, 0.015));
}

/* ---------- Footer ---------- */

.foot { text-align: center; padding: 6px 0 2px; }
.foot p { color: var(--faint); font-size: 11.5px; }

/* ---------- Entrance-animation ---------- */

.fade-up { animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: var(--d, 0s); }

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

/* ============================================================
   Responsivitet
   ============================================================ */

@media (max-width: 940px) {
  .greet-week { display: none; }
}

@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 940px) {

  .view-switch { display: block; }

  .view-switch-track {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--soft);
    border-radius: 12px;
    padding: 3px;
    gap: 3px;
  }

  .view-btn {
    appearance: none;
    border: 0;
    background: transparent;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 650;
    color: var(--muted);
    padding: 8px 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
  }
  .view-btn[aria-selected="true"] {
    background: var(--card);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
  }

  .tab-badge {
    background: #e11d48;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    border-radius: 999px;
    padding: 1px 7px;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
  }

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

  html[data-view="vecka"] .side-pane { display: none; }
  html[data-view="idag"] .week { display: none; }

  .cal-grid { grid-template-columns: 42px repeat(7, minmax(132px, 1fr)); min-width: 966px; }

  .members { padding: 14px 16px 12px; }
  .members-head .hint { display: none; }

  .page { padding: 14px 14px 32px; gap: 12px; }
  .topbar-inner { padding: 8px 14px; }
  .topbar-date strong { font-size: 13px; }

  .din-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .din-grid .din-cell.is-today { grid-column: span 2; }
}

@media (max-width: 560px) {
  .brand-text small { max-width: 38vw; }
  .topbar-date small { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
  .ov-grid { grid-template-columns: 1fr; }
  .din-grid { grid-template-columns: 1fr; }
  .din-grid .din-cell.is-today { grid-column: auto; }
  .members-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; margin-inline: -16px; padding-inline: 16px; scrollbar-width: none; }
  .members-row::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }
}

/* ---------- Snabbadda & ta bort uppgifter ---------- */

.task-add-btn {
  appearance: none;
  width: 100%;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 650;
  padding: 9px 10px;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.task-add-btn svg { width: 13px; height: 13px; }
.task-add-btn:hover { color: #e11d48; border-color: rgba(225, 29, 72, 0.45); background: rgba(225, 29, 72, 0.04); }

.task-form { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.task-form-row { display: grid; grid-template-columns: 1fr 96px auto; gap: 7px; }

.task-form input[type="text"],
.task-form select,
.task-form input[type="time"],
.set-sec input[type="text"],
.set-sec select {
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  min-width: 0;
  width: 100%;
}
.task-form input[type="text"]:focus,
.task-form select:focus,
.task-form input[type="time"]:focus,
.set-sec input[type="text"]:focus,
.set-sec select:focus { outline: 2px solid #0284c7; outline-offset: 1px; }

.btn-primary {
  appearance: none;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 650;
  padding: 9px 13px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.btn-ghost:hover { color: #be123c; border-color: rgba(225, 29, 72, 0.4); }

.task-del {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--faint);
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 7px;
  display: grid;
  place-items: center;
  cursor: pointer;
  margin-top: 1px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.task-del svg { width: 12px; height: 12px; }
.task label:hover .task-del,
.task-del:focus-visible { opacity: 1; }
.task-del:hover { color: #be123c; background: rgba(225, 29, 72, 0.08); }

@media (hover: none) {
  .task-del { opacity: 0.75; }
}

/* ---------- Inställningsdrawer ---------- */

.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 12, 10, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  width: min(360px, 92vw);
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 50px -20px rgba(0, 0, 0, 0.4);
  transform: translateX(calc(100% + 30px));
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 16.5px; }

.drawer-body { padding: 6px 18px 22px; overflow-y: auto; }

.set-sec { padding: 16px 0 2px; }
.set-sec + .set-sec { border-top: 1px solid var(--line); margin-top: 14px; }

.set-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
  margin-bottom: 9px;
}

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--soft);
  border-radius: 11px;
  padding: 3px;
  gap: 3px;
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.seg button[aria-pressed="true"] {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
}

.set-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  padding: 4px 0;
}
.set-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.sw {
  flex: 0 0 auto;
  width: 42px;
  height: 25px;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  transition: background 0.2s ease;
}
.sw::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.set-switch input:checked ~ .sw { background: #16a34a; }
.set-switch input:checked ~ .sw::after { transform: translateX(17px); }
.set-switch input:focus-visible ~ .sw { outline: 2.5px solid #0284c7; outline-offset: 2px; }

.set-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.drawer-note {
  margin-top: 18px;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.5;
}

/* ---------- Helger av ---------- */

body.no-weekend .cal-dayhead.is-weekend,
body.no-weekend .cal-col.is-weekend,
body.no-weekend .din-cell[data-day="5"],
body.no-weekend .din-cell[data-day="6"] { display: none; }

body.no-weekend .cal-grid { grid-template-columns: 46px repeat(5, minmax(148px, 1fr)); min-width: 786px; }
body.no-weekend .din-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }

@media (max-width: 940px) {
  body.no-weekend .cal-grid { grid-template-columns: 42px repeat(5, minmax(132px, 1fr)); min-width: 702px; }
  body.no-weekend .din-grid { grid-template-columns: 1fr; }
}

/* ---------- Utskrift (kylskåpsplanering) ---------- */

@media print {
  @page { size: A4 landscape; margin: 10mm; }

  body { background: #fff; }
  body::before, .topbar, .view-switch, .members, .side-pane, .foot,
  .drawer, .drawer-scrim, .now-line { display: none !important; }

  .page { padding: 0; max-width: none; gap: 8px; }

  .card { box-shadow: none; border-color: #ccc; }

  .week { padding-bottom: 0; overflow: visible; }
  .cal-scroll { overflow: visible; padding-bottom: 0; }
  .cal-grid { min-width: 0; grid-template-columns: 34px repeat(7, minmax(0, 1fr)); }
  .cal-gutter { position: static; }

  .dinners-strip { page-break-inside: avoid; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
