/* Mobile layout is intentionally isolated from domain palettes and desktop geometry. */

.mobile-map-menu {
  display: none;
}

.mobile-concept-menu {
  display: contents;
}

.mobile-concept-menu > summary {
  display: none;
}

.alpha-map-layout > .mobile-concept-menu > .concept-panel {
  height: 100%;
  min-height: 0;
  max-height: 100%;
}

@media (max-width: 760px), (max-width: 900px) and (max-height: 520px) {
  :root {
    --header-height: 56px;
  }

  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    min-width: 0;
  }

  button,
  input,
  summary {
    touch-action: manipulation;
  }

  .alpha-header {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) minmax(48px, auto);
    gap: 8px;
    height: var(--header-height);
    min-height: var(--header-height);
    padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  }

  .alpha-brand {
    width: 32px;
    gap: 0;
  }

  .alpha-brand strong {
    display: none;
  }

  .alpha-brand-mark {
    width: 30px;
    height: 30px;
    border-width: 7px;
  }

  .alpha-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 3px;
  }

  .alpha-nav > a,
  .alpha-nav > span {
    display: grid;
    min-width: 0;
    min-height: 38px;
    place-items: center;
    padding: 0 4px;
    font-size: 12px;
  }

  .alpha-header-meta {
    min-width: 0;
    margin: 0;
  }

  .alpha-header-purchase,
  .alpha-header-progress {
    display: none;
  }

  .ghost-button.alpha-header-account {
    width: auto;
    min-width: 48px;
    max-width: 70px;
    min-height: 38px;
    padding: 0 9px;
    border-radius: 8px;
    font-size: 11px;
  }

  #alphaApp {
    height: calc(100dvh - var(--header-height));
  }

  body:has(#aiMapView:not([hidden])) > .alpha-header {
    display: none;
  }

  body:has(#aiMapView:not([hidden])) #alphaApp {
    height: 100dvh;
  }

  /* Catalog: reserve the lower edge for filing links and keep controls tappable. */
  .catalog-intro {
    top: 20px;
    left: 16px;
    width: calc(100vw - 32px);
  }

  .catalog-intro h1 {
    max-width: 330px;
    font-size: 32px;
    line-height: 1.12;
  }

  .catalog-hint {
    bottom: 88px;
    padding: 8px 12px;
    font-size: 10px;
    line-height: 1.35;
  }

  .catalog-filing {
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 8px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, auto));
    justify-content: center;
    gap: 3px 12px;
    padding: 6px 8px;
    background: rgba(3, 10, 15, .5);
    font-size: 9px;
    text-align: center;
    white-space: normal;
  }

  .domain-preview {
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    max-height: calc(100dvh - var(--header-height) - 8px);
    overflow-y: auto;
    padding: 22px 18px max(18px, env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
  }

  .domain-preview h2 {
    padding-right: 34px;
    font-size: 28px;
  }

  .domain-preview-description,
  .preview-note {
    font-size: 13px;
    line-height: 1.65;
  }

  /* Domain map: a vertical learning flow replaces the desktop overlay. */
  #aiMapView {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scroll-padding-bottom: calc(58px + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
  }

  #aiMapView .mobile-map-menu {
    position: relative;
    z-index: 36;
    display: block;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--domain-line, rgba(33, 78, 88, .12));
    background: color-mix(in srgb, var(--domain-panel-bg, #ffffff) 94%, transparent);
    box-shadow: 0 6px 18px rgba(31, 68, 79, .08);
  }

  .mobile-map-menu > summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) 20px;
    min-height: 48px;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    cursor: pointer;
    list-style: none;
    user-select: none;
  }

  .mobile-map-menu > summary::-webkit-details-marker {
    display: none;
  }

  .mobile-map-menu > summary strong {
    font-size: 14px;
  }

  .mobile-map-menu > summary span {
    overflow: hidden;
    color: var(--domain-muted, #647278);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-map-menu > summary::after {
    content: "⌄";
    color: var(--domain-accent, #248ea6);
    font-size: 18px;
    text-align: center;
    transition: transform 160ms ease;
  }

  .mobile-map-menu[open] > summary::after {
    transform: rotate(180deg);
  }

  .mobile-map-menu-panel {
    display: grid;
    gap: 10px;
    padding: 0 12px 12px;
  }

  .mobile-map-menu-topline,
  .mobile-map-menu-domain {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
  }

  .mobile-map-menu-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: 44px;
    overflow: hidden;
    border: 1px solid var(--domain-line, rgba(33, 78, 88, .12));
    border-radius: 8px;
  }

  .mobile-map-menu-nav > * {
    display: grid;
    min-width: 0;
    place-items: center;
    color: var(--domain-muted, #647278);
    font-size: 12px;
    text-decoration: none;
  }

  .mobile-map-menu-nav > [aria-current="page"] {
    color: var(--domain-accent-strong, #176c80);
    background: color-mix(in srgb, var(--domain-accent, #248ea6) 10%, transparent);
    font-weight: 700;
  }

  .mobile-map-account,
  #mobileMapBackButton {
    min-height: 44px;
    border-radius: 8px;
    font-size: 12px;
  }

  .mobile-map-account {
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-map-menu-domain {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .mobile-map-menu-domain strong {
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-map-menu-modes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .mobile-map-menu-modes button {
    min-width: 0;
    min-height: 44px;
    padding: 0 8px;
    border: 1px solid var(--domain-line, rgba(33, 78, 88, .14));
    border-radius: 8px;
    color: var(--domain-muted, #647278);
    background: var(--domain-panel-bg, #ffffff);
    font: inherit;
    font-size: 12px;
  }

  .mobile-map-menu-modes button.is-active {
    color: var(--domain-accent-strong, #176c80);
    border-color: var(--domain-accent, #248ea6);
    background: color-mix(in srgb, var(--domain-accent, #248ea6) 10%, #ffffff);
    font-weight: 700;
  }

  .ai-map-header {
    display: none;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 44px;
    gap: 8px;
    height: 56px;
    min-height: 56px;
    padding: 6px 12px;
  }

  .ai-map-back {
    grid-row: 1;
    min-height: 44px;
    align-self: center;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
  }

  .ai-map-heading {
    min-width: 0;
    align-self: center;
    margin: 0;
  }

  .ai-map-heading h1,
  #aiMapView[data-domain-theme] .ai-map-heading h1 {
    overflow: hidden;
    font-size: 16px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ai-map-heading p,
  #aiMapView[data-domain-theme] .ai-map-heading p {
    display: none;
  }

  .ai-map-header .header-chip {
    display: none;
  }

  .map-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
    min-height: 60px;
    padding: 8px 12px;
    overflow: visible;
  }

  .node-search {
    grid-column: 1;
    width: 100%;
    min-width: 0;
    order: initial;
    flex: none;
  }

  .node-search input {
    height: 44px;
    padding: 0 13px;
    border-radius: 8px;
    font-size: 16px;
  }

  .node-search-results {
    width: calc(100vw - 24px);
    max-height: min(360px, 48dvh);
  }

  #resetMapViewButton {
    grid-column: 2;
    width: 44px;
    height: 44px;
    min-height: 44px;
    order: initial;
    padding: 0;
    border-radius: 8px;
    font-size: 0;
  }

  #resetMapViewButton::after {
    content: "↺";
    font-size: 19px;
  }

  .map-mode-tabs {
    grid-column: 1 / -1;
    display: none;
    width: auto;
    min-width: 0;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .map-mode-tabs::-webkit-scrollbar {
    display: none;
  }

  .map-mode-tabs button {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 12px;
  }

  .map-toolbar .toolbar-spacer,
  .toolbar-separator,
  .region-filters {
    display: none;
  }

  .alpha-map-layout {
    position: static;
    display: flex;
    height: auto;
    min-height: 0;
    flex-direction: column;
  }

  .mobile-concept-menu {
    position: fixed;
    z-index: 30;
    right: 0;
    bottom: calc(56px + env(safe-area-inset-bottom));
    left: 0;
    display: block;
    max-height: calc(100svh - 112px - env(safe-area-inset-bottom));
    overflow: hidden;
    border-top: 1px solid var(--domain-line, rgba(33, 78, 88, .14));
    background: color-mix(in srgb, var(--domain-panel-bg, #ffffff) 96%, transparent);
    box-shadow: 0 -10px 28px rgba(24, 60, 70, .14);
  }

  .mobile-concept-menu[open] {
    display: grid;
    height: auto;
    grid-template-rows: 42px auto;
  }

  .mobile-concept-menu > summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) 20px;
    min-height: 42px;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    cursor: pointer;
    list-style: none;
    user-select: none;
  }

  .mobile-concept-menu > summary::-webkit-details-marker {
    display: none;
  }

  .mobile-concept-menu > summary strong {
    font-size: 14px;
  }

  .mobile-concept-menu > summary span {
    overflow: hidden;
    color: var(--domain-muted, #647278);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-concept-menu > summary::after {
    content: "⌃";
    color: var(--domain-accent, #248ea6);
    font-size: 17px;
    text-align: center;
    transition: transform 160ms ease;
  }

  .mobile-concept-menu[open] > summary::after {
    transform: rotate(180deg);
  }

  .mobile-concept-menu.is-entry-ready {
    max-height: 42px;
    border-top-color: color-mix(in srgb, var(--domain-accent, #248ea6) 42%, transparent);
    background: var(--domain-accent-strong, #176c80);
  }

  .mobile-concept-menu.is-entry-ready > summary {
    color: #ffffff;
  }

  .mobile-concept-menu.is-entry-ready > summary span {
    color: rgba(255, 255, 255, .78);
  }

  .mobile-concept-menu.is-entry-ready > summary::after {
    color: #ffffff;
    content: "→";
    transform: none;
  }

  .map-viewport {
    position: relative;
    inset: auto;
    flex: 0 0 auto;
    width: 100%;
    height: clamp(500px, calc(100svh - 212px), 760px);
    min-height: 500px;
    border-bottom: 1px solid var(--domain-line, rgba(255,255,255,.08));
  }

  .map-canvas {
    width: 1800px;
    height: 1200px;
  }

  #aiMapView[data-domain-theme] .knowledge-node {
    transform:
      translate(-50%, -50%)
      scale(calc(var(--inverse-scale, 1) * .62));
  }

  #aiMapView[data-domain-theme] .knowledge-node span {
    font-size: 14px;
    line-height: 1.3;
  }

  #aiMapView[data-domain-theme] .knowledge-node small {
    font-size: 9px;
  }

  #aiMapView[data-domain-theme] .knowledge-edge text {
    fill: var(--domain-accent-strong, #0c4fa5);
    stroke: color-mix(in srgb, var(--domain-map-surface, #fff) 94%, transparent);
    stroke-width: calc(1.2px * var(--inverse-scale, 1));
    paint-order: stroke fill;
    font-size: calc(4.5px * var(--inverse-scale, 1));
    font-weight: 650;
  }

  .concept-panel,
  #aiMapView[data-domain-theme] .concept-panel {
    position: relative;
    inset: auto;
    z-index: 10;
    width: 100%;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 0;
    border-top: 1px solid var(--domain-line, rgba(255,255,255,.08));
    border-radius: 0;
    box-shadow: none;
  }

  .mobile-concept-menu .concept-panel,
  #aiMapView[data-domain-theme] .mobile-concept-menu .concept-panel {
    height: auto;
    min-height: 0;
    max-height: calc(100svh - 154px - env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
  }

  .concept-card {
    min-height: 0;
    padding: 12px 12px 68px;
  }

  .concept-card.is-undiscovered,
  #aiMapView[data-domain-theme] .concept-card.is-undiscovered {
    height: auto;
    padding: 8px 10px;
    overflow: hidden;
  }

  .concept-card.is-undiscovered > .concept-badge,
  .concept-card.is-undiscovered > h2,
  .concept-card.is-undiscovered > .concept-meta,
  .concept-card.is-undiscovered > .concept-discovery-guidance {
    display: none;
  }

  .concept-card.is-undiscovered .concept-question,
  #aiMapView[data-domain-theme] .concept-card.is-undiscovered .concept-question {
    display: grid;
    height: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    align-content: start;
    gap: 6px 8px;
    margin: 0;
    padding: 8px;
    overflow: hidden;
  }

  .concept-card.is-undiscovered .concept-question h3 {
    grid-column: 1;
    align-self: center;
  }

  .concept-card.is-undiscovered .concept-question-balance {
    grid-column: 2;
    padding: 3px 7px;
    font-size: 10px;
  }

  .concept-card.is-undiscovered .concept-question-prompt,
  .concept-card.is-undiscovered .concept-question-options,
  .concept-card.is-undiscovered .concept-question-message,
  .concept-card.is-undiscovered .concept-question-actions,
  .concept-card.is-undiscovered .concept-question-loading,
  .concept-card.is-undiscovered .concept-question-error {
    grid-column: 1 / -1;
  }

  .concept-card.is-undiscovered .concept-question-prompt {
    display: none;
  }

  .concept-card.is-undiscovered .concept-question-clue {
    display: block;
    grid-column: 1 / -1;
    margin: 0;
    padding: 6px 8px;
    border-left-width: 2px;
    font-size: 10px;
    line-height: 1.35;
  }

  .concept-card.is-undiscovered .concept-question-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .concept-card.is-undiscovered .concept-question-options label,
  #aiMapView[data-domain-theme] .concept-card.is-undiscovered .concept-question-options label {
    grid-template-columns: 16px 22px minmax(0, 1fr);
    min-height: 40px;
    gap: 5px;
    padding: 5px 6px;
    font-size: 10px;
    line-height: 1.25;
  }

  .concept-card.is-undiscovered .concept-question-options input {
    width: 15px;
    height: 15px;
  }

  .concept-card.is-undiscovered .concept-question-options label strong {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }

  .concept-card.is-undiscovered .concept-question-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .concept-card.is-undiscovered .concept-question-actions button {
    min-height: 36px;
    padding: 0 6px;
    font-size: 10px;
  }

  .concept-card.is-undiscovered .concept-question-actions .primary-button,
  .concept-card.is-undiscovered .concept-question-actions .concept-recharge-button {
    grid-column: auto;
  }

  .concept-card.is-undiscovered .concept-question-message:empty {
    display: none;
  }

  .concept-card > h2,
  #aiMapView[data-domain-theme] .concept-card > h2 {
    margin-top: 8px;
    font-size: 18px;
    line-height: 1.2;
  }

  .concept-badge,
  .concept-meta {
    font-size: 10px;
  }

  .concept-discovery-guidance {
    max-width: none;
    font-size: 12px;
    line-height: 1.55;
  }

  .concept-question,
  #aiMapView[data-domain-theme] .concept-question {
    gap: 10px;
    margin: 12px 0 0;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(16, 48, 57, .1);
  }

  .concept-question h3,
  #aiMapView[data-domain-theme] .concept-question h3 {
    font-size: 12px;
  }

  .concept-question-balance,
  #aiMapView[data-domain-theme] .concept-question-balance {
    padding: 6px 9px;
    font-size: 12px;
  }

  .concept-question-prompt,
  #aiMapView[data-domain-theme] .concept-question-prompt {
    font-size: 13px;
    line-height: 1.5;
  }

  .concept-question-clue,
  #aiMapView[data-domain-theme] .concept-question-clue {
    padding: 10px 11px;
    font-size: 12px;
    line-height: 1.55;
  }

  .concept-question-options {
    gap: 9px;
  }

  .concept-question-options label,
  #aiMapView[data-domain-theme] .concept-question-options label {
    grid-template-columns: 22px 28px minmax(0, 1fr);
    min-height: 54px;
    align-items: center;
    gap: 8px;
    padding: 11px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.45;
  }

  .concept-question-options input {
    width: 18px;
    height: 18px;
    margin: 0;
  }

  .concept-question-options label strong {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 13px;
  }

  .concept-question-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .concept-question-actions button {
    width: 100%;
    min-height: 46px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.3;
  }

  .concept-question-actions .primary-button,
  .concept-question-actions .concept-recharge-button {
    grid-column: 1 / -1;
  }

  .concept-question-actions .concept-recharge-button {
    border: 1px solid color-mix(in srgb, var(--domain-accent) 28%, transparent);
    background: color-mix(in srgb, #ffffff 92%, var(--domain-accent) 8%);
  }

  .concept-question-message,
  .concept-question-loading,
  .concept-question-error,
  .concept-question-explanation,
  #aiMapView[data-domain-theme] .concept-question-message,
  #aiMapView[data-domain-theme] .concept-question-loading,
  #aiMapView[data-domain-theme] .concept-question-explanation {
    font-size: 13px;
    line-height: 1.6;
  }

  .concept-question-answer {
    font-size: 11px;
  }

  .concept-block p,
  .concept-more p,
  #aiMapView[data-domain-theme] .concept-block p,
  #aiMapView[data-domain-theme] .concept-more p {
    font-size: 12px;
    line-height: 1.6;
  }

  .concept-block h3,
  .concept-sources h3,
  .concept-more summary,
  .concept-relations button,
  .concept-sources a {
    font-size: 12px;
  }

  .route-footer,
  #aiMapView[data-domain-theme] .route-footer {
    position: fixed;
    z-index: 28;
    right: 0;
    bottom: 0;
    left: 0;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    height: auto;
    min-height: calc(56px + env(safe-area-inset-bottom));
    padding: 0 12px env(safe-area-inset-bottom);
    backdrop-filter: blur(16px);
  }

  .route-footer button,
  .route-footer strong,
  #aiMapView[data-domain-theme] .route-footer button,
  #aiMapView[data-domain-theme] .route-footer strong {
    min-width: 0;
    min-height: 44px;
    padding: 0 4px;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #aiMapView[data-domain-theme] #previousRouteButton,
  #aiMapView[data-domain-theme] #nextRouteButton {
    font-size: 0;
  }

  #aiMapView[data-domain-theme] #previousRouteButton::after,
  #aiMapView[data-domain-theme] #nextRouteButton::after {
    font-size: 11px;
  }

  #previousRouteButton::after {
    content: "← 上一个";
  }

  #nextRouteButton::after {
    content: "下一个 →";
  }

  #conceptDetailView {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .concept-detail-header {
    min-height: 58px;
    gap: 10px;
    padding: 8px 12px;
  }

  .concept-detail-header .ghost-button {
    min-height: 42px;
    padding: 0 10px;
    font-size: 12px;
  }

  .concept-detail-header span { font-size: 10px; }
  .concept-detail-header h1 { display: none; }

  .concept-detail-content {
    width: calc(100% - 24px);
    padding: 20px 0 54px;
    counter-reset: detail-section;
  }

  .concept-detail-intro {
    position: relative;
    padding: 4px 0 22px;
  }
  .concept-detail-intro::before {
    display: block;
    width: 36px;
    height: 3px;
    margin-bottom: 14px;
    background: var(--domain-accent, #176bd6);
    content: "";
  }
  .concept-detail-badge {
    border-radius: 4px;
    font-size: 9px;
  }
  .concept-detail-intro h1 {
    margin: 12px 0 6px;
    font-size: 28px;
    line-height: 1.18;
  }
  .concept-detail-meta { font-size: 11px; }
  .concept-detail-block {
    display: block;
    padding: 20px 0;
    counter-increment: detail-section;
  }
  .concept-detail-block h2 {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 12px;
  }
  .concept-detail-block h2::before {
    color: var(--domain-muted, #65798a);
    font-size: 8px;
    font-variant-numeric: tabular-nums;
    content: counter(detail-section, decimal-leading-zero);
  }
  .concept-detail-block p {
    font-size: 14px;
    line-height: 1.72;
  }
  .concept-detail-block.is-summary p {
    font-size: 16px;
    line-height: 1.62;
  }
  .concept-detail-block.is-misconception {
    margin: 0 -12px;
    padding: 18px 12px;
    background: color-mix(in srgb, var(--domain-accent-3, #c78716) 7%, var(--domain-panel, #fff));
  }
  .concept-detail-relations > div {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .concept-detail-relations a {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 9px 11px;
    border: 1px solid var(--domain-line, rgba(23, 107, 214, .18));
    border-radius: 6px;
    background: var(--domain-panel, #fff);
    font-size: 12px;
    line-height: 1.55;
  }
  .concept-detail-relations a::after {
    color: var(--domain-accent, #176bd6);
    content: "→";
  }
  .concept-detail-sources ul {
    display: grid;
    gap: 8px;
    padding: 0;
    list-style: none;
  }
  .concept-detail-sources li::before {
    margin-right: 8px;
    color: var(--domain-accent, #176bd6);
    content: "↗";
  }

  /* Dialogs and secondary views must remain usable without browser zoom. */
  .alpha-dialog,
  .account-dialog,
  .points-dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .alpha-dialog-shell {
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
  }

  .dialog-field input,
  .account-inline-form input,
  .points-dialog input {
    min-height: 46px;
    font-size: 16px;
  }

  .dialog-actions,
  .account-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-actions button,
  .account-actions button {
    min-height: 44px;
  }

  .points-recharge-form { grid-template-columns: 1fr; }
  .points-recharge-button { grid-column: 1; grid-row: auto; width: 100%; }

  #domainPreviewView {
    padding: 10px;
  }

  .locked-domain-page {
    margin: 0 auto;
    padding: 20px 16px;
    border-radius: 12px;
  }

  .locked-domain-page h1 {
    font-size: 30px;
    line-height: 1.2;
  }

  .locked-facts {
    grid-template-columns: 1fr;
  }

  /* About keeps the illustration as the background, with a protected copy zone. */
  .about-hero {
    min-height: calc(310px + 225vw);
  }

  .about-hero-media {
    inset: 300px 0 auto;
    height: 225vw;
    object-fit: cover;
    object-position: center top;
    opacity: .94;
  }

  .about-hero-copy {
    width: auto;
    padding: 38px 18px 0;
  }

  .about-hero h1 {
    font-size: 34px;
    line-height: 1.25;
  }

  .about-lead {
    margin-top: 18px;
    font-size: 14px;
    line-height: 1.7;
  }

  .about-actions {
    align-items: stretch;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-top: 20px;
  }

  .about-primary-action,
  .about-secondary-action {
    min-height: 44px;
  }

  .about-future-note {
    padding: 14px 18px max(14px, env(safe-area-inset-bottom));
  }

  .about-mission,
  .about-ai-literacy {
    padding-right: 18px;
    padding-left: 18px;
  }

  .about-mission h2 {
    font-size: 25px;
  }

  .about-mission p,
  .about-ai-literacy-copy p {
    font-size: 14px;
    line-height: 1.75;
  }

  .about-ai-literacy-heading h2 {
    font-size: 32px;
  }

  .about-contribute {
    width: calc(100% - 36px);
  }

  .about-contribute h2 {
    font-size: 31px;
  }
}

@media (max-width: 380px) {
  .alpha-header {
    grid-template-columns: 30px minmax(0, 1fr) 48px;
    gap: 5px;
    padding-right: 7px;
    padding-left: 7px;
  }

  .alpha-nav > a,
  .alpha-nav > span {
    font-size: 11px;
  }

  .ghost-button.alpha-header-account {
    width: 48px;
    max-width: 48px;
    padding: 0 6px;
  }

  .ai-map-back {
    padding: 0 8px;
    font-size: 11px;
  }

  .ai-map-heading h1 {
    font-size: 16px;
  }

  .concept-question {
    padding: 14px;
  }

  .concept-question-options label {
    grid-template-columns: 20px 26px minmax(0, 1fr);
    padding: 10px 8px;
    font-size: 13px;
  }

  .concept-question-actions {
    grid-template-columns: 1fr;
  }

  .concept-question-actions .primary-button,
  .concept-question-actions .concept-recharge-button {
    grid-column: 1;
  }

  .route-footer strong {
    max-width: 100px;
  }
}

@media (max-width: 760px) and (max-height: 620px) {
  .map-viewport {
    height: max(360px, calc(100svh - 250px));
    min-height: 360px;
  }

  .catalog-intro h1 {
    font-size: 28px;
  }
}

@media (min-width: 761px) and (max-width: 900px) and (max-height: 520px) {
  .map-toolbar {
    grid-template-columns: minmax(220px, 1fr) auto 44px;
    grid-template-rows: 44px;
  }

  .map-toolbar .node-search {
    grid-column: 1;
    grid-row: 1;
  }

  .map-toolbar .map-mode-tabs {
    grid-column: 2;
    grid-row: 1;
  }

  .map-toolbar #resetMapViewButton {
    grid-column: 3;
    grid-row: 1;
  }

  .map-viewport {
    height: 240px;
    min-height: 240px;
  }

  .ai-map-header {
    min-height: 66px;
  }

  .about-hero {
    min-height: 860px;
  }
}
