@font-face { font-family: "DM Sans"; font-weight: 400; font-display: swap; src: url(fonts/dm-sans-v17-latin_latin-ext-regular.woff2) format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 500; font-display: swap; src: url(fonts/dm-sans-v17-latin_latin-ext-500.woff2) format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 600; font-display: swap; src: url(fonts/dm-sans-v17-latin_latin-ext-600.woff2) format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-display: swap; src: url(fonts/poppins-v24-latin_latin-ext-500.woff2) format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-display: swap; src: url(fonts/poppins-v24-latin_latin-ext-600.woff2) format("woff2"); }

:root {
  --navy: #0d2535;
  --bg: #eef2f4; --card: #fff; --line: #dde4e8; --muted: #566773;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { min-height: 100dvh; background: var(--bg); color: var(--navy); font: 400 16px/1.45 "DM Sans", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.top :focus-visible { outline-color: #fff; }

.top { position: sticky; top: 0; z-index: 10; padding: calc(var(--safe-top) + 14px) 0 10px; background: var(--navy); color: #fff; }
.top-row { display: flex; align-items: center; justify-content: space-between; padding: 0 18px 12px; }
.logo { display: block; height: 16px; width: auto; margin-bottom: 7px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.docs-btn { min-height: 44px; padding: 0 15px; border-radius: 100px; background: rgba(255,255,255,.12); font-size: 14px; font-weight: 600; }
h1 { font: 600 27px/1.2 "Poppins", sans-serif; }
.refresh { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.12); font-size: 21px; }
.refresh.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 18px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 100px; background: rgba(255,255,255,.12); color: #fff; font-size: 14px; font-weight: 500; }
.chip[aria-pressed="true"] { background: #fff; color: var(--navy); }

.layout { max-width: 640px; margin: 0 auto; }
main, aside { padding: 8px 14px calc(var(--safe-bottom) + 92px); }
aside { display: none; }
body[data-view="calendar"] main { display: none; }
body[data-view="calendar"] aside { display: block; }
.month { display: inline-block; padding: 3px 11px; border-radius: 100px; background: var(--m-bg); color: var(--m-fg); }
.cal { margin-top: 8px; padding: 12px; background: var(--card); border-radius: 16px; box-shadow: 0 1px 2px rgba(13,37,53,.06); }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 4px; border-radius: 12px; background: var(--m-bg); color: var(--m-fg); }
.cal-head h2 { font: 600 17px "Poppins", sans-serif; }
.cal-head button { width: 44px; height: 44px; font-size: 26px; line-height: 1; color: inherit; }
.week, .grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.week { margin-top: 9px; text-align: center; color: var(--muted); font-size: 12px; font-weight: 600; }
.grid { gap: 2px; margin-top: 3px; }
.day { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; height: 46px; border-radius: 10px; font-size: 15px; color: var(--muted); }
.day.busy { background: var(--m-bg); color: var(--m-fg); font-weight: 600; }
.day.now span { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: var(--navy); color: #fff; }
.day.due { box-shadow: inset 0 0 0 2px var(--m-fg); }
.day[aria-pressed="true"] { background: var(--m-fg); color: #fff; }
.day em { display: flex; gap: 2px; height: 5px; }
.day i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; color: var(--muted); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 11px; height: 11px; border-radius: 4px; background: var(--m-bg); }
.dot.due { box-shadow: inset 0 0 0 2px var(--m-fg); }
.empty.small { padding: 18px; }
@media (min-width: 960px) {
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 12px; max-width: 1180px; align-items: start; }
  aside, body[data-view="calendar"] aside { display: block; position: sticky; top: 132px; max-height: calc(100dvh - 205px); overflow-y: auto; padding-bottom: 16px; }
  body[data-view="calendar"] main { display: block; }
  .tabs button[data-view="calendar"] { display: none; }
  body .tabs { grid-template-columns: repeat(3, minmax(0, 160px)); justify-content: center; }
}
.group { padding: 18px 4px 8px; font: 600 13px "Poppins", sans-serif; letter-spacing: .03em; color: var(--muted); }
.card { display: flex; gap: 13px; width: 100%; margin-bottom: 9px; padding: 13px; text-align: left; background: var(--card); border-radius: 15px; box-shadow: 0 1px 2px rgba(13,37,53,.06); }
.date { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 52px; height: 58px; border-radius: 11px; background: var(--m-bg, var(--bg)); color: var(--m-fg, var(--muted)); }
.date b { font: 600 20px/1.05 "Poppins", sans-serif; }
.date small { font-size: 11.5px; font-weight: 600; text-transform: uppercase; }
.date.soon { box-shadow: inset 0 0 0 2px var(--m-fg); }
.date.none { background: var(--bg); color: var(--muted); }
.card-body { min-width: 0; flex: 1; }
.card h2 { font: 600 15.5px/1.3 "DM Sans", sans-serif; overflow-wrap: anywhere; }
.meta { margin-top: 3px; color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.tag { padding: 2px 8px; border-radius: 100px; background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 500; }
.tag.high { background: var(--navy); color: #fff; }
.tag.state { background: #fff; color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty button { margin-top: 14px; padding: 10px 18px; border-radius: 100px; background: var(--navy); color: #fff; font-weight: 600; }

.tabs { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 8px calc(var(--safe-bottom) + 6px); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 1px; min-height: 50px; justify-content: center; border-radius: 12px; color: var(--muted); font-size: 12px; font-weight: 600; }
.tabs span { font-size: 20px; line-height: 1.1; }
.tabs button[aria-current="page"] { color: #fff; background: var(--navy); }

.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(13,37,53,.5); }
.sheet { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; max-width: 640px; max-height: 88dvh; margin: 0 auto; overflow: hidden; background: #fff; border-radius: 22px 22px 0 0; }
.sheet-head { flex: none; display: flex; justify-content: flex-end; padding: 8px 20px 0; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 20px 10px; }
.sheet-actions { flex: none; padding: 10px 20px calc(var(--safe-bottom) + 12px); border-top: 1px solid var(--line); background: #fff; }
.close { width: 44px; height: 44px; margin-right: -8px; border-radius: 50%; font-size: 22px; color: var(--muted); }
.sheet h2 { font: 600 21px/1.28 "Poppins", sans-serif; overflow-wrap: anywhere; }
.why { margin-top: 13px; padding: 12px 14px; border-radius: 12px; background: var(--bg); font-size: 15px; overflow-wrap: anywhere; }
.facts { margin: 14px 0 0; }
.facts div { display: grid; grid-template-columns: 94px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.status { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.status button { min-height: 44px; padding: 0 4px; border-radius: 11px; background: var(--bg); font-size: 14px; font-weight: 600; }
.status button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.open { display: block; margin-top: 8px; padding: 12px; border-radius: 12px; background: var(--navy); color: #fff; text-align: center; text-decoration: none; font-weight: 600; }
.toast { position: fixed; z-index: 50; left: 16px; right: 16px; bottom: calc(var(--safe-bottom) + 84px); max-width: 420px; margin: 0 auto; padding: 11px 15px; border-radius: 12px; background: var(--navy); color: #fff; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.toast button { min-height: 44px; margin: -11px -6px -11px 0; padding: 0 10px; color: #fff; font-weight: 600; text-decoration: underline; }
.chip { position: relative; }
.chip::after { content: ""; position: absolute; inset: -5px 0; }
@media (prefers-reduced-motion: reduce) { .refresh.spin { animation: none; } }
/* Small iPhones: smaller header so the whole month fits. */
@media (max-height: 700px) {
  .top { padding-top: calc(var(--safe-top) + 6px); padding-bottom: 8px; }
  .top-row { padding-bottom: 6px; }
  .logo { height: 12px; margin-bottom: 4px; }
  h1 { font-size: 21px; }
  aside { padding-top: 2px; }
  .cal { margin-top: 6px; padding: 8px; }
  .cal-head { padding: 0 4px; }
  .week { margin-top: 5px; }
  .day { height: 40px; }
  .legend { margin-top: 6px; }
}
@media (max-width: 350px) { main, aside { padding-left: 8px; padding-right: 8px; } .cal { padding: 6px; } .grid { gap: 1px; } }
/* Phone sideways: the header scrolls away and the bars get slimmer. */
@media (max-height: 480px) {
  .top { position: static; }
  .tabs { padding-top: 3px; padding-bottom: calc(var(--safe-bottom) + 3px); }
  .tabs button { flex-direction: row; gap: 6px; min-height: 44px; }
  .sheet-head { position: absolute; right: 0; top: 0; padding: 4px 16px 0; z-index: 1; }
  .sheet-body { padding-top: 14px; padding-right: 58px; }
  .sheet-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; align-items: center; padding-top: 7px; padding-bottom: calc(var(--safe-bottom) + 7px); }
  .open { margin-top: 0; }
}

.day.due[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--m-fg), inset 0 0 0 4px #fff; }
.docs-note { margin-top: 4px; color: var(--muted); font-size: 14px; }
.doc { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 8px 2px; border-top: 1px solid var(--line); color: var(--navy); text-decoration: none; font-weight: 500; }
.doc span { flex: 1; min-width: 0; }
.doc small { flex: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.sheet-actions .open:only-child { grid-column: 1 / -1; margin-top: 0; }
.fresh { max-width: 1180px; margin: 10px auto -4px; padding: 0 18px; color: var(--muted); font-size: 12.5px; }
.fresh.stale { color: var(--navy); font-weight: 600; }
