:root {
  --bg: #0e0f11;
  --cell: #17191c;
  --cell-hi: #1d2024;
  --line: #2a2d33;
  --text: #e7e8ea;
  --muted: #7f848c;
  --faint: #4b4f56;
  --accent: #9db4ff;
  --ev: #7d8db0;
  --gap: 8px;
  --pad: 8px;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 14px 16px 16px;
  gap: 12px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.title-wrap { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.01em; white-space: nowrap; }
.status { width: 7px; height: 7px; border-radius: 50%; background: transparent; transition: background .3s; }
.status.saving { background: #d6b55e; }
.status.offline { background: #d4776b; }
.nav { display: flex; align-items: center; gap: 4px; }
.icon { width: 32px; height: 32px; border-radius: 10px; font-size: 22px; line-height: 1; color: var(--muted); }
.icon:hover, .pill:hover { background: var(--cell-hi); color: var(--text); }
.pill { height: 32px; padding: 0 14px; border-radius: 10px; background: var(--cell); color: var(--text); }
.views { display: flex; background: var(--cell); border-radius: 12px; padding: 3px; }
.views button { padding: 5px 12px; border-radius: 9px; color: var(--muted); }
.views button:hover { color: var(--text); }
.views button.on { background: #2a2e36; color: var(--text); }

/* ---------- add box ---------- */
.add { position: relative; }
#add {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--cell);
  outline: none;
  font-size: 15px;
  transition: border-color .15s;
}
#add::placeholder { color: var(--faint); }
#add:focus { border-color: #3c4250; }
.preview {
  height: 18px;
  margin-top: 6px;
  padding-left: 4px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview b { color: var(--text); font-weight: 500; }
.preview .warn { color: #c9a95a; }

/* ---------- grids ---------- */
main { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--gap); }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--gap); padding: 0 var(--pad); }
.weekdays div { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.grid { flex: 1; min-height: 0; display: grid; gap: var(--gap); }
.cell {
  position: relative;
  background: var(--cell);
  border-radius: var(--radius);
  padding: var(--pad);
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  transition: background .12s;
}
.cell:hover { background: var(--cell-hi); }
.cell.out { opacity: .4; }
.cell.past .num { color: var(--muted); }
.cell .head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 2px; }
.cell .num { font-size: 13px; font-weight: 600; min-width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 11px; margin: -3px 0 0 -3px; }
.cell .dow { font-size: 12px; color: var(--muted); }
.cell.today { box-shadow: inset 0 0 0 1px rgba(157, 180, 255, .35); }
.cell.today .num { background: var(--accent); color: #0e0f11; }
.cell .has-note { width: 5px; height: 5px; border-radius: 50%; background: var(--faint); margin-left: auto; align-self: center; }
.big .cell .num { font-size: 18px; min-width: 30px; height: 30px; line-height: 30px; border-radius: 15px; }
.big .cell .dow { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.big .cell { --pad: 12px; padding: var(--pad); }

/* multi-day bars: continuing pieces reach across the gap to meet the next day */
.bar, .lane-gap { height: 19px; flex: none; }
.bar {
  position: relative;
  z-index: 1;
  border-radius: 6px;
  padding: 0 7px;
  font-size: 11.5px;
  line-height: 19px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #f1f2f4;
  background: color-mix(in srgb, var(--c, var(--ev)) 38%, #17191c);
}
.bar.cl { margin-left: calc(-1 * (var(--pad) + var(--gap) / 2)); padding-left: calc(var(--pad) + var(--gap) / 2 + 7px); border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bar.cr { margin-right: calc(-1 * (var(--pad) + var(--gap) / 2)); border-top-right-radius: 0; border-bottom-right-radius: 0; }
.bar.quiet { color: transparent; }

.items { display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden; }
.big .items { overflow-y: auto; gap: 4px; }
.ev { display: flex; align-items: center; gap: 6px; font-size: 12px; min-width: 0; border-radius: 6px; padding: 1px 3px; margin: 0 -3px; }
.ev:hover { background: rgba(255, 255, 255, .05); }
.big .ev { font-size: 13px; padding: 3px 5px; margin: 0 -5px; }
.ev .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--ev)); flex: none; }
.ev .t { color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.ev .ti { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more { font-size: 11.5px; color: var(--muted); padding-left: 3px; }
.cell .note-peek { font-size: 12px; color: var(--muted); white-space: pre-wrap; overflow: hidden; margin-top: 4px; border-top: 1px solid var(--line); padding-top: 6px; }

/* ---------- day editor (zoom + day view) ---------- */
.dayview { flex: 1; min-height: 0; background: var(--cell); border-radius: 18px; overflow: hidden; display: flex; }
.editor { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 22px 26px 18px; gap: 16px; }
.ed-head { display: flex; align-items: flex-start; gap: 12px; }
.ed-head .when { flex: 1; }
.ed-dow { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.ed-date { font-size: 26px; font-weight: 600; letter-spacing: -0.015em; }
.ed-date .today-tag { font-size: 12px; font-weight: 500; color: #0e0f11; background: var(--accent); padding: 2px 8px; border-radius: 8px; vertical-align: middle; margin-left: 8px; letter-spacing: 0; }
.ed-btns { display: flex; gap: 2px; }
.ed-add {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  outline: none;
  font-size: 14.5px;
}
.ed-add::placeholder { color: var(--faint); }
.ed-add:focus { border-color: #3c4250; }
.ed-preview { margin-top: 5px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.list .empty { color: var(--faint); font-size: 13.5px; padding: 4px 0; }
.it { border-radius: 10px; }
.it.open { background: #1f2227; }
.it-line { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.it-line:hover { background: #1f2227; }
.it-line .t { color: var(--muted); min-width: 92px; font-variant-numeric: tabular-nums; font-size: 13px; }
.it-line .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--ev)); flex: none; }
.it-line .ti { flex: 1; font-size: 15px; }
.it-line .range { font-size: 12px; color: var(--muted); }
.it-line .who { font-size: 12px; color: var(--c); }
.it-edit { padding: 2px 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.it-edit .f-title { width: 100%; }
.fields { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.fields label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.it-edit input, .it-edit select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  outline: none;
  font-size: 13.5px;
  color-scheme: dark;
}
.it-edit input:focus, .it-edit select:focus { border-color: #3c4250; }
.f-time, .f-endtime { width: 84px; }
.del { margin-left: auto; color: #d4776b; font-size: 13px; padding: 6px 10px; border-radius: 8px; }
.del:hover { background: rgba(212, 119, 107, .12); }
.notes {
  flex: 1;
  min-height: 80px;
  resize: none;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  padding: 14px 2px 0;
  outline: none;
  font-size: 15px;
  line-height: 1.55;
}
.notes::placeholder { color: var(--faint); }

/* zoom: the card grows out of the day you clicked */
.zoom { position: fixed; inset: 0; z-index: 20; }
.backdrop { position: absolute; inset: 0; background: rgba(5, 6, 8, .6); opacity: 0; transition: opacity .28s; backdrop-filter: blur(2px); }
.zoomcard {
  position: fixed;
  background: var(--cell);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  transition: left .32s cubic-bezier(.2, .8, .2, 1), top .32s cubic-bezier(.2, .8, .2, 1),
              width .32s cubic-bezier(.2, .8, .2, 1), height .32s cubic-bezier(.2, .8, .2, 1), border-radius .32s;
}
.zoomcard .editor { opacity: 0; transition: opacity .18s; }
.zoom.open .backdrop { opacity: 1; }
.zoom.open .zoomcard { border-radius: 20px; }
.zoom.open .zoomcard .editor { opacity: 1; transition: opacity .2s .12s; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #23262c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 10px 9px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 40;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  font-size: 13.5px;
  max-width: calc(100vw - 24px);
}
.toast button { color: var(--accent); padding: 4px 8px; border-radius: 8px; }
.toast button:hover { background: rgba(157, 180, 255, .1); }

/* login */
.login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 50; }
.login form { display: flex; flex-direction: column; gap: 10px; width: 260px; }
.login-title { font-size: 20px; font-weight: 600; text-align: center; margin-bottom: 6px; }
.login input { height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--cell); padding: 0 14px; outline: none; }
.login .pill { height: 40px; }
.login-err { color: #d4776b; font-size: 13px; text-align: center; min-height: 18px; }

@media (max-width: 700px) {
  :root { --gap: 4px; --pad: 5px; --radius: 10px; }
  body { padding: 10px 8px 10px; gap: 8px; }
  h1 { font-size: 17px; }
  .views button { padding: 5px 8px; font-size: 13px; }
  .cell .num { font-size: 12px; }
  .month .ev .t { display: none; }
  .month .ev { font-size: 10.5px; gap: 3px; }
  .bar { font-size: 10px; padding: 0 3px; }
  .editor { padding: 18px 16px 14px; }
  .it-line .t { min-width: 64px; }
}
