/* V27: desktop shell. Mobile rules remain in styles.css / update.css. */
.desktop-rail { display: none; }
.filter-type-label { display: none; }

@media (min-width: 960px) {
  :root { --rail-width: 80px; --gallery-gap: 16px; --page-gutter: 24px; }

  .app-shell {
    width: calc(100% - var(--rail-width));
    max-width: none;
    min-height: 100dvh;
    margin: 0 0 0 var(--rail-width);
  }
  .app-shell .topbar { display: none !important; }
  .app-shell .main { min-height: 100dvh !important; padding: 0 0 32px !important; }
  .view { scroll-margin-top: 24px; }

  .desktop-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 90;
    width: var(--rail-width);
    height: 100dvh;
    background: var(--bg);
    border-right: 1px solid var(--line);
    padding: 16px 0 14px;
  }
  .desktop-rail-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
  }
  .desktop-rail-main::-webkit-scrollbar { display: none; }
  .desktop-rail-bottom { margin-top: auto; padding-top: 20px; flex: 0 0 auto; }

  .app-shell .desktop-rail .header-collab {
    flex-direction: column;
    width: 44px !important;
    min-width: 44px !important;
    height: 96px !important;
    padding: 9px 7px !important;
    gap: 5px !important;
    margin: 0 0 2px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .08) !important;
  }
  .desktop-rail .header-round-logo {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
  }
  .desktop-rail .header-collab-x { font-size: 16px !important; line-height: 16px !important; margin: 0 !important; }

  .desktop-rail .bottom-nav {
    display: flex;
    flex-direction: column;
    align-items: center !important;
    gap: 12px;
    position: static;
    width: 100%;
    max-width: none;
    height: auto !important;
    padding: 0 !important;
    transform: none;
    background: transparent;
    border: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    flex: 0 0 auto;
  }
  .desktop-rail .icon-btn,
  .desktop-rail .bottom-item {
    position: relative;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    padding: 0 !important;
    border-radius: 16px;
    color: var(--text);
    transition: background .18s ease, transform .18s ease;
  }
  .desktop-rail .bottom-item span { display: none !important; }
  .desktop-rail .bottom-item svg,
  .desktop-rail .icon-btn > svg {
    width: 26px !important;
    height: 26px !important;
    transform: none !important;
  }
  .desktop-rail .bottom-item:hover,
  .desktop-rail .icon-btn:hover,
  .desktop-rail .bottom-item.active,
  .desktop-rail .menu-trigger[aria-expanded="true"] { background: var(--soft); }
  .desktop-rail button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
  .desktop-rail .bottom-item:active,
  .desktop-rail .icon-btn:active { transform: scale(.94); }
  .desktop-filter[aria-pressed="true"]::after {
    content: "";
    position: absolute;
    top: 9px;
    right: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 2px var(--bg);
  }
  .desktop-filter:disabled { opacity: .35; cursor: default; }

  /* Seven masonry columns, including laptop widths and desktop mode on phones. */
  .app-shell .masonry {
    columns: 7 auto;
    column-gap: var(--gallery-gap) !important;
    padding: 16px var(--page-gutter) 24px !important;
  }
  .app-shell #homeGrid { padding-top: 24px !important; }
  .app-shell .pin-card { margin-bottom: var(--gallery-gap); }
  .app-shell .pin-img-wrap,
  .app-shell .pin-card img { border-radius: 16px; }
  .thumbnail-only .pin-img-wrap { transition: filter .18s ease; }
  .thumbnail-only:hover .pin-img-wrap { filter: brightness(.93); }

  .menu-overlay { left: var(--rail-width); }
  .side-menu {
    left: var(--rail-width);
    width: 340px;
    border-right: 1px solid var(--line);
    box-shadow: 12px 0 40px rgba(0, 0, 0, .12);
    transform: translateX(-24px);
    opacity: 0;
    transition: transform .22s ease, opacity .22s ease, visibility .22s;
  }
  .side-menu.open { transform: translateX(0); opacity: 1; }

  /* Filters and share dialogs stay comfortably sized on a wide screen. */
  .sheet-overlay { padding: 24px 24px 24px calc(var(--rail-width) + 24px); align-items: center; }
  .sheet-overlay .sheet { max-width: 480px; max-height: calc(100dvh - 48px); border-radius: 24px; }
  /* Centered, vertical filter. Rows adapt to the available viewport height. */
  #filterSheet { padding: 12px 12px 12px calc(var(--rail-width) + 12px); align-items: center; }
  #filterSheet .filter-sheet {
    display: flex; flex-direction: column;
    width: 100%; max-width: 480px;
    max-height: calc(100dvh - 24px) !important;
    padding: clamp(10px, 2dvh, 22px) 24px;
    border-radius: 24px;
    overflow-y: auto !important;
  }
  #filterSheet .sheet-head { flex: 0 0 auto; margin: 0 0 8px !important; }
  #filterSheet .filter-type-label { display: none; }
  #filterSheet .filter-label { flex: 0 0 auto; margin: 8px 0 2px !important; }
  #filterSheet .filter-group { display: flex; flex-direction: column; flex: 0 0 auto; gap: 0; }
  #filterSheet .line { flex: 0 0 1px; margin: 8px 0 !important; }
  #filterSheet .filter-choice {
    height: clamp(16px, calc((100dvh - 176px) / 10), 42px) !important;
    min-height: 0; flex: none; padding: 0 6px !important; gap: 12px;
    border: 0; border-radius: 8px; background: transparent; text-align: left;
  }
  #filterSheet .filter-choice:hover { background: var(--soft); }
  #filterSheet .filter-choice i { width: 20px !important; height: 20px !important; flex: 0 0 20px; }
  #filterSheet .filter-choice.selected i { border: 6px solid var(--brand) !important; }
  #filterSheet .primary-sheet-btn { flex: 0 0 auto; width: 100%; margin: 10px 0 0; }
  #filterSheet button:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

  .search-head { position: sticky; top: 0; z-index: 40; background: var(--bg); padding: 20px var(--page-gutter) 8px; }
  .app-shell .search-page-search { height: 52px !important; border-radius: 18px !important; }
  .search-head #filterBtn { display: none; }
  .search-head .tool-row { padding-bottom: 0; }
  .batch-status { margin-inline: var(--page-gutter); }
  .home-hero { margin: 24px var(--page-gutter) 0; border-radius: 24px; }
  .hero-slider { border-radius: 24px; }
  .hero-search-wrap { width: min(640px, calc(100% - 48px)); left: 50%; right: auto; transform: translateX(-50%); }
  .home-ideas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; padding: 28px var(--page-gutter) 24px; }
  .home-ideas .idea-section { min-width: 0; padding: 0; }
  .home-ideas .idea-section h2 { font-size: 23px !important; }
  .home-ideas .strip { height: 150px !important; }
  .home-ideas .strip img { height: 150px !important; }

  .page-title-row { padding: 28px var(--page-gutter) 12px; }
  .saved-note { margin-left: var(--page-gutter) !important; }
  .empty-state { margin-inline: var(--page-gutter); }
  .app-shell .profile-card { max-width: 760px; margin: 32px auto 16px !important; padding: 28px !important; }
  .profile-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .profile-desc { max-width: 560px; }
  .history-tabs, .search-history-list { margin-inline: var(--page-gutter) !important; }
  .app-shell .detail-page { max-width: none; margin: 0; padding: 24px var(--page-gutter) 0; }
  .detail-board { position: relative; width: 100%; min-width: 0; }
  .detail-card {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    width: calc((100% - 6 * var(--gallery-gap)) / 7 * 4 + 3 * var(--gallery-gap));
    height: clamp(340px, calc(100dvh - 48px), 960px);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .035);
  }
  .detail-card .detail-photo-wrap {
    display: grid; place-items: center; min-width: 0; min-height: 0 !important;
    grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
    height: 100%; border-radius: 0; overflow: hidden; background: var(--soft) !important;
  }
  .detail-card #detailImage, .detail-card #detailVideo {
    min-width: 0 !important; min-height: 0 !important;
    width: 100% !important; height: 100% !important; max-width: 100% !important; max-height: 100% !important;
    object-fit: contain !important; border-radius: 0 !important; background: transparent !important;
  }
  .detail-card .detail-loading, .detail-card .detail-error { width: 100%; background: transparent; padding: 50px 16px; }
  .detail-card .detail-info { min-width: 0; min-height: 0; padding: clamp(12px, 1.25vw, 24px) !important; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  .detail-card .detail-actions { flex-wrap: wrap; gap: 6px; margin-bottom: 24px; }
  .detail-card .detail-icon-btn { min-width: 30px; height: 36px; padding: 0; }
  .detail-card .detail-icon-btn svg { width: 23px; height: 23px; }
  .detail-card .save-big { margin-left: auto; padding-inline: 12px; }
  .detail-card .author-row { align-items: center; margin-bottom: 18px; }
  .detail-card .author-row > div:last-child { min-width: 0; overflow-wrap: anywhere; }
  .detail-card .author-row b { font-size: 14px; }
  .detail-card .author-row small { font-size: 12px; margin-top: 4px; }
  .detail-card .detail-info h1 { font-size: clamp(20px, 1.6vw, 28px) !important; line-height: 1.2 !important; overflow-wrap: anywhere; }
  .detail-card .detail-info p { line-height: 1.5 !important; overflow-wrap: anywhere; }
  .detail-card .meta-row { margin-bottom: 0; gap: 6px; }
  .detail-card .meta-row span { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
  .detail-board > .detail-related > .related-title { display: none; }
  .app-shell #relatedGrid {
    position: relative; columns: auto; width: 100%; padding: 0 !important; min-height: 340px;
  }
  .detail-board #relatedGrid > .pin-card { margin: 0 !important; }
  .detail-board #relatedGrid .title {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
    overflow: hidden; font-size: 12px !important; line-height: 1.3 !important;
  }
  .detail-board #relatedGrid > .empty-state { position: absolute; left: calc((100% + var(--gallery-gap)) / 7 * 4); right: 0; margin: 0; }
  .toast { left: calc(50% + var(--rail-width) / 2); top: auto !important; bottom: 28px !important; }
}

@media (min-width: 960px) and (max-width: 1279px) {
  :root { --gallery-gap: 12px; --page-gutter: 16px; }
  .home-ideas { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) and (max-height: 640px) {
  .desktop-rail { padding-block: 10px; }
  .desktop-rail-main, .desktop-rail .bottom-nav { gap: 6px; }
  .desktop-rail-bottom { padding-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .desktop-rail *, .desktop-rail *::before, .desktop-rail *::after { animation: none !important; transition: none !important; }
  .desktop-rail .bottom-item svg { transition: none !important; }
  .app-shell .profile-desc, .app-shell .profile-socials .profile-social { opacity: 1; transform: none; animation: none !important; }
}

@media (min-width: 960px) and (max-height: 440px) {
  #filterSheet .filter-sheet { padding: 8px 22px; }
  #filterSheet .sheet-head { margin-bottom: 4px !important; }
  #filterSheet .sheet-head h2 { font-size: 18px !important; }
  #filterSheet .sheet-x { width: 26px !important; height: 26px !important; }
  #filterSheet .filter-label { margin: 3px 0 1px !important; }
  #filterSheet .line { margin: 4px 0 !important; }
  #filterSheet .filter-choice { font-size: 13px !important; }
  #filterSheet .filter-choice i { width: 15px !important; height: 15px !important; flex-basis: 15px; }
  #filterSheet .filter-choice.selected i { border-width: 4px !important; }
  #filterSheet .primary-sheet-btn { height: 32px !important; margin-top: 4px; }
  .detail-card { height: calc(100dvh - 32px); min-height: 260px; }
  .app-shell .detail-page { padding-top: 16px; }
}
