
/* 바보툰/바보노벨 제공 프론트엔드 반응형 보강 레이어 */
html {
  width: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}
body {
  width: 100%;
  min-width: 0 !important;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
#app {
  width: min(1440px, 100%) !important;
  max-width: 100%;
  margin: 0 auto;
}
button, a, input {
  -webkit-tap-highlight-color: rgba(0,0,0,0.08);
}
button, a {
  touch-action: manipulation;
}
input {
  min-width: 0;
}

/* Runtime UI */
.babo-toast-stack {
  position: fixed;
  left: 50%;
  bottom: max(88px, calc(24px + env(safe-area-inset-bottom)));
  transform: translateX(-50%);
  z-index: 10000;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.babo-toast {
  background: rgba(26, 26, 31, 0.94);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.16);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
  box-shadow: 0 14px 40px rgba(0,0,0,0.22);
  backdrop-filter: blur(10px);
  animation: baboToastIn 0.18s ease-out;
}
@keyframes baboToastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.babo-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: max(72px, env(safe-area-inset-top)) 18px 24px;
  background: rgba(26,26,31,0.48);
  backdrop-filter: blur(7px);
  overflow-y: auto;
}
.babo-modal {
  width: min(560px, 100%);
  background: var(--paper, #fff);
  color: var(--ink, #1A1A1F);
  border: 2px solid var(--ink, #1A1A1F);
  border-radius: 20px;
  box-shadow: 8px 8px 0 var(--ink, #1A1A1F), 0 18px 80px rgba(0,0,0,0.24);
  padding: 22px;
}
.babo-modal h3 {
  font-size: 24px;
  letter-spacing: -0.04em;
  margin-bottom: 8px;
}
.babo-modal p {
  color: var(--ink-2, #4A4A55);
  font-size: 13px;
  line-height: 1.55;
}
.babo-modal-close {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1.5px solid var(--ink, #1A1A1F);
  background: transparent;
  font-weight: 900;
}
.babo-modal-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.babo-field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-2, #4A4A55);
}
.babo-field input {
  width: 100%;
  min-height: 46px;
  border: 1.5px solid var(--ink, #1A1A1F);
  border-radius: 12px;
  background: var(--bg, #FAF7F2);
  color: var(--ink, #1A1A1F);
  padding: 0 13px;
  font: inherit;
  font-size: 15px;
  outline: none;
}
.babo-field input:focus {
  box-shadow: 0 0 0 3px rgba(255,77,61,0.2);
}
.babo-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.babo-primary-btn, .babo-secondary-btn {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 850;
  border: 1.5px solid var(--ink, #1A1A1F);
}
.babo-primary-btn {
  background: var(--tomato, var(--navy, #FF4D3D));
  color: var(--paper, #fff);
  box-shadow: 3px 3px 0 var(--ink, #1A1A1F);
}
.babo-secondary-btn {
  background: transparent;
  color: var(--ink, #1A1A1F);
}
.babo-search-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.babo-search-item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  padding: 10px;
  border: 1px solid rgba(26,26,31,0.14);
  border-radius: 14px;
  background: rgba(255,255,255,0.42);
  text-align: left;
}
.babo-search-thumb {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1.5px solid var(--ink, #1A1A1F);
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--tomato, #FF4D3D), var(--yolk, #FFD93D));
  color: var(--ink, #1A1A1F);
  font-size: 19px;
  font-weight: 900;
}
.babo-mobile-dock {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 9996;
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  background: rgba(26,26,31,0.92);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 22px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.26);
  backdrop-filter: blur(12px);
}
.babo-mobile-dock button, .babo-mobile-dock a {
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 16px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.babo-mobile-dock .active {
  background: rgba(255,255,255,0.14);
}
.babo-mobile-dock .badge {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--tomato, #FF4D3D);
  color: #fff;
  font-size: 10px;
  padding: 0 5px;
  margin-left: 3px;
}

@media (max-width: 1180px) {
  .babo-hero > div,
  .novel-hero > div {
    box-shadow: 5px 5px 0 var(--ink, #1A1A1F) !important;
  }
}

@media (max-width: 900px) {
  body { padding-bottom: 78px; }
  .babo-mobile-dock { display: grid; }

  .babo-topbar,
  .novel-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg, #FAF7F2) 92%, white 8%);
    backdrop-filter: blur(12px);
  }
  .babo-topbar > div:first-child,
  .novel-topbar > div:first-child {
    padding: 7px 14px !important;
    gap: 10px !important;
  }
  .babo-topbar > div:first-child > div:last-child,
  .novel-topbar > div:first-child > div:last-child {
    display: none !important;
  }
  .babo-topbar > div:nth-child(2),
  .novel-topbar > div:nth-child(2) {
    padding: 12px 14px 14px !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .babo-topbar > div:nth-child(2) > div:first-child,
  .novel-topbar > div:nth-child(2) > div:first-child {
    width: 100% !important;
    display: flex !important;
    gap: 12px !important;
    overflow-x: auto !important;
    padding-bottom: 2px !important;
    scrollbar-width: none;
  }
  .babo-topbar > div:nth-child(2) > div:first-child::-webkit-scrollbar,
  .novel-topbar > div:nth-child(2) > div:first-child::-webkit-scrollbar { display: none; }
  .babo-topbar nav,
  .novel-topbar nav {
    display: flex !important;
    overflow-x: auto !important;
    gap: 14px !important;
    min-width: max-content !important;
    padding-right: 8px !important;
    scrollbar-width: none;
  }
  .babo-topbar nav::-webkit-scrollbar,
  .novel-topbar nav::-webkit-scrollbar { display: none; }
  .babo-topbar > div:nth-child(2) > div:last-child,
  .novel-topbar > div:nth-child(2) > div:last-child {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr auto auto !important;
    gap: 8px !important;
  }
  .babo-topbar > div:nth-child(2) > div:last-child > div:first-child,
  .novel-topbar > div:nth-child(2) > div:last-child > div:first-child {
    width: 100% !important;
    min-height: 44px !important;
  }
  .babo-topbar button,
  .babo-topbar a,
  .novel-topbar button,
  .novel-topbar a {
    min-height: 42px;
  }

  .babo-hero,
  .babo-quickstrip,
  .babo-weekly,
  .babo-rankings,
  .babo-genres,
  .babo-curation,
  .babo-notice,
  .novel-hero,
  .novel-rankings,
  .novel-quote,
  .novel-genres,
  .novel-new,
  .novel-club,
  .novel-completed,
  .novel-cross {
    padding-left: 14px !important;
    padding-right: 14px !important;
    padding-bottom: 46px !important;
  }
  .babo-hero { padding-top: 18px !important; }
  .novel-hero { padding-top: 18px !important; }

  .babo-hero > div {
    min-height: 0 !important;
    height: auto !important;
    border-radius: 20px !important;
    box-shadow: 5px 5px 0 var(--ink) !important;
  }
  .babo-hero > div > div[style*="grid-template-columns"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 22px !important;
    padding: 62px 18px 58px !important;
  }
  .babo-hero h1 {
    font-size: clamp(42px, 15vw, 64px) !important;
    line-height: 0.94 !important;
    text-shadow: 2.5px 2.5px 0 var(--paper) !important;
  }
  .babo-hero p { font-size: 15px !important; }
  .babo-hero button { min-height: 48px; }
  .babo-hero > div > div[style*="grid-template-columns"] > div:last-child {
    justify-self: start !important;
    transform: rotate(-2deg) scale(0.78) !important;
    transform-origin: left top !important;
    height: 320px !important;
  }
  .babo-hero > div > div[style*="grid-template-columns"] > div:last-child > div {
    width: 220px !important;
    height: 300px !important;
  }
  .babo-hero > div > div[style*="top: 24"] {
    top: 14px !important;
    right: 14px !important;
  }
  .babo-hero > div > div[style*="bottom: 20px; left"] { left: 18px !important; }
  .babo-hero > div > div[style*="bottom: 20px; right"] { right: 14px !important; }

  .babo-quickstrip > div {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    padding: 20px !important;
    gap: 16px !important;
  }
  .babo-quickstrip > div > div {
    border-right: 0 !important;
    padding-right: 0 !important;
  }
  .babo-weekly > div:last-child {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 18px 12px !important;
  }
  .babo-rankings > div:last-child {
    grid-template-columns: 1fr !important;
    column-gap: 0 !important;
  }
  .babo-rankings > div:last-child > div {
    grid-template-columns: 54px 58px 1fr auto !important;
    gap: 10px !important;
  }
  .babo-rankings > div:last-child > div > div:nth-child(4) { display: none !important; }
  .babo-genres > div:last-child,
  .novel-genres > div:last-child {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  .babo-curation > div:last-child,
  .novel-club > div:last-child {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  .babo-notice > div {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    padding: 18px !important;
  }
  .babo-notice ul {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .babo-notice li { border-right: none !important; padding-right: 0 !important; }

  .novel-hero > div {
    display: grid !important;
    grid-template-columns: 1fr !important;
    padding: 30px 20px 74px !important;
    gap: 26px !important;
    min-height: 0 !important;
  }
  .novel-hero h1 {
    font-size: clamp(42px, 14vw, 62px) !important;
    line-height: 1 !important;
  }
  .novel-hero blockquote {
    font-size: 18px !important;
    padding-left: 15px !important;
  }
  .novel-hero p { font-size: 14px !important; }
  .novel-hero > div > div:nth-child(3) {
    min-height: 360px !important;
  }
  .novel-hero > div > div:nth-child(3) > div:not(:last-child) {
    transform: none !important;
    opacity: 0.24 !important;
  }
  .novel-hero button { min-height: 48px; }
  .novel-rankings > div:last-child {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }
  .novel-rankings > div:last-child > div:first-child {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 14px !important;
  }
  .novel-quote > div {
    grid-template-columns: 1fr !important;
    padding: 36px 22px !important;
  }
  .novel-quote p { font-size: 26px !important; }
  .novel-new > div:last-child {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 22px 14px !important;
  }
  .novel-completed > div:last-child { padding: 20px !important; }
  .novel-completed > div:last-child > div {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  .novel-cross a { padding: 28px 22px !important; }
  .novel-cross a > div { grid-template-columns: 1fr !important; }
  .novel-cross h3 { font-size: 30px !important; }

  footer.babo-footer,
  footer.novel-footer {
    padding: 42px 18px 110px !important;
  }
  footer.babo-footer > div:first-child,
  footer.novel-footer > div:first-child {
    grid-template-columns: 1fr 1fr !important;
    gap: 24px 18px !important;
  }
  footer.babo-footer > div:first-child > div:first-child,
  footer.novel-footer > div:first-child > div:first-child {
    grid-column: 1 / -1;
  }
  footer.babo-footer > div:last-child,
  footer.novel-footer > div:last-child {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .section-header,
  .novel-section-header {
    align-items: flex-start !important;
    flex-direction: column !important;
    gap: 12px !important;
    margin-bottom: 18px !important;
  }
  .section-header > div:first-child {
    display: grid !important;
    gap: 5px !important;
  }
  .section-header h2,
  .novel-section-header h2 {
    font-size: clamp(30px, 9vw, 38px) !important;
  }
  .section-header > div:last-child,
  .novel-section-header > div:last-child {
    width: 100% !important;
    overflow-x: auto !important;
    padding-bottom: 4px !important;
  }
}

@media (max-width: 520px) {
  .babo-modal-backdrop {
    align-items: flex-end;
    padding: 12px 10px max(12px, env(safe-area-inset-bottom));
  }
  .babo-modal {
    border-radius: 22px;
    padding: 18px;
    box-shadow: 0 -10px 60px rgba(0,0,0,0.22);
  }
  .babo-search-item {
    grid-template-columns: 42px 1fr;
  }
  .babo-search-item > span:last-child { display: none; }

  .babo-topbar > div:nth-child(2) > div:last-child,
  .novel-topbar > div:nth-child(2) > div:last-child {
    grid-template-columns: 1fr auto !important;
  }
  .babo-topbar > div:nth-child(2) > div:last-child > button:first-of-type,
  .novel-topbar > div:nth-child(2) > div:last-child > button:first-of-type {
    display: none !important;
  }
  .babo-topbar input,
  .novel-topbar input { font-size: 16px !important; }
  .babo-topbar kbd { display: none !important; }

  .babo-hero > div > div[style*="grid-template-columns"] > div:first-child > div:last-child,
  .novel-hero > div > div:first-of-type > div:last-child {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    width: 100% !important;
  }
  .babo-hero > div > div[style*="grid-template-columns"] > div:first-child > div:last-child button,
  .novel-hero > div > div:first-of-type > div:last-child button {
    justify-content: center !important;
    width: 100% !important;
  }
  .babo-quickstrip > div,
  .babo-weekly > div:last-child,
  .babo-genres > div:last-child,
  .novel-genres > div:last-child,
  .novel-new > div:last-child {
    grid-template-columns: 1fr 1fr !important;
  }
  .babo-rankings > div:last-child > div {
    grid-template-columns: 46px 52px 1fr auto !important;
  }
  .babo-rankings > div:last-child > div button { min-width: 38px; min-height: 38px; }
  .novel-rankings > div:last-child > div:first-child {
    grid-template-columns: 1fr !important;
  }
  .novel-rankings > div:last-child > div:first-child > div {
    display: grid !important;
    grid-template-columns: 110px 1fr !important;
    gap: 14px !important;
    align-items: center !important;
  }
  .novel-rankings > div:last-child > div:first-child > div > div:first-child {
    margin-bottom: 0 !important;
  }
}

/* 뷰어/리더 모바일 최적화 */
@media (max-width: 720px) {
  .topbar {
    padding: max(10px, env(safe-area-inset-top)) 12px 10px !important;
    gap: 10px !important;
  }
  .topbar .left { gap: 10px !important; min-width: 0; }
  .topbar .title,
  .topbar .meta-title .work {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 46vw;
  }
  .topbar .right { gap: 6px !important; }
  .topbar .right .icon-btn:not(:first-child):not(:last-child) { display: none; }
  .icon-btn, .topbar a.back {
    width: 42px !important;
    height: 42px !important;
    flex: 0 0 42px;
  }
  .canvas, .reader {
    width: 100% !important;
    max-width: 100% !important;
  }
  .panel-inner {
    min-height: 420px !important;
    padding: 28px 20px !important;
  }
  .scene-img { aspect-ratio: 4/3 !important; }
  .bubble {
    max-width: 86% !important;
    font-size: 15px !important;
    padding: 12px 16px !important;
  }
  .sfx { font-size: clamp(48px, 17vw, 70px) !important; }
  .reader {
    margin: 0 auto 24px !important;
    border-left: none !important;
    border-right: none !important;
    padding: 36px 22px 58px !important;
  }
  .chapter-meta { margin-bottom: 32px !important; padding-bottom: 24px !important; }
  .chapter-meta h1 { font-size: 30px !important; }
  .chapter-meta .num-line {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
  }
  .reader p {
    font-size: max(var(--reader-size, 17px), 17px) !important;
    line-height: max(var(--reader-leading, 1.85), 1.8) !important;
    text-align: left !important;
  }
  .reader p.dialogue { margin-left: 0 !important; }
  .comments,
  section[style*="max-width: 720px"] {
    padding-left: 16px !important;
    padding-right: 16px !important;
    margin-bottom: 76px !important;
  }
  .footer-bar {
    position: sticky !important;
    bottom: 0 !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom)) !important;
  }
  .footer-bar .nav-ep {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    width: 100%;
  }
  .footer-bar .nav-ep button {
    min-height: 44px;
    justify-content: center;
  }
  .progress-row,
  .footer-bar > div:nth-child(2) {
    width: 100%;
  }
  .footer-bar > div:last-child { display: none !important; }
  .settings-drawer {
    width: min(100%, 380px) !important;
    padding: 24px 18px max(24px, env(safe-area-inset-bottom)) !important;
  }
}

@media (max-width: 900px) {
  .babo-topbar > div:nth-child(2) > div:first-child > a:first-child,
  .novel-topbar > div:nth-child(2) > div:first-child > a:first-child {
    flex: 0 0 auto !important;
    min-width: max-content !important;
  }
  .babo-topbar > div:nth-child(2) > div:first-child > a:first-child > div,
  .novel-topbar > div:nth-child(2) > div:first-child > a:first-child > div {
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
  }
  .babo-topbar > div:nth-child(2) > div:first-child > a:first-child span,
  .novel-topbar > div:nth-child(2) > div:first-child > a:first-child span {
    white-space: nowrap !important;
  }
}

@media (max-width: 520px) {
  .novel-topbar > div:nth-child(2) > div:first-child > a:first-child span {
    font-size: 24px !important;
  }
  .novel-topbar > div:nth-child(2) > div:first-child > a:first-child svg {
    width: 30px !important;
    height: 30px !important;
  }
}

@media (max-width: 900px) {
  .babo-topbar > div:nth-child(2) > div:first-child > div:nth-child(2),
  .novel-topbar > div:nth-child(2) > div:first-child > div:nth-child(2) {
    flex: 0 0 auto !important;
    min-width: max-content !important;
  }
  .babo-topbar > div:nth-child(2) > div:first-child > div:nth-child(2) a,
  .babo-topbar > div:nth-child(2) > div:first-child > div:nth-child(2) span,
  .novel-topbar > div:nth-child(2) > div:first-child > div:nth-child(2) a,
  .novel-topbar > div:nth-child(2) > div:first-child > div:nth-child(2) span {
    white-space: nowrap !important;
  }
}