:root {
  --bg: #f8fafc; --card: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2563eb; --accent-ink: #ffffff; --danger: #dc2626; --today: #dbeafe; --holiday: #b45309;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --card: #141c2e; --ink: #e5e7eb; --muted: #94a3b8; --line: #243049;
    --accent: #3b82f6; --today: #1e3a8a; --holiday: #fbbf24;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { max-width: 720px; margin: 0 auto; padding: 12px 12px 110px; }

.top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.top h1 { flex: 1; margin: 0; font-size: 1.25rem; text-align: center; }
.top h1::first-letter, .day-head h2::first-letter { text-transform: uppercase; }
.icon-btn { background: var(--card); border: 1px solid var(--line); border-radius: 12px; width: 44px; height: 44px; font-size: 1.2rem; }
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 40px; }
.pill.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.row.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
.who { margin-left: auto; font-size: .85rem; color: var(--muted); }

.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 12px; }
.dow { text-align: center; font-size: .75rem; color: var(--muted); padding: 2px 0; }
.cell { background: var(--card); border: 1px solid var(--line); border-radius: 10px; min-height: 64px; padding: 4px;
  display: flex; flex-direction: column; gap: 2px; text-align: left; overflow: hidden; }
.cell.out { opacity: .45; }
.cell.today { background: var(--today); }
.cell.sel { outline: 2px solid var(--accent); }
.cell .n { font-weight: 600; font-size: .95rem; }
.cell .h { font-size: .62rem; color: var(--holiday); line-height: 1.1; max-height: 2.2em; overflow: hidden; }
.dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: auto; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); }
.more { font-size: .6rem; color: var(--muted); }

.day-head { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 6px; }
.day-head h2 { margin: 0; font-size: 1rem; }
.day-head .hol { font-size: .8rem; color: var(--holiday); }
.ev { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: var(--card);
  border: 1px solid var(--line); border-left: 6px solid var(--c, var(--muted)); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 8px; }
.ev .t { min-width: 3.2em; font-variant-numeric: tabular-nums; font-weight: 600; }
.ev .b { flex: 1; min-width: 0; }
.ev .b strong { display: block; overflow-wrap: anywhere; }
.ev .b small { color: var(--muted); }
.ev.done { opacity: .55; }
.ev.done strong { text-decoration: line-through; }
.empty { color: var(--muted); padding: 8px 2px; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); display: flex; gap: 8px; max-width: 720px; margin: 0 auto; }
.bar input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.fab { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 1.6rem; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 5; }
.sheet { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0 0 10px; font-size: 1.1rem; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=date], input[type=time], input[type=password], input[type=tel], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; }
textarea { min-height: 70px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; color: var(--ink); font-size: 1rem; }
.check input { width: 22px; height: 22px; }
.actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px 16px; min-height: 46px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); flex: 1; font-weight: 600; }
.btn.danger { color: var(--danger); }

.login { max-width: 420px; margin: 8vh auto 0; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.login h1 { margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 14px; }
.persons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.persons .pill { text-align: center; border-left: 6px solid var(--c, var(--muted)); border-radius: 12px; }
.err { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #111827; color: #fff;
  padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90%; z-index: 9; }
#toast.show { opacity: 1; }
.offline { background: #fef3c7; color: #92400e; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: .9rem; }
