:root {
  --bg: #f6f7f2; --card: #ffffff; --ink: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --deep: #14532d; --lime: #a3e635; --pale: #ecfccb; --danger: #b91c1c;
  --work: #65a30d; --content: #d97706; --health: #059669; --people: #db2777; --hobby: #78716c;
  --tab: rgba(255,255,255,.92);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1410; --card: #13201a; --ink: #e8f0e4; --muted: #9aa79e; --line: #22332a;
    --pale: #1d3a24; --danger: #f87171;
    --work: #a3e635; --content: #fbbf24; --health: #34d399; --people: #f472b6; --hobby: #a8a29e;
    --tab: rgba(15,26,20,.92);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 24px; }

.top { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; }
.top h1 { font-size: 22px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -.01em; }
.top .sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); font-size: 18px; }
.pill { padding: 7px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; background: var(--card); border: 1px solid var(--line); }
.pill.on { background: var(--deep); color: #ecfccb; border-color: var(--deep); }
.status { font-size: 12px; color: var(--muted); text-align: center; margin-top: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.now { border-left: 0; position: relative; overflow: hidden; }
.now .label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.now .big { font-size: 20px; font-weight: 700; margin: 2px 0; }
.now .when { font-size: 14px; color: var(--muted); }
.now .stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }

.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 6px 0 2px; }
.progress > i { display: block; height: 100%; background: var(--lime); border-radius: 99px; }
.prog-text { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; }

.list { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-top: 1px solid var(--line); position: relative; }
.row:first-child { border-top: 0; }
.row .bar { position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; }
.row .time { width: 62px; flex: none; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.row .time small { display: block; font-weight: 400; color: var(--muted); }
.row .body { flex: 1; min-width: 0; text-align: left; }
.row .title { font-weight: 600; font-size: 15px; }
.row .meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.row.done .title { text-decoration: line-through; color: var(--muted); }
.row.skipped { opacity: .5; }
.row.busy { background: repeating-linear-gradient(135deg, transparent 0 8px, rgba(127,127,127,.06) 8px 16px); }
.row.current { background: var(--pale); }
.tick { width: 32px; height: 32px; flex: none; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 800; color: transparent; }
.row.done .tick { background: var(--lime); border-color: var(--lime); color: #14532d; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--pale); color: var(--ink); margin-left: 4px; }
.tag.warn { background: rgba(220,38,38,.15); color: var(--danger); }

.a-work { background: var(--work); } .a-content { background: var(--content); } .a-health { background: var(--health); }
.a-people { background: var(--people); } .a-hobby { background: var(--hobby); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 4px 8px; font-weight: 700; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 4px 6px; }
.day-head b { font-size: 15px; }
.day-head span { font-size: 13px; color: var(--muted); }
.mini { display: flex; gap: 8px; align-items: center; padding: 7px 12px; border-top: 1px solid var(--line); font-size: 14px; }
.mini:first-child { border-top: 0; }
.mini .t { width: 76px; white-space: nowrap; flex: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.mini.skipped { opacity: .45; text-decoration: line-through; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; background: var(--pale); font-size: 14px; font-weight: 600; }
.chip button { font-size: 16px; line-height: 1; color: var(--muted); }
.add { color: var(--work); font-weight: 700; font-size: 14px; padding: 6px 4px; }

.bars .b { margin: 10px 0; }
.bars .b .l { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.bars .track { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bars .track > i { display: block; height: 100%; border-radius: 99px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat .n { font-size: 24px; font-weight: 800; }
.stat .k { font-size: 12px; color: var(--muted); }
.daydots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; font-size: 12px; color: var(--muted); }
.daydots .c { height: 40px; border-radius: 10px; background: var(--line); display: grid; place-items: center; font-weight: 700; color: var(--ink); margin-bottom: 4px; }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  background: var(--tab); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
nav.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; }
nav.tabs button svg { width: 24px; height: 24px; }
nav.tabs button.on { color: var(--ink); }
nav.tabs button.on svg { stroke: var(--work); }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; z-index: 10; }
.sheet { background: var(--card); width: 100%; max-width: 640px; margin: 0 auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; }
.sheet h3 { margin: 0 0 4px; font-size: 19px; }
.sheet .sub { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.field { margin: 12px 0; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input[type=text], .field input[type=time], .field input[type=number], .field input[type=password], .field select {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 16px;
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.days button { height: 38px; border-radius: 9px; border: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.days button.on { background: var(--deep); color: #ecfccb; border-color: var(--deep); }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); gap: 12px; }
.toggle small { display: block; color: var(--muted); font-size: 12px; }
.switch { width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch.on { background: var(--health); }
.switch.on::after { left: 23px; }
.btn { width: 100%; height: 48px; border-radius: 12px; font-weight: 700; font-size: 16px; margin-top: 8px; background: var(--bg); border: 1px solid var(--line); }
.btn.primary { background: var(--deep); color: #ecfccb; border-color: var(--deep); }
.btn.danger { color: var(--danger); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.err { color: var(--danger); font-size: 13px; margin-top: 6px; min-height: 18px; }
.note { font-size: 14px; color: var(--muted); line-height: 1.5; }

.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; }
.login img { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 18px; }
.login h1 { font-size: 30px; margin: 0 0 6px; }
