:root {
  --brand: #4f6096;
  --brand-deep: #394a7a;
  --ink: #303949;
  --muted: #596477;
  --brand-tint: #eff2fa;
  --brand-tint-hover: #e4e9f6;
  --brand-border: #c5cde2;
}

.shop-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.shop-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: 8px;
  min-width: 44px;
  height: 44px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--brand);
  background: transparent;
  text-decoration: none;
  font: 600 15px/1.2 Sarabun, sans-serif;
  cursor: pointer;
}
.shop-action svg {
  width: 23px;
  height: 23px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bag-action { border-color: var(--brand-border); background: var(--brand-tint); }
.shop-action:hover { background: var(--brand-tint-hover); }
#bag-count {
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border-radius: 10px;
  background: var(--brand);
  color: white;
  text-align: center;
  font: 600 12px/19px Sarabun, sans-serif;
}
#bag {
  width: min(420px, calc(100% - 32px));
  max-height: 90dvh;
  overflow: auto;
  margin: auto;
  border: 0;
  padding: 20px;
  border-radius: 18px;
  background: white;
  color: var(--ink);
}
#bag::backdrop { background: #302521a8; }
#bag h2, #bag h3, #bag p, #bag dl, #bag dd { margin: 0; }
#bag h2 { font: 600 22px/1.5 Mali, sans-serif; }
#bag h3 { overflow-wrap: anywhere; }
#bag .dialog-top, #bag .total, #bag-costs div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
#bag .dialog-top { align-items: center; margin-bottom: 12px; }
#close-bag {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}
.cart-line { display: flex; align-items: center; gap: 15px; padding: 16px 0; }
.cart-line + .cart-line { border-top: 1px solid var(--line); }
.cart-line img { width: 85px; }
.cart-line p, .cart-line button, #bag-costs { font-size: 14px; }
.cart-line button {
  padding: 3px 0;
  border: 0;
  color: var(--brand);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: .25em;
}
.bag-quantity { display: inline-flex; align-items: center; width: max-content; margin: 4px 0; border: 1px solid var(--brand-border); border-radius: 12px; background: var(--brand-tint); }
.bag-quantity button { min-width: 44px; min-height: 44px; padding: 0; font: 600 19px/1 Mali,sans-serif; text-decoration: none; border-radius: 12px; }
.bag-quantity button:enabled:hover { background: var(--brand-tint-hover); }
.bag-quantity button:disabled { opacity: .4; }
.bag-quantity output { min-width: 22px; text-align: center; font: 600 16px Mali,sans-serif; }
.cart-line .text-button { display: block; min-height: 36px; }
#bag-costs div { color: var(--muted); padding: 2px 0; }
#bag .total {
  border-top: 1px solid var(--line);
  margin: 14px 0 6px;
  padding-top: 12px;
}
#bag .demo-note { color: var(--muted); font-size: 12px; }
#bag-checkout {
  width: 100%;
  min-height: 45px;
  margin-top: 12px;
  padding: 8px 15px;
  border: 1px solid var(--brand);
  border-radius: 12px;
  background: var(--brand);
  color: white;
  font-weight: 600;
}
#bag-checkout:hover { background: var(--brand-deep); }
.bag-links { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-top: 5px; }
.bag-links button, .bag-links a { display: inline-flex; align-items: center; min-height: 44px; border: 0; padding: 2px 0; background: transparent; color: var(--brand); font: 600 14px Sarabun, sans-serif; text-decoration: underline; text-underline-offset: .2em; }
#bag-error { color: #9a392c; }
@media (max-width: 650px) {
  .action-label { display: none; }
  .shop-action { padding: 0; }
  .shop-actions { gap: 5px; }
  #bag-count {
    position: absolute;
    top: -2px;
    right: -3px;
    box-shadow: 0 0 0 2px white;
  }
  #bag { padding: 16px; }
}

.mobile-menu { display: none; }
@media (max-width: 650px), (pointer: coarse) and (max-width: 980px) and (max-height: 500px) {
  header > .wrap, .bar > .wrap.row {
    width: 100%;
    min-height: 63px;
    height: auto;
    padding: 0 10px;
    display: grid;
    grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
    align-items: center;
    gap: 0;
  }
  header .home, .bar .brand {
    font: 600 clamp(18px, 5.4vw, 21px)/1.3 Mali, sans-serif;
    color: var(--brand);
    white-space: nowrap;
  }
  header .logomark, .bar .shelf-icon { display: none; }
  .shop-actions { gap: 1px; justify-self: end; }
  .shop-action { padding: 0; }
  .shop-actions .action-label { display: none; }
  .mobile-menu {
    display: grid; place-items: center; justify-self: start;
    width: 44px; height: 44px; padding: 0; margin: 0;
    background: transparent; color: var(--brand); border: 0; border-radius: 12px;
  }
  .mobile-menu span, .mobile-menu span::before, .mobile-menu span::after {
    display: block; width: 21px; height: 2px; border-radius: 2px; background: currentColor;
  }
  .mobile-menu span { position: relative; }
  .mobile-menu span::before, .mobile-menu span::after { position: absolute; left: 0; content: ""; }
  .mobile-menu span::before { top: -7px; }
  .mobile-menu span::after { top: 7px; width: 15px; }
}
body:has(#book-drawer[open]) { overflow: hidden; }
#book-drawer {
  box-sizing: border-box; inset: 0 auto 0 0; margin: 0;
  width: min(82vw, 340px); max-width: none; height: 100%; height: 100dvh; max-height: none;
  padding: max(12px, env(safe-area-inset-top)) 20px max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  border: 0; border-radius: 0; color: var(--ink); background: #fff; overflow: auto; overscroll-behavior: contain;
}
#book-drawer::backdrop { background: #27231f55; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; }
.drawer-head, .drawer-shortcuts { border-bottom: 1px solid #e2d9ce; }
.drawer-head h2 { margin: 0; font: 600 23px/1.4 Mali, sans-serif; }
.drawer-close { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--brand); }
#book-drawer svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#book-drawer h3 { margin: 16px 0 8px; font: 600 17px/1.5 Mali, sans-serif; }
.drawer-shortcuts { padding: 4px 0; }
#book-drawer a { display: flex; align-items: center; gap: 12px; min-height: 48px; border-radius: 8px; color: inherit; text-decoration: none; }
#book-drawer a:hover, #book-drawer a:focus-visible, .drawer-close:hover { background: var(--brand-tint); }
#drawer-themes a { min-height: 51px; font: 600 15px/1.5 Mali, sans-serif; }
#drawer-themes img { width: 32px; height: 36px; object-fit: contain; }
#drawer-themes a::after { content: ""; width: 6px; height: 6px; border: solid #83776b; border-width: 1.4px 1.4px 0 0; margin: 0 6px 0 auto; transform: rotate(45deg); }
@media (prefers-reduced-motion: no-preference) {
  #book-drawer[open] { animation: drawer-in 200ms cubic-bezier(.22,.8,.25,1); }
  @keyframes drawer-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }
}
