:root {
  --ink: #172033;
  --muted: #687386;
  --line: #e4e8ef;
  --paper: #f5f6f8;
  --brand: #173b7a;
  --brand-deep: #0d2859;
  --accent: #d5ae57;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

button, a { font: inherit; }

.top-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #fff;
  border-bottom: 1px solid #eaeaea;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.nav-inner {
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  padding: 12px 20px;
  display: grid;
  grid-template-columns: minmax(220px, 1.25fr) minmax(0, 5.5fr) minmax(220px, 1.25fr);
  align-items: center;
  gap: 12px;
}

.logo { min-width: 0; display: flex; align-items: center; gap: 10px; text-decoration: none; border-radius: 10px; }
.logo-img { height: 56px; width: auto; flex: 0 0 auto; transition: transform 0.3s ease; }
.logo:hover .logo-img { transform: scale(1.05); }
.logo:focus-visible { outline: 3px solid #94b5ed; outline-offset: 3px; }
.logo-text { font-size: 18px; font-weight: 700; color: #222; letter-spacing: 0.02em; white-space: nowrap; }
.info { min-width: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; font-size: 11px; }

.info .item {
  min-width: 0;
  min-height: 64px;
  display: flex;
  align-items: center;
  position: relative;
  padding: 8px 8px 8px 34px;
  color: #222;
  line-height: 1.3;
  text-decoration: none;
  background-color: #f7f7f7;
  background-repeat: no-repeat;
  background-position: 9px center;
  background-size: 17px 17px;
  border-radius: 8px;
  transition: all 0.25s ease;
}

.info .item:hover { background-color: #eee; transform: translateY(-2px); }
.info .item span { min-width: 0; overflow-wrap: anywhere; }
.info .item a { display: block; width: 100%; min-width: 0; color: inherit; text-decoration: none; }
.item.phone { background-image: url('/images/icons/phone.png'); }
.item.email { background-image: url('/images/icons/email.png'); }
.item.address { background-image: url('/images/icons/address.png'); }
.item.bank { background-image: url('/images/icons/bank.png'); }
.item.cloud { background-image: url('/images/icons/cloud.png'); }
.item.phone:hover { background-image: url('/images/icons/phone_mouseover.png'); }
.item.email:hover { background-image: url('/images/icons/email_mouseover.png'); }
.item.address:hover { background-image: url('/images/icons/address_mouseover.png'); }
.item.bank:hover { background-image: url('/images/icons/bank_mouseover.png'); }
.item.cloud:hover { background-image: url('/images/icons/cloud_mouseover.png'); }

.header-ebook-button {
  min-width: 0;
  min-height: 64px;
  padding: 8px 11px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(135deg, var(--brand-deep), var(--brand));
  border-radius: 10px;
  box-shadow: 0 7px 18px rgba(13, 40, 89, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.header-ebook-button:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(13, 40, 89, 0.28); }
.header-ebook-icon { width: 34px; height: 34px; display: grid; place-items: center; color: var(--brand-deep); background: #fff; border-radius: 9px; font-size: 18px; }
.header-ebook-button strong { display: block; overflow: hidden; font-size: 13px; letter-spacing: -0.04em; white-space: nowrap; text-overflow: ellipsis; }
.header-ebook-button small { display: block; margin-top: 3px; color: #cbd8ee; font-size: 10px; white-space: nowrap; }
.header-ebook-arrow { font-size: 18px; }

.catalog-layout {
  width: 100%;
  max-width: 1500px;
  height: calc(100dvh - 89px);
  min-height: 0;
  margin: 0 auto;
  padding: 28px 40px;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 42px;
  align-items: stretch;
  overflow: hidden;
}

.category-sidebar {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 14px 35px rgba(18, 33, 58, 0.07);
}

.category-sidebar::-webkit-scrollbar,
.category-nav::-webkit-scrollbar { width: 0; height: 0; display: none; }

.category-nav { padding: 10px; scrollbar-width: none; -ms-overflow-style: none; }

.category-button {
  width: 100%;
  padding: 14px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #4e596b;
  font-size: 13px;
  letter-spacing: -0.035em;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #eef0f4;
  border-radius: 9px;
  cursor: pointer;
  transition: 0.2s ease;
}

.category-button > span:first-child { white-space: nowrap; }

.category-button:last-child { border-bottom: 0; }
.category-button:hover { color: var(--brand); background: #f0f4fb; }
.category-button[aria-current="true"] { color: #fff; font-weight: 700; background: var(--brand); box-shadow: 0 8px 20px rgba(23, 59, 122, 0.22); }
.category-button .count { min-width: 31px; color: #8b95a5; font-size: 11px; text-align: right; }
.category-button[aria-current="true"] .count { color: #cddbf2; }

.product-main {
  min-width: 0;
  height: 100%;
  padding-right: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.product-heading {
  min-height: 82px;
  margin-bottom: 25px;
  padding-bottom: 21px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
}

.product-heading h1 { font-size: clamp(25px, 2.6vw, 34px); letter-spacing: -0.045em; }
.product-count { color: var(--muted); font-size: 13px; white-space: nowrap; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
}

.product-card {
  overflow: hidden;
  position: relative;
  aspect-ratio: 290 / 400;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 25px rgba(25, 39, 66, 0.06);
  cursor: zoom-in;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.product-card:hover { transform: translateY(-5px); box-shadow: 0 16px 38px rgba(25, 39, 66, 0.13); }
.product-card img { width: 100%; height: 100%; display: block; object-fit: contain; transition: transform 0.35s ease; }
.product-card:hover img { transform: scale(1.025); }
.product-card::after { content: "크게 보기 +"; position: absolute; right: 12px; bottom: 12px; padding: 7px 10px; color: #fff; font-size: 11px; font-weight: 700; background: rgba(12, 35, 78, 0.88); border-radius: 99px; opacity: 0; transform: translateY(5px); transition: 0.2s ease; }
.product-card:hover::after, .product-card:focus-visible::after { opacity: 1; transform: translateY(0); }
.product-page { position: absolute; left: 12px; bottom: 12px; padding: 7px 10px; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: 0.035em; background: rgba(12, 35, 78, 0.88); border-radius: 99px; opacity: 0; transform: translateY(5px); transition: 0.2s ease; }
.product-card:hover .product-page, .product-card:focus-visible .product-page { opacity: 1; transform: translateY(0); }
.product-card:focus-visible { outline: 3px solid #94b5ed; outline-offset: 3px; }

.image-modal[hidden] { display: none; }
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  padding: 12px;
  display: grid;
  place-items: center;
  background: rgba(5, 12, 28, 0.83);
  backdrop-filter: blur(8px);
  animation: modal-fade 0.22s ease both;
}

.modal-panel {
  width: min(1500px, calc(100vw - 24px));
  height: calc(100dvh - 24px);
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.55), 0 0 0 10px rgba(255, 255, 255, 0.09);
  animation: modal-float 0.3s cubic-bezier(.2, .8, .2, 1) both;
}

.modal-close {
  width: 50px;
  height: 50px;
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(12, 35, 78, 0.94);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.modal-close:hover { transform: rotate(8deg) scale(1.08); background: #071b41; }
.modal-close:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.modal-media { min-width: 0; min-height: 0; display: grid; place-items: center; overflow: hidden; background: #eceff4; }
.modal-media img { width: 100%; height: 100%; min-width: 0; min-height: 0; display: block; object-fit: contain; }
.modal-caption { padding: 12px 22px; display: flex; justify-content: space-between; gap: 16px; color: #596577; font-size: 13px; border-top: 1px solid var(--line); }
.modal-caption span:first-child { color: var(--ink); font-weight: 700; }

body.modal-open { overflow: hidden; }

@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-float { from { opacity: 0; transform: translateY(22px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

.site-footer { margin-top: 70px; padding: 32px 0 42px; color: #fff; background: #111214; border-radius: 18px 18px 0 0; font-size: 11px; }
.footer-inner { max-width: 1300px; margin: 0 auto; padding: 0 20px; display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 28px; text-align: left; }
.footer-inner h3 { margin-bottom: 7px; color: #fff; }
.footer-inner p { color: #d7dbe2; line-height: 1.65; }
.footer-bottom { max-width: 1300px; margin: 22px auto 0; padding: 14px 20px 0; color: #9299a5; border-top: 1px solid #333; }

@media (max-width: 1260px) {
  .nav-inner { grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr); }
  .info { grid-column: 1 / -1; grid-row: 2; font-size: 12px; }
  .header-ebook-button { grid-column: 2; grid-row: 1; }
  .catalog-layout { height: calc(100dvh - 164px); padding-inline: 28px; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .catalog-layout { height: auto; min-height: 0; display: block; overflow: visible; }
  .category-sidebar { height: auto; position: sticky; top: 95px; z-index: 100; margin-bottom: 32px; overflow-y: hidden; border-radius: 14px; }
  .category-nav { display: flex; gap: 8px; overflow-x: auto; padding: 10px; }
  .category-button { width: auto; min-width: max-content; padding: 11px 14px; border: 0; }
  .product-main { height: auto; padding-right: 0; overflow: visible; }
  .product-heading { position: static; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .nav-inner { padding: 8px 10px; grid-template-columns: minmax(0, 1fr) minmax(145px, 0.95fr); gap: 8px; }
  .logo { gap: 7px; }
  .logo-img { height: 42px; }
  .logo-text { font-size: 15px; letter-spacing: 0; }
  .info { display: none; }
  .header-ebook-button { min-height: 50px; padding: 7px 9px; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 6px; }
  .header-ebook-icon { width: 30px; height: 30px; font-size: 15px; }
  .header-ebook-button strong { font-size: 11px; }
  .header-ebook-button small { font-size: 9px; }
  .catalog-layout { padding: 20px 15px 60px; }
  .category-sidebar { top: 66px; }
  .product-heading { align-items: start; flex-direction: column; gap: 10px; }
  .product-grid { gap: 12px; }
  .product-card { border-radius: 10px; }
  .product-card::after { display: none; }
  .product-page { display: none; }
  .image-modal { padding: 8px; }
  .modal-panel { width: 100%; height: calc(100dvh - 16px); border-radius: 14px; }
  .modal-close { width: 44px; height: 44px; top: 10px; left: 10px; font-size: 29px; }
  .modal-caption { padding: 13px 15px; }
  .footer-inner { display: block; padding: 0 15px; }
  .footer-contact, .footer-bank { margin-top: 16px; }
  .footer-bottom { padding-inline: 15px; }
}

@media (max-width: 460px) {
  .nav-inner { grid-template-columns: minmax(0, 1fr) 142px; }
  .logo-text { font-size: 14px; }
  .header-ebook-arrow { display: none; }
  .product-grid { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.previous-catalog { position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 1100; padding: 11px 15px; border: 1px solid #d9e1ed; border-radius: 99px; background: #fff; color: #173b7a; box-shadow: 0 4px 16px #17203326; font-size: 12px; font-weight: 700; text-decoration: none; }
.previous-catalog:focus-visible { outline: 3px solid #94b5ed; outline-offset: 3px; }
