/* Modal dialogs: event card, form, reminders drawer, small prompts. */
dialog.dlg {
  padding: 0; border: 0; color: var(--ink); background: var(--surface); overflow: hidden;
  width: min(580px, calc(100vw - 32px)); max-height: min(88dvh, 920px); border-radius: var(--r-l); box-shadow: var(--shadow-lg);
}
dialog.dlg[open] { display: flex; flex-direction: column; }
dialog.dlg::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.dlg-inner { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; animation: dlg-in 0.16s ease-out; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px); } }

dialog.dlg--small { width: min(420px, calc(100vw - 24px)); }
dialog.dlg--small .dlg-inner { padding: 20px 20px 0; }
dialog.dlg--drawer {
  margin: 0 0 0 auto; width: min(460px, 100vw); height: 100dvh; max-height: 100dvh; border-radius: var(--r-l) 0 0 var(--r-l);
}
dialog.dlg--drawer .dlg-inner { animation-name: drawer-in; }
@keyframes drawer-in { from { opacity: 0; transform: translateX(24px); } }

.dlg-title { font: 600 19px/1.25 var(--font-display); letter-spacing: -0.01em; }
.dlg-text { color: var(--ink-2); margin: 6px 0 14px; }
.dlg-footer {
  flex: none; display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px; border-top: 1px solid var(--line-soft); background: var(--surface);
}
dialog.dlg--small .dlg-footer { margin: 14px -20px 0; }
.foot-note { margin-right: auto; font-size: 13px; color: var(--danger); }

.card-head { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 12px 8px 20px; }
.card-titles { min-width: 0; display: grid; gap: 4px; }
.card-title { font: 600 24px/1.2 var(--font-display); letter-spacing: -0.015em; overflow-wrap: anywhere; }
.card-kind { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--meet); }
.status { padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); }
.status--in_progress { background: color-mix(in oklab, var(--meet) 22%, var(--surface)); color: var(--ink); }
.status--done { background: var(--accent-soft); color: var(--ink); }
.status--cancelled { background: color-mix(in oklab, var(--danger) 16%, var(--surface)); color: var(--ink); text-decoration: line-through; }

.card-body, .form-body, .drawer-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 4px 20px 20px; }
.facts { display: grid; gap: 12px; margin-bottom: 14px; }
.fact { display: flex; gap: 12px; align-items: flex-start; }
.fact > .icon { margin-top: 2px; color: var(--muted); }
.fact-main { font-size: 15px; overflow-wrap: anywhere; }
.fact-sub { font-size: 13.5px; color: var(--muted); }
.card-desc { white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px 14px; border-radius: var(--r-m); background: var(--surface-2); margin-bottom: 14px; }
.card-sec { margin: 6px 0 12px; }
.sec-h { font-size: 13.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; display: block; }
.sec-h--big { font: 600 17px/1.3 var(--font-display); color: var(--ink); }
.plain-list { display: grid; gap: 6px; }
.plain-list li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.plain-list li .icon { color: var(--muted); }
.plain-list li.is-done { color: var(--muted); }

/* Form */
.form { min-height: 0; }
.form-body { display: flex; flex-direction: column; gap: 14px; }
.row-3 { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 10px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-end { display: grid; gap: 6px; justify-items: start; }
.row-end .field { width: 100%; }
.wd-row { display: flex; flex-wrap: wrap; gap: 6px; }
.wd { position: relative; display: block; }
.wd input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.wd span { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line-strong); border-radius: 999px; font-weight: 600; font-size: 13.5px; }
.wd input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.wd input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.meeting-toggle { display: grid; gap: 10px; padding: 12px 14px; border-radius: var(--r-m); background: color-mix(in oklab, var(--meet) 9%, var(--surface)); border: 1px solid color-mix(in oklab, var(--meet) 26%, var(--line)); }
.switch { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; font-weight: 600; cursor: pointer; }
.switch .field-hint { grid-column: 2; font-weight: 400; }
.participants { display: grid; gap: 8px; }

.choices { display: grid; gap: 6px; }
.choice { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-m); cursor: pointer; }
.choice--hint { padding: 10px 12px; }
.choice-text { display: grid; gap: 2px; }
.choice:hover { background: var(--surface-2); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* Reminders drawer */
.drawer-body { display: grid; gap: 18px; align-content: start; }
.rem-form { display: grid; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line-soft); }
.rem-form .btn { justify-self: start; }
.rem-list { display: grid; gap: 8px; }
.rem-ul { display: grid; gap: 8px; }
.rem { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-m); }
.rem.is-done .rem-title { text-decoration: line-through; color: var(--muted); }
.rem-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.rem-title { font-weight: 600; overflow-wrap: anywhere; }
.rem-when { font-size: 13px; color: var(--muted); }
.rem-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-left: -8px; }
.rem-edit { display: grid; gap: 8px; padding-top: 6px; }
.rem-edit-actions { display: flex; gap: 6px; }
.round-check {
  position: relative; width: 28px; height: 28px; flex: none; border-radius: 50%; border: 2px solid var(--line-strong);
  display: grid; place-items: center; color: transparent; margin-top: 1px;
}
.round-check::after { content: ""; position: absolute; inset: -8px; }
.round-check:hover { color: var(--muted); border-color: var(--ink-2); }
.round-check.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

@media (max-width: 720px) {
  dialog.dlg--card, dialog.dlg--form, dialog.dlg--drawer {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0;
  }
  .card-head { padding: 12px 8px 6px 16px; }
  .card-body, .form-body, .drawer-body { padding: 4px 16px 18px; }
  .dlg-footer { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .dlg-footer .btn { flex: 1; }
  .card-title { font-size: 21px; }
  .row-3 { grid-template-columns: 1fr 1fr; }
  .row-3 > :first-child { grid-column: 1 / -1; }
  .wd span { width: 40px; height: 40px; }
}

/* Event card: reminders of the occurrence */
.cr-list { margin-bottom: 8px; }
.cr-line { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.cr-line > .icon { color: var(--muted); }
.cr-sel { width: auto; min-height: 36px; padding: 4px 28px 4px 8px; }
.cr-scope { font-size: 12.5px; color: var(--muted); }
.cr-line .icon-btn { margin-left: auto; }
.cr-add .input { flex: 0 1 auto; width: auto; }
.cr-add select { min-height: 36px; padding: 4px 8px; }
/* Narrow widths: stack the two selects so «Для всех повторов» is not clipped. */
@media (max-width: 520px) {
  .add-row--wrap.cr-add select { flex: 1 1 100%; width: 100%; min-width: 0; }
}

/* Reminders drawer: collapsible «Выполненные» */
.sec-h--toggle { margin: 0; }
.sec-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 6px 0 0; font: inherit; color: inherit; border-radius: var(--r-s); }
.sec-toggle:hover { color: var(--ink); }
.sec-toggle-ic { transition: transform 0.15s; transform: rotate(-90deg); }
.sec-toggle[aria-expanded="true"] .sec-toggle-ic { transform: none; }
.rem-done { display: grid; gap: 8px; justify-items: start; padding-top: 4px; }
.rem-done .rem-ul { justify-self: stretch; }
