/* Shared flat surfaces, including hover states and dynamically added panels.
 * Layered !important declarations override existing unlayered theme/template
 * shadows without removing their borders, backgrounds or spacing.
 */
@layer poker-flat-surfaces {
  body .rebuild-profiles-table,
  body .rebuild-profiles-table :is(thead, tbody, tr) {
    border-color: rgb(23 23 23) !important;
  }

  body .rebuild-profiles-table tbody tr {
    background-color: rgb(27 27 27) !important;
  }

  body .rebuild-profiles-table thead th {
    color: #f7f7f7 !important;
    text-transform: none !important;
  }

  body .rebuild-profiles-table table,
  body .rebuild-profiles-table table * {
    font-size-adjust: cap-height 0.66;
  }

  body .rebuild-profiles-table tbody td {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }

  /* Schema colors captured from the user's DevTools adjustments. */
  body :is(.schema-card, #schema-grid > section) {
    background-color: rgb(33 34 35) !important;
    border-color: rgb(36 39 45 / 46%) !important;
  }

  body :is(#schema-grid, .grid.items-start) thead th {
    border-color: rgb(48 48 49 / 46%) !important;
  }

  body :is(#schema-grid, .grid.items-start) tbody tr {
    background-color: rgb(24 24 24 / 50%) !important;
  }

  body :is(#schema-grid, .grid.items-start) tbody tr:hover {
    background-color: rgb(69 164 101 / 8%) !important;
  }

  body main:has(#choose-storage-folder) :is(input:not([type="hidden"]), textarea) {
    background-color: #161515 !important;
    border-color: rgb(33 33 36 / 60%) !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
  }

  body main:has(#choose-storage-folder) input:not([type="hidden"]) {
    height: 36px !important;
  }

  body main:has(#choose-storage-folder) :is(input, textarea):focus {
    border-color: var(--poker-active, #45a465) !important;
  }

  .border-zinc-700\/60 {
    border-color: rgb(33 33 36 / 60%) !important;
  }

  /* Database list colors captured from the user's DevTools adjustments. */
  body main:has(#choose-storage-folder) article.database-list-row,
  body main article.imports-session-row {
    background-color: #171717 !important;
    border-color: rgba(35, 35, 39, 0.55) !important;
    border-radius: 4px !important;
    padding: 0 20px !important;
  }

  body main .imports-session-row {
    font-size: 12px !important;
  }

  body main .imports-session-row :is(a, .import-hands-count, .whitespace-nowrap) {
    font-size: 12px !important;
    font-size-adjust: cap-height 0.66;
  }

  body main:has(#choose-storage-folder) article.database-list-row-active {
    background-color: rgb(39 39 39) !important;
    border-color: rgb(47 47 47) !important;
  }

  body main:has(#choose-storage-folder) .database-create-form label {
    font-size: 12px !important;
  }

  body main:has(#choose-storage-folder) .database-create-form > div:first-of-type {
    margin-top: 0 !important;
  }

  body main:has(#choose-storage-folder) .database-list-row :is(.poker-title, .database-hands-count, [data-database-size]) {
    font-size: 12px !important;
    font-size-adjust: cap-height 0.66;
  }

  body main:has(#choose-storage-folder) .database-list-heading,
  body main .imports-list-heading {
    color: #f7f7f7 !important;
    text-transform: none !important;
  }

  /* Bare icons keep their click targets; dropdown panels retain their styling. */
  body main:has(#choose-storage-folder) article > div:first-child {
    gap: 8px !important;
  }

  body main:has(#choose-storage-folder) article > div:first-child > span:first-child {
    width: 20px !important;
    height: 20px !important;
    color: rgb(217 217 217) !important;
  }

  body main:has(#choose-storage-folder) article > div:last-child {
    gap: 0 !important;
  }

  body main:has(#choose-storage-folder) article :is(summary, button)[title] {
    width: 32px !important;
    height: 32px !important;
  }

  body main:has(#choose-storage-folder) article > div:first-child > span:first-child,
  body main:has(#choose-storage-folder) article :is(summary, button)[title] {
    background-color: transparent !important;
    background-image: none !important;
    border-width: 0 !important;
  }

  html,
  body,
  body main {
    background-color: #161515 !important;
  }

  body,
  body *,
  body *::before,
  body *::after {
    box-shadow: none !important;
  }

  /* Remove decorative gradients from page backgrounds and structural blocks. */
  body,
  body :is(section, article, aside, header, footer, main, nav, form, dialog, thead),
  body .shadow-sm:not(button),
  body [class*="bg-gradient-"]:not(button):not([id$="-progress-bar"]),
  body :is(.schema-card, .consult-home-card, .mode-card, .mode-icon-box,
    .board-analysis-schema-card--accordion, .board-analysis-schema-card-body,
    .board-analysis-schema-accordion),
  body .consult-home-card::after,
  body .mode-shell::before {
    background-image: none !important;
  }

  body :is(section, article, div)[class*="bg-gradient-"]:not([id$="-progress-bar"]),
  body :is(.consult-home-card, .mode-card,
    .board-analysis-schema-card--accordion, .board-analysis-schema-card-body,
    .board-analysis-schema-accordion) {
    background-color: #171717 !important;
  }

  /* Buttons use solid fills in normal, hover and dynamically rendered states. */
  body :is(button, [role="button"], input[type="button"], input[type="submit"], input[type="reset"]),
  body :is(button, [role="button"])::before,
  body :is(button, [role="button"])::after,
  body a[class*="bg-gradient-"] {
    background-image: none !important;
  }

  body :is(button, [role="button"], input, a)[class*="bg-gradient-"] {
    background-color: #059669 !important;
  }

  body :is(button, [role="button"], input, a)[class*="bg-gradient-"]:hover {
    background-color: #10b981 !important;
  }

  /* Keep keyboard focus visible after removing Tailwind's shadow-based rings. */
  body :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--poker-active, #45a465) !important;
    outline-offset: 2px !important;
  }
}
