:root {
  --navy: #081435; --navy-2: #13204a; --cream: #F7EBCA; --gold: #CC8F00; --gold-2: #e0a412; --terra: #A44A3F;
  --bg: #f7f3ea; --card: #fff; --ink: #0d1530; --muted: #6b6a73; --line: #e7e0cf;
  --green: #2f7d4f; --green-bg: #e3f2e8; --red-bg: #f8e4e1; --blue: #2c5aa0; --blue-bg: #e2ebf8; --gold-bg: #fbefd0;
  --radius: 16px; --shadow: 0 1px 2px rgba(8, 20, 53, .06), 0 4px 14px rgba(8, 20, 53, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; overscroll-behavior-y: contain; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 10; background: var(--navy); color: var(--cream); padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px; }
.top-row { display: flex; align-items: center; gap: 12px; max-width: 760px; margin: 0 auto; }
.logo { height: 28px; width: auto; }
.top .who { margin-left: auto; font-size: 14px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.datebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; max-width: 760px; margin: 10px auto 0; }
.datebar button { width: 44px; height: 40px; border-radius: 12px; background: var(--navy-2); color: var(--cream); font-size: 22px; }
.datebar .day { flex: 1; text-align: center; font-weight: 700; font-size: 17px; }
.datebar .day small { display: block; font-weight: 500; font-size: 12px; opacity: .7; }
.datebar .day button { width: auto; height: auto; background: none; font-size: inherit; font-weight: inherit; }

main { max-width: 760px; margin: 0 auto; padding: 14px 14px calc(110px + var(--safe-b)); }

/* ---------- summary + filters ---------- */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.sum { background: var(--card); border-radius: 14px; padding: 10px 6px; text-align: center; box-shadow: var(--shadow); border: 2px solid transparent; }
.sum b { display: block; font-size: 24px; line-height: 1.1; }
.sum span { font-size: 12px; color: var(--muted); }
.sum.on { border-color: var(--navy); }
.sum.problem b { color: var(--terra); } .sum.doing b { color: var(--blue); } .sum.done b { color: var(--green); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -14px 4px; padding-left: 14px; padding-right: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--navy); color: var(--cream); border-color: var(--navy); }
.chip .n { margin-left: 6px; font-size: 12px; opacity: .7; }

/* ---------- task cards ---------- */
.section { margin: 18px 4px 8px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; gap: 8px; }
.section.late, .section.problem { color: var(--terra); }
.card { position: relative; display: block; width: 100%; text-align: left; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 14px 14px 18px; margin-bottom: 10px; overflow: hidden; }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--line); }
.card.s-doing::before { background: var(--blue); } .card.s-done::before { background: var(--green); } .card.s-problem::before { background: var(--terra); }
.card.urgent.s-todo::before { background: var(--gold); }
.card.s-done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.card .title { font-weight: 700; font-size: 17px; line-height: 1.25; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; font-size: 13px; color: var(--muted); align-items: center; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag.urgent { background: var(--gold-bg); color: #8a5d00; }
.tag.late { background: var(--red-bg); color: var(--terra); }
.tag.doing { background: var(--blue-bg); color: var(--blue); }
.tag.done { background: var(--green-bg); color: var(--green); }
.tag.problem { background: var(--red-bg); color: var(--terra); }
.tag.todo { background: #efeadf; color: #5d5a52; }
.problem-text { margin-top: 8px; padding: 8px 10px; background: var(--red-bg); color: var(--terra); border-radius: 10px; font-size: 14px; }
.card .note { margin-top: 6px; font-size: 14px; color: #3b3d4a; white-space: pre-wrap; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty b { display: block; font-size: 20px; color: var(--ink); margin-bottom: 4px; }
.empty strong { color: var(--ink); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 18px; border-radius: 14px; font-weight: 700; font-size: 17px; background: #efeadf; color: var(--ink); }
.btn.full { width: 100%; }
.btn.grow { flex: 1; }
.btn.primary { background: var(--navy); color: var(--cream); }
.btn.gold { background: var(--gold); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.danger { background: var(--red-bg); color: var(--terra); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.small { min-height: 40px; font-size: 15px; padding: 0 14px; border-radius: 12px; }
.btn:disabled { opacity: .5; }
.fab { position: fixed; right: max(18px, calc(50% - 362px)); bottom: calc(84px + var(--safe-b)); z-index: 20; height: 60px; padding: 0 24px 0 20px; border-radius: 30px; background: var(--gold); color: #fff; font-weight: 800; font-size: 18px; box-shadow: 0 6px 20px rgba(204, 143, 0, .45); display: flex; align-items: center; gap: 8px; }
.fab span { font-size: 30px; line-height: 0; margin-top: -3px; }

/* ---------- bottom nav ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.nav-row { display: flex; max-width: 760px; margin: 0 auto; }
.nav button { flex: 1; padding: 10px 4px 9px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; }
.nav button svg { width: 24px; height: 24px; }
.nav button.on { color: var(--navy); font-weight: 700; }
.nav button.on svg { color: var(--gold); }

/* ---------- sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(8, 20, 53, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 94dvh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 8px 18px calc(22px + var(--safe-b)); animation: up .2s ease; }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 22px; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }
.grab { width: 44px; height: 5px; border-radius: 3px; background: #d6cfbd; margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 22px; line-height: 1.2; flex: 1; }
.x { width: 40px; height: 40px; border-radius: 50%; background: #ece5d4; font-size: 22px; line-height: 40px; flex: none; }

/* ---------- forms ---------- */
label.lbl { display: block; font-weight: 700; font-size: 14px; margin: 16px 0 8px; }
.input, textarea.input, select.input { width: 100%; min-height: 52px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; font-size: 17px; }
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(204, 143, 0, .18); }
.big-input { font-size: 20px; font-weight: 600; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick button { min-height: 46px; padding: 0 16px; border-radius: 12px; background: #fff; border: 1.5px solid var(--line); font-weight: 600; font-size: 16px; }
.pick button.on { background: var(--navy); border-color: var(--navy); color: var(--cream); }
.pick.days button { min-width: 46px; padding: 0 8px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-top: 10px; font-weight: 600; width: 100%; text-align: left; }
.toggle .sw { width: 50px; height: 30px; border-radius: 15px; background: #d9d2c2; position: relative; flex: none; transition: background .15s; }
.toggle .sw::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle.on .sw { background: var(--gold); }
.toggle.on .sw::after { left: 23px; }
.toggle small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.suggest { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; scrollbar-width: none; }
.suggest button { flex: none; padding: 6px 12px; border-radius: 999px; background: #ece5d4; font-size: 14px; }
.more { margin-top: 14px; color: var(--navy); font-weight: 700; padding: 8px 0; }
.err { color: var(--terra); font-weight: 600; margin-top: 10px; min-height: 1em; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---------- detail ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; background: #fff; border-radius: 14px; padding: 14px; font-size: 15px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); margin-left: 6px; position: relative; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.timeline li.k-done::before { background: var(--green); } .timeline li.k-problem::before { background: var(--terra); }
.timeline li.k-started::before { background: var(--blue); } .timeline li.k-note::before { background: var(--gold); }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .msg { display: block; margin-top: 2px; white-space: pre-wrap; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; background: #ddd; }
.viewer { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; }
.stack > * + * { margin-top: 10px; }

/* ---------- people / lists ---------- */
.list { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 700; }
.item.off { opacity: .55; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--cream); color: var(--navy); font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; }
.avatar.m { background: var(--navy); color: var(--cream); }
.counts { display: flex; gap: 6px; flex: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 12px; }
.page-head h1 { margin: 0; font-size: 24px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; background: var(--navy); color: var(--cream); padding: calc(env(safe-area-inset-top, 0px) + 28px) 18px 30px; }
.login-in { max-width: 420px; margin: 0 auto; }
.login .logo { height: 44px; display: block; margin: 0 auto 6px; }
.login .sub { text-align: center; color: var(--gold-2); letter-spacing: .2em; font-size: 12px; font-weight: 700; margin-bottom: 26px; }
.login h2 { text-align: center; font-size: 20px; margin: 0 0 16px; }
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.names button { min-height: 58px; border-radius: 14px; background: var(--navy-2); color: var(--cream); font-weight: 700; font-size: 17px; padding: 6px 10px; border: 1px solid rgba(247, 235, 202, .12); }
.names button.last { border-color: var(--gold); }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 22px; min-height: 18px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--cream); }
.pin-dots i.f { background: var(--gold); border-color: var(--gold); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 320px; margin: 0 auto; }
.pad button { height: 68px; border-radius: 18px; background: var(--navy-2); color: var(--cream); font-size: 28px; font-weight: 600; }
.pad button.fn { background: transparent; font-size: 16px; }
.login .err { text-align: center; color: #ffb4a8; }
.login p.small { text-align: center; opacity: .8; margin: -8px 0 0; }
.login .back { color: var(--cream); opacity: .8; margin-bottom: 8px; padding: 8px 0; }
.login .input { background: var(--navy-2); color: var(--cream); border-color: rgba(247, 235, 202, .2); }
.login label.lbl { color: var(--cream); }

.toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%); z-index: 90; background: var(--navy); color: var(--cream); padding: 12px 18px; border-radius: 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90vw; animation: fade .15s; }
.offline { background: var(--terra); color: #fff; text-align: center; font-size: 13px; padding: 4px; }
.spin { text-align: center; padding: 60px; color: var(--muted); }
