/**
 * [INPUT]: 依赖 account-detail-app.css 的身份头、轶闻卡和十入口双列书斋语义，以及动态视口单位
 * [OUTPUT]: 提供手机常用高度下一屏完整展示首页的紧凑栅格，并为矮屏保留可读的降级布局
 * [POS]: public 的账号详情移动视口约束层，最后加载以覆盖桌面比例，不修改弹层内部滚动规则
 * [PROTOCOL]: 变更时更新此头部，然后检查 CLAUDE.md
 */

@media (max-width: 680px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .container {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    padding: 0 12px 10px;
    grid-template-rows: 72px 124px minmax(0, 1fr);
    gap: 8px;
    overflow: hidden;
  }

  .account-app-header {
    min-height: 0;
    height: 72px;
    padding: 9px 1px 7px;
  }

  .account-app-identity .user-name {
    font-size: 18px;
  }

  .account-app-resources {
    margin-top: 2px;
    font-size: 11px;
  }

  .section-card.lore-section {
    height: 124px;
  }

  .lore-app-content {
    height: 86px;
    padding: 10px 12px 8px;
  }

  .lore-app-heading {
    gap: 7px;
  }

  .lore-app-heading img {
    width: 20px;
    height: 20px;
  }

  .lore-app-heading h2 {
    font-size: 18px;
  }

  .lore-app-heading > span {
    font-size: 15px;
    line-height: 1.35;
  }

  .lore-app-copy {
    min-height: 36px;
    margin-top: 7px;
    font-size: 13px;
    line-height: 1.4;
    -webkit-line-clamp: 2;
  }

  .lore-section .section-footer {
    min-height: 37px;
    height: 37px;
    padding: 0 12px;
  }

  .lore-section .section-footer .btn {
    min-height: 36px;
    font-size: 14px;
  }

  .shrine-section,
  .shrine-board,
  .shrine-column {
    min-height: 0;
    height: 100%;
  }

  .shrine-board {
    gap: 7px;
    align-items: stretch;
  }

  .shrine-column {
    grid-template-rows: repeat(5, minmax(0, 1fr));
    align-content: stretch;
    gap: 7px;
  }

  .shrine-module,
  .shrine-wish,
  .shrine-treasure-card,
  .shrine-heritage,
  .shrine-voucher,
  .shrine-rumors,
  .shrine-collection,
  .shrine-milestone,
  .shrine-gambling,
  .shrine-pawn,
  .shrine-ranking {
    min-height: 0;
    height: 100%;
    padding: 9px 10px;
    overflow: hidden;
  }

  .shrine-module-heading {
    gap: 5px;
  }

  .shrine-module-icon {
    width: 18px;
    height: 18px;
  }

  .shrine-module-title {
    font-size: 16px;
  }

  .shrine-module-trailing {
    font-size: 11px;
  }

  .shrine-module-divider {
    margin: 7px 0 6px;
  }

  .shrine-module-body {
    overflow: hidden;
    font-size: 12px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .shrine-collection {
    padding: 0;
  }

  .shrine-collection-grid {
    min-height: 0;
    height: 100%;
  }

  .shrine-collection-cell {
    padding: 0 7px;
    gap: 4px;
    font-size: 14px;
  }

  .shrine-collection-icon {
    width: 17px;
    height: 17px;
  }
}

@media (max-width: 360px), (max-height: 700px) {
  .container {
    padding-right: 8px;
    padding-left: 8px;
    grid-template-rows: 64px 100px minmax(0, 1fr);
    gap: 6px;
  }

  .account-app-header {
    height: 64px;
  }

  .section-card.lore-section {
    height: 100px;
  }

  .lore-app-content {
    height: 66px;
    padding: 7px 10px 6px;
  }

  .lore-section .section-footer {
    min-height: 33px;
    height: 33px;
  }

  .lore-app-copy {
    min-height: 18px;
    margin-top: 5px;
    -webkit-line-clamp: 1;
  }

  .shrine-board,
  .shrine-column {
    gap: 5px;
  }

  .shrine-module,
  .shrine-wish,
  .shrine-treasure-card,
  .shrine-heritage,
  .shrine-voucher,
  .shrine-rumors,
  .shrine-milestone,
  .shrine-gambling,
  .shrine-pawn,
  .shrine-ranking {
    padding: 7px 8px;
  }

  .shrine-module-body {
    -webkit-line-clamp: 1;
  }
}

/*
 * 首屏收束：新版书斋是“入口面板”，不是长列表。
 * 12 个入口按一张手机画布重新排成“行商 + 六行双列”，内容只在卡片内截断，
 * 详情仍由各自弹层承载。该层必须位于全部主题样式之后，避免 min-height 被主题覆盖。
 */
@media (max-width: 680px), (max-height: 760px) {
  html[data-ui-mode="new"],
  html[data-ui-mode="new"] body {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  html[data-ui-mode="new"] body {
    overscroll-behavior: none;
  }

  html[data-ui-mode="new"] .container {
    --account-header-height: clamp(64px, 10.8dvh, 78px);
    width: 100%;
    height: 100dvh;
    min-height: 0;
    box-sizing: border-box;
    padding: 0 16px calc(60px + env(safe-area-inset-bottom));
    gap: 8px;
    grid-template-rows: var(--account-header-height) minmax(0, 1fr);
    overflow: hidden;
  }

  html[data-ui-mode="new"] .account-app-header {
    min-height: 0;
    height: var(--account-header-height);
    box-sizing: border-box;
    padding: 9px 1px 7px;
  }

  html[data-ui-mode="new"] .shrine-section {
    min-height: 0;
    height: 100%;
    padding: 0 0 48px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  html[data-ui-mode="new"] .shrine-view-panel[data-shrine-view-panel="team"] {
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  html[data-ui-mode="new"] .shrine-board {
    min-height: 0;
    height: auto;
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(7, minmax(0, 1fr));
    grid-auto-flow: row;
    gap: 7px;
    align-items: stretch;
    overflow: hidden;
  }

  html[data-ui-mode="new"] .shrine-column {
    min-height: 0;
    display: contents;
  }

  html[data-ui-mode="new"] .shrine-module,
  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry,
  html[data-ui-mode="new"] .shrine-module.shrine-collection {
    min-width: 0;
    min-height: 0;
    height: auto;
    box-sizing: border-box;
    padding: 8px;
    border-radius: 16px;
    overflow: hidden;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry {
    grid-column: 1 / -1;
  }

  html[data-ui-mode="new"] .shrine-module-heading {
    inset: auto 10px 8px;
    gap: 5px;
  }

  html[data-ui-mode="new"] .shrine-module-icon {
    width: 17px;
    height: 17px;
  }

  html[data-ui-mode="new"] .shrine-module-title {
    min-width: 0;
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html[data-ui-mode="new"] .shrine-module-trailing {
    font-size: 10px;
  }

  html[data-ui-mode="new"] .shrine-module-body {
    right: 10px;
    bottom: 30px;
    max-width: 76%;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html[data-ui-mode="new"] .shrine-collection {
    padding: 7px;
  }

  html[data-ui-mode="new"] .shrine-collection-grid {
    width: 100%;
    height: 100%;
    min-height: 0;
    gap: 4px;
  }

  html[data-ui-mode="new"] .shrine-collection-cell {
    min-width: 0;
    min-height: 0;
    padding: 4px;
    gap: 3px;
    border-radius: 9px;
    font-size: 11px;
  }

  html[data-ui-mode="new"] .shrine-collection-icon {
    width: 18px;
    height: 18px;
  }

  html[data-ui-mode="new"] .shrine-settings-entry {
    flex: 0 0 40px;
    height: 40px;
    min-height: 0;
    margin-top: 5px;
  }

  html[data-ui-mode="new"] .shrine-settings-entry button {
    min-height: 40px;
    height: 40px;
    padding: 5px 10px;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 7px;
    border-radius: 14px;
  }

  html[data-ui-mode="new"] .shrine-settings-entry img {
    width: 20px;
    height: 20px;
  }

  html[data-ui-mode="new"] .shrine-settings-entry strong {
    font-size: 13px;
  }

  html[data-ui-mode="new"] .shrine-settings-entry small {
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html[data-ui-mode="new"] .shrine-settings-entry b {
    font-size: 20px;
  }

  html[data-ui-mode="new"] .shrine-bottom-nav {
    width: 190px;
    height: 46px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  html[data-ui-mode="new"] .shrine-bottom-nav button {
    height: 34px;
  }

  html[data-ui-mode="new"] .shrine-view-panel[data-shrine-view-panel="map"] {
    min-height: 0;
    height: 100%;
    overflow: auto;
  }

  /* 行商卡由 merchant 专属样式承载，首屏只保留状态、金额与进度。 */
  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry {
    min-height: 0;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-entry-copy {
    inset: auto auto 11px 14px;
    max-width: 55%;
    gap: 4px;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-entry-heading {
    gap: 7px;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-entry-heading strong {
    font-size: clamp(1.05rem, 3.5vw, 1.45rem);
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-entry-heading small {
    max-width: 130px;
    font-size: .7rem;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-entry-principal {
    gap: 4px;
    font-size: .8rem;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-entry-principal b {
    width: 13px;
    height: 13px;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-progress,
  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-entry-idle {
    right: 14px;
    bottom: 13px;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-progress {
    left: 52%;
    height: 8px;
  }
}

@media (max-width: 390px), (max-height: 700px) {
  html[data-ui-mode="new"] .container {
    --account-header-height: 64px;
    padding-right: 10px;
    padding-left: 10px;
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
    gap: 6px;
  }

  html[data-ui-mode="new"] .shrine-section {
    padding-bottom: 44px;
  }

  html[data-ui-mode="new"] .shrine-board {
    gap: 5px;
  }

  html[data-ui-mode="new"] .shrine-module,
  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry,
  html[data-ui-mode="new"] .shrine-module.shrine-collection {
    padding: 6px;
    border-radius: 13px;
  }

  html[data-ui-mode="new"] .shrine-module-heading {
    inset: auto 8px 6px;
  }

  html[data-ui-mode="new"] .shrine-module-icon {
    width: 15px;
    height: 15px;
  }

  html[data-ui-mode="new"] .shrine-module-title {
    font-size: 13px;
  }

  html[data-ui-mode="new"] .shrine-module-body {
    right: 8px;
    bottom: 25px;
    font-size: 9px;
  }

  html[data-ui-mode="new"] .shrine-collection {
    padding: 5px;
  }

  html[data-ui-mode="new"] .shrine-collection-cell {
    padding: 3px;
    font-size: 10px;
  }

  html[data-ui-mode="new"] .shrine-collection-icon {
    width: 15px;
    height: 15px;
  }

  html[data-ui-mode="new"] .shrine-settings-entry {
    flex-basis: 34px;
    height: 34px;
    margin-top: 4px;
  }

  html[data-ui-mode="new"] .shrine-settings-entry button {
    min-height: 34px;
    height: 34px;
    padding: 4px 8px;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    gap: 5px;
    border-radius: 12px;
  }

  html[data-ui-mode="new"] .shrine-settings-entry img {
    width: 17px;
    height: 17px;
  }

  html[data-ui-mode="new"] .shrine-settings-entry strong {
    font-size: 11px;
  }

  html[data-ui-mode="new"] .shrine-settings-entry small {
    display: none;
  }

  html[data-ui-mode="new"] .shrine-bottom-nav {
    width: 174px;
    height: 42px;
  }

  html[data-ui-mode="new"] .shrine-bottom-nav button {
    height: 30px;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-entry-copy {
    inset: auto auto 8px 10px;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-entry-heading strong {
    font-size: 1rem;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-entry-heading small {
    max-width: 90px;
    font-size: .62rem;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-entry-principal {
    font-size: .7rem;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-progress,
  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-entry-idle {
    right: 10px;
    bottom: 10px;
  }

  html[data-ui-mode="new"] .shrine-module.shrine-merchant-entry .merchant-progress {
    left: 50%;
  }
}
