/* Platform layer: keep layout, dictionary content and desktop styles intact. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-top: calc(16px + env(safe-area-inset-top, 0px));
  scroll-padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}
/* This is a scrolling document: retain page scrolling and pull-to-refresh. */
body {
  min-height: 100svh;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.site-header { padding-top: env(safe-area-inset-top, 0px); }
.site-footer { padding-bottom: calc(25px + env(safe-area-inset-bottom, 0px)); }
.toast { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
.skip-link:focus { top: calc(10px + env(safe-area-inset-top, 0px)); }
button, summary, [role="button"], .button, .text-button,
.variant-option, .exercise-option, .comparison-filter-control, .step-check {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea, select { font-size: 16px; }
input:not([type="radio"]):not([type="checkbox"]), textarea, select {
  scroll-margin-block: calc(24px + env(safe-area-inset-top, 0px));
}
.compare-list { overscroll-behavior: contain; }
@media (max-width: 430px) {
  .navigation, .site-header nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 10px; width: 100%; }
  .navigation a { min-width: 44px; }
}
@media (max-width: 700px) {
  .tool-page.visible-analysis #copy-preview-text { font-size: 16px; }
  .reading h1, .reading h2 { overflow-wrap: anywhere; }
  .reading .inline-button { max-width: 100%; white-space: normal; line-height: 1.5; text-align: left; }
}

/* Include hybrid devices without making width a proxy for touch. */
@media (any-pointer: coarse) {
  button, summary, [role="button"], .button, .text-button {
    min-height: 44px;
    min-width: 44px;
  }
  .practice-link, .dictionary-source, .footer-links a,
  .comparison-filter-control, .step-check { min-height: 44px; }
  .tool-page.visible-analysis #copy-preview-text,
  .comparison-selectors select { font-size: 16px; }
  button:not(#analyze-button):not(:disabled):active,
  .history-area>summary:active, .practice-drawer .support-action:active, [role="button"]:active,
  .variant-option:active, .exercise-option:active, .step-check:active {
    filter: brightness(.94);
  }
}

/* Inherited mouse styles only apply with hover + a fine primary pointer.
   Restore normal controls otherwise; selected, checked, expanded and
   keyboard-focus states deliberately keep their own appearance. */
@media (hover: none), (pointer: coarse), (pointer: none) {
  a:hover { color: inherit; }
  .button:hover {
    background: var(--cobalt);
    border-color: var(--cobalt);
    color: var(--white);
  }
  .text-button:hover, .practice-link:hover, .support-guide-link:hover {
    background: transparent;
    color: var(--cobalt);
  }
  .input-row input:hover:not(:focus):not([aria-invalid="true"]),
  .tool-page.visible-analysis #word-input:hover:not(:focus):not([aria-invalid="true"]) {
    background: var(--white);
    border-color: var(--line);
  }
  .context-choice:hover:not([aria-pressed="true"]),
  .variant-option:hover:not(:has(input:checked)) { border-color: var(--line); }
  .tool-page.visible-analysis .context-choice:hover:not([aria-pressed="true"]) {
    background: var(--white);
    border: var(--content-frame);
    color: var(--ink);
  }
  .tool-page.visible-analysis .variant-option:hover:not(:has(input:checked)) {
    background: transparent;
    border: var(--content-frame);
  }
  .tool-page .stress-choice-row button:hover:not([aria-pressed="true"]) {
    background: var(--white);
    border-color: var(--line);
    color: var(--cobalt);
  }
  .tool-page .part-of-speech:hover,
  .tool-page .part-of-speech:hover>span { background: transparent; color: var(--cobalt); }
  .tool-page.visible-analysis .part-of-speech:hover>span {
    background: var(--white);
    border: var(--content-frame);
  }
  /* Focus remains the accessible touch/keyboard alternative to mouse hover. */
  .visible-analysis .pos-help:not(.tooltip-dismissed):hover:not(:focus-within) .pos-tooltip {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
  }
  .tool-page .feature summary:hover,
  .tool-page .feature summary:hover>.feature-value { background: transparent; color: var(--ink); }
  .tool-page .feature.is-active summary:hover>.feature-value { color: var(--cobalt); }
  .tool-page .copy-button:hover { background: var(--white); color: var(--ink); border-color: var(--line); }
  .tool-page.visible-analysis #result-actions .copy-button:hover {
    background: var(--white);
    color: var(--cobalt);
    border: var(--content-frame);
  }
  .tool-page #history-items button:hover { background: transparent; color: var(--ink); }
  .tool-page .history-area>summary:hover { color: var(--muted); }
  .tool-page .word-links a:hover { color: inherit; border-color: var(--line); background: transparent; }
  .tool-page .support-tools>details>summary:hover { color: var(--ink); background: transparent; }
  .tool-page.visible-analysis .practice-drawer>summary:hover .support-action,
  .tool-page.visible-analysis .practice-drawer>summary .support-action:hover {
    background: var(--white);
    color: var(--cobalt);
  }
  .tool-page .support-content .exercise-footer .practice-link:hover {
    border-color: var(--line);
    background: var(--white);
    color: var(--cobalt);
  }
  .tool-page .more-examples>summary:hover .support-title { color: var(--ink); }
  .exercise-option:hover:not(:has(input:checked)):not(.is-answer),
  .answer-option:hover:not(:has(input:checked)):not(.is-answer) { border-color: var(--line); }
  .practice-page .exercise-option:hover:not(:has(input:checked)):not(.is-answer) {
    background: var(--paper);
    border-color: var(--line);
  }
  .exercise-footer>.text-button:hover { background: transparent; }
  .practice-page .practice-reset:hover { color: var(--muted); background: transparent; }
  .practice-page #exercise-jump button:hover:not([aria-current="step"]):not(.is-solved) {
    background: var(--paper);
    color: var(--muted);
    border-color: var(--line);
  }
  .practice-page #next-exercise:hover { background: var(--white); color: var(--muted); border-color: var(--line); }
  .guide-tracker .text-button:hover { color: var(--white); background: transparent; }
  .step-check:hover:not(:has(input:checked)) { background: transparent; }
  .tool-page .quiz-toggle:hover { background: transparent; color: var(--cobalt); border-color: var(--line); }
  .tool-page #feature-quiz-options label:hover:not(:has(input:checked)):not(.is-answer) {
    background: var(--white);
    border-color: var(--line);
    color: var(--ink);
  }
  .tool-page #feature-quiz-check:hover { background: var(--cobalt); color: var(--white); border-color: var(--cobalt); }
  .tool-page.visible-analysis .compare-trigger:hover:not([aria-expanded="true"]) {
    background: var(--white);
    border: var(--content-frame);
  }
  .tool-page.visible-analysis .compare-option:hover:not([aria-selected="true"]) { background: var(--white); }
  .tool-page.visible-analysis .comparison-apply .text-button:hover {
    background: var(--white);
    color: var(--cobalt);
    border: var(--content-frame);
  }
}
