/* KIRU 161 — launch viewport hardening. Loaded last on the interactive app. */
html,
body.kiru-core84 { max-width: 100%; overflow-x: clip; }
body.kiru-core84 :is(.app-shell, .app-shell > main, .view, .panel, .page-head, .section-head, .topbar, .top-actions),
body.kiru-core84 :is(.view, .panel, .page-head, .section-head, .topbar, .top-actions) > * { min-width: 0; }
body.kiru-core84 :is(button, a, input, select, textarea):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--k84-crimson, #f43f5e) 42%, transparent) !important;
  outline-offset: 3px !important;
}
body.kiru-core84 :is(.anime-row, .poster-row, .home-stream-track, .atlas-track) {
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

/* Tablet is an intentional bridge: compact command header, editorial hero, touch-sized controls. */
@media (min-width: 761px) and (max-width: 980px) {
  body.kiru-core84 .app-shell > main { padding: 0 18px calc(104px + env(safe-area-inset-bottom)) !important; }
  body.kiru-core84 .topbar {
    grid-template-columns: minmax(112px, 1fr) auto !important;
    min-height: 72px !important;
    gap: 12px !important;
  }
  body.kiru-core84 .topbar .top-actions { justify-content: end !important; }
  body.kiru-core84 .topbar :is(#searchOpen, #askKiruOpen, .k82-cloud-pill) {
    width: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
    padding: 0 !important;
    border-radius: 14px !important;
  }
  body.kiru-core84 #home > .v47-home {
    padding: 38px 34px 30px !important;
    grid-template-columns: minmax(0, 1.12fr) minmax(220px, .68fr) !important;
    grid-template-areas: "copy art" "jobs jobs" "continue continue" !important;
    gap: 26px 28px !important;
  }
  body.kiru-core84 #home .v47-home-copy h1 {
    max-width: 560px !important;
    font-size: clamp(50px, 7.2vw, 66px) !important;
  }
  body.kiru-core84 #home .v48-art-stack { min-height: 250px !important; }
  body.kiru-core84 #home .v47-jobs { grid-template-columns: 1fr 1fr !important; }
  body.kiru-core84 #home .v47-jobs > button { min-width: 0 !important; min-height: 92px !important; }
  body.kiru-core84 :is(.primary-button, .secondary-button, .filter-row button, .v13-subnav button) { min-height: 46px; }
  body.kiru-core84 :is(.k150-dialog, .k82-account-dialog, #detailDialog, #actionDialog) {
    width: calc(100vw - 32px) !important;
    max-width: calc(100vw - 32px) !important;
  }
}

@media (max-width: 760px) {
  body.kiru-core84 { --k161-gutter: 14px; }
  body.kiru-core84 .app-shell > main {
    width: 100% !important;
    min-width: 0 !important;
    padding-right: var(--k161-gutter) !important;
    padding-left: var(--k161-gutter) !important;
    padding-bottom: calc(98px + env(safe-area-inset-bottom)) !important;
    overflow-x: clip !important;
  }
  body.kiru-core84 .topbar {
    width: calc(100% + (var(--k161-gutter) * 2)) !important;
    margin-inline: calc(var(--k161-gutter) * -1) !important;
    padding-inline: var(--k161-gutter) !important;
  }
  body.kiru-core84 .topbar .top-actions { min-width: 0 !important; overflow: visible !important; }

  body.kiru-core84 #home > .v47-home {
    width: 100% !important;
    min-width: 0 !important;
    padding: 24px 18px 18px !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: "copy" "continue" "jobs" !important;
    gap: 14px !important;
  }
  body.kiru-core84 #home .v47-home-copy,
  body.kiru-core84 #home .v47-continue,
  body.kiru-core84 #home .v47-jobs { width: 100% !important; min-width: 0 !important; }
  body.kiru-core84 #home .v47-home-copy h1 {
    max-width: 100% !important;
    margin-bottom: 14px !important;
    font-size: clamp(41px, 12vw, 54px) !important;
    line-height: .92 !important;
    overflow-wrap: anywhere !important;
  }
  body.kiru-core84 #home .v47-home-copy > p { max-width: 32rem !important; font-size: 14px !important; }
  body.kiru-core84 #home .v47-continue,
  body.kiru-core84 #home .v47-continue.empty {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: start !important;
    gap: 10px !important;
    min-height: 0 !important;
    padding: 15px !important;
  }
  body.kiru-core84 #home .v47-continue > :is(span, div, button) { min-width: 0 !important; max-width: 100% !important; }
  body.kiru-core84 #home .v47-continue > button {
    position: static !important;
    width: 100% !important;
    min-height: 48px !important;
    margin: 0 !important;
    justify-content: center !important;
    white-space: normal !important;
  }
  body.kiru-core84 #home .v47-jobs {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 9px !important;
  }
  body.kiru-core84 #home .v47-jobs > button {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }
  body.kiru-core84 #home .v47-jobs > button > div { min-width: 0 !important; }
  body.kiru-core84 #home .v47-jobs b { white-space: normal !important; overflow-wrap: anywhere !important; }
  body.kiru-core84 #home .continue-section { margin-top: 26px !important; padding-bottom: 6px !important; }

  body.kiru-core84 .section-head { align-items: flex-start !important; }
  body.kiru-core84 .section-head > :is(a, button) { flex: 0 0 auto; }
  body.kiru-core84 :is(.page-head h1, .editorial-head h1, .section-head h2) { overflow-wrap: anywhere; }
  body.kiru-core84 :is(.panel, .library-card, .smart-rec-card, .k150-thread-card, .k155-form-card) { max-width: 100%; }
  body.kiru-core84 :is(input, select, textarea) { max-width: 100%; font-size: 16px !important; }
  body.kiru-core84 :is(button, .primary-button, .secondary-button) { min-height: 44px; }

  body.kiru-core84 .bottom-nav {
    right: 8px !important;
    left: 8px !important;
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    padding-bottom: max(5px, env(safe-area-inset-bottom)) !important;
  }
  body.kiru-core84 .bottom-nav button { min-width: 0 !important; overflow: hidden !important; }
  body.kiru-core84 .bottom-nav button > span:last-child {
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  body.kiru-core84 :is(.app-dialog, .k150-dialog, .k82-account-dialog, #detailDialog, #actionDialog, #roomDialog) {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    inset: 0 !important;
  }
  body.kiru-core84 :is(.app-dialog, .k150-dialog, .k82-account-dialog, #detailDialog, #actionDialog, #roomDialog) > * {
    max-width: 100% !important;
  }
  body.kiru-core84 .k150-dialog-shell,
  body.kiru-core84 .k82-account-shell,
  body.kiru-core84 #detailContent { border-radius: 0 !important; }
  body.kiru-core84 :is(.k150-dialog-shell > main, .k82-account-shell > main, #detailContent .detail-body) {
    padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
    overscroll-behavior: contain !important;
  }
  body.kiru-core84 .k155-profile-form > footer { bottom: calc(82px + env(safe-area-inset-bottom)) !important; }
  body.kiru-core84 .k80-site-footer { margin-bottom: calc(94px + env(safe-area-inset-bottom)) !important; }
}

@media (max-width: 520px) {
  body.kiru-core84.kiru-mobile85 #home > .v47-home .v47-jobs {
    display: flex !important;
    width: 100% !important;
    flex-direction: column !important;
  }
  body.kiru-core84.kiru-mobile85 #home > .v47-home .v47-jobs > button {
    width: 100% !important;
    min-height: 74px !important;
    grid-template-columns: auto auto minmax(0, 1fr) auto !important;
  }
  body.kiru-core84.kiru-mobile85 #home > .v47-home .v47-jobs :is(small, b) {
    writing-mode: horizontal-tb !important;
    word-break: normal !important;
  }
  body.kiru-core84 .section-head { flex-direction: column !important; gap: 10px !important; }
  body.kiru-core84 .section-head > :is(a, button) { align-self: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  body.kiru-core84 *, body.kiru-core84 *::before, body.kiru-core84 *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
