/* ==========================================================================
   Mobile Knowledge Graph — viewer-only entity browse.
   ========================================================================== */

@media (max-width: 767px) {
  body.mkg-no-scroll { overflow: hidden; }

  .mkg-overlay {
    position: fixed;
    inset: 0;
    background: #0a2e2e;
    color: #e0e0e8;
    z-index: 11500;
    display: flex;
    flex-direction: column;
  }

  .mkg-shell { display: flex; flex-direction: column; height: 100%; }

  .mkg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px;
    background: #0f3636;
    border-bottom: 1px solid #1a5252;
  }

  /* .mkg-lp-close (the full-screen Living Portrait's back) had NO rule and drew
     as a bare 24×27 default button (Greg 2026-10-17, FergiPhone probe). */
  .mkg-back,
  .mkg-lp-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    color: #e0e0e8;
    border-radius: 22px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }
  .mkg-back:active,
  .mkg-lp-close:active { background: rgba(255, 255, 255, 0.08); }

  .mkg-title {
    flex: 1;
    margin: 0;
    font-family: "Playfair Display", Georgia, serif;
    font-size: 18px;
    font-weight: 700;
  }

  /* The phone Living Portrait's reading surface (unifying-portrait-voice S2). Until S2 the
     shell had NO rules: `.mkg-lp-body` inherited the overlay's dark teal, the shared prose
     styles (FFALivingPortrait, written for the desktop card's white page) drew dark text on it,
     and nothing scrolled — the overlay measured 7,810 px of content in 844 px with
     `overflow: visible` under `body.mkg-no-scroll`, so most of a portrait was unreachable.
     The header stays dark; the reading body is the desktop card's light page and it scrolls. */
  .mkg-lp-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .mkg-lp-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: #fff;
    color: #1c1430;
    padding: 14px calc(16px + env(safe-area-inset-right, 0px))
             calc(28px + env(safe-area-inset-bottom, 0px))
             calc(16px + env(safe-area-inset-left, 0px));
    font-size: 16px;
    line-height: 1.5;
  }

  /* The phone Living Portrait's hero Say It (unifying-portrait-voice S2, R4). */
  .mkg-sayit-slot {
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }
  .mkg-sayit-slot:empty { display: none; }

  .mkg-readonly-chip {
    background: rgba(232, 160, 64, 0.15);
    color: #f0c270;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 4px 10px;
    border-radius: 999px;
    flex-shrink: 0;
  }

  .mkg-body {
    flex: 1;
    overflow-y: auto;
    /* binary-hatching-pearl D2 (2026-05-09): L/R floor removed per Iron-Law
       class fix — env safe-area only. */
    padding: 12px env(safe-area-inset-right, 0px) calc(80px + env(safe-area-inset-bottom, 0px))
             env(safe-area-inset-left, 0px);
  }

  .mkg-loading,
  .mkg-error,
  .mkg-empty {
    padding: 32px 16px;
    text-align: center;
    color: #a8b0b8;
    font-size: 14px;
  }

  .mkg-error { color: #ff8a80; }

  /* Toolbar */
  .mkg-toolbar { margin-bottom: 10px; }

  .mkg-search {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: #0f3636;
    border: 1px solid #1a5252;
    border-radius: 12px;
    color: #e0e0e8;
    font-size: 16px;
    padding: 12px 14px;
    min-height: 44px;
    box-sizing: border-box;
  }

  .mkg-search::placeholder { color: #6f7d85; }
  .mkg-search:focus {
    outline: none;
    border-color: #6DD4D4;
    box-shadow: 0 0 0 2px rgba(109, 212, 212, 0.25);
  }

  /* Filter chips */
  .mkg-chips {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .mkg-chip {
    appearance: none;
    background: rgba(255, 255, 255, 0.06);
    color: #a8b0b8;
    border: 1px solid #1a5252;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    min-height: 32px;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }

  .mkg-chip-active {
    background: #6DD4D4;
    color: #0a2e2e;
    border-color: #6DD4D4;
  }

  /* Entity list */
  .mkg-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .mkg-entity-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
    background: #0f3636;
    border: 1px solid #1a5252;
    border-radius: 12px;
    padding: 12px 14px;
    min-height: 56px;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mkg-entity-row:active { transform: scale(0.99); }

  .mkg-row-name {
    font-family: "Playfair Display", Georgia, serif;
    font-size: 15px;
    font-weight: 700;
    color: #e0e0e8;
    line-height: 1.25;
  }

  .mkg-row-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #7d8a92;
  }

  .mkg-row-type {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6DD4D4;
    font-weight: 600;
  }

  /* Detail */
  .mkg-detail {
    padding: 4px 4px 16px;
  }

  .mkg-detail-tag {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6DD4D4;
    font-weight: 700;
    margin-bottom: 4px;
  }

  .mkg-detail-name {
    margin: 0 0 8px;
    font-family: "Playfair Display", Georgia, serif;
    font-size: 22px;
    font-weight: 700;
  }

  .mkg-detail-summary {
    margin: 0 0 14px;
    font-size: 14px;
    line-height: 1.55;
    color: #c8cdd2;
  }

  .mkg-detail-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
  }

  .mkg-action {
    appearance: none;
    border: 1px solid #1a5252;
    background: rgba(255, 255, 255, 0.06);
    color: #e0e0e8;
    border-radius: 12px;
    padding: 10px 14px;
    min-height: 44px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex: 1;
  }

  .mkg-action-primary {
    background: #6DD4D4;
    color: #0a2e2e;
    border-color: #6DD4D4;
  }

  .mkg-members-title {
    font-family: "Playfair Display", Georgia, serif;
    font-size: 15px;
    font-weight: 700;
    color: #e0e0e8;
    margin: 0 0 8px;
  }

  .mkg-members-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .mkg-member {
    appearance: none;
    border: 0;
    padding: 0;
    background: #1a5252;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mkg-member img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
}
