:root {
  --bg: #fff6e9;
  --card: #ffffff;
  --ink: #2b2118;
  --muted: #7d6b5c;
  --line: #f0e2cf;
  --tomato: #e8553e;
  --tomato-soft: #fde3dc;
  --leaf: #3f9d5a;
  --leaf-soft: #dff2e3;
  --mustard: #f2b33d;
  --mustard-soft: #fdf0d2;
  --shadow: 0 2px 0 rgba(80, 50, 20, .06), 0 8px 24px rgba(80, 50, 20, .07);
  --radius: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1814;
    --card: #2a231d;
    --ink: #f6ece0;
    --muted: #b6a493;
    --line: #3b3129;
    --tomato-soft: #4a2720;
    --leaf-soft: #213a28;
    --mustard-soft: #43361a;
    --shadow: 0 2px 0 rgba(0,0,0,.2), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 Nunito, system-ui, sans-serif;
  min-height: 100vh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: Fredoka, Nunito, sans-serif; font-weight: 600; margin: 0; line-height: 1.15; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 16px 16px 96px; }

/* Topp */
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 34px; }
.brand h1 { font-size: 28px; }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; background: var(--card); border: 2px solid var(--line);
  font-weight: 700; font-size: 14px;
}
.linkbtn { background: none; border: 0; color: var(--muted); font-weight: 700; font-size: 14px; padding: 6px; text-decoration: underline; }

/* Flikar */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1; max-width: 220px; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--card); font-weight: 800; font-size: 16px;
}
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Veckonavigering */
.weekbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.weekbar h2 { font-size: 24px; }
.weekbar .range { color: var(--muted); font-weight: 700; }
.navbtn {
  width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--line); background: var(--card);
  font-size: 20px; font-weight: 800; display: grid; place-items: center;
}
.todaybtn { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-weight: 800; font-size: 14px; }
.badge { padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 14px; }
.badge.kids { background: var(--mustard-soft); color: #8a5a00; }
@media (prefers-color-scheme: dark) { .badge.kids { color: var(--mustard); } }
.badge.nokids { background: var(--line); color: var(--muted); }

.notice { background: var(--card); border: 2px dashed var(--line); border-radius: 14px; padding: 10px 14px; color: var(--muted); font-weight: 600; margin-bottom: 14px; font-size: 14px; }

/* Dagar */
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.day {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; border: 3px solid transparent;
}
.day.today { border-color: var(--tomato); }
.day.past { opacity: .7; }
.dayhead { display: flex; align-items: baseline; gap: 8px; }
.dayhead h3 { font-size: 20px; text-transform: capitalize; }
.dayhead .date { color: var(--muted); font-weight: 700; font-size: 14px; }
.dayhead .tags { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.kidstag { background: var(--leaf-soft); color: #23683a; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.kidstag.away { background: var(--line); color: var(--muted); }
@media (prefers-color-scheme: dark) { .kidstag { color: #8fd4a2; } .kidstag.away { color: var(--muted); } }
.ownertag { background: var(--mustard-soft); color: #8a5a00; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.ownertag.me { background: var(--mustard); color: #3a2600; }
@media (prefers-color-scheme: dark) { .ownertag { color: var(--mustard); } .ownertag.me { color: #3a2600; } }
.dinner.empty.mine { border-color: var(--mustard); color: var(--ink); }
.dinner.empty.wait { font-weight: 700; text-align: center; }
select.small { appearance: none; -webkit-appearance: none; padding-right: 10px; cursor: pointer; }
.dayhead .todaytag { background: var(--tomato); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 800; }

.dinner {
  border-radius: 16px; padding: 12px; background: var(--leaf-soft); display: flex; align-items: center; gap: 12px;
  min-height: 74px; width: 100%; text-align: left; border: 0;
}
.dinner .emoji { font-size: 40px; line-height: 1; }
.dinner .name { font-family: Fredoka, sans-serif; font-weight: 600; font-size: 20px; line-height: 1.15; }
.dinner .by { font-size: 13px; color: var(--muted); font-weight: 700; }
.dinner.empty { background: transparent; border: 3px dashed var(--line); justify-content: center; color: var(--muted); font-weight: 800; }
.dinner.empty:hover { border-color: var(--tomato); color: var(--tomato); }
.dinner.locked { background: var(--mustard-soft); }
.adult {
  display: flex; align-items: center; gap: 4px; margin-top: -4px; padding: 6px 10px; border-radius: 12px;
  background: var(--bg); font-size: 14px; color: var(--muted); font-weight: 700;
}
.adult .label { font-weight: 800; }
.adult .aname { color: var(--ink); }
.adultpick { flex: 1; text-align: left; background: none; border: 0; padding: 0; font: inherit; color: inherit; }
.adult .del { font-size: 14px; padding: 0 2px; }
.dayactions { display: flex; gap: 6px; flex-wrap: wrap; }
.small {
  border: 2px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px;
  font-size: 13px; font-weight: 800; color: var(--muted);
}
.small:hover { border-color: var(--ink); color: var(--ink); }

.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.events li { display: flex; gap: 8px; font-size: 14px; align-items: flex-start; }
.events .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none; }
.events .time { font-weight: 800; min-width: 84px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.day { container-type: inline-size; }
/* Smala kort: pricken och förklaringen visar vems händelsen är. */
@container (max-width: 280px) { .events .whoname { display: none; } }
.events .title { color: var(--ink); }
.events .whoname { color: var(--muted); font-weight: 700; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; font-weight: 800; color: var(--ink); margin: -4px 0 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Rätter */
.addform {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.addform h3 { font-size: 20px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); font-size: 17px;
}
.input:focus { outline: 3px solid var(--mustard); outline-offset: 1px; border-color: transparent; }
.btn {
  padding: 12px 18px; border-radius: 14px; border: 0; background: var(--tomato); color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: 0 3px 0 #b63b28;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #b63b28; }
.btn.ghost { background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.emojis { display: flex; flex-wrap: wrap; gap: 4px; }
.emojis button {
  font-size: 24px; width: 42px; height: 42px; border-radius: 12px; border: 2px solid transparent; background: var(--bg);
}
.emojis button[aria-pressed="true"] { border-color: var(--tomato); background: var(--tomato-soft); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filters button { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: 14px; }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.dishes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.dish {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 12px 14px;
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "emoji name name" "emoji meta actions";
  column-gap: 12px; row-gap: 6px; align-items: center;
}
.dish .emoji { grid-area: emoji; font-size: 40px; line-height: 1; }
.dish .name { grid-area: name; font-family: Fredoka, sans-serif; font-weight: 600; font-size: 19px; line-height: 1.15; overflow-wrap: anywhere; }
.dish .meta { grid-area: meta; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12px; color: var(--muted); font-weight: 700; min-width: 0; }
.dish .dishactions { grid-area: actions; display: flex; align-items: center; gap: 2px; }
.tag { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.tag.kid { background: var(--mustard-soft); color: #8a5a00; }
.tag.parent { background: var(--leaf-soft); color: #23683a; }
@media (prefers-color-scheme: dark) { .tag.kid { color: var(--mustard); } .tag.parent { color: #8fd4a2; } }
.heart {
  border: 2px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; font-weight: 800; font-size: 14px;
  display: inline-flex; align-items: center; gap: 4px; flex: none;
}
.heart[aria-pressed="true"] { background: var(--tomato-soft); border-color: var(--tomato); }
.del { border: 0; background: none; color: var(--muted); font-size: 18px; padding: 4px; flex: none; }
.empty-state { text-align: center; color: var(--muted); padding: 32px 16px; font-weight: 700; }
.empty-state .big { font-size: 48px; }

/* Betyg */
.rate { display: flex; align-items: center; gap: 4px; margin-top: -4px; flex-wrap: wrap; }
.rate .label { font-size: 13px; font-weight: 800; color: var(--muted); margin-right: 2px; }
.face {
  border: 2px solid var(--line); background: transparent; border-radius: 999px; padding: 2px 8px;
  font-size: 15px; font-weight: 800; color: var(--muted);
}
.face[aria-pressed="true"] { border-color: var(--mustard); background: var(--mustard-soft); color: var(--ink); }
.face.lg { font-size: 16px; padding: 8px 14px; background: var(--card); color: var(--ink); }
.face.lg:hover { border-color: var(--mustard); }
.ratebanner {
  display: flex; gap: 14px; align-items: center; background: var(--mustard-soft); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.ratebanner .big { font-size: 48px; line-height: 1; }
.ratebanner b { font-family: Fredoka, sans-serif; font-weight: 600; font-size: 19px; display: block; margin-bottom: 8px; }
.ratebanner .faces { display: flex; gap: 6px; flex-wrap: wrap; }
.dish .rank { font-size: 18px; }

/* Egen rätt / passar inte */
.altrow { background: var(--leaf-soft); }
.altrow .adultpick:disabled { cursor: default; }
.warnalt {
  border: 2px dashed var(--tomato); background: var(--tomato-soft); color: var(--ink); border-radius: 12px;
  padding: 8px 10px; font-weight: 800; font-size: 14px; text-align: left; width: 100%;
}
.nftag { background: var(--tomato-soft); color: var(--tomato); border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.pick:disabled { opacity: .45; cursor: not-allowed; }
.pick:disabled:hover { border-color: transparent; }
.notfor { border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; display: flex; gap: 16px; flex-wrap: wrap; margin: 0; }
.notfor legend { font-weight: 800; font-size: 14px; padding: 0 4px; }
.check-label { display: flex !important; flex-direction: row !important; align-items: center; gap: 6px; font-size: 16px !important; }
.check-label input { width: 20px; height: 20px; accent-color: var(--tomato); }

/* Hjälpare */
.helpers { display: flex; gap: 6px; flex-wrap: wrap; }
.helperchip {
  border: 2px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px;
  font-size: 13px; font-weight: 800; color: var(--muted);
}
.helperchip.me { background: var(--leaf-soft); border-color: var(--leaf); color: var(--ink); }
.helperchip.ask { border-style: dashed; }
.helperchip.ask:hover { border-color: var(--tomato); color: var(--tomato); }

/* Slumphjul */
.btn.spin { background: var(--mustard); color: #3a2600; box-shadow: 0 3px 0 #b8841f; font-size: 18px; }
.spinbox {
  background: var(--card); border-radius: 18px; padding: 16px; text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 6px; border: 3px solid var(--mustard);
}
.spinbox .emoji { font-size: 56px; line-height: 1.1; }
.spinbox .name { font-family: Fredoka, sans-serif; font-weight: 600; font-size: 24px; }
.spinbox.spinning .emoji { animation: shake .12s linear infinite; }
.spinactions { display: flex; gap: 8px; margin-top: 6px; }
@keyframes shake { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }

/* Inköpslista */
.shoplist { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.shopitem { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 14px; padding: 8px 10px; box-shadow: var(--shadow); }
.check {
  width: 30px; height: 30px; border-radius: 9px; border: 3px solid var(--line); background: var(--bg); flex: none;
  font-weight: 900; font-size: 16px; color: #fff; display: grid; place-items: center;
}
.check[aria-pressed="true"] { background: var(--leaf); border-color: var(--leaf); }
.shoptext { flex: 1; min-width: 0; font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }
.shoptext .src { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.shopitem.done { box-shadow: none; opacity: .6; }
.shopitem.done .shoptext { text-decoration: line-through; }
.shophead { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.shophead h3 { font-size: 18px; color: var(--muted); }
.editform { display: flex; flex-direction: column; gap: 10px; }
.editform label { display: flex; flex-direction: column; gap: 4px; font-weight: 800; font-size: 14px; }
.editform .hint { font-weight: 600; color: var(--muted); }
textarea.input { resize: vertical; font-size: 16px; line-height: 1.4; }

/* Väljare (bottenark) */
.sheet-bg { position: fixed; inset: 0; background: rgba(30, 20, 10, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; animation: fade .15s; }
.sheet {
  background: var(--bg); width: 100%; max-width: 620px; max-height: 88vh; border-radius: 24px 24px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; animation: up .2s ease-out; overflow-y: auto;
}
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 24px; } }
.sheet header { display: flex; align-items: center; gap: 8px; }
.sheet header h2 { font-size: 22px; }
.sheet header .x { margin-left: auto; border: 0; background: var(--card); width: 38px; height: 38px; border-radius: 50%; font-size: 18px; font-weight: 800; }
.picklist { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px; }
.pick {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: var(--card);
  border: 2px solid transparent; text-align: left; width: 100%;
}
.pick:hover { border-color: var(--tomato); }
.pick .emoji { font-size: 30px; }
.pick .name { font-family: Fredoka, sans-serif; font-weight: 600; font-size: 18px; flex: 1; }
.pick .hearts { font-size: 14px; font-weight: 800; color: var(--muted); }
.sheet .divider { text-align: center; color: var(--muted); font-weight: 800; font-size: 13px; }

/* Inloggning */
.login { max-width: 420px; margin: 8vh auto 0; padding: 0 16px; text-align: center; }
.login .logo { font-size: 72px; animation: wiggle 3s ease-in-out infinite; display: inline-block; }
.login h1 { font-size: 36px; margin: 8px 0 4px; }
.login p { color: var(--muted); font-weight: 700; margin: 0 0 20px; }
.login form { display: flex; flex-direction: column; gap: 10px; background: var(--card); padding: 18px; border-radius: var(--radius); box-shadow: var(--shadow); }
.login label { text-align: left; font-weight: 800; font-size: 14px; }
.err { color: var(--tomato); font-weight: 800; min-height: 1.4em; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-weight: 800; transition: transform .25s; z-index: 20; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { transform: translateX(-50%) translateY(0); }

.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(.9); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(-10deg); } 20% { transform: rotate(8deg); } 30% { transform: rotate(0); } }

@media (max-width: 520px) {
  .brand h1 { font-size: 24px; }
  .weekbar h2 { font-size: 20px; }
  .tab { max-width: none; font-size: 14px; padding: 10px 6px; white-space: nowrap; }
  .tabs { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
