/* Carevetta 0.6.0: the sheet (bottom sheet on a phone, right-side panel from 900px), the confirm dialog, forms, the tour, toasts. */
dialog { padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); }
#sheet:modal, #confirm:modal { overscroll-behavior: contain; }
#sheet::backdrop, #confirm::backdrop { background: rgb(8 20 24 / .45); overflow: hidden; overscroll-behavior: contain; }

#sheet { width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; border-width: 1px 0 0; border-radius: 12px 12px 0 0; }
#sheet[open] { display: flex; flex-direction: column; }
#sheetForm { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px; }
.sheet-foot { padding: 10px 16px calc(env(safe-area-inset-bottom) + 12px); border-top: 1px solid var(--line); }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.error { color: var(--danger); font-weight: 600; margin: 0; }
.error:not(:empty) { margin-bottom: 8px; }
@media (min-width: 900px) {
  #sheet { width: 520px; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; border-width: 0 0 0 1px; border-radius: 0; }
}

#confirm { width: min(440px, calc(100vw - 32px)); border-radius: var(--radius); }
#confirmForm { padding: 18px 18px 16px; }
#confirm h2 { margin-bottom: 8px; }
#confirmBody p:last-child { margin-bottom: 14px; }
#confirm .error:not(:empty) { margin-bottom: 12px; }

/* ---------- forms ---------- */
.field { display: block; margin: 0 0 12px; }
.field > span:first-child { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field input, .field select, .field textarea, .pick select { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--text); font: inherit; }
.field input[type="file"] { padding: 8px; }
.field textarea { min-height: 96px; resize: vertical; }
.hint { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; }
fieldset.roles { border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 12px 6px; margin: 0 0 12px; }
fieldset.roles legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
fieldset.quiz.wrong { border-color: var(--danger); }
.statusline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.plain-text { margin-bottom: 12px; }
.note { background: var(--brand-soft); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 14px; margin: 0 0 12px; }
.warn { background: var(--due-bg); color: var(--due); border: 1px solid color-mix(in srgb, var(--due) 35%, transparent); border-radius: 6px; padding: 8px 10px; font-size: 14px; margin: 0 0 12px; }
.warn.bad { background: var(--expired-bg); color: var(--expired); border-color: color-mix(in srgb, var(--expired) 35%, transparent); }
.box { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 2px; margin: 0 0 12px; }
.box > .label { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.files { margin: 0 0 10px; padding-left: 18px; font-size: 14px; }
.files li { margin: 4px 0; overflow-wrap: anywhere; }
details.more { border-top: 1px solid var(--line); }
details.more:last-of-type { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
details.more > summary { display: flex; align-items: center; min-height: 44px; font-weight: 600; cursor: pointer; }
details.more > summary::marker { color: var(--muted); }
details.more > summary { display: list-item; padding: 11px 0; }
details.more > .in { padding: 2px 0 6px; }
details.plain > summary { min-height: 44px; padding: 11px 2px; cursor: pointer; }
.policy { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 12px; }
.cat { font-weight: 600; }

/* ---------- the tour: a modal dialog with a clear backdrop, so focus stays in the card and the page stays visible ---------- */
dialog.tour { position: fixed; inset: auto 12px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px) 12px; margin: 0 auto; width: auto; max-width: 440px;
  padding: 14px 16px 12px; border-radius: var(--radius); border-color: var(--brand); border-width: 2px; }
dialog.tour::backdrop { background: transparent; }
.tour h2 { margin: 2px 0 6px; }
.tour-count { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 0; }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-actions .linkbtn { min-height: 44px; }
body.touring { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 46dvh); }
.tour-spot { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: var(--radius); scroll-margin-top: 96px; }
@media (min-width: 900px) {
  dialog.tour { inset: auto 24px 24px auto; margin: 0; width: 400px; }
  body.touring { padding-bottom: 40dvh; }
  .tour-spot { scroll-margin-top: 48px; }
}

/* ---------- toasts ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px); z-index: 30; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; max-width: min(520px, calc(100vw - 24px)); padding: 10px 14px; border-radius: 6px;
  background: var(--text); color: var(--surface); font-weight: 500; visibility: hidden; opacity: 0; transition: opacity .15s; }
.toast.show { visibility: visible; opacity: 1; }
.toast.error { background: #9f1c12; color: #ffffff; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 70px); }
.toast-btn { min-height: 32px; padding: 0 10px; border-radius: 4px; border: 1px solid currentColor; background: none; color: inherit; font: inherit; font-weight: 650; cursor: pointer; }
@media (min-width: 900px) { .toast { bottom: 24px; } .toast.error { bottom: 80px; } }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
