:root {
  --bg: #f6f6fb;
  --card: #ffffff;
  --text: #1c1c28;
  --muted: #6e6e82;
  --line: #e7e7f0;
  --accent: #5b5bd6;
  --accent-soft: #ececfe;
  --danger: #d64545;
  --shadow: 0 1px 2px rgba(20, 20, 50, .05), 0 4px 16px rgba(20, 20, 50, .06);
  --radius: 18px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111118;
    --card: #1b1b25;
    --text: #ececf4;
    --muted: #9a9ab0;
    --line: #2a2a38;
    --accent: #8b8bff;
    --accent-soft: #26264a;
    --danger: #ff6b6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.app { max-width: 560px; margin: 0 auto; padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; gap: 8px; }
.date-title { flex: 1; text-align: center; }
.date-title h1 { margin: 0; font-size: 1.35rem; letter-spacing: -.01em; }
.date-title p { margin: 0; color: var(--muted); font-size: .9rem; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 0; background: var(--card); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.icon-btn:active { transform: scale(.94); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 12px; }
.day-chip {
  border: 0; background: transparent; border-radius: 14px;
  padding: 6px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.day-chip .dow { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.day-chip .num { font-weight: 650; font-size: 1.02rem; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; }
.day-chip .dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.day-chip.has .dot { background: var(--accent); }
.day-chip.today .num { color: var(--accent); }
.day-chip.active .num { background: var(--accent); color: #fff; }

/* Main */
main { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
main.slide-left { animation: slideL .22s ease; }
main.slide-right { animation: slideR .22s ease; }
@keyframes slideL { from { opacity: .3; transform: translateX(24px); } }
@keyframes slideR { from { opacity: .3; transform: translateX(-24px); } }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 10px; font-size: 1rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px 0; }

.progress-card { padding: 14px 16px; }
.progress-text { display: flex; justify-content: space-between; align-items: center; font-size: .92rem; color: var(--muted); margin-bottom: 8px; }
.bar { height: 8px; background: var(--accent-soft); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s ease; }

/* Priorities */
.priorities { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.priorities li { display: flex; align-items: center; gap: 10px; }
.prio-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: .82rem; font-weight: 700;
}
.priorities input {
  flex: 1; border: 0; border-bottom: 1px dashed var(--line); background: transparent;
  padding: 8px 2px; outline: none; min-width: 0;
}
.priorities input:focus { border-bottom-color: var(--accent); }

/* Agenda */
.agenda { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; font-size: .95rem; }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }
.task {
  display: flex; align-items: stretch; gap: 12px;
  background: var(--bg); border-radius: 14px; padding: 10px 10px 10px 0; overflow: hidden;
  position: relative;
}
.task::before { content: ""; width: 5px; border-radius: 0 4px 4px 0; background: var(--c, var(--accent)); flex: none; }
.task .time { flex: none; width: 52px; display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.task .time b { font-size: .95rem; }
.task .time small { color: var(--muted); font-size: .75rem; }
.task .body { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 0; display: flex; flex-direction: column; justify-content: center; }
.task .title { font-weight: 600; overflow-wrap: anywhere; }
.task .meta { color: var(--muted); font-size: .8rem; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task.now { box-shadow: inset 0 0 0 2px var(--c, var(--accent)); }
.check {
  flex: none; align-self: center; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--card); display: grid; place-items: center; padding: 0;
}
.check svg { width: 16px; height: 16px; stroke: #fff; opacity: 0; }
.task.done .check { background: var(--c, var(--accent)); border-color: var(--c, var(--accent)); }
.task.done .check svg { opacity: 1; }
.gap { color: var(--muted); font-size: .78rem; padding: 0 4px 0 66px; display: flex; align-items: center; gap: 8px; }
.gap::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.now-line { display: flex; align-items: center; gap: 8px; color: var(--danger); font-size: .75rem; font-weight: 700; }
.now-line::after { content: ""; flex: 1; height: 2px; background: var(--danger); border-radius: 2px; }

textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  padding: 10px 12px; resize: vertical; outline: none; min-height: 96px;
}
textarea:focus { border-color: var(--accent); }

.footnote { text-align: center; color: var(--muted); font-size: .8rem; margin: 4px 0 0; }

/* FAB */
.fab {
  position: fixed; right: max(18px, calc(50% - 262px)); bottom: calc(22px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; border: 0; z-index: 6;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 45%, transparent);
}
.fab svg { width: 28px; height: 28px; }
.fab:active { transform: scale(.94); }

/* Bottom sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 10, 25, .4); z-index: 10; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-width: 560px; margin: 0 auto;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(110%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .15);
}
.sheet.open { transform: none; }
.grabber { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 2px; }
.sheet h3 { margin: 0; font-size: 1.15rem; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.field > span { font-size: .82rem; color: var(--muted); font-weight: 600; }
.field input, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  padding: 12px; outline: none; font-size: 16px; min-height: 48px;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field-row { display: flex; gap: 12px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--c); position: relative; }
.swatch.sel::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--c); }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 650; min-height: 46px; }
.btn.primary { background: var(--accent); color: #fff; flex: 1; max-width: 160px; }
.btn.ghost { background: var(--bg); }
.btn.danger { color: var(--danger); margin-right: auto; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20;
  display: flex; gap: 14px; align-items: center; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
