/* «Мой день»: a quiet paper day-sheet. The schedule is a vertical time rail; subitems hang under an event as a thread.
   Layout/structure drafted by Antigravity (sketches/myday), reworked for contrast, mobile widths and focus. Tokens only. */

/* ---- App shell in «Мой день» mode --------------------------------------- */
#main[data-tab="myday"] > .cal-progress,
#main[data-tab="myday"] > .cal-content { display: none; }
body[data-tab="myday"] .nav-ctrl,
body[data-tab="myday"] .seg--views { display: none; }
body[data-tab="myday"] .layout { grid-template-columns: minmax(0, 1fr); }

.seg--tabs .seg-btn { white-space: nowrap; }
@media (max-width: 720px) {
  .topbar { grid-template-areas: "title actions" "tabs tabs" "ctrl seg"; }
  .seg--tabs { grid-area: tabs; justify-self: stretch; display: flex; }
  .seg--tabs .seg-btn { flex: 1; min-height: 40px; font-size: 14px; }
  body[data-tab="myday"] .topbar { grid-template-areas: "title actions" "tabs tabs"; }
  body[data-tab="myday"] .calendar { padding-bottom: 0; }
}

/* ---- Page ---------------------------------------------------------------- */
.md { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg); color: var(--ink); }
.md-scroll { flex: 1; min-height: 0; overflow: auto; padding: 20px 24px 32px; overscroll-behavior: contain; }

.md-progress { position: absolute; top: 0; left: 0; right: 0; height: 2px; z-index: 6; overflow: hidden; }
.md-progress::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 30%; background: var(--sun);
  animation: slide 1.1s ease-in-out infinite;
}

.md-bar {
  flex: none; display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line-soft);
}
.md-nav { display: flex; align-items: center; gap: 4px; }
.md-title { margin: 0 auto 0 0; display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; font: 300 28px/1.15 var(--font-display); letter-spacing: -0.02em; min-width: 0; }
.md-title-sub { font: 400 14px/1.2 var(--font-ui); letter-spacing: 0; color: var(--muted); }
.md-datepick { display: inline-flex; }
.md-datepick .input { width: auto; min-height: 40px; }

.md-body { display: grid; gap: 16px; max-width: 1280px; margin: 0 auto; }
.md-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 900px) { .md-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }

.md-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; display: grid; gap: 12px; min-width: 0; align-content: start; }
.md-sec-h { min-height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.md-sec-title { display: flex; align-items: center; gap: 8px; font: 600 17px/1.3 var(--font-display); letter-spacing: -0.01em; }
.md-count { padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); font: 600 12px/1.4 var(--font-ui); }
.md-sec-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.md-sec-body { min-width: 0; }
.md-sec-body .empty { padding: 20px 8px; }
.empty .btn .icon { color: inherit; }
.md-empty { padding: 4px 2px 8px; }
.md-err .empty { padding: 12px; }

.seg--small .seg-btn { min-height: 32px; padding: 0 12px; font-size: 13px; }
@media (pointer: coarse), (max-width: 720px) { .seg--small .seg-btn { min-height: 40px; } }

/* ---- Schedule: time rail -------------------------------------------------- */
.md-sched { display: grid; gap: 0; }
.md-ev { position: relative; padding: 0 0 12px 68px; }
.md-ev:last-child { padding-bottom: 0; }
.md-ev::before { content: ""; position: absolute; left: 54px; top: 22px; bottom: -2px; width: 1px; background: var(--line); }
.md-ev:last-child::before { display: none; }
.md-ev::after {
  content: ""; position: absolute; left: 49px; top: 9px; width: 11px; height: 11px; box-sizing: border-box;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong);
}
.md-ev.is-now::after { background: var(--sun); border-color: var(--sun); box-shadow: 0 0 0 4px color-mix(in oklab, var(--sun) 28%, transparent); }
.md-ev.is-past::after { border-color: var(--line); background: var(--surface-3); }
.md-ev-time { position: absolute; left: 0; top: 7px; width: 44px; text-align: right; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.md-ev.is-past .md-ev-time { color: var(--muted); font-weight: 500; }

.md-ev-row { display: flex; align-items: flex-start; gap: 4px; border-radius: var(--r-s); }
.md-ev.is-now > .md-ev-row { background: color-mix(in oklab, var(--sun) 16%, var(--surface)); }
.md-ev-title { flex: 1; min-width: 0; min-height: 44px; padding: 4px 8px; border-radius: var(--r-s); display: flex; align-items: center; }
.md-ev-title:hover { background: var(--surface-2); }
.md-ev-main { display: grid; gap: 1px; min-width: 0; }
.md-ev-name { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.md-ev.is-past .md-ev-name { color: var(--ink-2); font-weight: 500; }
.md-ev-range { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.md-ev-meet { flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--meet); color: var(--surface); }

.md-ev-toggle { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 44px; min-height: 44px; padding: 0 8px; border-radius: var(--r-s); color: var(--ink-2); }
.md-ev-toggle:hover { background: var(--surface-2); color: var(--ink); }
.md-ev-toggle .icon { transition: transform 0.18s; }
.md-ev.is-open .md-ev-toggle .icon { transform: rotate(180deg); }
.md-chip { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--ink); font-size: 12px; font-weight: 700; }
.md-chip--add { background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); padding: 0 5px; min-width: 24px; }

.md-ev-panel { position: relative; background: var(--surface); display: none; margin: 4px 0 2px 4px; padding-left: 12px; border-left: 2px solid var(--line); }
.md-ev.is-open > .md-ev-panel { display: grid; gap: 6px; }
.md-rule-note { font-size: 12.5px; color: var(--muted); line-height: 1.4; max-width: 60ch; }

/* ---- Todos ---------------------------------------------------------------- */
.md-todos { display: grid; gap: 2px; }
.md-todo { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 2px 4px 2px 2px; border-radius: var(--r-s); }
.md-todo:hover { background: var(--surface-2); }
.md-todo .round-check { margin: 0; width: 40px; height: 40px; border: 0; background: none; border-radius: 50%; }
/* The 40 px box is the hit area; the 28 px ring is drawn by ::before. */
.md-todo .round-check::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; border: 2px solid var(--line-strong); }
.md-todo .round-check::after { inset: 0; }
.md-todo .round-check .icon { position: relative; z-index: 1; }
.md-todo .round-check:hover::before { border-color: var(--ink-2); }
.md-todo .round-check.is-on { background: none; }
.md-todo .round-check.is-on::before { background: var(--accent); border-color: var(--accent); }
.md-todo-body { flex: 1; min-width: 0; display: flex; align-items: center; }
.md-todo-text { flex: 1; min-width: 0; min-height: 40px; display: flex; align-items: center; overflow-wrap: anywhere; line-height: 1.35; border-radius: var(--r-s); }
.md-todo-input { min-height: 40px; }
.md-todo.is-done .md-todo-text { color: var(--muted); text-decoration: line-through; }
.md-todo-rule { flex: none; display: inline-flex; color: var(--accent); }
.md-todo-actions { flex: none; display: flex; align-items: center; }
@media (hover: hover) and (pointer: fine) {
  .md-todo-actions { opacity: 0; transition: opacity 0.12s; }
  .md-todo:hover .md-todo-actions, .md-todo:focus-within .md-todo-actions { opacity: 1; }
}
@media (max-width: 720px) {
  .md-todo-actions .icon-btn:first-child:not(:last-child) { display: none; } /* tap the text to edit */
}

.md-add { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.md-add .input { flex: 1 1 160px; min-width: 0; }
.md-repeat { flex: 1 1 100%; display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }

/* ---- Notes list ----------------------------------------------------------- */
.nt-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.nt-list > li { display: flex; min-width: 0; }
.nt-card {
  width: 100%; min-height: 84px; padding: 12px 14px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); transition: background-color 0.12s, border-color 0.12s;
}
.nt-card:hover { background: var(--surface-2); border-color: var(--line-strong); }
.nt-card-title { font: 600 15px/1.3 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-card-prev { font-size: 13px; line-height: 1.4; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.nt-card-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* ---- Repeat rules dialog -------------------------------------------------- */
dialog.dlg--rule { width: min(520px, calc(100vw - 32px)); }
.md-rule-list { display: grid; gap: 8px; }
.md-rule { display: flex; align-items: center; gap: 10px; padding: 10px 6px 10px 12px; border: 1px solid var(--line); border-radius: var(--r-m); }
.md-rule-ic { flex: none; color: var(--accent); display: inline-flex; }
.md-rule-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.md-rule-text { font-weight: 600; overflow-wrap: anywhere; }
.md-rule-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.md-rule-actions { flex: none; display: flex; }
@media (max-width: 720px) {
  dialog.dlg--rule { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
}

/* ---- Narrow screens -------------------------------------------------------- */
@media (max-width: 720px) {
  .md-bar { padding: 8px 12px; gap: 8px; }
  .md-title { flex: 1 1 100%; order: 3; font-size: 24px; margin: 0; }
  .md-datepick { margin-left: auto; }
  .md-scroll { padding: 12px 12px 24px; }
  .md-sec { padding: 12px; }
}
@media (max-width: 480px) {
  .md-ev { padding-left: 56px; }
  .md-ev::before { left: 44px; }
  .md-ev::after { left: 39px; }
  .md-ev-time { width: 36px; font-size: 12px; }
  /* the subitem thread uses the full width: the time column would squeeze the text */
  .md-ev-panel { margin-left: -56px; padding-left: 8px; }
  .md-add .btn { flex: 1 1 100%; }
}
