html[data-h5] .commerce-web {
  --commerce-action-height: 68px;
  --commerce-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-h5] .commerce-web .gc-page-head {
  justify-content: flex-end;
  margin-bottom: 12px;
}

html[data-h5] .commerce-web .gc-page-head > div {
  display: none;
}

html[data-h5] .commerce-web .gc-page-head > .gc-primary {
  width: 100%;
  min-height: 44px;
  font-size: 14px;
}

html[data-h5] .commerce-web .gc-tabs {
  gap: 0 4px;
  margin-bottom: 14px;
}

html[data-h5] .commerce-web .gc-tab {
  flex: 1 0 calc(25% - 4px);
  min-height: 44px;
  padding: 4px;
}

html[data-h5] .commerce-web .gc-tab[aria-pressed="true"]::after {
  left: 10px;
  right: 10px;
}

html[data-h5] .commerce-web .gc-case-foot button {
  min-height: 44px;
  padding-inline: 4px;
}

html[data-h5] .commerce-web.commerce-creating {
  padding-bottom: calc(var(--commerce-action-height) + var(--commerce-safe-bottom) + 20px);
}

html[data-h5] .commerce-web.commerce-creating .gc-creator-heading {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

html[data-h5] .commerce-web .gc-creator-heading > .gc-small {
  display: none;
}

html[data-h5] .commerce-web .gc-creator-heading h1 {
  font-size: 19px;
}

html[data-h5] .commerce-web .gc-creator-heading .gc-back {
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--gc-line);
  border-radius: 8px;
  background: var(--gc-surface);
  font-size: 0;
}

html[data-h5] .commerce-web .gc-creator-heading .gc-back svg {
  width: 18px;
  height: 18px;
}

html[data-h5] .commerce-web .gc-creator-heading .commerce-compact-preview {
  min-height: 44px;
  padding-inline: 10px;
}

html[data-h5] .commerce-web .commerce-editor-surface :is(.gc-author, .commerce-reverse-entry) {
  min-height: 44px;
}

html[data-h5] .commerce-web .commerce-editor-surface :is(.gc-field, input:not([type]), select, textarea) {
  font-size: 16px;
}

html[data-h5] .commerce-web .commerce-editor-surface .commerce-editor-submit {
  position: fixed;
  z-index: 40;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(132px, 45%, 210px);
  align-items: center;
  gap: 8px;
  min-height: calc(var(--commerce-action-height) + var(--commerce-safe-bottom));
  margin: 0;
  padding: 8px max(12px, env(safe-area-inset-right, 0px))
    calc(8px + var(--commerce-safe-bottom)) max(12px, env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--gc-line);
  background: var(--gc-surface);
  text-align: start;
}

html[data-h5] .commerce-web .commerce-editor-surface .commerce-editor-submit > div {
  min-width: 0;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

html[data-h5] .commerce-web .commerce-editor-surface .commerce-editor-submit > .gc-primary {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding-inline: 8px;
  font-size: 14px;
}

html[data-h5] .commerce-web .commerce-settings-section > .commerce-form-error {
  position: fixed;
  z-index: 41;
  bottom: calc(var(--commerce-action-height) + var(--commerce-safe-bottom));
  inset-inline: 0;
  max-height: 28dvh;
  margin: 0;
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
  overflow: auto;
  border-top: 1px solid var(--gc-line);
  background: var(--gc-surface);
}

html[data-h5][data-h5-keyboard] .commerce-web .commerce-editor-surface .commerce-editor-submit,
html[data-h5][data-h5-keyboard] .commerce-web .commerce-settings-section > .commerce-form-error {
  position: static;
}

html[data-h5][data-h5-keyboard] .commerce-web.commerce-creating {
  padding-bottom: 0;
}

html[data-h5] dialog.commerce-modal[open]:has(:is(.commerce-type-choices, .commerce-size-options, .commerce-host-grid, .gc-writer, .commerce-submission)) {
  position: fixed;
  inset: auto 0 0;
  width: min(100%, 560px);
  max-width: none;
  max-height: calc(100dvh - max(12px, env(safe-area-inset-top, 0px)));
  margin: 0 auto;
  border-radius: 16px 16px 0 0;
}

html[data-h5] dialog.commerce-modal:has(:is(.commerce-type-choices, .commerce-size-options, .commerce-host-grid, .gc-writer, .commerce-submission)) > .modal-heading {
  gap: 8px;
  align-items: center;
  padding: 8px 14px;
}

html[data-h5] dialog.commerce-modal:has(:is(.commerce-type-choices, .commerce-size-options, .commerce-host-grid, .gc-writer, .commerce-submission)) > .modal-body {
  padding: 12px 14px;
}

html[data-h5] dialog.commerce-modal:has(:is(.commerce-size-options, .commerce-host-grid, .gc-writer, .commerce-submission)) > .modal-footer {
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px));
}

html[data-h5] dialog.commerce-modal:has(.commerce-type-choices) > .modal-body {
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}

html[data-h5] dialog.commerce-modal:has(.commerce-type-choices) > .modal-footer {
  display: none;
}

html[data-h5] .commerce-dialog .commerce-type-choices {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

html[data-h5] .commerce-type-choices > button {
  min-height: 48px !important;
  padding-inline: 6px;
  white-space: normal;
}

html[data-h5] dialog.commerce-modal.commerce-detail-modal[open] {
  position: fixed;
  inset: auto 0 0;
  width: min(100%, 600px);
  max-width: none;
  height: calc(100dvh - max(8px, env(safe-area-inset-top, 0px)));
  max-height: none;
  margin: 0 auto;
  border-radius: 16px 16px 0 0;
}

html[data-h5] dialog.commerce-detail-modal .commerce-detail-viewer {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "heading" "navigation" "pages" "actions";
}

html[data-h5] .commerce-detail-info {
  display: contents;
}

html[data-h5] .commerce-detail-modal > .modal-heading {
  top: 6px;
  right: 8px;
}

html[data-h5] .commerce-detail-info > .commerce-viewer-heading {
  grid-area: heading;
  padding: 12px 56px 4px 14px;
}

html[data-h5] .commerce-detail-info > .commerce-viewer-heading h3 {
  font-size: 17px;
}

html[data-h5] .commerce-detail-navigation {
  grid-area: navigation;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 14px 8px;
}

html[data-h5] .commerce-detail-navigation > p,
html[data-h5] .commerce-detail-page-title {
  display: none;
}

html[data-h5] .commerce-dialog .commerce-detail-jump {
  display: flex;
  flex: 0 0 44px;
  justify-content: center;
  width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 4px;
}

html[data-h5] .commerce-detail-viewport {
  grid-area: pages;
  padding: 0;
}

html[data-h5] .commerce-detail-actions {
  grid-area: actions;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px));
}

html[data-h5] .commerce-detail-actions > .gc-primary {
  min-height: 44px;
}

html[data-h5] .commerce-dialog .commerce-size-options {
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

html[data-h5] .commerce-size-options h3 {
  margin-bottom: 8px;
}

html[data-h5] .commerce-dialog .commerce-ratio-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

html[data-h5] .commerce-dialog .commerce-ratio-grid > button {
  min-width: 0;
  min-height: 54px;
  gap: 5px;
  padding-inline: 4px;
}

html[data-h5] .commerce-dialog .commerce-host-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 8px;
}

html[data-h5] .commerce-dialog .gc-host-toolbar {
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-bottom: 10px;
}

html[data-h5] .commerce-dialog :is(.gc-host-toolbar button, .commerce-writer-tools button, .commerce-history-row, .commerce-modal-actions button) {
  min-height: 44px;
}

html[data-h5] .commerce-dialog .gc-host-toolbar .gc-chip {
  padding-inline: 8px;
}

html[data-h5] .commerce-dialog .gc-host-toolbar .commerce-local-upload {
  padding-inline: 8px;
}

html[data-h5] .commerce-host-preview img {
  max-height: min(50dvh, 390px);
  object-fit: contain;
}

html[data-h5] dialog.commerce-modal:has(.gc-writer) .modal-heading > button {
  min-height: 44px;
}

html[data-h5] .commerce-dialog .gc-writer {
  gap: 12px;
}

html[data-h5] .commerce-dialog .gc-writer :is(input, select, textarea) {
  font-size: 16px;
}

html[data-h5] .commerce-dialog .commerce-writer-form textarea {
  min-height: 88px;
}

html[data-h5] .commerce-dialog .gc-writer .gc-draft-area {
  min-height: auto;
  padding: 12px;
}

html[data-h5] .commerce-dialog .commerce-writer-result .commerce-editable-result {
  min-height: clamp(120px, 26dvh, 220px);
  font-size: 16px;
}

html[data-h5] dialog.commerce-modal:has(:is(.commerce-size-options, .gc-writer)) > .modal-footer button {
  min-height: 44px;
}

html[data-h5]:has(.commerce-web.commerce-creating) dialog.drama-modal[open]:has(.reverse-panel) {
  position: fixed;
  inset: auto 0 0;
  width: min(100%, 560px);
  max-width: none;
  max-height: calc(100dvh - max(12px, env(safe-area-inset-top, 0px)));
  margin: 0 auto;
  border-radius: 16px 16px 0 0;
}

html[data-h5]:has(.commerce-web.commerce-creating) dialog.drama-modal:has(.reverse-panel) > :is(.modal-body, .modal-heading) {
  padding: 10px 14px;
}

html[data-h5]:has(.commerce-web.commerce-creating) dialog.drama-modal:has(.reverse-panel) > .modal-footer {
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px));
}

html[data-h5]:has(.commerce-web.commerce-creating) .reverse-panel :is(.reverse-nav, .reverse-modes, .reverse-result-tabs) {
  margin-bottom: 12px;
}

html[data-h5]:has(.commerce-web.commerce-creating) .reverse-panel textarea {
  font-size: 16px;
}

html[data-h5]:has(.commerce-web.commerce-creating) dialog.drama-modal:has(.reverse-panel) .reverse-cost {
  flex: 1 1 135px;
  margin-bottom: 0;
}

@media (min-width: 640px) {
  html[data-h5] .commerce-web .gc-page-head > .gc-primary {
    width: auto;
  }

  html[data-h5] .commerce-web .gc-tab {
    flex-basis: auto;
  }

  html[data-h5] .commerce-dialog .commerce-host-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  html[data-h5] .commerce-dialog .commerce-size-options {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  html[data-h5] dialog.commerce-modal.commerce-detail-modal[open] {
    inset: 0;
    width: min(calc(100% - 24px), 720px);
    height: calc(100dvh - 16px);
    margin: auto;
    border-radius: 12px;
  }

  html[data-h5] dialog.commerce-detail-modal .commerce-detail-viewer {
    grid-template-columns: minmax(0, 1fr) minmax(0, 215px);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "pages heading" "pages navigation" "pages actions";
  }

  html[data-h5] .commerce-detail-navigation {
    align-content: flex-start;
    flex-wrap: wrap;
    overflow: auto;
  }
}
