/* Mobile layout overrides. Desktop styles remain unchanged. */
@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  .topbar,
  .site {
    width: 100%;
    min-width: 0;
  }

  .topbar {
    padding: 0 12px;
  }

  .topbar::before {
    width: 100%;
    background-size: cover;
  }

  .brand {
    min-width: 0;
    gap: 8px;
  }

  .brand-title {
    max-width: 132px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav {
    position: relative;
    top: auto;
    right: auto;
    flex: 0 0 auto;
  }

  .divider {
    margin: 0 10px;
  }

  /* Index page */
  .main {
    width: 100%;
    padding: 24px 12px 72px;
  }

  .connect-shell,
  .browser-alert,
  .connect-panel {
    width: 100%;
    max-width: 100%;
  }

  .browser-alert {
    height: auto;
    min-height: 90px;
  }

  .browser-alert-content,
  .browser-alert-desc {
    width: 100%;
    height: auto;
  }

  .connect-panel {
    height: auto;
    min-height: 0;
    padding: 24px 16px 32px;
  }

  body.is-english .connect-panel {
    height: auto;
  }

  .panel-title {
    width: 100%;
    margin: 0 0 28px;
    padding: 0;
    font-size: 22px;
    line-height: 1.35;
    white-space: normal;
  }

  body:not(.is-english) .panel-title {
    width: 100%;
    margin: 0 0 28px;
    font-size: 22px;
    line-height: 1.35;
    white-space: normal;
  }

  .content-grid {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 520px;
    height: auto;
    margin: 0 auto;
    gap: 28px;
  }

  .device-preview {
    width: 100%;
    height: auto;
    min-height: 0;
    align-content: start;
  }

  .image-stage {
    width: min(280px, 78vw);
    height: min(280px, 78vw);
    margin: 0 auto 16px;
  }

  .image-stage::before {
    width: 92%;
    height: 92%;
  }

  .device-photo {
    width: 100%;
    height: 100%;
  }

  .device-name,
  .device-name-strong,
  .device-name-pass {
    max-width: 100%;
    font-size: 24px;
    line-height: 1.25;
    flex-wrap: wrap;
  }

  .device-subtitle,
  body.is-english .device-subtitle {
    width: 100%;
    min-height: 0;
    white-space: normal;
    line-height: 1.5;
  }

  .steps,
  .step,
  .step-title,
  .step-desc,
  .select-wrap,
  .device-select,
  .device-select-trigger,
  .device-select-value,
  .step-divider,
  .connect-btn,
  .notice,
  .notice span[data-i18n="notice"] {
    width: 100%;
    max-width: 100%;
  }

  .step {
    padding-bottom: 28px;
  }

  .step:not(:last-of-type)::after {
    width: 100%;
    bottom: 14px;
  }

  .step-title {
    min-height: 24px;
    line-height: 1.4;
  }

  .step-desc,
  body.is-english .step-desc,
  .step-desc.is-two-line {
    height: auto;
    min-height: 0;
    margin-top: 8px;
    line-height: 1.55;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .device-select-value {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .device-select-menu {
    max-height: 260px;
    overflow-y: auto;
  }

  .connect-btn {
    height: 48px;
  }

  .notice {
    align-items: flex-start;
    min-height: 0;
    white-space: normal;
  }

  .notice span[data-i18n="notice"],
  body.is-english .notice span[data-i18n="notice"] {
    width: auto;
    height: auto;
    min-width: 0;
    line-height: 1.5;
  }

  /* Detail page */
  .page {
    width: 100%;
    min-width: 0;
    min-height: auto;
    padding: 24px 12px 48px;
  }

  .summary-card,
  .summary-inner,
  .product-intro,
  .detail-layout,
  .left-stack,
  .card,
  .overview-card,
  .realtime-card,
  .battery-card,
  .exceptions-card {
    width: 100%;
    max-width: 100%;
  }

  .summary-card,
  .overview-card,
  .realtime-card,
  .battery-card,
  .exceptions-card {
    height: auto;
  }

  .summary-card {
    padding: 16px;
  }

  .summary-inner {
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
  }

  .product-intro {
    height: auto;
    display: grid;
    grid-template-columns: minmax(88px, 120px) minmax(0, 1fr);
    column-gap: 16px;
    align-items: start;
  }

  .product-image-wrap,
  .product-image {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .product-copy {
    width: auto;
    min-width: 0;
    padding: 8px 0 0;
  }

  .product-title {
    width: 100%;
    height: auto;
    margin: 0 0 14px;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 22px;
    line-height: 1.3;
  }

  .meta-grid,
  body.is-english .meta-grid {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .meta-grid > .meta-item:nth-child(n) {
    grid-column: auto;
    grid-row: auto;
  }

  .meta-item {
    white-space: normal;
  }

  .meta-value {
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .summary-action {
    position: static;
    align-self: flex-start;
    margin: 0;
  }

  .detail-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .left-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .card {
    padding: 20px 16px;
  }

  .metric-grid,
  .kv-grid,
  .battery-grid {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 14px;
    row-gap: 20px;
  }

  .metric {
    min-width: 0;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 8px;
  }

  .metric-value,
  .realtime-card .kv-value {
    font-size: 22px;
    line-height: 28px;
  }

  .battery-grid {
    grid-template-columns: 1fr;
  }

  .battery-card .kv-value {
    height: auto;
  }

  .exceptions-card {
    min-height: 300px;
    overflow: hidden;
  }

  .exceptions-list {
    max-height: 420px;
    padding-bottom: 64px;
  }

  .exception-heading {
    align-items: baseline;
  }

  .exception-time {
    white-space: normal;
    text-align: right;
  }

  .exception-footer {
    width: 100%;
    padding: 18px 24px;
  }

  .metric-note-dialog,
  .disconnect-confirm-dialog,
  .help-dialog,
  .disconnected-notice-dialog {
    width: min(416px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }

  .metric-note-body,
  .metric-note-title,
  .metric-note-text,
  .disconnect-confirm-content,
  .help-body {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 560px) {
  .topbar {
    min-height: 48px;
    gap: 8px;
    padding: 0 10px;
  }

  .nav {
    font-size: 11px;
  }

  .divider {
    margin: 0 6px;
  }

  .main {
    padding: 16px 10px 48px;
  }

  .connect-panel,
  .summary-card {
    border-radius: 10px;
  }

  .product-intro {
    grid-template-columns: 92px minmax(0, 1fr);
    column-gap: 12px;
  }

  .product-title {
    font-size: 20px;
  }

  .metric-grid,
  .kv-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metric {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 6px;
  }

  .metric-icon,
  .metric-icon img {
    width: 24px;
    height: 24px;
    max-width: 24px;
    max-height: 24px;
  }

  .metric-value,
  .realtime-card .kv-value {
    font-size: 20px;
    line-height: 26px;
  }
}
