/*
 * PokeTeamOn M8.3 — Bottom-sheet consistency + paint candidate v0.2.0
 * Mobile-only CSS. The M8.2 editor is the visual reference and remains frozen.
 * No engine, state owner, result semantics, persistence or desktop changes.
 */
@media (max-width:820px) {
  html.ptm8so-mobile-page {
    --ptm83-ink:#101828;
    --ptm83-muted:#667085;
    --ptm83-line:#e1e4ea;
    --ptm83-soft:#f8fafc;
    --ptm83-accent:#155eef;
    --ptm83-gradient:linear-gradient(100deg,#1768ef,#6545ef 70%,#7b2de2);
  }

  /* One scrolling surface. Preserve M8.2's keyboard and safe-area geometry. */
  html.ptm8so-mobile-page .ptm8so-sheet,
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay {
    box-sizing:border-box!important;
    overscroll-behavior:contain!important;
    -webkit-overflow-scrolling:touch;
    background:#fff!important;
    color:var(--ptm83-ink)!important;
    box-shadow:none!important;
    overflow-x:hidden!important;
  }

  html.ptm8so-mobile-page .ptm8so-backdrop {
    background:rgba(15,23,42,.48);
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
  }
  html.ptm8so-mobile-page.ptm8so-sheet-open .ptm8so-bottom {
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
    box-shadow:none!important;
  }

  /* Native picker: identical header, fields, and row rhythm. */
  html.ptm8so-mobile-page .ptm8so-sheet {
    padding-top:12px!important;
  }
  html.ptm8so-mobile-page .ptm8so-sheet > header {
    margin:-12px -14px 14px;
    padding:12px 14px;
    min-height:56px;
    box-sizing:border-box;
    background:var(--ptm83-gradient);
    color:#fff;
    border-radius:23px 23px 0 0;
    align-items:center;
  }
  html.ptm8so-mobile-page .ptm8so-sheet > header > div {
    min-width:0;
  }
  html.ptm8so-mobile-page .ptm8so-sheet > header small,
  html.ptm8so-mobile-page .ptm8so-sheet > header h2 {
    color:#fff;
  }
  html.ptm8so-mobile-page .ptm8so-sheet > header h2 {
    font-size:16px;
    line-height:1.3;
    letter-spacing:-.01em;
  }
  html.ptm8so-mobile-page .ptm8so-sheet > header button {
    flex:0 0 42px;
    border:1px solid rgba(255,255,255,.55);
    border-radius:11px;
    color:#fff;
    font-size:25px;
    line-height:1;
  }
  html.ptm8so-mobile-page .ptm8so-picker > label span {
    color:#475467;
    font-size:12px;
    font-weight:800;
  }
  html.ptm8so-mobile-page .ptm8so-picker input {
    min-height:50px;
    border:1px solid var(--ptm83-line);
    border-radius:11px;
    font-size:16px;
    box-shadow:none;
  }
  html.ptm8so-mobile-page .ptm8so-picker input:focus-visible {
    border-color:var(--ptm83-accent);
    outline:2px solid rgba(21,94,239,.18);
    outline-offset:1px;
  }
  html.ptm8so-mobile-page .ptm8so-option {
    border-color:var(--ptm83-line);
    border-radius:11px;
    box-shadow:none;
  }
  html.ptm8so-mobile-page .ptm8so-option:focus-visible {
    outline:2px solid var(--ptm83-accent);
    outline-offset:2px;
  }

  /* The actual legacy tool surfaces, not a second editor or copied results. */
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay {
    --ptm83-ink:#101828;
    --ptm83-muted:#667085;
    --ptm83-line:#e1e4ea;
    --ptm83-soft:#f8fafc;
    --ptm83-accent:#155eef;
    --ptm83-gradient:linear-gradient(100deg,#1768ef,#6545ef 70%,#7b2de2);
    font-family:inherit;
    font-size:13px;
    line-height:1.5;
    padding:12px 14px calc(20px + env(safe-area-inset-bottom))!important;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-close {
    width:42px;
    height:42px;
    border:1px solid rgba(255,255,255,.65);
    border-radius:11px;
    background:#fff;
    color:#344054;
    font-size:25px;
    box-shadow:none;
    touch-action:manipulation;
  }

  /* Match the accepted Battle setup / Moves / EV-IV section language. */
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-legality-heading,.basic-analysis-heading,.basic-matchup-heading,
      .m34-stress-heading,.m45-repair-heading) {
    display:block;
    margin:-12px -14px 14px;
    padding:12px 66px 14px 14px;
    border-radius:23px 23px 0 0;
    background:var(--ptm83-gradient);
    color:#fff;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-legality-heading,.basic-analysis-heading,.basic-matchup-heading,
      .m34-stress-heading,.m45-repair-heading) > div {
    min-width:0;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-legality-heading,.basic-analysis-heading,.basic-matchup-heading,
      .m34-stress-heading,.m45-repair-heading) .eyebrow {
    margin:0 0 5px;
    color:rgba(255,255,255,.82);
    font-size:9px;
    font-weight:800;
    letter-spacing:.1em;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-legality-heading,.basic-analysis-heading,.basic-matchup-heading,
      .m34-stress-heading,.m45-repair-heading) h2 {
    margin:0 0 7px;
    color:#fff;
    font-size:16px;
    line-height:1.3;
    letter-spacing:-.01em;
    overflow-wrap:anywhere;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-legality-heading,.basic-analysis-heading,.basic-matchup-heading,
      .m34-stress-heading,.m45-repair-heading) p {
    margin:0;
    color:rgba(255,255,255,.9);
    font-size:12px;
    line-height:1.45;
  }

  /* The M1.7/M1.8 run buttons are real controls inside their headings. */
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-legality-heading,.basic-analysis-heading) > button {
    display:block;
    width:100%;
    min-height:46px;
    margin-top:12px;
    border:1px solid rgba(255,255,255,.8);
    border-radius:11px;
    background:#fff;
    color:#155eef;
    font:inherit;
    font-size:13px;
    font-weight:800;
    box-shadow:none;
  }

  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-legality-run,.basic-analysis-run,.basic-matchup-run,
      .m34-stress-run,.m45-repair-run,.m45-apply) {
    min-height:48px;
    width:100%;
    border:0;
    border-radius:12px;
    background:var(--ptm83-gradient);
    color:#fff;
    font:inherit;
    font-size:13px;
    font-weight:800;
    box-shadow:none;
    touch-action:manipulation;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay button:disabled {
    cursor:not-allowed;
    opacity:.6;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay button:focus-visible,
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay summary:focus-visible {
    outline:2px solid var(--ptm83-accent);
    outline-offset:2px;
  }

  /* All tool fields use one readable mobile column. */
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.m34-stress-controls,.m45-repair-controls,.m45-repair-candidates,
      .m34-stress-evidence,.basic-analysis-grid,.basic-matchup-grid,
      .m55-source-grid,.m55-explain-sections) {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    gap:10px;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.m34-stress-controls,.m45-repair-controls) {
    margin:12px 0;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.m45-repair-controls > label,.m34-stress-check,.matchup-threat-field) {
    min-width:0;
    display:grid;
    gap:7px;
    margin:0;
    padding:11px;
    border:1px solid var(--ptm83-line);
    border-radius:11px;
    background:#fff;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.m45-repair-controls > label > span,.m34-stress-check > span:first-child,
      .matchup-threat-field > label,.showdown-io-field > span) {
    color:#475467;
    font-size:12px;
    font-weight:800;
    line-height:1.4;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
      select,textarea) {
    box-sizing:border-box;
    width:100%;
    min-width:0;
    min-height:48px;
    border:1px solid var(--ptm83-line);
    border-radius:11px;
    background:#fff;
    color:var(--ptm83-ink);
    padding:10px 12px;
    font:inherit;
    font-size:16px;
    line-height:1.4;
    box-shadow:none;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
      select,textarea):focus-visible {
    border-color:var(--ptm83-accent);
    outline:2px solid rgba(21,94,239,.18);
    outline-offset:1px;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay input[type="checkbox"] {
    width:18px;
    height:18px;
    margin:0 7px 0 0;
    accent-color:var(--ptm83-accent);
    vertical-align:middle;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  .m34-stress-type-pair {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    gap:8px;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.m34-stress-check small,.m45-repair-controls small) {
    color:var(--ptm83-muted);
    font-size:12px;
    line-height:1.45;
  }

  /* Flat result surfaces and row-like evidence, without removing data. */
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-legality-result,.basic-analysis-result,.basic-matchup-result,
      .m34-stress-result,.m45-repair-result,.m55-explain-result) {
    margin-top:14px;
    padding:12px;
    border:1px solid var(--ptm83-line);
    border-radius:14px;
    background:#fff;
    box-shadow:none;
    min-width:0;
    overflow-wrap:anywhere;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-legality-result,.basic-analysis-result,.basic-matchup-result,
      .m34-stress-result,.m45-repair-result,.m55-explain-result) > strong {
    display:block;
    color:#0c1942;
    font-size:14px;
    line-height:1.35;
    font-weight:800;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-legality-result,.basic-analysis-result,.basic-matchup-result,
      .m34-stress-result,.m45-repair-result,.m55-explain-result) > p {
    color:var(--ptm83-muted);
    font-size:12px;
    line-height:1.5;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-analysis-card,.basic-matchup-card,.m34-stress-card,
      .m45-candidate-card,.m55-source-card,.m55-explain-section,.m55-explain-item) {
    min-width:0;
    padding:12px;
    border:1px solid var(--ptm83-line);
    border-radius:11px;
    background:#fff;
    box-shadow:none;
    overflow-wrap:anywhere;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-analysis-card,.basic-matchup-card,.m34-stress-card,
      .m45-candidate-card,.m55-source-card,.m55-explain-section,.m55-explain-item)
  :is(p,small) {
    color:var(--ptm83-muted);
    line-height:1.5;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-analysis-card,.basic-matchup-card) h3 {
    color:#344054;
    font-size:13px;
    line-height:1.4;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.basic-analysis-chip,.basic-matchup-chip) {
    max-width:100%;
    white-space:normal;
    overflow-wrap:anywhere;
    font-size:12px;
    line-height:1.4;
  }

  /* Repair: preserve source ordering, eligibility, all evidence and Preview. */
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m45-repair-candidates {
    margin-top:12px;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m45-candidate-card {
    display:grid;
    align-content:start;
    gap:9px;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m45-candidate-head {
    display:flex;
    flex-wrap:wrap;
    align-items:flex-start;
    gap:8px;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m45-candidate-head strong {
    flex:1 1 180px;
    min-width:0;
    color:#101828;
    font-size:13px;
    line-height:1.45;
    overflow-wrap:anywhere;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m45-candidate-head span,
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m34-stress-card-head span {
    flex:0 0 auto;
    max-width:100%;
    padding:4px 8px;
    border:1px solid #d9ddf5;
    border-radius:999px;
    background:#f5f3ff;
    color:#5b21b6;
    font-size:11px;
    font-weight:800;
    line-height:1.3;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m45-candidate-card p {
    margin:0;
    font-size:12px;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m45-candidate-card button {
    width:100%;
    min-height:46px;
    margin:0;
    border:1px solid #c7d2fe;
    border-radius:11px;
    background:#fff;
    color:#4f46e5;
    font:inherit;
    font-size:12px;
    font-weight:800;
    box-shadow:none;
    touch-action:manipulation;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m45-selection-preview {
    padding:12px;
    border:1px solid #c7d2fe;
    border-radius:11px;
    background:#f8faff;
    box-shadow:none;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m45-selection-preview > strong {
    color:#0c1942;
    font-size:13px;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m45-selection-preview p {
    color:#475467;
    font-size:12px;
    line-height:1.5;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.m45-repair-caveat,.m34-stress-caveat,.basic-analysis-caveat,
      .basic-matchup-caveat,.basic-legality-unevaluated,.m55-caveat) {
    color:var(--ptm83-muted);
    font-size:12px;
    line-height:1.5;
    overflow-wrap:anywhere;
  }

  /* Explain and Import/Export retain their native, functional accordions. */
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay.m55-explain-panel {
    border:0!important;
    border-radius:24px 24px 0 0!important;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m55-explain-details {
    overflow:visible;
    border:0;
    background:#fff;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m55-explain-details > summary,
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay.showdown-io-panel > summary {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    margin:-12px -14px 12px;
    padding:14px 66px 14px 14px;
    min-height:56px;
    border-radius:23px 23px 0 0;
    background:var(--ptm83-gradient);
    color:#fff;
    font-size:15px;
    font-weight:800;
    line-height:1.4;
    box-shadow:none;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m55-explain-details > summary::after {
    content:"＋";
    font-size:20px;
    color:#fff;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m55-explain-details[open] > summary::after {
    content:"−";
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay.showdown-io-panel > summary :is(strong,small) {
    color:#fff;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay.showdown-io-panel > summary::after {
    color:#fff;
    background:rgba(255,255,255,.18);
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m55-explain-body,
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .showdown-io-body {
    padding:0;
    border:0;
    background:#fff;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m55-source-card button,
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .showdown-io-actions button {
    min-height:46px;
    border:1px solid #c7d2fe;
    border-radius:11px;
    background:#fff;
    color:#4f46e5;
    font:inherit;
    font-size:12px;
    font-weight:800;
    box-shadow:none;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m55-meta-row {
    grid-template-columns:minmax(0,1fr);
    gap:3px;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay
  :is(.m55-meta-row code,.m55-list,.showdown-io-status) {
    overflow-wrap:anywhere;
    white-space:normal;
    font-size:12px;
    line-height:1.5;
  }

  /* Real expand/collapse controls only; no fabricated interactive chrome. */
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m75-explainer,
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m46-result-toggle {
    box-shadow:none;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m75-explainer {
    margin:10px 0;
    border:1px solid var(--ptm83-line);
    border-radius:11px;
    background:#fff;
  }
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay .m75-explainer > summary {
    padding:12px;
    color:#344054;
    font-size:12px;
    font-weight:800;
  }

  /* No result truncation, hidden evidence, artificial score, or new state owner.
     Offscreen card containment reduces layout/paint work on long result lists.
     It is progressive and must still pass real-device scroll/keyboard testing. */
  @supports (content-visibility:auto) {
    html.ptm8so-mobile-page .ptm8so-live-panel-overlay
    :is(.basic-analysis-card,.basic-matchup-card,.m34-stress-card,
        .m45-candidate-card,.m55-explain-item) {
      content-visibility:auto;
      contain-intrinsic-size:auto 160px;
    }
  }

  /* Preserve every existing hidden/disabled contract. */
  html.ptm8so-mobile-page .ptm8so-live-panel-overlay [hidden],
  html.ptm8so-mobile-page .ptm8so-sheet [hidden] {
    display:none!important;
  }
}
