@layer components {

  /* ===================================================
     Floating read-aloud button wrapper + popover
     =================================================== */

  .tgk-read-aloud-wrapper {
    position: relative;
    pointer-events: auto;
  }

  .tgk-read-aloud-popover {
    position: absolute;
    bottom: 0;
    left: calc(100% + 0.75rem);
    width: 260px;
    padding: 1rem 1.1rem;
    border: 1px solid var(--gold-border);
    border-radius: 1rem;
    background:
      linear-gradient(
        180deg,
        color-mix(in srgb, var(--bg-surface) 94%, transparent),
        color-mix(in srgb, var(--bg-alt) 88%, transparent)
      );
    box-shadow: var(--page-shadow-soft);
    backdrop-filter: blur(4px);
    z-index: var(--z-floating, 10050);
  }

  .tgk-read-aloud-popover-copy {
    margin: 0 0 0.75rem;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.55;
  }

  .tgk-read-aloud-popover-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 160ms ease, border-color 160ms ease;
  }

  .tgk-read-aloud-popover-link:hover,
  .tgk-read-aloud-popover-link:focus-visible {
    color: var(--highlight);
    border-bottom-color: currentColor;
  }

  @media (max-width: 640px) {
    .tgk-read-aloud-popover {
      bottom: calc(100% + 0.5rem);
      left: 0;
      width: 240px;
    }
  }

  /* ===================================================
     Full guide page styles (/accessibility/read-aloud/)
     =================================================== */

  .read-aloud-guide-kicker {
    margin: 0 0 1rem;
    color: var(--text-muted);
    font-size: 0.98rem;
    line-height: 1.6;
  }

  .read-aloud-guide-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--gold-border);
    border-radius: 1rem;
    background:
      linear-gradient(
        180deg,
        color-mix(in srgb, var(--bg-surface) 88%, transparent),
        color-mix(in srgb, var(--bg-alt) 80%, transparent)
      );
    box-shadow: var(--page-shadow-soft);
  }

  .read-aloud-guide-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-size: 0.96rem;
  }

  .read-aloud-guide-table th,
  .read-aloud-guide-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid color-mix(in srgb, var(--section-border) 82%, transparent);
    text-align: left;
    vertical-align: top;
  }

  .read-aloud-guide-table th {
    color: var(--strong-text);
    font-weight: 700;
    background: color-mix(in srgb, var(--accent-soft) 62%, transparent);
  }

  .read-aloud-guide-table tbody tr:last-child td {
    border-bottom: 0;
  }

  .read-aloud-guide-table td {
    color: var(--text-secondary);
  }

  .read-aloud-guide-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .read-aloud-guide-card {
    padding: clamp(1rem, 2vw, 1.25rem);
    border: 1px solid var(--gold-border);
    border-radius: 1rem;
    background:
      linear-gradient(
        180deg,
        color-mix(in srgb, var(--bg-surface) 90%, transparent),
        color-mix(in srgb, var(--bg-alt) 84%, transparent)
      );
    box-shadow: var(--page-shadow-soft);
  }

  .read-aloud-guide-card h3,
  .read-aloud-guide-card h4 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: var(--strong-text);
  }

  .read-aloud-guide-card p {
    margin-top: 0;
    margin-bottom: 0.85rem;
  }

  .read-aloud-guide-card ol,
  .read-aloud-guide-card ul {
    margin: 0;
    padding-left: 1.2rem;
  }

  .read-aloud-guide-card li + li {
    margin-top: 0.45rem;
  }

  .read-aloud-guide-card strong {
    color: var(--strong-text);
  }

  .read-aloud-guide-note {
    margin-top: 0.9rem;
    color: var(--text-muted);
    font-size: 0.92rem;
  }

  .read-aloud-guide-callout {
    padding: 1rem 1.1rem;
    border-left: 3px solid var(--text-accent);
    border-radius: 0.8rem;
    background: color-mix(in srgb, var(--accent-soft) 54%, transparent);
    color: var(--text-secondary);
  }

  .read-aloud-guide-callout p:last-child {
    margin-bottom: 0;
  }

  .read-aloud-guide-shortcut {
    display: inline-flex;
    align-items: center;
    min-height: 1.9rem;
    padding: 0.15rem 0.55rem;
    border: 1px solid var(--gold-border);
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent-soft) 44%, transparent);
    color: var(--strong-text);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
  }

  @media (max-width: 800px) {
    .read-aloud-guide-grid {
      grid-template-columns: 1fr;
    }
  }

  @media (max-width: 640px) {
    .read-aloud-guide-table th,
    .read-aloud-guide-table td {
      padding: 0.8rem 0.85rem;
    }
  }
}
