/*
 * Mobile layout corrections.  These rules fix sizing at the component level;
 * they deliberately do not hide horizontal overflow at the page level.
 */
@media (max-width: 991px) {
  :root { --mobile-nav-visible-height: 70px; }

  body {
    padding-bottom: calc(var(--mobile-nav-visible-height) + env(safe-area-inset-bottom) + 20px);
  }

  main.container {
    min-width: 0;
    padding-bottom: calc(var(--mobile-nav-visible-height) + env(safe-area-inset-bottom) + 28px) !important;
  }

  .mobile-nav {
    height: calc(var(--mobile-nav-visible-height) + env(safe-area-inset-bottom)) !important;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)) !important;
    box-sizing: border-box;
  }

  .app-nav > .container-fluid {
    min-height: 62px;
    align-items: center;
  }

  .app-nav .navbar-brand,
  .app-nav .navbar-toggler,
  .app-nav .reminder-mobile {
    align-self: center;
  }

  .journal-feed-shell,
  .journal-feed-column,
  .journal-post-card,
  .journal-post-card > .d-flex,
  .journal-post-card > .d-flex > .d-flex:first-child {
    min-width: 0;
  }

  /* Match the container's 12px side padding: larger gutters spill on tablets. */
  .journal-feed-shell { --bs-gutter-x: 24px; }

  .journal-post-card > .d-flex:first-child {
    align-items: flex-start !important;
  }

  .journal-post-card > .d-flex:first-child > .d-flex:first-child {
    flex: 1 1 auto;
  }

  .journal-post-card .author,
  .journal-post-card h2,
  .journal-post-card .entry-content,
  .journal-post-card .entry-context,
  .journal-post-card .entry-context span {
    overflow-wrap: anywhere;
  }

  .journal-post-card .post-menu,
  .journal-post-card .dropdown {
    flex: 0 0 auto;
  }

  [data-reader-open] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    max-width: 100%;
    white-space: normal;
    position: relative;
    z-index: 1;
  }
}

@media (max-width: 575px) {
  main.container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .journal-feed-shell { --bs-gutter-x: 0; }

  .journal-post-card {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding: 15px !important;
  }

  /* Metadata previously had a fixed max width and nowrap/ellipsis. */
  .journal-post-card .meta {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    line-height: 1.4;
  }

  .journal-post-card .avatar {
    flex: 0 0 34px;
  }

  .journal-post-card .type-badge,
  .journal-post-card .entry-pin-label {
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .filter-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    overflow: visible;
  }

  .filter-bar a {
    min-width: 0;
    padding-left: 5px;
    padding-right: 5px;
    font-size: clamp(.62rem, 2.9vw, .74rem);
  }

  .mobile-nav a {
    min-width: 0 !important;
  }

  .mobile-nav .mobile-create {
    flex: 0 0 54px !important;
    min-width: 54px !important;
    width: 54px !important;
    height: 54px !important;
    margin-top: -18px !important;
  }
}

@media (max-width: 360px) {
  .journal-post-card .type-badge,
  .journal-post-card .entry-pin-label {
    display: none;
  }

  .mobile-nav {
    padding-left: 3px !important;
    padding-right: 3px !important;
  }
}

@media (min-width: 992px) {
  /* Desktop retains its established spacing and bottom navigation is absent. */
  body { padding-bottom: 0; }
}

@media (max-width: 991px) {
  .learning-shell main.container {
    margin-left: 0;
    width: 100%;
    max-width: none;
    padding-left: 18px !important;
    padding-right: 18px !important;
  }
}
/* Reading-first mobile surfaces and the single native post-action sheet. */
dialog.post-action-sheet{position:fixed;inset:auto 0 0;width:min(100%,540px);max-width:100%;max-height:82dvh;margin:0 auto;padding:12px 14px max(14px,env(safe-area-inset-bottom));border:1px solid var(--ds-line,#dce5df);border-radius:20px 20px 0 0;background:var(--ds-surface,#fff);color:var(--ds-text,#203246);overflow-y:auto;overscroll-behavior:contain;box-sizing:border-box}
dialog.post-action-sheet::backdrop{background:rgba(15,30,45,.4)}
dialog.post-action-sheet>header{display:flex;align-items:center;justify-content:space-between;gap:12px;position:sticky;top:-12px;background:var(--ds-surface,#fff);z-index:1;padding:6px 0}
dialog.post-action-sheet h2{font-size:16px;margin:0}dialog.post-action-sheet>header button{width:44px;height:44px;border:0;background:var(--ds-soft,#edf3ef);color:inherit;border-radius:50%}
dialog.post-action-sheet>.dropdown-menu{display:block!important;position:static!important;inset:auto!important;transform:none!important;float:none;min-width:0!important;max-width:none!important;width:100%!important;max-height:none!important;overflow:visible!important;border:0!important;box-shadow:none!important;padding:0!important;margin:0!important;background:transparent!important}
dialog.post-action-sheet .dropdown-item{white-space:normal;min-height:48px;display:flex;align-items:center;gap:8px;border-radius:10px;font-size:15px!important}
dialog.post-action-sheet .entry-color-menu>div,dialog.post-action-sheet .entry-icon-menu>div{display:flex;flex-wrap:wrap;gap:8px}
dialog.post-action-sheet .entry-color-chip,dialog.post-action-sheet .entry-icon-chip{width:44px!important;height:44px!important;min-width:44px}
dialog.post-action-sheet .text-danger{margin-top:8px;border-top:1px solid var(--ds-line,#dce5df)}
.mobile-disclosure>summary{min-height:48px;padding:12px 14px;border:1px solid var(--ds-line,#dce5df);border-radius:12px;background:var(--ds-surface,#fff);font-size:14px;font-weight:650;cursor:pointer;margin-bottom:12px}
.post-read-more{min-height:44px;padding:6px 0;border:0;background:transparent;color:var(--ds-primary,#245d7e);font-size:14px;font-weight:650}.reader-body .post-read-more{display:none}
.reader-auto-options[open]>.reader-still-mode{position:absolute;top:152px;right:0;width:210px;z-index:4;background:var(--ds-surface,#fff);font-size:12px;border:1px solid #d4e1e8;border-radius:10px}
@media(min-width:768px){.mobile-disclosure>summary{display:none}}
@media(max-width:767px){
 main .entry-card,.reader-body .entry-card{padding:16px!important;border-radius:14px!important;min-width:0}
 main .entry-card .entry-content,.reader-body .reader-full-content,main .entry-card .detail-content{font-size:16px!important;line-height:1.75!important;overflow-wrap:anywhere}
 main .entry-card h2{font-size:19px!important;line-height:1.4!important}
 .entry-card .meta{font-size:12px!important;line-height:1.5;white-space:normal!important;max-width:none!important}
 .entry-card .post-menu{width:44px!important;height:44px!important;min-width:44px!important;min-height:44px!important}
 .entry-card .post-actions a,.entry-card .post-actions button{min-height:44px}
 .entry-card .author{font-size:14px;overflow-wrap:anywhere}
 .learning-journey{padding:14px!important}.learning-journey h2{font-size:19px!important}
 .learning-journey .journey-actions{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
 .learning-journey .journey-actions a{padding:10px 7px;font-size:12px}.learning-journey .journey-actions small{font-size:11px}
 .learning-journey .journey-stats strong{font-size:22px}
}
