@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("../assets/fonts/schibsted-grotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("../assets/fonts/schibsted-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #efe9da;
  --paper-2: #e5dec9;
  --ink: #1c1b19;
  --ink-2: #5a5547;
  --red: #b3261e;
  --moss: #4f5f49;
  --rule: #c9c0a8;
  --on-fill: #efe9da;
  --tabs-h: 58px;
  --gut: 16px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #181714;
    --paper-2: #24211c;
    --ink: #efe9da;
    --ink-2: #b4ad99;
    --red: #e8786d;
    --moss: #a3b99a;
    --rule: #3b372e;
    --on-fill: #181714;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--paper); }
body {
  font: 400 16px/1.35 "Schibsted Grotesk", system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 96px);
  overscroll-behavior-y: none;
}
::selection { background: var(--red); color: var(--paper); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 4px; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
html { scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }

#view { max-width: 640px; margin: 0 auto; padding: 0 var(--gut); }

/* numerals that line up in columns: dates, times, ranges */
.d b, .item-meta, .head-right, .wk-range { font-variant-numeric: tabular-nums; }

/* page head: the almanac's masthead */
.page-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: calc(env(safe-area-inset-top) + 22px) 2px 12px;
  border-bottom: 2px solid var(--ink);
}
.page-head h1 { font-size: 34px; font-weight: 800; letter-spacing: -.025em; line-height: 1.05; }
.head-right { font-size: 14px; font-weight: 600; color: var(--ink-2); }

.wk {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 28px; padding: 0 2px 8px; border-bottom: 2px solid var(--ink);
  font-size: 22px; font-weight: 800; letter-spacing: -.02em;
}
.wk-range { font-size: 14px; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }

/* day rows */
.day { display: grid; grid-template-columns: 54px 1fr; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.day.empty { padding: 8px 2px; }
.day .d { text-align: left; align-self: start; }
.nothing { color: var(--ink-2); font-size: 14px; padding: 8px 0; }
.d b { display: block; font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.d i { display: block; margin-top: 3px; font-style: normal; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.day.empty .d b { font-size: 20px; color: var(--ink-2); font-weight: 700; }
.day.red .d b, .day.red .d i { color: var(--red); }
.day.today .d b {
  display: inline-block; min-width: 40px; padding: 4px 6px; margin: -4px 0 0 -6px;
  background: var(--ink); color: var(--paper); text-align: center; border-radius: 4px;
}
.in { min-width: 0; }
.hol { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--red); margin-bottom: 4px; }
.now { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 4px; }

/* items */
.item { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 6px 0; }
.item-text.static { cursor: default; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { font-size: 13px; color: var(--ink-2); margin-top: 1px; }
.item.done .item-title { text-decoration: line-through; text-decoration-thickness: 1.5px; color: var(--ink-2); font-weight: 500; }
.item.done .item-meta { opacity: .75; }

/* owner marks: ring = open, filled = done. Square = event */
.mark {
  flex: none; width: 36px; height: 36px; border-radius: 50%; padding: 2px; display: grid; place-items: center;
  background: var(--ink); transition: transform .18s var(--ease);
}
.mark:active { transform: scale(.92); }
button.mark { position: relative; }
button.mark::before { content: ""; position: absolute; inset: -6px; }
.o-b { background: var(--moss); }
.o-ab { background: linear-gradient(90deg, var(--ink) 50%, var(--moss) 50%); }
.mark-in {
  width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper); color: var(--ink); font-size: 14px; font-weight: 800;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.mark.is-event { border-radius: 8px; }
.mark.is-event .mark-in { border-radius: 6px; }
.mark.is-done .mark-in { background: transparent; color: var(--on-fill); }
.mark svg { width: 20px; height: 20px; stroke-width: 2.4; }
.mark.pop svg path { stroke-dasharray: 22; animation: tick .32s var(--ease); }
@keyframes tick { from { stroke-dashoffset: 22; } to { stroke-dashoffset: 0; } }

/* blocks */
.block { margin-top: 22px; }
.block > h2, .row-between h2 { font-size: 15px; font-weight: 800; letter-spacing: -.005em; padding: 0 2px 6px; border-bottom: 1px solid var(--ink); margin-bottom: 4px; }
.block.overdue > h2 { color: var(--red); border-color: var(--red); }
.row-between { display: flex; justify-content: space-between; align-items: baseline; }
.row-between h2 { flex: 1; margin-right: 12px; }
.done-block summary { font-size: 15px; font-weight: 800; padding: 6px 2px; cursor: pointer; border-bottom: 1px solid var(--ink); list-style: none; }
.done-block summary::-webkit-details-marker { display: none; }
.first-run { margin: 18px 2px 22px; max-width: 46ch; color: var(--ink-2); font-size: 15px; }
.empty-note { padding: 40px 2px; color: var(--ink-2); }
.more-btn { display: block; margin: 26px auto 0; padding: 12px 20px; font-weight: 700; color: var(--ink); border: 1.5px solid var(--ink); border-radius: 999px; }
.link { color: var(--ink); font-weight: 700; padding: 0 2px; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }

.filters { display: flex; gap: 8px; padding: 14px 0 0; overflow-x: auto; }
.chip { flex: none; min-height: 44px; padding: 0 16px; border-radius: 999px; font-weight: 700; font-size: 14px; border: 1.5px solid var(--ink); }
.chip.on { background: var(--ink); color: var(--paper); }

/* shopping */
.shop-add { display: flex; gap: 8px; padding-top: 16px; }
.shop-add input { flex: 1; min-width: 0; }
.shop-mark { border-radius: 8px; background: transparent; border: 1.5px solid var(--ink-2); padding: 0; }
.shop-mark .mark-in { border-radius: 6px; background: transparent; }
.shop-mark.is-done { background: var(--ink-2); }
.shop-mark.is-done .mark-in { color: var(--paper); }
.x { width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink-2); }
.x svg { width: 20px; height: 20px; }

/* forms */
input[type=text], input[type=date], input[type=time], select {
  width: 100%; min-height: 46px; padding: 10px 12px; background: var(--paper-2);
  border: 1.5px solid transparent; border-radius: 10px; font-size: 16px;
  caret-color: var(--red); appearance: none; -webkit-appearance: none;
}
input:focus, select:focus { outline: none; border-color: var(--ink); }
input::placeholder { color: var(--ink-2); opacity: .8; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.code { font-size: 26px; font-weight: 800; letter-spacing: .06em; margin: 14px 0 4px; user-select: all; -webkit-user-select: all; font-variant-numeric: tabular-nums; }
.sync-status { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.sync-status.offline { color: var(--red); }
.help.first { margin-top: 12px; }
.pair-hint { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; margin: 0 0 8px; padding: 12px 2px; min-height: 48px; border-bottom: 1px solid var(--rule); font-size: 15px; color: var(--ink-2); }
.pair-hint b { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; flex: none; }
.btn:disabled { opacity: .5; }
.help { font-size: 14px; color: var(--ink-2); margin-top: 10px; max-width: 60ch; }
.err { color: var(--red); font-weight: 600; font-size: 14px; min-height: 0; margin-top: 8px; }
.err:empty { display: none; }

.seg { display: flex; background: var(--paper-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { flex: 1; min-height: 40px; padding: 0 10px; border-radius: 8px; font-weight: 700; font-size: 15px; text-align: center; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: var(--paper); }

.btn { min-height: 46px; padding: 0 20px; border-radius: 10px; font-weight: 700; background: var(--ink); color: var(--paper); text-align: center; }
.btn.primary { background: var(--red); color: var(--on-fill); flex: 1; }
.btn.ghost { background: transparent; border: 1.5px solid var(--ink); color: var(--ink); }
.btn.danger { background: transparent; color: var(--red); border: 1.5px solid var(--red); }
.btn-row { display: flex; gap: 10px; margin-top: 10px; }
[hidden] { display: none !important; }

/* add button + tabs */
.add {
  position: fixed; right: max(var(--gut), calc((100vw - 640px) / 2 + var(--gut)));
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 50%; background: var(--red); color: var(--on-fill);
  display: grid; place-items: center; box-shadow: 0 6px 16px rgba(28, 27, 25, .28); z-index: 5;
  transition: transform .2s var(--ease);
}
.add:active { transform: scale(.94); }
.add svg { width: 26px; height: 26px; stroke-width: 2.2; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-inline: max(0px, calc((100vw - 640px) / 2));
  background: var(--paper); border-top: 2px solid var(--ink);
}
.tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 700; color: var(--ink-2); position: relative; text-align: center; }
.tabs svg { width: 24px; height: 24px; }
.tabs button[aria-current] { color: var(--red); }
.tabs button[aria-current]::before { content: ""; position: absolute; top: -2px; left: 22%; right: 22%; height: 4px; background: var(--red); }

/* sheet */
dialog#sheet {
  position: fixed; inset: auto 0 0 0; width: 100%; max-width: 640px; margin: 0 auto; max-height: 92dvh; overflow: auto;
  border: 0; border-radius: 18px 18px 0 0; background: var(--paper); color: var(--ink);
  padding: 18px var(--gut) calc(env(safe-area-inset-bottom) + 20px);
  border-top: 2px solid var(--ink);
}
dialog#sheet[open] { animation: rise .32s var(--ease); }
dialog#sheet::backdrop { background: rgba(20, 18, 14, .5); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.sheet-actions { margin-top: 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
