:root {
  --bg: #f6f4ef; --card: #fffdf8; --fg: #1d1c1a; --mute: #5d5a54; --line: #d9d4c9; --soft: #efebe2;
  --acc: #1f5f8b; --acc-fg: #fff;
  --day: #f2c14e; --day-fg: #2b2100; --night: #2f3c8a; --night-fg: #fff;
  --today: #b4410c; --common: #cfead5; --common-fg: #0f3d1c; --mark: #8a1c4a; --mark-fg: #fff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18; --card: #24221f; --fg: #ece8df; --mute: #a9a397; --line: #3a3732; --soft: #2e2c28;
    --acc: #6fb3e0; --acc-fg: #0d1b26;
    --day: #e3b341; --day-fg: #1f1700; --night: #8e9cf2; --night-fg: #0c1033;
    --today: #ff9a5c; --common: #245c34; --common-fg: #e2f7e6; --mark: #f08ab4; --mark-fg: #2a0716;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main, .top { max-width: 760px; margin: 0 auto; padding: 0 10px; }
.top { padding-top: 18px; padding-right: 70px; }
h1 { font-size: 1.45rem; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
.lead { margin: 0 0 12px; color: var(--mute); }
.presetnote { margin: 0 0 12px; padding: 10px 12px; border-left: 4px solid var(--acc); background: var(--card); border-radius: 6px; overflow-wrap: anywhere; }
.presetnote[hidden] { display: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 10px; margin: 0 0 14px; }
@media (min-width: 420px) { .card { padding: 16px; } main, .top { padding-left: 16px; padding-right: 16px; } .top { padding-right: 76px; } }
.field { margin: 0 0 12px; min-width: 0; }
label, .lbl { display: block; font-weight: 600; font-size: .95rem; margin: 0 0 4px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; min-height: 44px; margin: 0; cursor: pointer; }
input[type=checkbox] { width: 22px; height: 22px; margin: 0; accent-color: var(--acc); }
select, input[type=date], input[type=number], input[type=text], input[type=time] {
  width: 100%; min-height: 44px; font: inherit; font-size: 16px; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; max-width: 100%;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; align-items: end; }
.hint { margin: 4px 0 0; color: var(--mute); font-size: .92rem; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
.btn, .ghost, .seg button { min-height: 44px; min-width: 44px; border-radius: 8px; padding: 8px 12px; border: 1px solid var(--line); background: var(--bg); }
.btn { background: var(--acc); color: var(--acc-fg); border-color: var(--acc); font-weight: 600; }
.btn:disabled, .ghost:disabled { opacity: .6; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg button[aria-pressed=true] { background: var(--acc); color: var(--acc-fg); border-color: var(--acc); font-weight: 700; }

/* pattern strip */
.pattern { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--soft); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-direction: column; line-height: 1; font-size: 15px; padding: 0; }
.chip small { font-size: 10px; font-weight: 500; opacity: .8; margin-top: 2px; }
.chip.D { background: var(--day); color: var(--day-fg); border-color: transparent; }
.chip.N { background: var(--night); color: var(--night-fg); border-color: transparent; }
div.chip { cursor: default; }
.crewrow { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; align-items: end; }

/* calendar */
.viewbar, .nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.nav h2 { margin: 0; text-align: center; flex: 1; font-size: 1.15rem; }
.navbtn { font-size: 1.4rem; line-height: 1; width: 48px; }
.crewbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 10px; }
.crewbar .lbl { margin: 0; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; }
@media (min-width: 420px) { .month { gap: 3px; } }
.wd { text-align: center; font-size: .8rem; color: var(--mute); padding: 2px 0; font-weight: 600; }
.day { position: relative; min-height: 58px; min-width: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--card); padding: 2px; display: flex; flex-direction: column; align-items: stretch; text-align: left; overflow: hidden; }
.day .num { font-size: .8rem; font-weight: 600; padding-left: 2px; }
.day .big { font-weight: 800; font-size: 1.05rem; text-align: center; margin-top: 2px; }
.day.D { background: var(--day); color: var(--day-fg); border-color: transparent; }
.day.N { background: var(--night); color: var(--night-fg); border-color: transparent; }
.day.today { box-shadow: inset 0 0 0 3px var(--today); }
.day.sel { outline: 3px solid var(--fg); outline-offset: -1px; }
.day.common { background: var(--common); color: var(--common-fg); }
.badges { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; margin-top: 2px; }
.b { display: inline-block; min-width: 18px; padding: 1px 2px; border-radius: 4px; font-size: .75rem; font-weight: 700; text-align: center; line-height: 1.3; }
.b.D { background: var(--day); color: var(--day-fg); }
.b.N { background: var(--night); color: var(--night-fg); }
.b.me { box-shadow: 0 0 0 2px var(--fg); }
.tag { display: block; font-size: .62rem; font-weight: 700; text-align: center; border-radius: 3px; background: var(--mark); color: var(--mark-fg); margin-top: 2px; line-height: 1.4; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0; font-size: .9rem; color: var(--mute); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 16px; height: 16px; border-radius: 4px; display: inline-block; border: 1px solid var(--line); }
.sw.D { background: var(--day); } .sw.N { background: var(--night); } .sw.T { box-shadow: inset 0 0 0 3px var(--today); } .sw.C { background: var(--common); }

/* year */
.year { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
@media (min-width: 640px) { .year { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .year { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mini h3 { margin: 0; }
.mini h3 button { width: 100%; min-height: 44px; background: none; border: 0; text-align: left; font-weight: 700; font-size: .95rem; padding: 0 2px; text-decoration: underline; text-underline-offset: 3px; }
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; }
.mgrid div { font-size: .68rem; text-align: center; line-height: 20px; border-radius: 3px; min-width: 0; }
.mgrid .h { color: var(--mute); font-weight: 600; }
.mgrid .D { background: var(--day); color: var(--day-fg); }
.mgrid .N { background: var(--night); color: var(--night-fg); }
.mgrid .common { background: var(--common); color: var(--common-fg); }
.mgrid .today { box-shadow: inset 0 0 0 2px var(--today); font-weight: 800; }

/* panels and tables */
#daypanel { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
#daypanel h3, #totals h3 { font-size: 1rem; margin: 0 0 6px; }
.dlist { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.dlist li { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: .92rem; }
.dlist li.D { background: var(--day); color: var(--day-fg); border-color: transparent; }
.dlist li.N { background: var(--night); color: var(--night-fg); border-color: transparent; }
.note { font-size: .9rem; color: var(--mute); margin: 6px 0; }
.pro { display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .03em; padding: 1px 6px; border-radius: 4px; border: 1px solid currentColor; margin-left: 6px; vertical-align: middle; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: right; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--mute); font-weight: 600; font-size: .85rem; }
tr.me td { font-weight: 700; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
#totals { margin-top: 12px; }
.prolist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.prolist li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.prolist li span { flex: 1 1 180px; }
.store { color: var(--mute); font-size: .92rem; text-align: center; margin: 4px 10px 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#poster { display: none; }

/* share */
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.share .hint { margin: 0; }
#share-box { flex: 1 1 100%; min-width: 0; }
