:root {
  --bg: #f4f5f7; --card: #fff; --fg: #15171c; --muted: #6b7280; --line: #e5e7eb;
  --accent: #4f6bed; --ok: #15803d; --warn: #b45309; --bad: #dc2626;
  --fixed: #9ca3af; --planned: #4f6bed; --slack: #c7d2fe; --meal: #f59e0b;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --card: #181b22; --fg: #e8eaf0; --muted: #9aa1ad; --line: #2a2f3a;
          --fixed: #4b5563; --slack: #2e3768; --ok: #4ade80; --warn: #fbbf24; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 20px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 10px; } h3 { font-size: 14px; margin: 14px 0 6px; }
.inline { display: inline; }
a { color: var(--accent); text-decoration: none; }
.wrap { max-width: 760px; margin: 0 auto; padding: 12px 12px 60px; }
.nav { position: sticky; top: 0; z-index: 5; display: flex; gap: 4px; align-items: center; padding: 8px 12px;
  background: var(--card); border-bottom: 1px solid var(--line); }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--fg); }
.nav a.on { background: var(--accent); color: #fff; }
.nav .logout { margin-left: auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.hero { text-align: left; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .err, .danger { color: var(--bad) !important; }
.flash { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
@media (prefers-color-scheme: dark) { .flash { background: #3a2410; color: #fed7aa; border-color: #7c2d12; } }
.tag { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--line); color: var(--muted); vertical-align: middle; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
input[type=checkbox] { width: auto; }
input[type=color] { width: 42px; padding: 2px; height: 36px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.chk { flex-direction: row; align-items: center; gap: 6px; }
button { padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link { border: 0; background: none; padding: 4px 6px; color: var(--accent); }
.wide { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end; }
.grid2 .wide { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.row input { width: auto; }
form.inline { display: inline; }

.login { max-width: 320px; margin: 18vh auto; text-align: center; }
.login form { display: flex; flex-direction: column; gap: 10px; }

.dayhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.meals { font-size: 14px; padding: 6px 10px; border-radius: 10px; background: var(--bg); white-space: nowrap; }
.meals.bad { background: #fee2e2; color: var(--bad); }

.budget { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--bg); margin: 12px 0 6px; }
.seg { display: block; height: 100%; }
.seg.fixed, .dot.fixed { background: var(--fixed); }
.seg.planned, .dot.planned { background: var(--planned); }
.seg.planned.over { background: var(--bad); }
.seg.slack, .dot.slack { background: var(--slack); }
.legend, .tl-legend { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; }

.quota { padding: 8px 0; border-top: 1px solid var(--line); }
.quota:first-of-type { border-top: 0; }
.qhead, .qrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.bar i { display: block; height: 100%; background: var(--accent); }
.quick { display: flex; gap: 4px; }
.quick button { padding: 4px 8px; font-size: 12.5px; }

.additem { display: grid; grid-template-columns: 1fr 72px 92px 1fr 44px; gap: 6px; margin-bottom: 10px; }
@media (max-width: 560px) { .additem { grid-template-columns: 1fr 70px 92px; } .additem select { grid-column: 1 / 3; } }
.items { list-style: none; padding: 0; margin: 0; }
.items li { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.items li.fixed .t { color: var(--muted); }
.items li.done .t { text-decoration: line-through; color: var(--muted); }
.items details { flex: 1; }
.items summary { list-style: none; display: flex; justify-content: space-between; gap: 8px; cursor: pointer; }
.items summary::-webkit-details-marker { display: none; }
.check { width: 26px; height: 26px; padding: 0; border-radius: 8px; font-weight: bold; color: var(--ok); }
.edit { padding: 8px 0 2px; }

.tl { position: relative; display: flex; height: 900px; margin-top: 10px; gap: 4px; }
.tl-ticks { position: relative; width: 44px; flex: none; }
.tl-ticks span { position: absolute; left: 0; transform: translateY(-50%); font-size: 11px; color: var(--muted); }
.tl-main { position: relative; flex: 1; background: var(--bg); border-radius: 10px; }
.tl-line { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); }
.tl-now { position: absolute; left: -4px; right: 0; border-top: 2px solid var(--bad); z-index: 3; }
.tl-item { position: absolute; left: 4px; right: 4px; overflow: hidden; border-radius: 7px; padding: 2px 6px; font-size: 12px;
  background: var(--planned); color: #fff; border: 1px solid rgba(0,0,0,.08); z-index: 2; }
.tl-item.fixed { background: var(--fixed); }
.tl-item.meal { background: var(--meal); color: #1f1300; }
.tl-item.clash { outline: 2px solid var(--bad); }
.tl-item.done { opacity: .55; }
.tl-layer { position: relative; width: 12px; flex: none; background: var(--bg); border-radius: 6px; }
.tl-layer i { position: absolute; left: 0; right: 0; border-radius: 6px; opacity: .8; }
.free { padding-left: 18px; margin: 4px 0 0; }

.scroll { overflow-x: auto; }
table.week { border-collapse: collapse; width: 100%; font-size: 13px; }
.week th, .week td { padding: 6px 6px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.week td:first-child { text-align: left; }
.week th.today { color: var(--accent); }

.catrow { display: flex; gap: 6px; align-items: end; margin-bottom: 8px; }
.catrow.wrapline { flex-wrap: wrap; }
.catrow input { width: auto; min-width: 0; }
.catrow > input[name=name] { flex: 1; min-width: 120px; }
.catrow .emoji { width: 46px; text-align: center; }
.catrow label input { width: 90px; }
.catrow label.grow { flex: 1; min-width: 180px; } .catrow label.grow input { width: 100%; }
.catrow.new { border-top: 1px dashed var(--line); padding-top: 10px; }
.wd { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.wd label { flex-direction: row; align-items: center; gap: 2px; font-size: 12px; }
.layer { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.windows { margin: 4px 0 8px; padding-left: 18px; font-size: 13px; }
.tzhint { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tzhint[hidden] { display: none; }
.catrow label select { width: auto; max-width: 220px; }
