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

  .main-content,
  .page,
  .workspace,
  .form-card,
  .meihua-workspace,
  .meihua-shell,
  .meihua-card,
  .liuyao-workspace,
  .liuyao-shell,
  .liuyao-card {
    max-width: 100%;
    box-sizing: border-box;
  }

  .workspace,
  .meihua-workspace {
    padding-left: 16px;
    padding-right: 16px;
    overflow-x: hidden;
  }

  .form-card {
    padding-left: 16px;
    padding-right: 16px;
    overflow-x: hidden;
  }

  .field,
  .field-group,
  .basic-grid,
  .date-mode-panel,
  .time-left,
  .time-right,
  .location-field,
  .birth-time-controls,
  .birth-time-controls .time-select-row,
  .wide-location {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  input[type="text"],
  input[type="number"],
  select,
  .date-display,
  .date-trigger,
  .meihua-question {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 48px;
    min-height: 48px !important;
    box-sizing: border-box !important;
    font-size: 16px;
  }

  .date-trigger {
    height: 54px;
    min-height: 54px !important;
  }

  .time-layout,
  .date-mode-panel {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 18px !important;
  }

  .date-mode-panel.hidden,
  .bazi-mode-panel.hidden,
  .hidden {
    display: none !important;
  }

  .time-right {
    padding: 0 !important;
    justify-self: stretch;
  }

  .birth-time-controls .time-select-row,
  .time-select-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 10px !important;
    margin: 0 !important;
  }

  .wide-location {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 48px !important;
  }

  .search-btn {
    width: 48px;
    min-width: 48px;
    min-height: 48px;
    box-sizing: border-box;
  }

  .solar-line,
  .birth-known-line {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    box-sizing: border-box;
  }

  .solar-line > span:not(.switch-ui):not(.help-dot),
  .birth-known-line > span:not(.switch-ui) {
    min-width: 0;
  }

  .input-mode {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    width: 100%;
  }

  .input-mode .mode-pill,
  .calendar-switch {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  .page-header.liuyao-title {
    min-height: auto;
    padding: 34px 16px 44px;
  }

  .page-header.liuyao-title h1 {
    max-width: 100%;
    font-size: 32px;
    line-height: 1.16;
    overflow-wrap: anywhere;
  }

  .page-header.liuyao-title .page-desc {
    max-width: 100%;
    font-size: 16px;
    line-height: 1.55;
  }

  .meihua-method-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .meihua-tabs,
  .liuyao-card .meihua-tabs {
    width: 100% !important;
    max-width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    padding: 6px !important;
    border-radius: 10px !important;
    box-sizing: border-box;
  }

  .meihua-tabs label,
  .liuyao-card .meihua-tabs label {
    min-width: 0;
    min-height: 44px;
    padding: 0 8px !important;
    border-radius: 6px !important;
    white-space: normal;
    word-break: keep-all;
    line-height: 1.2;
    box-sizing: border-box;
  }

  .liuyao-card .meihua-tabs label:last-child {
    grid-column: 1 / -1;
  }

  .meihua-panel,
  .liuyao-shake-panel,
  .liuyao-card .meihua-panel[data-liuyao-panel="manual"] {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .liuyao-shake-panel,
  .liuyao-card .meihua-panel[data-liuyao-panel="manual"] {
    margin: 8px 0 18px;
    padding: 18px 14px 20px;
  }

  .liuyao-shake-panel h3 {
    max-width: 100%;
    font-size: 20px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .liuyao-coin-area {
    width: fit-content !important;
    max-width: 100% !important;
    margin: 0 auto;
    justify-content: center;
    gap: clamp(10px, 4vw, 18px);
    flex-wrap: nowrap;
    min-height: 110px;
    padding: 0;
    box-sizing: border-box;
  }

  .liuyao-coin-area img {
    width: clamp(58px, 21vw, 76px);
    height: clamp(58px, 21vw, 76px);
    flex: 0 0 auto;
  }

  .liuyao-shake-tip {
    padding: 14px 12px;
    font-size: 16px;
    line-height: 1.65;
    overflow-wrap: anywhere;
    box-sizing: border-box;
  }

  .liuyao-shake-lines {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .liuyao-shake-line-row {
    grid-template-columns: 40px 40px minmax(0, 132px) 18px !important;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    font-size: 16px;
    box-sizing: border-box;
    overflow: hidden;
  }

  .coin-line {
    width: 100% !important;
    max-width: 132px !important;
    min-width: 0;
    height: 22px;
  }

  .coin-moving {
    min-width: 0;
    justify-self: start;
    font-size: 22px !important;
    line-height: 1;
  }

  .manual-lines,
  .manual-line,
  .manual-select-shell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .manual-lines {
    justify-self: center;
    margin-left: auto;
    margin-right: auto;
  }

  .manual-line {
    display: grid !important;
    grid-template-columns: 52px minmax(0, 1fr) !important;
    gap: 10px !important;
    align-items: center;
  }

  .manual-line-name {
    min-width: 0;
    font-size: 16px !important;
  }

  .manual-select-shell {
    min-width: 0 !important;
  }

  .manual-select-preview {
    inset: 0 32px 0 12px !important;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px !important;
    min-width: 0;
    overflow: hidden;
  }

  .manual-type-text,
  .manual-placeholder {
    min-width: 32px !important;
    font-size: 15px !important;
  }

  .manual-yao-line {
    width: 100% !important;
    max-width: 124px;
    min-width: 0;
  }

  .manual-yao-line.yin {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: clamp(18px, 6vw, 28px);
  }

  .manual-yao-line.yin i {
    width: 100% !important;
  }

  .manual-change-mark {
    min-width: 14px !important;
    font-size: 20px !important;
    line-height: 1;
  }

  #ziwei-hehun-result .markdown-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  #ziwei-hehun-result .markdown-table {
    width: max-content;
    min-width: 780px !important;
    table-layout: auto;
  }

  #ziwei-hehun-result .markdown-table th,
  #ziwei-hehun-result .markdown-table td {
    min-width: 92px;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
  }

  #ziwei-hehun-result .markdown-table th:first-child,
  #ziwei-hehun-result .markdown-table td:first-child {
    min-width: 190px;
    white-space: nowrap;
  }
}

@media (max-width: 380px) {
  .workspace,
  .meihua-workspace,
  .form-card {
    padding-left: 12px;
    padding-right: 12px;
  }

  .meihua-tabs label,
  .liuyao-card .meihua-tabs label {
    font-size: 13px;
  }
}
