/* Shared cards and dialog surfaces. Layout-specific workspaces retain their geometry. */
body {
  --surface-radius:16px;
  --dialog-radius:20px;
  --surface-shadow:0 2px 8px rgb(0 0 0 / .12);
  --dialog-shadow:0 24px 72px rgb(0 0 0 / .38);
  --surface-overlay:rgb(3 7 14 / .64);
  --surface-inset:20px;
}
body.mode-light {
  --surface-shadow:0 2px 10px rgb(20 30 50 / .05);
  --dialog-shadow:0 24px 72px rgb(20 30 50 / .2);
  --surface-overlay:rgb(15 23 42 / .4);
}
body :is(.widget, .desk-card, .shopping-list-card, .settings-section, .saved-link-card,
  .note-editor, .note-welcome, .notes-library, .trash-row, .finance-card,
  .fp-card, .calendar-container, .fw-metrics > *, .fw-category, .fw-limit-list > button) {
  box-sizing:border-box;
  min-width:0;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--surface-radius) !important;
  box-shadow:var(--surface-shadow);
}
body :is(.saved-link-card, .trash-row, .fp-card, .note-editor, .note-welcome,
  .settings-section, .shopping-list-card) { padding:var(--surface-inset) !important; }
body :is(.fw-category, .fw-limit-list > button) { padding:var(--surface-inset) !important; }
body .fw-metrics > * { padding:var(--surface-inset); }
body .fw-accounts button { border-radius:12px; box-shadow:none; }
body :is(.fp-shopping, .fp-notice) { border-radius:12px; box-shadow:none; }
body .desk-card-head { padding:var(--surface-inset); }
body .desk-card-foot { padding:16px var(--surface-inset); background:var(--card); gap:12px; flex-wrap:wrap; }
body :is(.desk-task-list, .desk-money) { padding-inline:var(--surface-inset); }
body .desk-task-summary { margin-inline:var(--surface-inset); }
body #page-wiki .wiki-layout { border:1px solid var(--border); border-radius:var(--surface-radius); box-shadow:var(--surface-shadow); }
body #page-wiki :is(.wiki-nav, .wiki-library, .wiki-panel) { box-shadow:none; }
body #page-wiki .wiki-nav { background:var(--bg2); }
body :is(.saved-link-card, .fp-card, .shopping-list-card) h4 { margin-top:0; }
body .modal-overlay:not(.planner-drawer) {
  box-sizing:border-box;
  padding:24px;
  background:var(--surface-overlay);
  backdrop-filter:blur(3px);
  -webkit-backdrop-filter:blur(3px);
}
body .modal-overlay:not(.planner-drawer) > .modal,
body dialog:not(#wikiFileDialog):not(#noteLightbox),
body #issuedTokenDialog {
  box-sizing:border-box;
  background:var(--card);
  color:var(--text);
  border:1px solid var(--border);
  border-radius:var(--dialog-radius);
  box-shadow:var(--dialog-shadow);
  padding:24px;
  max-height:calc(100dvh - 48px);
  overflow-y:auto;
  overscroll-behavior:contain;
  scrollbar-width:thin;
  scrollbar-color:var(--border) transparent;
  scroll-padding-block:20px;
}
body .modal-overlay:not(.planner-drawer) > .modal { width:100%; max-width:560px; }
body dialog:not(#wikiFileDialog):not(#noteLightbox) { max-width:calc(100vw - 48px); }
body dialog::backdrop { background:var(--surface-overlay); backdrop-filter:blur(3px); -webkit-backdrop-filter:blur(3px); }
body .modal-close { top:12px; right:12px; color:var(--muted); }
body .modal h2 { margin:0 0 20px; padding-right:44px; }
body :is(.fp-dialog, .fw-dialog) h3 { margin-top:0; }
body :is(.fp-dialog, .fw-dialog) footer {
  border-top:1px solid var(--border);
  padding-top:16px;
  margin-top:20px;
}
body .modal :is(.hint, .section-title) { overflow-wrap:anywhere; }
body #confirmModal > .modal { max-width:400px !important; padding:24px; }
body #confirmModal p { line-height:1.6; overflow-wrap:anywhere; }
body #confirmModal .form-submit { flex:1; min-width:0; }
body :is(#wikiFileDialog, #noteLightbox) { background:var(--card); border:1px solid var(--border); border-radius:var(--dialog-radius); box-shadow:var(--dialog-shadow); }
body .toast { background:var(--card); color:var(--text); border-radius:12px; box-shadow:var(--dialog-shadow); }
body:has(.modal-overlay.open:not(.planner-drawer)), body:has(dialog[open]) { overflow:hidden; }
@media(min-width:901px) {
  body #aiChatWindow { background:var(--card); border:1px solid var(--border); border-radius:var(--dialog-radius); box-shadow:var(--dialog-shadow); }
  body.pw-ui #editModal.planner-drawer .modal { background:var(--card); border-left:1px solid var(--border); box-shadow:-12px 0 40px rgb(0 0 0 / .12); }
}
@media(max-width:900px) {
  body { --surface-inset:16px; }
  body .fw-actions { flex-wrap:wrap; }
  body .fw-actions > button { flex:1 1 auto; }
  body .modal-overlay:not(.planner-drawer):not(#confirmModal) {
    align-items:flex-end;
    padding:0;
    padding-top:calc(12px + env(safe-area-inset-top));
  }
  body .modal-overlay:not(.planner-drawer):not(#confirmModal) > .modal,
  body #addTransactionModal .fw-entry {
    width:100%; max-width:100%; margin:0;
    max-height:calc(100dvh - 12px - env(safe-area-inset-top));
    border-radius:var(--dialog-radius) var(--dialog-radius) 0 0;
    padding:20px 16px calc(20px + env(safe-area-inset-bottom));
    border-bottom:0;
  }
  body dialog:not(#wikiFileDialog):not(#noteLightbox) {
    position:fixed;
    inset:auto 0 0;
    width:100%; max-width:100%;
    margin:0;
    max-height:calc(100dvh - 12px - env(safe-area-inset-top));
    border-radius:var(--dialog-radius) var(--dialog-radius) 0 0;
    padding:20px 16px calc(20px + env(safe-area-inset-bottom));
    border-bottom:0;
  }
  body #confirmModal { padding:16px; align-items:center; }
  body #confirmModal > .modal { max-height:calc(100dvh - 32px); border-radius:var(--dialog-radius); padding:20px 16px; }
  body.pw-ui #editModal.planner-drawer .modal { background:var(--card); border-radius:0; }
  body:has(#editModal.planner-drawer.open) { overflow:hidden; }
  body #wikiFileDialog.is-pdf { border-radius:0; }
}
@media(prefers-reduced-transparency:reduce) {
  body .modal-overlay, body dialog::backdrop { backdrop-filter:none; -webkit-backdrop-filter:none; }
}
