/* Top bar + phone bar (2026-11-08 rework): templates/base.html header, navigation.js. Prefixes mn- (nav + menus), tb-,
   pn- (phone bar), ms- (phone Menu sheet).
   >= 1280px  one row, 64px (the bar's own width runs to 1400px): logo | Live shops, Free Market shops, Price Check | Database, Guides, More menus | search | buttons
   761-1279   two rows, 108px: logo | search | buttons, then the tabs (menus still open from them)
   <= 760     60px: logo | search button | buttons; the bottom bar + Menu sheet do the navigating
   Loaded after hubcw.css, whose older top-bar rules (several layers) this file overrides. Soft shadows only. */

:root { --topbar-h: 64px; }
.topbar, .msheet { --mn-slot-1: #fff; --mn-slot-2: #e8eff7; --mn-slot-line: #cfdbe8; }

/* ---------- the bar ---------- */
.topbar .wrap { max-width: 1400px; display: flex; flex-wrap: nowrap; align-items: center; gap: 0 16px; height: var(--topbar-h); min-height: 0; padding-top: 0; padding-bottom: 0; }
.topbar .brand { flex: none; height: 44px; }
.topbar .brand svg { width: 30px; height: 30px; }
.topbar .brand .name { font-size: 23px; }

/* ---------- tabs ---------- */
.mnav { position: relative; display: flex; align-items: stretch; align-self: stretch; flex: none; min-width: 0; gap: 2px; }
.mn-tab { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 100%; padding: 0 10px; border: 0; background: none; color: var(--ink-2);
  font: 600 14px/1 var(--font); letter-spacing: -.005em; white-space: nowrap; cursor: pointer; text-decoration: none; }
.mn-tab::before { content: ''; position: absolute; inset: 12px 2px; z-index: -1; border-radius: 10px; background: var(--bg-2); opacity: 0; transition: opacity .15s; }
.mn-tab::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); transform: scaleX(0); transition: transform .2s; }
.mn-tab:hover, .mn-dd:hover > .mn-tab, .mn-dd:focus-within > .mn-tab, .mn-dd.open > .mn-tab { color: var(--ink); }
.mn-tab:hover::before, .mn-dd:hover > .mn-tab::before, .mn-dd:focus-within > .mn-tab::before, .mn-dd.open > .mn-tab::before { opacity: 1; }
.mn-tab.on { color: var(--ink); font-weight: 700; }
.mn-tab.on::after { transform: scaleX(1); }
.mn-tab:focus-visible { outline: none; }
.mn-tab:focus-visible::before { opacity: 1; box-shadow: inset 0 0 0 2px var(--accent); }
.mn-caret { width: 12px; height: 12px; margin-left: -1px; opacity: .55; transition: transform .15s, opacity .15s; }
.mn-dd:hover .mn-caret, .mn-dd:focus-within .mn-caret, .mn-dd.open .mn-caret { transform: rotate(180deg); opacity: 1; }
.mn-sep { flex: none; width: 1px; margin: 20px 6px; background: var(--line-2); }
@media (max-width: 1399px) { .mn-sep { display: none; } }
.mn-pulse { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); animation: mn-pulse 1.8s ease-in-out infinite; }
@keyframes mn-pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--green) 14%, transparent); } }
.mn-count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--green-soft); color: var(--green-ink); font: 700 11px/18px var(--font); text-align: center; }

/* ---------- menus: a game window with icons in inventory slots ---------- */
.mn-dd { position: relative; display: flex; align-items: stretch; }
.mn-menu { position: absolute; top: calc(100% - 4px); left: 0; z-index: 60; translate: var(--mn-x, 0) 0; min-width: 260px; padding: 8px;
  border-radius: 18px; background: var(--card); box-shadow: 0 0 0 1px var(--line), 0 24px 54px rgba(15, 20, 36, .16), 0 4px 12px rgba(15, 20, 36, .06);
  display: none; }
.mn-menu::before { content: ''; position: absolute; left: 0; right: 0; top: -10px; height: 10px; } /* the pointer crosses the gap */
.mn-dd:hover > .mn-menu, .mn-dd:focus-within > .mn-menu, .mn-dd.open > .mn-menu { display: block; animation: mn-in .16s ease; }
.mn-dd:hover > .mn-guides, .mn-dd:focus-within > .mn-guides, .mn-dd.open > .mn-guides { display: grid; }
.mn-dd.shut > .mn-menu { display: none; }
@keyframes mn-in { from { opacity: 0; transform: translateY(6px); } }
.mn-end > .mn-menu { left: auto; right: 0; }
.mn-slot { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 11px; overflow: hidden;
  background: linear-gradient(150deg, var(--mn-slot-1), var(--mn-slot-2)); box-shadow: inset 0 0 0 1px var(--mn-slot-line), inset 0 2px 0 rgba(255, 255, 255, .7); }
.mn-slot img { max-width: 32px; max-height: 32px; object-fit: contain; }
.mn-slot.svg { color: var(--accent-ink); }
.mn-slot svg { width: 20px; height: 20px; }
.mn-menu a { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 10px; border-radius: 12px; color: var(--ink); text-decoration: none; }
.mn-menu a:hover, .mn-menu a:focus-visible { background: var(--bg-2); color: var(--ink); outline: none; }
.mn-menu a:hover b { color: var(--accent-ink); }
.mn-menu a[aria-current] b { color: var(--accent-ink); }
.mn-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mn-tx b { font-size: 14px; font-weight: 650; line-height: 1.3; }
.mn-tx small { color: var(--ink-3); font-size: 12px; line-height: 1.35; }
.mn-db { width: 580px; }
.mn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 4px; }
.mn-foot { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px -8px -8px; padding: 10px 12px; border-top: 1px solid var(--line); border-radius: 0 0 18px 18px; background: var(--card-2); }
.mn-menu .mn-foot a { padding: 6px 10px; border-radius: 999px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.mn-menu .mn-foot a:hover { background: var(--card); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--line); }
.mn-guides { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 4px 14px; width: 500px; padding: 14px; }
.mn-col { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mn-h { padding: 0 8px 8px; color: var(--ink-3); font: 700 11px/1.2 var(--head); letter-spacing: .08em; text-transform: uppercase; }
.mn-jobs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
.mn-menu .mn-jobs a { gap: 8px; min-height: 40px; padding: 6px 8px; border-radius: 10px; font-size: 13.5px; font-weight: 550; }
.mn-jobs img { width: 22px; height: 22px; flex: none; image-rendering: pixelated; }
.mn-jobs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mn-menu .mn-line { padding: 7px 8px; border-radius: 10px; font-size: 13.5px; font-weight: 550; }
.mn-guides .mn-foot { grid-column: 1 / -1; margin: 8px -14px -14px; padding: 10px 16px; }
.mn-menu .mn-foot .mn-all { color: var(--accent-ink); font-weight: 700; }
.mn-more { width: 340px; }

/* ---------- search: a pill that widens over the tabs while you use it ---------- */
.tb-search { position: relative; flex: 1 1 200px; min-width: 150px; max-width: 280px; height: 44px; margin-left: auto; }
.topbar .tb-search .searchbox { display: block; position: absolute; top: 0; right: 0; width: 100%; max-width: none; margin: 0; z-index: 61; transition: width .2s ease; }
.topbar .tb-search .searchbox:focus-within { width: max(100%, 420px); }
.topbar .tb-search .searchbox input { display: block; width: 100%; height: 44px; padding: 0 40px 0 40px; border-radius: 12px; font-size: 14px;
  background: var(--bg-2); border: 1px solid transparent; box-shadow: none; }
.topbar .tb-search .searchbox input:hover { border-color: var(--line-2); }
.topbar .tb-search .searchbox input:focus { background: var(--card); border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent), 0 14px 34px rgba(15, 20, 36, .12); }
.topbar .tb-search .searchbox input::placeholder { color: var(--ink-3); opacity: 1; }
.topbar .tb-search .searchbox svg { left: 14px; width: 17px; height: 17px; }
.topbar .tb-search .searchbox .sb-ph { display: none; }
.topbar .tb-search .searchbox .slash { right: 12px; }
.topbar #search-toggle { display: none; }

/* ---------- buttons on the right ---------- */
.topbar .tb-actions { flex: none; margin-left: 0; gap: 4px; }
.topbar .iconbtn { width: 42px; height: 42px; border-radius: 12px; }
.topbar .tb-actions > .btn.sm { min-height: 40px; padding: 0 14px; border-radius: 11px; font-size: 13.5px; }
.topbar .usermenu summary { padding: 3px; border-radius: 12px; }
.topbar .usermenu .av { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(150deg, var(--mn-slot-1), var(--mn-slot-2)); box-shadow: inset 0 0 0 1px var(--mn-slot-line); }
.topbar .usermenu .un, .topbar .usermenu .caret { display: none; }
/* members: dark mode sits in the account menu; guests: in the globe menu below 1400px (keeps the row short) */
@media (max-width: 1399px) {
  .topbar:not(:has(.usermenu)) #theme-toggle { display: none; }
  .langmenu .menu .lm-theme { display: block; }
}
.topbar:has(.usermenu) #theme-toggle { display: none; }
.menu-theme { display: block !important; }

/* the shop sub-row repeated the tabs; Database keeps its own sub-row (sticky under the bar) */
.shop-subnav { display: none; }
.topbar ~ .subnav { top: var(--topbar-h); }
.phone-nav, .msheet { display: none; }

/* ---------- dark ---------- */
:root[data-theme="dark"] .topbar, :root[data-theme="dark"] .msheet { --mn-slot-1: #222c47; --mn-slot-2: #18203a; --mn-slot-line: #2f3b60; }
:root[data-theme="dark"] .mn-menu { box-shadow: 0 0 0 1px var(--line-2), 0 24px 54px rgba(0, 0, 0, .5); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .topbar, :root:not([data-theme="light"]) .msheet { --mn-slot-1: #222c47; --mn-slot-2: #18203a; --mn-slot-line: #2f3b60; }
  :root:not([data-theme="light"]) .mn-menu { box-shadow: 0 0 0 1px var(--line-2), 0 24px 54px rgba(0, 0, 0, .5); }
}

/* Japanese labels run wider: tighter tabs */
html[lang="ja"] .mn-tab { padding: 0 8px; font-size: 13.5px; }
html[lang="ja"] .mn-tab::after { left: 8px; right: 8px; }

/* ---------- 761-1279: two rows ---------- */
@media (max-width: 1279px) {
  :root { --topbar-h: 108px; }
  .topbar .wrap { flex-wrap: wrap; height: auto; min-height: var(--topbar-h); align-content: flex-start; gap: 0 16px; }
  .topbar .brand { height: 62px; }
  .tb-search { flex: 1 1 auto; max-width: 560px; margin: 0 auto; }
  .topbar .tb-search .searchbox:focus-within { width: 100%; }
  .mnav { order: 5; flex: 1 1 100%; height: 46px; margin: 0 -12px; border-top: 1px solid var(--line); }
  .mn-tab { height: 46px; }
  .mn-tab::before { inset: 6px 2px; }
  .mn-sep { margin: 14px 4px; }
  .mn-dd:last-child { margin-left: auto; }
  .mn-db { width: 560px; }
  .topbar .wrap { max-width: 1200px; }
}
@media (max-width: 900px) {
  .mn-tab { padding: 0 8px; font-size: 13.5px; }
  .mn-tab::after { left: 8px; right: 8px; }
  .topbar .tb-actions > .btn.sm { padding: 0 11px; }
}

/* ---------- phones ---------- */
@media (max-width: 760px) {
  :root { --topbar-h: 60px; }
  .topbar .wrap, .topbar:not(.searching) .wrap { flex-wrap: nowrap; height: 60px; min-height: 60px; padding: 0 12px; gap: 6px; }
  .topbar .brand { flex: 0 1 auto; min-width: 0; height: 44px; margin-right: auto; }
  .topbar .brand .name { font-size: 20px; }
  .topbar .brand svg { width: 26px; height: 26px; }
  .mnav { display: none; }
  .tb-search { display: none; position: absolute; top: 60px; left: 0; right: 0; max-width: none; height: auto; margin: 0; padding: 10px 12px;
    background: var(--card); border-bottom: 1px solid var(--line); box-shadow: 0 14px 30px rgba(15, 20, 36, .1); }
  .topbar.searching .tb-search { display: block; }
  .topbar .tb-search .searchbox, .topbar .tb-search .searchbox:focus-within { position: relative; width: 100%; }
  .topbar .tb-search .searchbox input { font-size: 16px; }
  .topbar .tb-search .searchbox .slash { display: none; }
  .topbar #search-toggle { display: inline-flex; }
  .topbar #search-toggle[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-ink); }
  .topbar .tb-actions { gap: 2px; }
  .topbar .iconbtn { width: 40px; height: 40px; }
  .topbar .tb-actions > a[data-unread-badge] { display: none; }
  .topbar .tb-actions > .btn:not(.ghost) { display: none; }
  .topbar .tb-actions > .btn.ghost.sm { padding: 0 10px; }
  .topbar:not(:has(.usermenu)) #theme-toggle { display: none; }
  .langmenu .menu .lm-theme { display: block; }

  /* the bottom bar */
  .phone-nav { position: fixed; z-index: 49; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--card) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px); box-shadow: 0 -1px 0 var(--line), 0 -8px 24px rgba(15, 20, 36, .06); }
  .phone-nav a, .phone-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 54px; padding: 4px 2px;
    border: 0; border-radius: 14px; background: none; color: var(--ink-3); font: 600 10.5px/1.15 var(--font); text-align: center; cursor: pointer; text-decoration: none;
    -webkit-tap-highlight-color: transparent; }
  .phone-nav > * > span:last-child { max-width: 100%; overflow-wrap: anywhere; }
  .pn-ic { position: relative; display: grid; place-items: center; width: 44px; height: 30px; border-radius: 999px; transition: background .15s; }
  .pn-ic svg { width: 21px; height: 21px; }
  .phone-nav .on, .phone-nav [aria-expanded="true"] { color: var(--accent-ink); }
  .phone-nav .on .pn-ic, .phone-nav [aria-expanded="true"] .pn-ic { background: var(--accent-soft); }
  .pn-count { position: absolute; top: -3px; right: 0; min-width: 17px; padding: 0 4px; border-radius: 999px; background: var(--green); color: #fff;
    font: 700 10px/16px var(--font); font-style: normal; box-shadow: 0 0 0 2px var(--card); }
  body:has(> .phone-nav) { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

  /* the Menu sheet */
  .msheet:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 48; }
  .ms-back { position: absolute; inset: 0; background: rgba(10, 14, 28, .42); animation: ms-fade .2s ease; }
  .ms-panel:focus { outline: none; }
  .ms-panel { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; max-height: calc(100dvh - 72px);
    padding-bottom: calc(68px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; background: var(--card); box-shadow: 0 -18px 50px rgba(10, 14, 28, .25);
    animation: ms-up .24s cubic-bezier(.2, .8, .2, 1); }
  @keyframes ms-up { from { transform: translateY(40px); opacity: 0; } }
  @keyframes ms-fade { from { opacity: 0; } }
  .ms-head { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 8px; }
  .ms-head::before { content: ''; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 4px; background: var(--line-2); }
  .ms-head b { font: 800 19px/1.2 var(--head); }
  .ms-x { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--bg-2); color: var(--ink-2); cursor: pointer; }
  .ms-x svg { width: 18px; height: 18px; }
  .ms-body { overflow-y: auto; overscroll-behavior: contain; padding: 0 16px 16px; }
  .ms-body section { padding: 12px 0 14px; }
  .ms-body section + section { border-top: 1px solid var(--line); }
  .ms-body h2 { margin: 0 0 10px; color: var(--ink-3); font: 700 11.5px/1.2 var(--head); letter-spacing: .08em; text-transform: uppercase; }
  .ms-body h2 a { color: inherit; }
  .ms-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 6px; }
  .ms-tiles a { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; color: var(--ink); font-size: 11.5px; font-weight: 600; line-height: 1.25; text-align: center; }
  .ms-tiles .mn-slot { width: 52px; height: 52px; border-radius: 14px; }
  .ms-tiles span:last-child { max-width: 100%; overflow-wrap: anywhere; }
  .ms-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
  .ms-chips a { padding: 7px 12px; border-radius: 999px; background: var(--bg-2); color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
  .ms-jobs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .ms-jobs a { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 44px; padding: 6px 10px; border-radius: 12px; background: var(--card-2);
    box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); font-size: 13px; font-weight: 600; }
  .ms-jobs img { width: 22px; height: 22px; flex: none; image-rendering: pixelated; }
  .ms-jobs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ms-list { display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; }
  .ms-list a { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 8px; border-radius: 12px; color: var(--ink); }
  .ms-list a[aria-current] b { color: var(--accent-ink); }
  .ms-auth { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: 6px; }
  .ms-auth .btn { justify-content: center; min-height: 46px; }
  html.ms-open { overflow: hidden; }
}
@media (max-width: 374px) {
  .topbar .wrap, .topbar:not(.searching) .wrap { gap: 3px; padding: 0 8px; }
  .topbar .brand .name { font-size: 17px; }
  .topbar .brand svg { width: 22px; height: 22px; }
}
@media (max-width: 359px) {
  html[lang="ja"] .topbar:not(:has(.usermenu)) .brand .name { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .mn-caret, .mn-tab::after, .mn-tab::before, .topbar .tb-search .searchbox { transition: none; }
  .mn-menu { animation: none !important; }
  .mn-pulse, .ms-panel, .ms-back { animation: none; }
}
