/* Day Planner — Omni Hub light ocean look, with a dark variant. */
:root {
  --bg: #EAF2F4; --surface: #FFFFFF; --ink: #0B2735; --text: #3D5A66; --muted: #506D79;
  --line: #A9C2CA; --line-soft: #E1EBEE; --grid: #F4F8F9;
  --accent: #0B6E8A; --accent-ink: #FFFFFF; --accent-soft: #DDF0F3;
  --hero: #0B4F7A; --hero-ink: #FFFFFF; --hero-sub: #CFE8EE; --hero-bar: #A7D6E1;
  --good: #1C7A64; --good-soft: #DDF2EA; --warn: #B5482E; --warn-soft: #FBE6DF;
  --tier-win: #7E97A1; --tier-ideal: #0B2735;
  --shadow: 0 1px 2px rgba(11,39,53,.05), 0 8px 24px rgba(11,39,53,.07);
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Hanken Grotesk', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #061820; --surface: #0C2530; --ink: #E6F3F6; --text: #B5CDD4; --muted: #8FAAB3;
    --line: #2A4A56; --line-soft: #173540; --grid: #0A1F28;
    --accent: #4FD1E0; --accent-ink: #04161D; --accent-soft: #0F3A47;
    --hero: #10314A; --hero-ink: #E6F3F6; --hero-sub: #9CC9DA; --hero-bar: #4FD1E0;
    --good: #5FE0B5; --good-soft: #0F3A30; --warn: #FF9C7E; --warn-soft: #3D2018;
    --tier-win: #6E8A95; --tier-ideal: #E6F3F6;
    --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

/* category colors: --c = ink, --cs = soft fill */
.c-navy   { --c: #0B4F7A; --cs: #DCEAF5; }
.c-teal   { --c: #0B6E8A; --cs: #DDF0F3; }
.c-green  { --c: #1C7A64; --cs: #DDF2EA; }
.c-coral  { --c: #B5482E; --cs: #FBE6DF; }
.c-purple, .c-family { --c: #5B4B8A; --cs: #ECE8F6; }
.c-event  { --c: #3D5A66; --cs: #E4ECEF; }
.c-site   { --c: #FFFFFF; --cs: #0B4F7A; }
.c-open, .c-wind { --c: #3D5A66; --cs: transparent; }
@media (prefers-color-scheme: dark) {
  .c-navy   { --c: #7CC4F2; --cs: #10314A; }
  .c-teal   { --c: #4FD1E0; --cs: #0F3A47; }
  .c-green  { --c: #5FE0B5; --cs: #0F3A30; }
  .c-coral  { --c: #FF9C7E; --cs: #3D2018; }
  .c-purple, .c-family { --c: #C9BCF7; --cs: #262043; }
  .c-event  { --c: #B5CDD4; --cs: #173540; }
  .c-site   { --c: #04161D; --cs: #7CC4F2; }
  .c-open, .c-wind { --c: #8FAAB3; --cs: transparent; }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -.01em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.shell { max-width: 1240px; margin: 0 auto; padding: 0 16px 96px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 8px; }
.brand { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.chip { font-size: 11px; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.chip.live { color: var(--good); border-color: var(--good); }
.chip.warn { color: var(--warn); border-color: var(--warn); }

.tabs { display: flex; gap: 4px; }
.tab { min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.tab[aria-current="page"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.tabs.top { display: none; }
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 4px 8px calc(8px + env(safe-area-inset-bottom)); }
.bottomnav .tab { flex-direction: column; gap: 2px; font-size: 12px; min-width: 88px; border-radius: 12px; }
.bottomnav .tab[aria-current="page"] { box-shadow: none; background: transparent; }
@media (min-width: 900px) {
  .tabs.top { display: flex; }
  .bottomnav { display: none; }
  .shell { padding-bottom: 48px; }
}

.card { background: var(--surface); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card h2 { font-size: 18px; font-weight: 700; }
.row { display: flex; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.text { color: var(--text); }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.btn { text-decoration: none; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 13px; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; padding: 0; }

/* ---------- day view ---------- */
.dayhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 8px 0 14px; flex-wrap: wrap; }
.dayhead h1 { font-size: 30px; font-weight: 700; }
.dayhead p { margin: 4px 0 0; color: var(--text); font-size: 14px; }
.daygrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 900px) { .daygrid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; } }

.banner { border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--accent-soft); border: 1px solid var(--accent); }
.banner strong { font-size: 15px; }
.changes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text); }
.changes b { color: var(--ink); }

.now { background: var(--hero); color: var(--hero-ink); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.now .eyebrow { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--hero-sub); }
.now .title { font-family: var(--display); font-size: 22px; font-weight: 700; }
.now .sub { font-size: 14px; color: var(--hero-sub); }
.now .bar { height: 6px; background: rgba(255,255,255,.22); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.now .bar span { display: block; height: 100%; background: var(--hero-bar); border-radius: 999px; }

.meter { display: flex; flex-direction: column; gap: 6px; }
.meter .track { position: relative; height: 10px; background: var(--cs); border-radius: 999px; }
.meter .fill { position: absolute; left: 0; top: 0; height: 10px; background: var(--c); border-radius: 999px; }
.meter .tick { position: absolute; top: -3px; height: 16px; width: 2px; background: var(--ink); }
.meter .tick.win { background: var(--muted); }
.meter .status { font-size: 12px; font-weight: 700; color: var(--muted); }
.meter .status.hit { color: var(--c); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 2px; height: 12px; background: var(--ink); margin-right: 5px; vertical-align: middle; }
.legend i.win { background: var(--muted); }

.note { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.note .kicker { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }

.plan { display: flex; flex-direction: column; gap: 8px; }
.blk { display: flex; gap: 10px; align-items: stretch; }
.blk .time { width: 46px; flex: none; text-align: right; padding-top: 11px; display: flex; flex-direction: column; font-size: 13px; font-weight: 600; }
.blk .time small { font-size: 10px; font-weight: 500; color: var(--muted); }
.blk .body { flex: 1; min-width: 0; background: var(--cs); border: 1px solid var(--cs); border-radius: 14px; padding: 10px 10px 10px 12px; display: flex; gap: 10px; align-items: center; }
.blk.c-open .body, .blk.c-wind .body { border: 1.5px dashed var(--line); }
.blk .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.blk .cat { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--c); }
.blk .meta { font-size: 11px; color: var(--text); }
.blk.c-site .meta, .blk.c-site .ttl { color: var(--c); }
.blk .ttl { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.blk .sub { font-size: 12px; color: var(--text); }
.blk.done .ttl { text-decoration: line-through; }
.blk.past:not(.done) .body { opacity: .7; }
.blk .pill { font-size: 10px; font-weight: 700; color: var(--hero-ink); background: var(--hero); border-radius: 999px; padding: 1px 7px; }
.check { width: 44px; height: 44px; flex: none; border-radius: 999px; border: 1.5px solid var(--c); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; padding: 0; color: var(--c); }
.check[aria-pressed="true"] { background: var(--c); color: var(--cs); }
.blk.c-site .check { border-color: var(--c); background: transparent; }
.blk.c-site .check[aria-pressed="true"] { background: var(--c); color: var(--cs); }

/* ---------- week view ---------- */
.weekwrap { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.weekmain { flex: 999 1 640px; min-width: 0; }
.weekside { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.scrollx { overflow-x: auto; }
.wgrid { min-width: 760px; display: grid; grid-template-columns: 44px repeat(7, minmax(0, 1fr)); gap: 6px; }
.whead { padding: 6px 4px; border-radius: 10px; display: flex; flex-direction: column; gap: 4px; min-height: 52px; border: 0; background: transparent; text-align: left; }
.whead .dn { font-size: 13px; font-weight: 700; }
.whead.today { background: var(--hero); color: var(--hero-ink); }
.whead .tag { align-self: flex-start; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 2px 7px; background: var(--warn-soft); color: var(--warn); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whead .tag.site { background: var(--accent-soft); color: var(--accent); }
.hours, .wcol { position: relative; }
.hours span { position: absolute; right: 4px; font-size: 10px; color: var(--muted); transform: translateY(-6px); }
.wcol { border-radius: 8px; background: repeating-linear-gradient(var(--line-soft) 0 1px, var(--grid) 1px var(--hourpx)); }
.wcol.past { opacity: .75; }
.wb { position: absolute; left: 3px; right: 3px; background: var(--cs); color: var(--c); border-radius: 6px; padding: 3px 6px; overflow: hidden; font-size: 10px; font-weight: 700; line-height: 1.25; }
.wb.c-open, .wb.c-wind { border: 1.5px dashed var(--line); }
.wb.done { box-shadow: inset 0 0 0 2px var(--c); }
.wlegend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text); }
.wlegend span { display: inline-flex; align-items: center; gap: 6px; }
.wlegend i { width: 12px; height: 12px; border-radius: 3px; background: var(--cs); border: 1px solid var(--c); }
.wlegend .c-open i { border-style: dashed; border-color: var(--line); }

.job { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); }
.job:last-child { border-bottom: 0; padding-bottom: 0; }
.job .st { font-size: 12px; font-weight: 700; }
.st.onTrack { color: var(--good); } .st.short, .st.pastDue { color: var(--warn); } .st.continues, .st.noEstimate { color: var(--muted); }
.jbar { position: relative; height: 8px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.jbar span { position: absolute; left: 0; top: 0; bottom: 0; background: #0B4F7A; border-radius: 999px; }
@media (prefers-color-scheme: dark) { .jbar span { background: #7CC4F2; } }
.jfields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 700; color: var(--muted); }
.field input { height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; background: var(--surface); font-size: 14px; font-weight: 500; color: var(--ink); min-width: 0; }

.bal { display: grid; grid-template-columns: minmax(0, 1fr) repeat(7, 22px); gap: 6px; align-items: center; }
.bal .lbl { display: flex; flex-direction: column; font-size: 13px; font-weight: 600; }
.bal .lbl small { font-size: 11px; font-weight: 500; color: var(--muted); }
.bal .dh { font-size: 10px; font-weight: 700; color: var(--muted); text-align: center; }
.sq { width: 22px; height: 22px; border-radius: 6px; background: var(--grid); }
.sq.below { background: var(--surface); border: 1.5px dashed var(--line); }
.sq.floor { background: var(--surface); border: 1.5px solid var(--text); }
.sq.win { background: var(--tier-win); }
.sq.ideal { background: var(--tier-ideal); }
.sq.actual { position: relative; }
.sq.actual::after { content: ''; position: absolute; right: -3px; top: -3px; width: 8px; height: 8px; border-radius: 999px; background: var(--good); border: 2px solid var(--surface); }
.stat { flex: 1; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 2px; background: var(--grid); }
.stat b { font-size: 20px; font-weight: 800; }
.stat span { font-size: 11px; font-weight: 700; color: var(--muted); }

/* ---------- rules view ---------- */
.rulesgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 900px) { .rulesgrid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.seg { display: flex; background: var(--bg); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--text); font-size: 13px; font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.target { border: 1px solid var(--line-soft); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.target .dot { width: 10px; height: 10px; border-radius: 999px; background: var(--c); flex: none; }
.target .name { font-size: 15px; font-weight: 700; }
.tiers { display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiers.one { grid-template-columns: minmax(0, 1fr); }
.tier { display: flex; flex-direction: column; gap: 6px; }
.tier .tn { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: center; }
.tier .tv { text-align: center; font-size: 17px; font-weight: 800; color: var(--c); background: var(--cs); border-radius: 8px; padding: 8px 2px; }
.tier .steps { display: flex; gap: 4px; }
.tier .steps button { flex: 1; height: 40px; min-width: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; }
.opt[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.swatch { width: 44px; height: 44px; border-radius: 999px; border: 3px solid var(--surface); background: var(--cs); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.swatch span { width: 18px; height: 18px; border-radius: 999px; background: var(--c); }
.swatch[aria-pressed="true"] { border-color: var(--c); }
.adder { border: 1.5px dashed var(--line); border-radius: 14px; min-height: 48px; background: var(--surface); color: var(--accent); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.form { border: 1.5px solid var(--accent); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.form input[type=text], .form input[type=password] { height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font-size: 15px; background: var(--surface); }
.toast { background: var(--ink); color: var(--bg); border-radius: 12px; padding: 6px 6px 6px 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.toast button { height: 40px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--hero-bar); font-weight: 700; }
.srcrow { display: flex; gap: 12px; align-items: center; min-height: 52px; border-top: 1px solid var(--line-soft); }
.srcrow:first-of-type { border-top: 0; }
.dot-state { width: 10px; height: 10px; border-radius: 999px; background: var(--line); flex: none; }
.dot-state.on { background: var(--good); }
.dot-state.err { background: var(--warn); }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* tap a block to change its length for that day */
.infobtn { appearance: none; border: 0; background: transparent; padding: 0; margin: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; border-radius: 8px; }
.adj { margin: -2px 0 6px 56px; background: var(--surface); border: 1.5px solid var(--c); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- editable timeline ---------- */
.tl { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 6px; }
.tl-hours { position: relative; }
.tl-hours span { position: absolute; right: 4px; font-size: 10px; color: var(--muted); transform: translateY(-6px); }
.tl-grid { position: relative; border-radius: 10px; background: repeating-linear-gradient(var(--line-soft) 0 1px, var(--grid) 1px var(--hourpx)); touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: copy; }
.tl-bg { position: absolute; left: 2px; right: 2px; border: 1.5px dashed var(--line); border-radius: 8px; padding: 3px 8px; font-size: 10px; font-weight: 700; color: var(--muted); pointer-events: none; overflow: hidden; }
.tb { position: absolute; box-sizing: border-box; background: var(--cs); color: var(--c); border: 1px solid var(--cs); border-radius: 8px; padding: 4px 8px; overflow: hidden; display: flex; flex-direction: column; gap: 1px; cursor: pointer; z-index: 1; touch-action: pan-y; }
.tb.c-site { color: var(--c); }
.tb .tb-t { font-size: 12px; font-weight: 700; line-height: 1.2; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 2px; }
.tb.c-site .tb-t, .tb.c-site .tb-m { color: var(--c); }
.tb .tb-m { font-size: 10px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb.editable { cursor: grab; }
.tb.locked { cursor: default; }
.tb.locked .tb-t::after { content: ' ·  calendar'; font-weight: 500; color: var(--muted); }
.tb.c-family.locked .tb-t::after { content: ''; }
.tb.done .tb-t { text-decoration: line-through; }
.tb.sel { outline: 2.5px solid var(--c); outline-offset: 1px; z-index: 3; touch-action: none; box-shadow: var(--shadow); }
.tb.c-site.sel { outline-color: var(--accent); }
.tb.dragging { opacity: .9; z-index: 4; cursor: grabbing; box-shadow: var(--shadow); }
.tb .tl-check { position: absolute; right: 4px; top: 4px; width: 36px; height: 36px; }
.tb:has(.tl-check) .tb-t, .tb:has(.tl-check) .tb-m { padding-right: 40px; }
.tb .th { display: none; position: absolute; left: 0; right: 0; bottom: 0; height: 14px; cursor: ns-resize; touch-action: none; }
.tb .th::after { content: ''; position: absolute; left: 50%; bottom: 4px; width: 28px; height: 4px; margin-left: -14px; border-radius: 4px; background: var(--c); opacity: .7; }
.tb.editable:hover .th, .tb.sel .th { display: block; }
.tl-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--warn); z-index: 5; pointer-events: none; }
.tl-now::before { content: ''; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 999px; background: var(--warn); }
@media (hover: none) { .tb.sel .th { height: 24px; } }

.sheet { position: fixed; left: 12px; right: 12px; bottom: 84px; z-index: 25; max-width: 520px; margin: 0 auto; background: var(--surface); border: 2px solid var(--c); border-radius: 18px; padding: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 10px; max-height: 70vh; overflow-y: auto; }
.sheet .field input { height: 44px; }
.sheet .opt[aria-pressed="true"] { background: var(--c); color: var(--cs); border-color: var(--c); }
.sheet.c-site .opt[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
@media (min-width: 900px) { .sheet { position: sticky; top: 12px; bottom: auto; left: auto; right: auto; width: auto; max-width: none; margin: 0; max-height: none; box-shadow: var(--shadow); } }
.tb.short { flex-direction: row; align-items: center; gap: 8px; padding: 1px 8px; }
.tb.short .tb-t { flex: none; max-width: 60%; }
