/* Typsnitt (SIL OFL, se fonts/): Fraunces till rubriker och stora siffror, Familjen Grotesk till text. */
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 400 700; font-display: swap;
             src: url("/static/fonts/fraunces.woff2") format("woff2"); }
@font-face { font-family: "Familjen Grotesk"; font-style: normal; font-weight: 400 700; font-display: swap;
             src: url("/static/fonts/familjen-grotesk.woff2") format("woff2"); }

:root {
  --bg: #fbf3e8; --panel: #fffaf3; --raise: #f4e9da; --text: #2b211c; --muted: #7a6b60;
  --line: #eadccb; --line-strong: #dbc8b3;
  --accent: #b5532c; --accent-soft: #f6dccd; --on-accent: #fff;
  --ok: #4f7a52; --ok-soft: #dfeadb; --warn: #a8670d; --bad: #b3261e; --bad-soft: #f6d9d4;
  --ice: #3f7aa6; --ice-soft: #dbe9f3; --honey: #b07a14; --honey-soft: #f5e6c4;
  --p0: #c25e34; --p1: #3f7f74; --p2: #7a5a9c; --p3: #b07a14;
  --shadow: 0 1px 2px rgb(80 50 20 / .06), 0 4px 16px rgb(80 50 20 / .06);
  --serif: "Fraunces", Georgia, serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1a1512; --panel: #241d19; --raise: #2e2621; --text: #f3e9df; --muted: #b0a196;
          --line: #352c26; --line-strong: #463a32;
          --accent: #ee8a5e; --accent-soft: #3d2519; --on-accent: #1f130d;
          --ok: #8fc093; --ok-soft: #1f2e20; --warn: #e3a64a; --bad: #f08a80; --bad-soft: #3a1d1a;
          --ice: #8cc0e6; --ice-soft: #172833; --honey: #e2b65a; --honey-soft: #33290f;
          --p0: #ee8a5e; --p1: #7cc2b5; --p2: #b99ade; --p3: #e2b65a;
          --shadow: none; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
       font: 16px/1.45 "Familjen Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif; }
main { max-width: 560px; margin: 0 auto;
       padding: calc(22px + env(safe-area-inset-top)) 16px calc(104px + env(safe-area-inset-bottom)); }
header.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
header.top a { font-weight: 500; text-decoration: none; white-space: nowrap; }
h1 { font-family: var(--serif); font-size: 32px; line-height: 1.08; font-weight: 600; letter-spacing: -0.02em;
     margin: 0; text-wrap: balance; font-variation-settings: "SOFT" 100, "WONK" 1; }
h2 { font-family: var(--serif); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin: 30px 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.eyebrow { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
a { color: var(--accent); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
small { color: var(--muted); font-size: 13px; }
.num, time, .big { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round;
       stroke-linejoin: round; flex: none; vertical-align: middle; }
.ico.sm { width: 18px; height: 18px; }
[hidden] { display: none !important; }

.flash { background: var(--accent-soft); border-radius: 14px; padding: 12px 16px; margin: 0 0 14px; }
.flash.bad { background: var(--bad-soft); }
.card { background: var(--panel); border-radius: 22px; padding: 16px 18px; box-shadow: var(--shadow); }
.card + .card, .card + .stack, .stack + .card { margin-top: 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { margin-bottom: 10px; }
.section-head a { font-size: 14px; font-weight: 500; text-decoration: none; }

ul.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border-radius: 22px; overflow: hidden;
          box-shadow: var(--shadow); }
ul.list > li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 56px;
               border-bottom: 1px solid var(--line); }
ul.list > li:last-child { border-bottom: 0; }
ul.list > li > .grow, .grow { flex: 1; min-width: 0; }
ul.list.links a { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; flex: 1;
                  min-height: 36px; }
ul.list.links a::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 20px; }
ul.list .meta { font-size: 13px; color: var(--muted); }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line-strong);
                          border-radius: 14px; background: var(--panel); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px;
         padding: 0 18px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--panel);
         cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text);
         transition: transform .15s ease, background-color .2s ease; }
button:hover, .button:hover { background: var(--raise); }
button:active, .button:active { transform: translateY(1px) scale(.99); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
button.danger { color: var(--bad); }
button.small, .button.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 12px; }
button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--accent); font-weight: 500; }
button.wide, .button.wide { width: 100%; }
form.confirming button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
form.confirming button.danger::after { content: ", tryck igen"; }
form.inline { display: inline; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
.row > button, .row > .button, .row > .fit { flex: 0 0 auto; }
.stack { display: grid; gap: 10px; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 15px; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
legend { font-size: 14px; font-weight: 600; margin-bottom: 6px; padding: 0; }

/* Chips: radioknappar och val som ser ut som knappar */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { display: block; font-weight: 500; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
              border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; font-size: 15px; }
.chips input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Huvudknapparna högst upp */
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.actions button { flex-direction: column; gap: 4px; min-height: 86px; border-radius: 22px; border: 0;
                  font-size: 15px; padding: 10px 6px; box-shadow: var(--shadow); }
.actions .emoji { font-size: 28px; line-height: 1; }
.actions .steg { background: var(--accent-soft); }
.actions .pass { background: var(--ok-soft); }
.actions .snack { background: var(--honey-soft); }

/* Streaken */
.streak { display: flex; align-items: center; gap: 16px; }
.streak .flame { font-size: 40px; line-height: 1; }
.streak .big { font-family: var(--serif); font-size: 52px; line-height: 1; font-weight: 600; letter-spacing: -0.03em; }
.streak .text { display: grid; gap: 2px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 3px 10px;
          border-radius: 999px; background: var(--raise); color: var(--muted); white-space: nowrap; }
.status.klarad { background: var(--ok-soft); color: var(--ok); }
.status.skyddad { background: var(--ice-soft); color: var(--ice); }
.status.missad { background: var(--bad-soft); color: var(--bad); }
.status.pagar { background: var(--accent-soft); color: var(--accent); }

/* Deltagarnas kort */
.people { display: grid; gap: 12px; }
.person { display: grid; gap: 12px; }
.person .who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc, var(--accent)); flex: none; }
.c0 { --pc: var(--p0); } .c1 { --pc: var(--p1); } .c2 { --pc: var(--p2); } .c3 { --pc: var(--p3); }
.today-steps { display: flex; align-items: baseline; gap: 8px; }
.today-steps .big { font-family: var(--serif); font-size: 40px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.bar { position: relative; height: 12px; border-radius: 999px; background: var(--raise); overflow: hidden; display: flex; }
.bar > span { height: 100%; }
.bar .own { background: var(--pc, var(--accent)); }
.bar .help { background: color-mix(in srgb, var(--pc, var(--accent)) 50%, var(--panel));
             background-image: repeating-linear-gradient(45deg, transparent 0 4px, rgb(255 255 255 / .35) 4px 8px); }
.bar .freeze { background: var(--ice); opacity: .7;
               background-image: repeating-linear-gradient(-45deg, transparent 0 4px, rgb(255 255 255 / .35) 4px 8px); }
.bar.thin { height: 6px; }
.weekline { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.weekline b { font-variant-numeric: tabular-nums; }
.dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dots span { display: grid; place-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.dots i { width: 22px; height: 22px; border-radius: 50%; border: 1.6px solid var(--line-strong); display: grid;
          place-items: center; font-style: normal; font-size: 11px; }
.dots .bra i { background: var(--pc, var(--accent)); border-color: var(--pc, var(--accent)); color: var(--on-accent); }
.dots .under i { border-color: var(--pc, var(--accent)); border-style: dashed; }
.dots .idag i { border-color: var(--pc, var(--accent)); border-width: 2.4px; }
.dots .freeze i { background: var(--ice-soft); border-color: var(--ice); color: var(--ice); }
.dots .paus i { background: var(--raise); border-style: dotted; }
.dots .ute i { opacity: .3; }
.tally { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tally a, .tally div { display: grid; gap: 2px; padding: 10px 12px; border-radius: 16px; background: var(--bg);
                       color: inherit; text-decoration: none; }
.tally b { font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tally small { font-size: 12px; }
.pips { display: inline-flex; gap: 4px; vertical-align: middle; }
.pips i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ok); }
.pips i.on { background: var(--ok); }

/* Bottenark (dialog) för snabb loggning */
dialog.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92vh;
               border-radius: 26px 26px 0 0; background: var(--panel); color: var(--text); }
dialog.sheet::backdrop { background: rgb(30 20 10 / .38); }
dialog.sheet[open] { animation: sheet-up .22s ease-out; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet-body { padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; }
.sheet-head button { min-height: 40px; width: 40px; padding: 0; border-radius: 50%; }
input.huge { font-family: var(--serif); font-size: 34px; text-align: center; min-height: 64px; font-weight: 600; }

/* Kalendern */
.weeknav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.weeknav > div { flex: 1; text-align: center; }
.weeknav a { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px;
             border: 1px solid var(--line-strong); color: var(--text); text-decoration: none; font-size: 20px; }
.calday { padding: 12px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.calday:last-child { border-bottom: 0; }
.calday.today { background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.calday .when { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.calday .when a { color: inherit; text-decoration: none; }
.entry { display: flex; align-items: center; gap: 8px; font-size: 15px; color: inherit; text-decoration: none; }
.entry .tag { font-size: 12px; color: var(--muted); }
.entry.planned { opacity: .75; }
.entry.planned .dot { background: transparent; border: 2px solid var(--pc); }
.pausebar { font-size: 13px; color: var(--muted); background: var(--raise); padding: 4px 10px; border-radius: 10px;
            justify-self: start; }

/* Tabeller (veckan) */
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 7px 4px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
th { font-weight: 600; color: var(--muted); font-size: 12px; }
tr.sum td { font-weight: 700; border-bottom: 0; }
tr.paused td { color: var(--muted); }
.scroll { overflow-x: auto; }

/* Tidslinjen */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 8px; bottom: 8px; width: 2px; background: var(--line-strong); }
.timeline > li { position: relative; padding: 0 0 14px 44px; }
.timeline .node { position: absolute; left: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%;
                  background: var(--panel); border: 2px solid var(--line-strong); display: grid; place-items: center;
                  font-size: 12px; }
.timeline .klarad .node { background: var(--ok); border-color: var(--ok); color: #fff; }
.timeline .skyddad .node { background: var(--ice); border-color: var(--ice); color: #fff; }
.timeline .missad .node { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.timeline .pagar .node { border-color: var(--accent); border-width: 3px; }
.timeline .stilla .node { border-style: dotted; }
.timeline a.wk { display: block; color: inherit; text-decoration: none; background: var(--panel); border-radius: 18px;
                 padding: 12px 14px; box-shadow: var(--shadow); }
.timeline .pagar a.wk { outline: 2px solid var(--accent-soft); }
.timeline .milestone { background: var(--honey-soft); border-radius: 14px; padding: 8px 12px; margin-top: 8px; font-size: 14px; }

/* Bottenmenyn */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
           background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(12px);
           -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line);
           padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
nav.tabs a { flex: 1; max-width: 112px; display: grid; justify-items: center; gap: 2px; padding: 6px 0;
             color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500; position: relative; }
nav.tabs a.active { color: var(--accent); }
nav.tabs .badge { position: absolute; top: 2px; left: calc(50% + 8px); min-width: 18px; height: 18px; border-radius: 9px;
                  background: var(--accent); color: var(--on-accent); font-size: 11px; display: grid; place-items: center;
                  padding: 0 5px; font-weight: 700; }

.empty { text-align: center; padding: 26px 16px; color: var(--muted); }
.note { font-size: 14px; color: var(--muted); background: var(--raise); border-radius: 14px; padding: 10px 14px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
        background: var(--raise); color: var(--muted); }
.pill.ice { background: var(--ice-soft); color: var(--ice); }
.pill.honey { background: var(--honey-soft); color: var(--honey); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
code, .code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--raise); padding: 2px 6px;
              border-radius: 6px; word-break: break-all; }
ol.steps { padding-left: 20px; display: grid; gap: 8px; margin: 0; }
details.more > summary { cursor: pointer; color: var(--accent); font-weight: 500; list-style: none; padding: 6px 0; }
details.more > summary::-webkit-details-marker { display: none; }
.login { margin-top: 10vh; }
.login h1 { font-size: 44px; margin-bottom: 6px; }

/* Spelen i överraskningarna */
.game { display: grid; gap: 14px; }
.board { display: grid; gap: 0; border: 3px solid var(--text); border-radius: 12px; overflow: hidden;
         background: var(--panel); max-width: 420px; width: 100%; margin: 0 auto; }
.board .cell { aspect-ratio: 1; min-height: 0; border-radius: 0; border: 0; border-right: 1px solid var(--line-strong);
               border-bottom: 1px solid var(--line-strong); font-family: var(--serif); font-size: 24px; font-weight: 600;
               padding: 0; position: relative; background: var(--panel); color: var(--accent); }
.board .cell.given { color: var(--text); background: var(--raise); }
.board .cell.sel { background: var(--accent-soft); }
.sol-board .cell { font-size: 22px; }
.edge { position: absolute; z-index: 1; font: 700 13px/1 system-ui; color: var(--muted); background: var(--panel);
        border-radius: 6px; padding: 1px 3px; }
.edge.right { right: -8px; top: 50%; transform: translateY(-50%); }
.edge.down { bottom: -8px; left: 50%; transform: translateX(-50%); }
.mem-board { grid-template-columns: repeat(4, 1fr); gap: 8px; border: 0; background: none; }
.mem-board .card { border-radius: 14px; border: 0; background: var(--accent); font-size: 30px; }
.mem-board .card.up { background: var(--panel); box-shadow: var(--shadow); }
.mem-board .card.found { background: var(--ok-soft); }
.pad { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; max-width: 420px; width: 100%; margin: 0 auto; }
.pad button { padding: 0; min-height: 50px; font-family: var(--serif); font-size: 20px; }
.pad button:disabled { opacity: .3; }
.pad .erase { font: 600 12px "Familjen Grotesk", system-ui; }
.game.solved .board { animation: solved .6s ease; border-color: var(--ok); }
@keyframes solved { 50% { transform: scale(1.04); } }

/* Fruktdjuret */
.pet-stage { display: grid; justify-items: center; gap: 10px; text-align: center; position: relative; }
.pet-btn { border: 0; background: none; padding: 0; min-height: 0; border-radius: 50%; color: var(--text); }
.pet-btn:hover { background: none; }
.pet { display: inline-block; color: var(--text); }
.pet .pet-body { transform-origin: 100px 175px; animation: breathe 3.2s ease-in-out infinite; }
.pet.m-sover .pet-body { animation-duration: 5s; }
.pet.m-hungrig .pet-body { animation: wobble 2.4s ease-in-out infinite; }
.pet.r-fniss .pet-body { animation: bounce .5s ease 3; }
.pet.r-favorit .pet-body { animation: dance .6s ease 3; }
.pet.r-mums .pet-body { animation: chew .25s ease 6; }
.pet.r-sur .pet-body, .pet.r-nej .pet-body { animation: shake .12s linear 6; }
.pet.r-vaknar .pet-body { animation: stretch 1s ease; }
.pet .zzz text { animation: float 2.4s ease-in-out infinite; }
.pet .zzz text:nth-child(2) { animation-delay: .4s; } .pet .zzz text:nth-child(3) { animation-delay: .8s; }
.pet .hearts { animation: float 1.6s ease-out forwards; }
.pet-leaf { transform-origin: 104px 40px; animation: leaf 4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.02, .98); } }
@keyframes wobble { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
@keyframes bounce { 40% { transform: translateY(-16px) scale(.98, 1.04); } 80% { transform: translateY(0) scale(1.05, .95); } }
@keyframes dance { 25% { transform: rotate(-8deg) translateY(-6px); } 75% { transform: rotate(8deg) translateY(-6px); } }
@keyframes chew { 50% { transform: scale(1.03, .96); } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes stretch { 40% { transform: scale(.94, 1.08); } }
@keyframes float { 50% { transform: translateY(-6px); opacity: .6; } }
@keyframes leaf { 50% { transform: rotate(-6deg); } }
@media (prefers-reduced-motion: reduce) { .pet *, .pet-leaf { animation: none !important; } }
.poops { display: flex; gap: 6px; font-size: 26px; }
.mood { margin: 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; text-align: left; }
.fruits { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.fruits button { width: 100%; flex-direction: column; gap: 2px; min-height: 72px; padding: 6px 4px; border-radius: 16px; }
.fruits button span { font-size: 28px; line-height: 1; }
.fruits button small { font-size: 11px; font-weight: 500; }
.pet-card { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
