:root {
  --bg: #0f1117;
  --bg2: #171b24;
  --card: #1c2230;
  --line: #2a3142;
  --txt: #f1f5f9;
  --muted: #94a3b8;
  --accent: #e94560;
  --accent2: #1a73e8;
  --today: #e94560;
  --ok: #34a853;
  --danger: #f87171;
  --hour-h: 52px;
  --gutter: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--txt); }
body { font-family: system-ui, sans-serif; }
button, input, textarea, select { font: inherit; }
#app { min-height: 100%; }

.login {
  max-width: 22rem;
  margin: 12vh auto;
  padding: 1.5rem 1.25rem calc(1.5rem + var(--safe-bot));
}
.login h1 { margin: 0 0 .35rem; font-size: 1.5rem; }
.login .lead { color: var(--muted); line-height: 1.45; margin: 0 0 1.1rem; }
.login label { display: block; font-size: .85rem; margin: .7rem 0 .25rem; color: var(--muted); }
.login input {
  width: 100%; padding: .7rem .8rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--txt);
}
.primary {
  display: block; width: 100%; margin-top: 1.1rem; padding: .8rem;
  border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer;
}
.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--txt);
  border-radius: 999px; padding: .45rem .8rem; cursor: pointer;
}
.danger { background: transparent; border: 0; color: var(--danger); cursor: pointer; padding: .5rem; }
.err { color: var(--danger); font-size: .9rem; }
code { color: #e2e8f0; }

.top {
  display: flex; align-items: center; gap: .6rem;
  padding: calc(.55rem + var(--safe-top)) .7rem .45rem;
  background: var(--bg2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 8;
}
.top h1 { font-size: 1rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-btns { display: flex; gap: .3rem; }
.nav-btns button {
  background: var(--card); border: 1px solid var(--line); color: var(--txt);
  border-radius: 8px; width: 2rem; height: 2rem; cursor: pointer;
}
.views { display: flex; gap: .25rem; }
.views button {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: .28rem .65rem; font-size: .8rem; cursor: pointer;
}
.views button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.who { font-size: .75rem; color: var(--muted); max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--txt);
  border-radius: 8px; min-width: 2rem; height: 2rem; cursor: pointer;
}
.icon-btn.who {
  width: 2rem; border-radius: 999px; font-weight: 700; max-width: none;
  display: grid; place-items: center;
}
.drawer-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30;
}
.drawer {
  width: min(18rem, 86vw); height: 100%; background: var(--bg2);
  padding: calc(1rem + var(--safe-top)) 1rem 1.2rem; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: .35rem;
}
.drawer-who { font-weight: 700; margin: 0 0 .6rem; word-break: break-all; }
.drawer nav { display: flex; flex-direction: column; gap: .15rem; }
.drawer nav a {
  color: var(--txt); text-decoration: none; padding: .55rem .45rem; border-radius: 8px;
}
.drawer nav a:hover { background: var(--card); }
.drawer-ver { color: var(--muted); font-size: .75rem; margin: auto 0 .8rem; }
.drawer #out { align-self: stretch; }
.drawer-cal-h { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .6rem 0 .25rem; }
.drawer-cal-empty { color: var(--muted); font-size: .85rem; margin: .2rem 0; }
.cal-list { display: flex; flex-direction: column; gap: .15rem; margin-bottom: .4rem; }
.cal-row {
  display: flex; align-items: center; gap: .45rem; font-size: .88rem;
  padding: .35rem .2rem; border-radius: 8px; cursor: pointer;
}
.cal-row:hover { background: var(--card); }
.cal-row input { accent-color: var(--accent2); }
.cal-dot { width: .65rem; height: .65rem; border-radius: 999px; flex-shrink: 0; }

.weekdays, .month-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekdays { padding: .35rem .4rem 0; color: var(--muted); font-size: .72rem; text-align: center; font-weight: 600; }
.month-grid { padding: .25rem .35rem 5rem; gap: 2px; }
.cell {
  min-height: 5.2rem; border-radius: 8px; padding: .2rem;
  background: var(--bg2); cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.cell.out { opacity: .38; }
.cell.sel { outline: 2px solid var(--accent); }
.cell .n {
  width: 1.5rem; height: 1.5rem; border-radius: 999px; display: grid; place-items: center;
  font-size: .78rem; font-weight: 700; align-self: center;
}
.cell.today .n { background: var(--today); color: #fff; }
.chip {
  font-size: .65rem; background: var(--accent2); color: #fff; border-radius: 4px;
  padding: 0 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.chip.all { background: var(--ok); }
.chip.task { background: #188038; }
.chip.task.done { opacity: .45; text-decoration: line-through; }

.timegrid { display: flex; overflow: auto; height: calc(100dvh - 7.2rem); padding-bottom: 4.5rem; }
.tg-gutter { flex: 0 0 var(--gutter); position: sticky; left: 0; background: var(--bg); z-index: 2; }
.tg-gutter span {
  display: block; height: var(--hour-h); font-size: .65rem; color: var(--muted);
  text-align: right; padding-right: .35rem; transform: translateY(-.4rem);
}
.tg-cols { display: flex; flex: 1; min-width: 0; }
.tg-col { flex: 1; min-width: 4.2rem; position: relative; border-left: 1px solid var(--line); }
.tg-col.head {
  position: sticky; top: 0; z-index: 3; background: var(--bg);
  text-align: center; font-size: .75rem; padding: .35rem 0; border-bottom: 1px solid var(--line);
}
.tg-col.head.today { color: var(--accent); font-weight: 700; }
.hour-line {
  position: absolute; left: 0; right: 0; height: 1px; background: var(--line);
  pointer-events: none;
}
.block {
  position: absolute; left: 2px; right: 2px; border-radius: 6px; padding: 2px 5px;
  background: var(--accent2); color: #fff; font-size: .7rem; overflow: hidden; cursor: pointer;
  z-index: 1;
}
.block.allday { position: relative; left: auto; right: auto; margin: 2px; height: auto; }
.block.task { background: #188038; }
.ev.task { border-left-color: #188038; }
.ev.task.done .t { text-decoration: line-through; opacity: .65; }
.drawer .tog {
  display: flex; align-items: center; gap: .5rem;
  margin: .35rem 0 .8rem; color: var(--txt); font-size: .9rem;
}
.drawer .tog input { width: 1rem; height: 1rem; }

.day-list { padding: .5rem .75rem 5.5rem; }
.day-list h2 { font-size: .95rem; margin: .4rem 0 .6rem; }
.ev {
  background: var(--card); border-radius: 12px; padding: .7rem .8rem; margin-bottom: .5rem; cursor: pointer;
  border-left: 4px solid var(--accent2);
}
.ev .t { font-weight: 700; }
.ev .m { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.empty { color: var(--muted); text-align: center; padding: 2rem 1rem; }

.fab {
  position: fixed; right: 1rem; bottom: calc(1rem + var(--safe-bot));
  width: 3.4rem; height: 3.4rem; border-radius: 999px; border: 0;
  background: var(--accent); color: #fff; font-size: 1.7rem; cursor: pointer;
  box-shadow: 0 8px 24px rgba(233, 69, 96, .35); z-index: 9;
}

.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--bg2); width: min(32rem, 100%); max-height: 92dvh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 1rem 1rem calc(1rem + var(--safe-bot));
}
.modal h2 { margin: 0 0 .8rem; font-size: 1.1rem; }
.modal label { display: block; font-size: .8rem; color: var(--muted); margin: .55rem 0 .2rem; }
.modal input, .modal textarea, .modal select {
  width: 100%; padding: .6rem .7rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--txt);
}
.agenda-day { margin-bottom: 1.1rem; }
.agenda-day h2 { font-size: .85rem; color: var(--muted); font-weight: 700; }
.row { display: flex; gap: .5rem; }
.row > * { flex: 1; }
.check { display: flex; align-items: center; gap: .45rem; margin: .6rem 0; color: var(--txt); }
.modal-actions { display: flex; gap: .5rem; margin-top: 1rem; align-items: center; }
.modal-actions .primary { width: auto; flex: 1; margin-top: 0; }

@media (min-width: 800px) {
  .modal { border-radius: 16px; margin-bottom: 8vh; }
  .cell { min-height: 6.4rem; }
}
