/* Kafra storage */
.kafra-backdrop {
  position: absolute;
  inset: -18px;
  width: calc(100% + 36px);
  height: calc(100% + 36px);
  object-fit: cover;
  object-position: right center;
  filter: blur(12px) brightness(.75);
}
.kafra-art {
  position: absolute;
  right: -3%;
  bottom: -10%;
  height: 125%;
  max-width: 78%;
  object-fit: contain;
  object-position: right bottom;
}
.kafra-scene .town-service-storage-window {
  width: 260px;
  height: calc(100% - 24px);
}
.town-service-storage-body { display: flex; flex: 1; min-height: 0; background: #fff; }
.town-service-storage-tabs {
  position: relative;
  flex: 0 0 24px;
  width: 24px;
  height: 282px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
.town-service-storage-tabs button {
  position: absolute;
  left: 0;
  width: 100%;
  height: 12.5%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.town-service-storage-tabs button:focus-visible { outline: 2px solid #2861a0; outline-offset: -2px; }
.town-service-storage-list {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background: #fff;
}
.town-service-storage-row {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  gap: 5px;
  padding: 2px 5px;
  border: 0;
  border-bottom: 1px solid #e9edf0;
  background: #fff;
  color: #293a4c;
  text-align: left;
  font-size: 12px;
  cursor: pointer;
}
.town-service-storage-row:hover,
.town-service-storage-row:focus-visible { background: #e8f1fb; }
.town-service-storage-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.town-service-storage-row b { font-size: 11px; }

/* User-authorized Kafra adaptation. The original art and category bitmaps are
   unchanged; layout shares the Merchant L composition and service host. */
.kafra-scene { --kafra-list-w: min(340px, 36%); --kafra-bag-height: 220px; }
.kafra-art { right: 0; bottom: 0; height: 100%; max-width: 66%; object-position: right bottom; }
.kafra-scene .town-service-storage-window { top: 8px; left: 8px; width: var(--kafra-list-w); height: calc(100% - 16px); max-height: none; }
.kafra-scene .town-service-bag-window { top: auto; bottom: 8px; left: calc(var(--kafra-list-w) + 16px); width: min(430px, calc(100% - var(--kafra-list-w) - 24px)); min-width: 0; height: var(--kafra-bag-height); max-height: calc(100% - 16px); }
.kafra-scene .town-service-bag-window > .titlebar,
.kafra-scene .town-service-bag-window > .town-service-foot { flex-shrink: 0; }
.kafra-bag-resize { position: absolute; top: 0; left: 0; right: 76px; height: 12px; z-index: 3; cursor: ns-resize; touch-action: none; }
.kafra-bag-resize:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
.kafra-bag-resize::after { content: ''; position: absolute; top: 3px; left: 40%; width: 20%; height: 2px; background: currentColor; opacity: .45; }
.kafra-scene .town-service-bag-grid { grid-template-columns: repeat(auto-fill, 44px); }
.kafra-scene .town-service-slot { width: 44px; height: 44px; }
.kafra-scene .town-service-slot:disabled,.kafra-scene .town-service-storage-row:disabled { opacity: .55; cursor: wait; }
.kafra-scene .town-service-storage-body { overflow: hidden; }
.kafra-scene .town-service-notice { line-height: 1.4; }
.kafra-check { margin: 0 8px 8px; }
.kafra-item-details { flex-basis: 100%; font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.kafra-scene .town-service-quantity-body { flex-wrap: wrap; }
@media (max-width: 520px) {
  .minimap-wrap.town-service-open:has(.kafra-scene) { height: 660px; }
  .kafra-scene .town-service-storage-window { top: 8px; bottom: 236px; left: 8px; width: 56%; height: auto; max-height: none; }
  .kafra-scene .kafra-art { top: 8px; bottom: auto; right: 0; height: calc(100% - 176px); max-width: 50%; object-position: right top; }
  .kafra-scene .town-service-storage-tabs { flex-basis: 30px; width: 30px; height: 352px; }
  .kafra-scene .town-service-bag-window { top: auto; bottom: 8px; left: 8px; width: calc(100% - 16px); }
  .kafra-scene .town-service-storage-name { white-space: normal; overflow-wrap: anywhere; }
  .kafra-scene .town-service-storage-row { min-height: 44px; }
}

/* 2026-09-28 user-authorized restyle: same glass theme as the Merchant shop
   and Refine forge. Layout (storage left, art right, bag bottom) is unchanged. */
.kafra-scene { background: #22170d; }
.kafra-film {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 72% 35%;
  pointer-events: none;
}
.kafra-scene .forge-sound { position: absolute; right: 10px; top: 10px; z-index: 2; }
.kafra-scene .town-service-window {
  border: 1px solid rgb(255 214 150 / 45%);
  border-radius: 8px;
  background: rgb(28 16 8 / 38%);
  backdrop-filter: blur(7px) saturate(1.15);
  box-shadow: 0 6px 22px rgb(0 0 0 / 35%), inset 0 1px 0 rgb(255 240 210 / 25%);
  color: #fbeed4;
}
.kafra-scene .town-service-window > .titlebar {
  background: linear-gradient(rgb(255 225 170 / 28%), rgb(120 70 30 / 22%));
  border-bottom: 1px solid rgb(255 214 150 / 35%);
  color: #fff3dc;
  text-shadow: 0 1px 2px rgb(0 0 0 / 70%);
}
.kafra-scene .town-service-preview-tag { color: #f5d9a6; }
.kafra-scene .town-service-close {
  border: 1px solid rgb(255 220 160 / 55%);
  border-radius: 4px;
  background: rgb(255 255 255 / 12%);
  color: #fff3dc;
}
.kafra-scene .town-service-storage-body,
.kafra-scene .town-service-storage-list,
.kafra-scene .town-service-bag-grid { background: transparent; }
.kafra-scene .town-service-storage-tabs { opacity: .92; border-right: 1px solid rgb(255 214 150 / 30%); }
.kafra-scene .town-service-storage-row {
  border-bottom-color: rgb(255 214 150 / 16%);
  background: transparent;
  color: #fbeed4;
  text-shadow: 0 1px 2px rgb(0 0 0 / 60%);
}
.kafra-scene .town-service-storage-row:hover,
.kafra-scene .town-service-storage-row:focus-visible { background: rgb(255 210 140 / 16%); }
.kafra-scene .town-service-storage-row b { color: #ffd98a; }
.kafra-scene .town-service-empty { color: #e0c9a2; }
.kafra-scene .town-service-foot { border-top-color: rgb(255 214 150 / 30%); color: #f1dfbf; }
.kafra-scene .town-service-foot button,
.kafra-scene .kafra-check {
  border: 1px solid rgb(255 220 150 / 70%);
  border-radius: 4px;
  background: linear-gradient(rgb(255 214 130 / 55%), rgb(190 120 40 / 55%));
  color: #fff;
  font-weight: bold;
  text-shadow: 0 1px 2px rgb(0 0 0 / 60%);
}
.kafra-scene .town-service-notice { color: #ffcf9a; text-shadow: 0 1px 2px rgb(0 0 0 / 60%); }
.kafra-scene .town-service-slot {
  border: 1px solid rgb(255 214 150 / 40%);
  border-radius: 4px;
  background: rgb(255 255 255 / 14%);
}
.kafra-scene .town-service-slot:hover,
.kafra-scene .town-service-slot:focus-visible { border-color: #ffd98a; background: rgb(255 210 140 / 26%); }
.kafra-scene .town-service-slot b { color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.kafra-scene .town-service-quantity-window {
  border: 1px solid rgb(255 214 150 / 55%);
  border-radius: 8px;
  background: rgb(36 22 10 / 82%);
  backdrop-filter: blur(8px);
  color: #fbeed4;
}
.kafra-scene .town-service-quantity-window > .titlebar { background: linear-gradient(rgb(255 225 170 / 30%), rgb(120 70 30 / 25%)); color: #fff3dc; }
.kafra-scene .town-service-quantity-body input { border: 1px solid rgb(255 214 150 / 50%); border-radius: 4px; background: rgb(0 0 0 / 30%); color: #fff6e4; }
.kafra-scene .town-service-quantity-actions .primary { border: 1px solid rgb(255 220 150 / 70%); border-radius: 4px; background: linear-gradient(rgb(255 214 130 / 60%), rgb(190 120 40 / 60%)); color: #fff; font-weight: bold; }
.kafra-scene .kafra-item-details { color: #e8d4b0; }
@media (max-width: 520px) {
  .kafra-film-scene {
    background: linear-gradient(rgb(27 15 7 / 55%), rgb(27 15 7 / 75%)), #22170d;
  }
  .kafra-film-scene .kafra-film {
    inset: 0 auto auto 0;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    transform-origin: 72% 0;
    transform: scale(1);
    transition: transform 900ms cubic-bezier(.22, .61, .36, 1);
  }
  .kafra-film-scene .kafra-film.kafra-zoom { transform: scale(var(--kafra-closeup-scale, 1.8)); transition-duration: 160ms; }
  .kafra-film-scene .town-service-storage-window { top: 214px; bottom: 168px; left: 8px; width: calc(100% - 16px); }
}
@media (prefers-reduced-motion: reduce) {
  .kafra-film-scene .kafra-film { transition: none; }
}
.kafra-scene.forge-quake-strong { animation: forge-quake-strong 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
.kafra-scene.forge-quake { animation: forge-quake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

/* Phones: a taller, Jensen-centred crop of the film, a thumb-sized sound
   button and a slightly taller host so the storage list keeps its height. */
@media (max-width: 520px) {
  .service-entry-host[data-service-kind="KAFRA"]:has(.kafra-film-scene),
  .minimap-wrap.town-service-open:has(.kafra-film-scene) { height: 700px; }
  .kafra-film-scene .kafra-film {
    height: 250px;
    aspect-ratio: auto;
    object-fit: cover;
    object-position: 78% 18%;
    transform-origin: 56% 20%;
  }
  .kafra-film-scene .town-service-storage-window { top: 256px; }
  .kafra-scene .forge-sound { top: 8px; right: 8px; width: 40px; height: 40px; font-size: 18px; }
}

/* Category tabs drawn in the glass theme (the RO tab bitmaps were retired). */
.kafra-scene .town-service-storage-tabs {
  display: flex;
  flex-direction: column;
  flex: 0 0 32px;
  width: 32px;
  height: auto;
  align-self: stretch;
  gap: 3px;
  padding: 4px 3px;
  border-right: 1px solid rgb(255 214 150 / 22%);
  background: rgb(0 0 0 / 20%);
  background-image: none;
  opacity: 1;
  overflow-y: auto;
}
.kafra-scene .town-service-storage-tabs button {
  position: static;
  flex: 1 1 0;
  min-height: 34px;
  width: 100%;
  height: auto;
  padding: 3px 0;
  border: 1px solid rgb(255 214 150 / 22%);
  border-radius: 4px;
  background: rgb(255 255 255 / 6%);
  color: #e9d6b2;
  font-size: 12px;
  line-height: 1.05;
  letter-spacing: 1px;
  writing-mode: vertical-rl;
  text-orientation: upright;
  text-shadow: 0 1px 2px rgb(0 0 0 / 70%);
  cursor: pointer;
}
.kafra-scene .town-service-storage-tabs button:hover { background: rgb(255 210 140 / 16%); color: #fff3dc; }
.kafra-scene .town-service-storage-tabs button[aria-selected='true'] {
  border-color: rgb(255 220 150 / 75%);
  background: linear-gradient(rgb(255 214 130 / 55%), rgb(190 120 40 / 50%));
  color: #fff;
  font-weight: bold;
}
.kafra-scene .town-service-storage-tabs button:focus-visible { outline: 2px solid #ffd98a; outline-offset: -2px; }
/* Phones: a horizontal, thumb-sized tab strip above the list. */
@media (max-width: 520px) {
  .kafra-scene .town-service-storage-body { flex-direction: column; }
  .kafra-scene .town-service-storage-tabs {
    flex: 0 0 auto;
    flex-direction: row;
    width: auto;
    height: auto;
    padding: 4px;
    border-right: 0;
    border-bottom: 1px solid rgb(255 214 150 / 22%);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .kafra-scene .town-service-storage-tabs button {
    flex: 1 1 0;
    width: auto;
    min-width: 40px;
    min-height: 40px;
    padding: 0 2px;
    letter-spacing: 0;
    writing-mode: horizontal-tb;
    font-size: 13px;
  }
}

/* Phone glass: blurred costume still behind the panels (desktop uses the film). */
.kafra-film-backdrop { display: none; }
@media (max-width: 520px) {
  .kafra-film-scene { background: #22170d; }
  .kafra-film-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 62% 45%;
    filter: blur(8px) brightness(.72) saturate(1.15);
    transform: scale(1.08);
    pointer-events: none;
  }
  .kafra-film-scene .town-service-window { background: rgb(28 16 8 / 30%); }
}

/* Phone storage uses the same icon/quantity slots as the inventory bag. */
@media (max-width: 520px) {
  .kafra-scene .town-service-storage-list {
    display: grid; grid-template-columns: repeat(auto-fill, 44px);
    align-content: start; gap: 3px; padding: 8px;
  }
  .kafra-scene .town-service-storage-row {
    position: relative; display: grid; place-items: center;
    width: 44px; height: 44px; min-height: 44px; padding: 2px;
    border: 1px solid rgb(255 214 150 / 40%); border-radius: 4px;
    background: rgb(255 255 255 / 14%);
  }
  .kafra-scene .town-service-storage-name { display: none; }
  .kafra-scene .town-service-storage-row b { position: absolute; right: 2px; bottom: 0; }
  .kafra-scene .town-service-storage-list > .town-service-empty { grid-column: 1 / -1; }
}
