:root {
  --legenda-brand: #cf202e;
  --legenda-ink: oklch(21% 0.018 22);
  --legenda-muted: oklch(47% 0.018 22);
  --legenda-line: oklch(89% 0.01 22);
  --legenda-panel: oklch(99% 0.006 22);
  --legenda-shade: oklch(15% 0.018 22 / 48%);
}

.legenda-mobile-nav,
.legenda-mobile-sheet-layer {
  display: none;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

@media (max-width: 767px) {
  body {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }

  .legenda-mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99998;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--legenda-panel);
    border-top: 1px solid var(--legenda-line);
    box-shadow: 0 -10px 30px oklch(20% 0.018 22 / 12%);
  }

  .legenda-mobile-nav__button {
    min-height: 58px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--legenda-muted);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 5px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .legenda-mobile-sheet__icon-button:hover,
  .legenda-mobile-sheet__icon-button:hover,
  .legenda-mobile-sheet__item:hover,
  .legenda-mobile-nav__button:hover {
    color: var(--legenda-brand) !important;
    background: oklch(96% 0.028 22) !important;
  }

  .legenda-mobile-nav__button svg,
  .legenda-mobile-sheet__item-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .legenda-mobile-nav__button[aria-selected="true"] {
    color: var(--legenda-brand);
    background: oklch(96% 0.028 22);
  }

  .legenda-mobile-sheet-layer {
    position: fixed;
    inset: 0 0 78px;
    z-index: 99997;
    display: grid;
    align-items: end;
    pointer-events: none;
    opacity: 0;
    transition: opacity 180ms ease-out;
  }

  .legenda-mobile-sheet-layer.is-open {
    pointer-events: auto;
    opacity: 1;
  }

  .legenda-mobile-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: var(--legenda-shade);
  }

  .legenda-mobile-sheet {
    position: relative;
    width: 100%;
    max-height: min(72vh, 620px);
    overflow: auto;
    box-sizing: border-box;
    padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
    background: var(--legenda-panel);
    box-shadow: 0 -18px 50px oklch(18% 0.02 22 / 22%);
    transform: translateY(24px);
    transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .legenda-mobile-sheet-layer.is-open .legenda-mobile-sheet {
    transform: translateY(0);
  }

  .legenda-mobile-sheet__handle {
    width: 42px;
    height: 4px;
    margin: 4px auto 12px;
    border-radius: 999px;
    background: oklch(82% 0.01 22);
  }

  .legenda-mobile-sheet__topbar {
    display: grid;
    grid-template-columns: 42px 1fr 42px;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
  }

  .legenda-mobile-sheet__icon-button {
    width: 42px;
    height: 42px;
    border: 1px solid var(--legenda-line);
    border-radius: 8px;
    background: var(--legenda-panel);
    color: var(--legenda-ink);
    display: grid;
    place-items: center;
    cursor: pointer;
  }

  .legenda-mobile-sheet__icon-button svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .legenda-mobile-sheet__icon-button[hidden] {
    visibility: hidden;
    display: block;
  }

  .legenda-mobile-sheet__heading {
    text-align: center;
  }

  .legenda-mobile-sheet__title {
    margin: 0;
    color: var(--legenda-ink);
    font-size: 20px;
    line-height: 1.2;
    font-weight: 780;
  }

  .legenda-mobile-sheet__description {
    margin: 5px 0 0;
    color: var(--legenda-muted);
    font-size: 14px;
    line-height: 1.35;
  }

  .legenda-mobile-sheet__list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
  }

  .legenda-mobile-sheet__item {
    width: 100%;
    min-height: 58px;
    box-sizing: border-box;
    border: 1px solid var(--legenda-line);
    border-radius: 8px;
    padding: 11px 12px;
    background: var(--legenda-panel);
    color: var(--legenda-ink);
    text-decoration: none;
    font: inherit;
    text-align: left;
    display: grid;
    grid-template-columns: 38px 1fr 18px;
    align-items: center;
    gap: 10px;
    cursor: pointer;
  }

  .legenda-mobile-sheet__item-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--legenda-brand);
    background: oklch(96% 0.028 22);
  }

  .legenda-mobile-sheet__item-title {
    display: block;
    font-size: 15px;
    font-weight: 720;
    line-height: 1.25;
  }

  .legenda-mobile-sheet__item-meta {
    display: block;
    margin-top: 2px;
    color: var(--legenda-muted);
    font-size: 12px;
    line-height: 1.3;
  }

  .legenda-mobile-sheet__chevron {
    color: oklch(58% 0.015 22);
    font-size: 20px;
  }
}
