:root {
  --bg: #f4f2ee; --card: #ffffff; --ink: #2b2a28; --muted: #8a867e; --line: #e6e2da;
  --accent: #7b6cf6; --accent-soft: #ece9ff; --green: #3fa36b; --green-soft: #e8f6ee;
  --amber: #e0a33a; --amber-soft: #fff4df; --red: #d9534f; --red-soft: #fdeceb;
  --mgr: #4f8ef7; --boss: #b05cd6; --chip: #f1efe9; --field: #faf9f6; --c7: #2bb3a8; --c8: #e2739f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a19; --card: #262523; --ink: #ecebe8; --muted: #9b968d; --line: #3a3835;
    --accent: #9a8dff; --accent-soft: #34305a; --green: #5cc38a; --green-soft: #1f3a2b;
    --amber: #f0b552; --amber-soft: #3d3220; --red: #ef6f6b; --red-soft: #45252a;
    --chip: #33312e; --field: #2e2c2a; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.35 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
#app { max-width: 560px; margin: 0 auto; padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 14px 16px 8px; display: flex; align-items: center; gap: 10px; }
header h1 { font-size: 20px; margin: 0; flex: 1; }
#who { font-size: 12px; background: var(--accent-soft); color: var(--accent); padding: 4px 9px; border-radius: 999px; }
main { padding: 0 12px; }
.card { background: var(--card); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 .grow { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; padding: 30px 0; }
nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; background: var(--card); border-top: 1px solid var(--line); display: flex; z-index: 9; padding-bottom: env(safe-area-inset-bottom, 0px); }
nav button { flex: 1; border: 0; background: none; padding: 8px 0 10px; font-size: 11px; color: var(--muted); }
nav button b { display: block; font-size: 20px; line-height: 24px; font-weight: 400; }
nav button.on { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
.days { display: flex; gap: 4px; margin-bottom: 12px; }
.day { flex: 1; text-align: center; background: var(--card); border-radius: 12px; padding: 6px 0 4px; font-size: 11px; color: var(--muted); border: 2px solid transparent; }
.day b { display: block; color: var(--ink); font-size: 13px; }
.day.sel { border-color: var(--accent); }
.day.today b { color: var(--accent); }
.ring { width: 22px; height: 22px; display: block; margin: 3px auto 0; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.row.done { opacity: .45; }
.row.done .t { text-decoration: line-through; }
.x { border: 0; background: none; color: var(--muted); font-size: 16px; padding: 0 4px; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.tag.rep { background: var(--accent-soft); color: var(--accent); }
.tag.late { background: var(--red-soft); color: var(--red); }
.form { display: grid; gap: 8px; margin-top: 10px; }
.form .line { display: flex; gap: 8px; flex-wrap: wrap; }
.form .line > * { flex: 1 1 120px; min-width: 0; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; min-height: 54px; }
.btn { border: 0; background: var(--accent); color: #fff; border-radius: 10px; padding: 9px 12px; font-size: 14px; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.seg { display: flex; background: var(--chip); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 0; border-radius: 8px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: 13px; }
.cal .h { color: var(--muted); font-size: 11px; }
.cal button { border: 0; background: none; padding: 7px 0; border-radius: 9px; position: relative; }
.cal .busy { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.cal .sup { background: var(--green-soft); color: var(--green); font-weight: 600; }
.cal .today { outline: 2px solid var(--accent); }
.cal .sel { background: var(--accent); color: #fff; }
.cal .bd::after { content: "🎂"; position: absolute; font-size: 9px; right: 1px; top: -1px; }
.monthnav { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.monthnav b { flex: 1; text-align: center; }
.col-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: 6px 0 4px; }
.mgr { color: var(--mgr); } .boss { color: var(--boss); }
.fixed { opacity: .7; }
.st { font-size: 12px; border-radius: 999px; padding: 2px 6px; width: auto; }
.st.new { background: var(--chip); } .st.work { background: var(--amber-soft); color: var(--amber); }
.st.done { background: var(--green-soft); color: var(--green); }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
td, th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
.need { color: var(--red); font-weight: 700; } .okc { color: var(--green); }
.hab { display: grid; grid-template-columns: minmax(0, 1fr) repeat(7, 26px) 38px 20px; gap: 4px; align-items: center; font-size: 13px; padding: 4px 0; }
.hab .c { width: 26px; height: 26px; border-radius: 7px; background: var(--chip); border: 0; }
.hab .c.y { background: var(--green); }
.pct { font-size: 11px; color: var(--muted); text-align: right; }
.bar { height: 8px; background: var(--chip); border-radius: 99px; overflow: hidden; margin: 2px 0 8px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.money { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-variant-numeric: tabular-nums; }
.big { font-size: 20px; font-weight: 700; }
.plus { color: var(--green); } .minus { color: var(--red); }
.pill { display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--chip); margin: 2px 4px 2px 0; }
.wheel { width: 100%; max-width: 320px; display: block; margin: 0 auto; }
.slider { display: grid; grid-template-columns: 110px 1fr 24px; gap: 8px; align-items: center; font-size: 13px; }
.slider input { padding: 0; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 13px; z-index: 20; }
.error { color: var(--red); }
.chart { width: 100%; display: block; }
/* week spread */
.spread { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.page { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.weekend { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pday { background: var(--card); border-radius: 12px; padding: 6px 7px 4px; min-height: 150px; display: flex; flex-direction: column; border: 2px solid transparent; min-width: 0; }
.pday.half { min-height: 72px; flex: 1 0 auto; }
.pday.sel { border-color: var(--accent); }
.phead { display: flex; align-items: baseline; gap: 5px; border: 0; background: none; padding: 0 0 3px; width: 100%; text-align: left; border-bottom: 1px solid var(--line); }
.phead .wd { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.phead b { font-size: 15px; }
.pday.today .phead b { color: var(--accent); }
.phead .cnt { margin-left: auto; font-size: 11px; color: var(--muted); }
.lines { flex: 1; background-image: repeating-linear-gradient(to bottom, transparent 0 21px, var(--line) 21px 22px); background-position: 0 1px; }
.pline { display: flex; align-items: flex-start; gap: 4px; font-size: 12px; line-height: 22px; min-height: 22px; overflow-wrap: anywhere; }
.pline input { width: 13px; height: 13px; margin: 4px 0 0; flex: none; accent-color: var(--accent); }
.pline.done span { text-decoration: line-through; opacity: .45; }
.pline .tag { font-size: 9px; padding: 0 4px; line-height: 16px; margin-top: 3px; }
.quick { border: 0; background: transparent; padding: 0; font-size: 12px; line-height: 22px; height: 22px; border-radius: 0; }
.quick:focus { outline: none; background: var(--field); }
/* birthdays */
.bday { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.bday:last-child { border-bottom: 0; }
.bmain { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bmain .left { font-size: 12px; color: var(--muted); }
.bday.soon .left { color: var(--accent); font-weight: 600; }
.age { text-align: right; line-height: 1.1; }
.age span { display: block; font-size: 10px; color: var(--muted); }
.age b { font-size: 22px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check input { width: 18px; height: 18px; }
.tag.anniversary, .tag.yearly, .tag.birthday { background: var(--amber-soft); }
#who.logout { cursor: pointer; }
.login { padding: 30px 16px; }
.seg { overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { white-space: nowrap; padding: 7px 8px; }
.cal button { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.dots { display: flex; gap: 2px; height: 5px; }
.dots i, .pill i { display: inline-block; width: 5px; height: 5px; border-radius: 50%; }
.pill i { margin-right: 4px; vertical-align: 1px; }
.d-task { background: var(--amber); } .d-fixed { background: var(--boss); } .d-out { background: var(--red); }
.cal .sel .dots i { outline: 1px solid #fff; }
.calkey { display: flex; flex-wrap: wrap; margin-top: 8px; }
.pill.busy { background: var(--accent-soft); color: var(--accent); } .pill.sup { background: var(--green-soft); color: var(--green); }
.dayevents { margin-bottom: 6px; border-bottom: 1px dashed var(--line); }
.tag.event { background: var(--accent-soft); color: var(--accent); } .tag.supply { background: var(--green-soft); color: var(--green); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin: 4px 0 6px; }
.legend i, .donutlegend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: 0; }
.donutwrap { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.donut { width: 130px; height: 130px; flex: none; margin: 0 auto; }
.donutlegend { flex: 1 1 180px; min-width: 0; font-size: 13px; }
.donutlegend .money { padding: 3px 0; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.kpis div { background: var(--field); border-radius: 10px; padding: 8px 10px; }
.kpis b { display: block; font-size: 19px; }
.kpis span { font-size: 12px; color: var(--muted); }
table.heat td, table.heat th { text-align: center; padding: 4px 2px; font-size: 11px; }
table.heat td:first-child { text-align: left; white-space: nowrap; font-size: 12px; padding-right: 6px; }
table.heat td { border-bottom: 2px solid var(--card); }
nav button { min-width: 0; }
/* week: spread and the selected day side by side on wide screens */
.weekgrid { display: block; }
.card.overdue { border: 1px solid var(--red-soft); }
.pday.drop { border-color: var(--green); background: var(--green-soft); }
.pline[draggable="true"] { cursor: grab; }
.form.edit { padding: 8px 0; border-bottom: 1px solid var(--line); }

/* ---------------------------------------------------------------- computer */
@media (min-width: 960px) {
  body { font-size: 15px; }
  #app { max-width: 1320px; padding-bottom: 24px; display: grid; grid-template-columns: 200px minmax(0, 1fr);
    grid-template-areas: "nav top" "nav main"; grid-template-rows: auto 1fr; column-gap: 8px; min-height: 100vh; }
  header { grid-area: top; padding: 20px 24px 12px; }
  header h1 { font-size: 24px; }
  main { grid-area: main; padding: 0 24px; }
  nav { grid-area: nav; position: sticky; top: 0; left: auto; transform: none; width: auto; max-width: none; height: 100vh;
    flex-direction: column; justify-content: flex-start; gap: 2px; padding: 20px 10px; border-top: 0; border-right: 1px solid var(--line); background: transparent; }
  nav button { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 15px; text-align: left; }
  nav button b { display: inline; font-size: 20px; }
  nav button.on { background: var(--accent-soft); }
  nav button:hover { background: var(--chip); }
  .toast { bottom: 24px; }
  /* week: the spread like an open planner, the day and "for the week" on the right */
  .weekgrid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
  .spread { gap: 12px; }
  .page { gap: 12px; }
  .pday { min-height: 230px; padding: 8px 10px 6px; }
  .pday.half { min-height: 109px; }
  .pline, .quick { font-size: 13px; }
  .weekside { position: sticky; top: 12px; }
  /* other screens: cards in two columns */
  #screen:not([data-tab="week"]) { columns: 2; column-gap: 16px; }
  #screen:not([data-tab="week"]) > * { break-inside: avoid; }
  #screen > .seg, #screen > .monthnav { column-span: all; max-width: 640px; }
  .card { break-inside: avoid; }
  .cal button { padding: 10px 0; }
}
@media (min-width: 1400px) {
  #screen[data-tab="year"] { columns: 3; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
