/* 僅補歷史內頁與對話框；不調整原版首頁、讀信及選單。 */
.mobile-history [hidden] {
  display: none !important;
}
.mobile-history #div-history {
  display: block;
}
.mobile-history #history-mailbox-status,
.mobile-history #history-recover-message {
  color: #a00;
  overflow-wrap: anywhere;
}
.mobile-history #history-recover-retry {
  padding: 1em;
  border: 1px solid #aaa;
}
.mobile-history #history-recover-key {
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  font-size: 16px;
}
.mobile-history #history-recover-form button {
  min-height: 44px;
  margin: 0.5em 0.5em 0.5em 0;
}
.mobile-history-dialog {
  z-index: 2000 !important;
}
.history-page .ui-widget-overlay {
  z-index: 1999 !important;
}

/* 手機上下控制列縮小並換行；桌面共用模板與操作邏輯保持原樣。 */
.mobile-history #div-history-help {
  margin: 0 0 0.65rem;
  font-size: 13px;
  line-height: 1.5;
}
.mobile-history #div-history-help p {
  margin-block: 0.4em;
}
.mobile-history #div-history > p:first-child {
  margin-block: 0.5em;
  font-size: 13px;
}
.mobile-history #div-history > p:first-child label {
  display: block;
  margin-bottom: 4px;
}
.mobile-history #select_domain {
  width: 100%;
  min-height: 36px;
}
.mobile-history #history_wrapper .dt-layout-row:not(.dt-layout-table) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-block: 0.35rem;
}
.mobile-history #history_wrapper .dt-layout-row:not(.dt-layout-table) .dt-layout-cell {
  flex: 1 1 160px;
  min-width: 0;
  width: auto;
  margin: 0;
  padding: 0;
  text-align: start;
}
.mobile-history .dt-length,
.mobile-history .dt-search,
.mobile-history .dt-length label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.mobile-history .dt-search {
  justify-content: flex-end;
}
.mobile-history .dt-search label {
  flex: 0 0 auto;
}
.mobile-history .dt-search input {
  flex: 1 1 60px;
  width: 0;
  min-width: 60px;
}
.mobile-history #history_wrapper .dt-input {
  box-sizing: border-box;
  min-height: 34px;
  margin: 0;
  padding: 4px 6px;
  font-size: 16px;
}
.mobile-history .dt-info {
  padding: 0;
  font-size: 12px;
  line-height: 1.4;
}
.mobile-history .dt-paging nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 3px;
}
.mobile-history #history_wrapper .dt-paging-button {
  min-width: 32px;
  min-height: 32px;
  margin: 0;
  padding: 4px;
  font-size: 12px;
  line-height: 1.2;
}
.mobile-history .history-toolbar {
  gap: 4px;
  padding-block: 4px;
}
.mobile-history .history-toolbar .ui-button {
  flex: 1 1 calc(33.333% - 4px);
  box-sizing: border-box;
  min-width: 0;
  min-height: 36px;
  margin: 0;
  padding: 6px;
  font-size: 12.5px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.mobile-history #history .history-row-action {
  min-width: 32px;
  min-height: 32px;
  width: 32px;
  height: 32px;
  font-size: 16px;
}
.mobile-history #history-recover-form button,
.mobile-history-dialog .ui-button,
.mobile-history-dialog .history-format-controls label {
  min-height: 36px;
  min-width: 36px;
  font-size: 12.5px;
}
.mobile-history-dialog .ui-dialog-titlebar {
  min-height: 36px;
  padding-inline-end: 40px;
  font-size: 14px;
}
.mobile-history-dialog .ui-dialog-titlebar-close {
  width: 36px;
  height: 36px;
  font-size: 0;
}
.mobile-history-dialog .ui-dialog-titlebar-close::before {
  font-size: 22px;
  line-height: 32px;
}
@media (max-width: 600px) {
  .mobile-history #history thead th {
    min-height: 36px;
    padding-block: 6px;
    font-size: 13px;
  }
  .mobile-history #history tbody tr {
    grid-template-columns: 28px minmax(0, 1fr) 34px 34px;
    padding-block: 6px;
  }
  .mobile-history #history input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }
  .mobile-history #history tbody td:nth-child(2) {
    font-size: 14px;
  }
  .mobile-history #history tbody td:nth-child(3) {
    font-size: 12px;
  }
}
