.toast,
#action-feedback,
#search-feedback,
#workspace-feedback,
#settings-toast,
#profile-feedback {
  border-color: #2c2c2c;
  background: #171717;
  color: #fff;
}

.livia-a11y-live {
  position: fixed !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.livia-skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 8px 11px;
  border-radius: 7px;
  background: #171717;
  color: #fff;
  font: 600 11px/16px Inter, Arial, sans-serif;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 120ms ease;
}
.livia-skip-link:focus { transform: translateY(0); outline: 2px solid #fff; outline-offset: 2px; }

.livia-keyboard-user :where(button, a, input, select, textarea, [contenteditable="true"], [tabindex]):focus-visible {
  outline: 2px solid #1b1b1b !important;
  outline-offset: 2px !important;
}

/* A Table já desenha o foco no limite da célula. Repetir o outline global no
   contenteditable criava uma segunda caixa dentro dela. */
.livia-keyboard-user .livia-data-table .table-cell-value:focus-visible,
html.livia-high-contrast .livia-data-table .table-cell-value:focus-visible {
  outline: 0 !important;
  outline-offset: 0 !important;
  box-shadow: none !important;
}

/* O bloco da Page é o próprio campo de escrita. O foco fica indicado pelo
   fundo do bloco, sem criar uma segunda caixa dentro da linha. */
.livia-keyboard-user #workspace-page [contenteditable="true"]:focus-visible,
html.livia-high-contrast #workspace-page [contenteditable="true"]:focus-visible {
  outline: 0 !important;
  outline-offset: 0 !important;
}
html.livia-high-contrast #workspace-page [contenteditable="true"]:focus-visible {
  box-shadow: inset 0 -2px #111 !important;
}

html.livia-high-contrast {
  --line: #777 !important;
  --border: #777 !important;
  --home-line: #777 !important;
  --muted: #555 !important;
}
html.livia-high-contrast :where(button, a, input, select, textarea, [contenteditable="true"], [tabindex]):focus-visible {
  outline: 3px solid #111 !important;
  outline-offset: 2px !important;
}
html.livia-high-contrast .livia-data-table td:has(.table-cell-value.is-selected),
html.livia-high-contrast .livia-data-table td:has(.table-cell-value.is-editing) {
  box-shadow: inset 0 0 0 3px #111 !important;
}
html.livia-high-contrast :where(input, select, textarea, dialog, [role="dialog"], [role="menu"], .popover, .workspace-context-menu, .table-config-menu) {
  border-color: #777 !important;
}
html.livia-high-contrast :where(.livia-state-toast, #action-feedback, #search-feedback, #workspace-feedback, #settings-toast, #profile-feedback) {
  border-color: #fff !important;
}

html.livia-reduce-motion *,
html.livia-reduce-motion *::before,
html.livia-reduce-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}

:where([role="menu"], .popover, .workspace-context-menu, #workspace-page-block-menu, #workspace-page-context-menu, .table-config-menu) {
  overscroll-behavior: contain;
}

@media (hover: none), (pointer: coarse) {
  :where(.row-more, .workspace-menu-title-edit, .workspace-menu-cover-edit, .page-version-edge) { opacity: 1 !important; }
}

@media (forced-colors: active) {
  .livia-state-toast,
  .livia-state-dialog,
  :where([role="menu"], .popover, .workspace-context-menu, #workspace-page-block-menu, #workspace-page-context-menu, .table-config-menu) { border: 1px solid CanvasText; }
  .livia-state-surface-mark { border: 1px solid CanvasText; }
}

.livia-state-toasts {
  position: fixed;
  z-index: 240;
  right: 22px;
  bottom: 22px;
  width: min(360px, calc(100vw - 32px));
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.livia-state-toast {
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  padding: 9px 9px 9px 13px;
  border: 1px solid #2c2c2c;
  border-radius: 9px;
  background: #171717;
  box-shadow: 0 10px 28px rgb(0 0 0 / 18%);
  color: #fff;
  pointer-events: auto;
  animation: livia-state-toast-in 150ms ease-out;
}

.livia-state-toast[data-tone="error"] { border-color: #5a2a2a; }
.livia-state-toast[data-tone="warning"] { border-color: #5a4a20; }
.livia-state-toast-message { min-width: 0; font-size: 11px; font-weight: 500; line-height: 16px; }
.livia-state-toast-action,
.livia-state-toast-close {
  border: 0;
  background: transparent;
  color: #fff;
}
.livia-state-toast-action {
  min-height: 27px;
  padding: 0 8px;
  border-radius: 6px;
  background: rgb(255 255 255 / 12%);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.livia-state-toast-action:hover,
.livia-state-toast-action:focus-visible { background: rgb(255 255 255 / 21%); outline: 0; }
.livia-state-toast-close {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0 0 2px;
  border-radius: 50%;
  color: #bdbdbd;
  font-size: 17px;
  line-height: 1;
}
.livia-state-toast-close:hover,
.livia-state-toast-close:focus-visible { background: rgb(255 255 255 / 12%); color: #fff; outline: 0; }
.livia-state-toast.is-leaving { animation: livia-state-toast-out 120ms ease-in forwards; }

.livia-state-surface { position: relative; }
.livia-state-surface[data-livia-surface-state] > :not(.livia-state-surface-layer) { display: none !important; }
.livia-state-surface-layer {
  min-height: 152px;
  display: grid;
  place-items: center;
  padding: 28px;
  color: #242424;
  text-align: center;
}
.livia-state-surface-copy { width: min(360px, 100%); display: grid; justify-items: center; gap: 6px; }
.livia-state-surface-mark { width: 30px; height: 30px; display: grid; place-items: center; margin-bottom: 6px; border-radius: 9px; background: #f0efee; color: #777276; }
.livia-state-surface-mark svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }
.livia-state-surface-layer[data-state="loading"] .livia-state-surface-mark { animation: livia-state-pulse 850ms ease-in-out infinite alternate; }
.livia-state-surface-layer[data-state="error"] .livia-state-surface-mark { background: #fff0f0; color: #c7474d; }
.livia-state-surface-layer[data-state="forbidden"] .livia-state-surface-mark { background: #f3efff; color: #7663a7; }
.livia-state-surface-layer[data-state="expired"] .livia-state-surface-mark { background: #fff6e8; color: #b47a28; }
.livia-state-surface-layer[data-state="removed"] .livia-state-surface-mark { background: #f1f0ef; color: #777276; }
.livia-state-skeleton {
  width: min(280px, 84%);
  height: 9px;
  border-radius: 4px;
  background: linear-gradient(90deg, #efeeee 25%, #f8f7f7 50%, #efeeee 75%);
  background-size: 220% 100%;
  animation: livia-state-skeleton 1.15s ease-in-out infinite;
}

html.livia-modal-open { overflow: hidden; }
.livia-state-skeleton.is-title { width: min(180px, 58%); height: 13px; margin-bottom: 8px; }
.livia-state-skeleton.is-short { width: min(220px, 68%); }
.livia-state-surface-copy strong { font-size: 13px; font-weight: 600; line-height: 18px; }
.livia-state-surface-copy p { margin: 0; color: #858585; font-size: 11px; line-height: 16px; }
.livia-state-surface-copy button {
  height: 29px;
  margin-top: 6px;
  padding: 0 11px;
  border: 1px solid #dedede;
  border-radius: 6px;
  background: #fff;
  color: #333;
  font-size: 10px;
  font-weight: 600;
}
.livia-state-surface-copy button:hover,
.livia-state-surface-copy button:focus-visible { background: #f3f3f3; color: #111; outline: 0; }

.livia-state-dialog-backdrop {
  position: fixed;
  z-index: 250;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgb(0 0 0 / 24%);
}
.livia-state-dialog {
  width: min(390px, 100%);
  overflow: hidden;
  border: 1px solid #dedede;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 20px 54px rgb(0 0 0 / 18%);
}
.livia-state-dialog-copy { padding: 18px 18px 15px; }
.livia-state-dialog-copy strong { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 600; line-height: 18px; }
.livia-state-dialog-copy p { margin: 0; color: #777; font-size: 11px; line-height: 17px; }
.livia-state-dialog-header {
  min-height: 52px;
  padding: 0 14px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #ecebea;
}
.livia-state-dialog-header strong { font-size: 13px; font-weight: 600; color: #242124; }
.livia-state-dialog-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #777276;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.livia-state-dialog-close:hover,
.livia-state-dialog-close:focus-visible { background: #f1f0ef; color: #242124; outline: 0; }
.livia-state-dialog-content { padding: 18px; color: #403c40; }
.livia-state-dialog-actions { display: flex; justify-content: flex-end; gap: 7px; padding: 10px; border-top: 1px solid #ececec; }
.livia-state-dialog-actions button { height: 31px; padding: 0 12px; border: 1px solid #dedede; border-radius: 7px; background: #fff; color: #444; font-size: 10.5px; font-weight: 600; }
.livia-state-dialog-actions button:hover,
.livia-state-dialog-actions button:focus-visible { background: #f3f3f3; outline: 0; }
.livia-state-dialog-actions .is-primary { border-color: #1d1d1d; background: #1d1d1d; color: #fff; }
.livia-state-dialog-actions .is-danger { border-color: #b53a3a; background: #b53a3a; color: #fff; }
.livia-state-dialog-actions .is-primary:hover,
.livia-state-dialog-actions .is-danger:hover { background: #000; }

[data-livia-busy="true"] { cursor: progress !important; opacity: .68; pointer-events: none; }

@keyframes livia-state-toast-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes livia-state-toast-out { to { opacity: 0; transform: translateY(5px); } }
@keyframes livia-state-pulse { from { opacity: .35; transform: scale(.82); } to { opacity: 1; transform: scale(1); } }
@keyframes livia-state-skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .livia-state-toast,
  .livia-state-toast.is-leaving,
  .livia-state-surface-layer[data-state="loading"] .livia-state-surface-mark,
  .livia-state-skeleton { animation: none; }
}

@media (max-width: 640px) {
  .livia-state-toasts { right: 16px; bottom: 16px; left: 16px; width: auto; }
  .livia-state-dialog-backdrop { padding: 12px; }
  .livia-state-dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }
}
