:root{
  --text-on-accent:#fff;
  --drawer-bg: color-mix(in srgb, var(--surface, #141922) 96%, transparent);
}

/* ===== Header ===== */
.top-header{
  position:sticky;
  top:0;
  z-index:60;
  margin:-14px -12px 14px;
  padding:14px 12px 10px;
  background:color-mix(in srgb, var(--bg, #0f1218) 92%, transparent);
  backdrop-filter:blur(14px);
  border-bottom:1px solid var(--line, #263041);
}
.header-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.brand-row{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
  flex:1 1 auto;
}
.app-shell-header .brand,
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}
.app-shell-header .brand.is-centered{
  justify-content:flex-start;
}
.app-shell-header .brand img,
.brand img{
  width:44px;
  height:44px;
  border-radius:14px;
  object-fit:cover;
  background:var(--surface, #141922);
  border:1px solid var(--line, #263041);
  box-shadow:var(--shadow-soft, 0 6px 14px rgba(0,0,0,.18));
  padding:2px;
  flex:0 0 auto;
}
.app-shell-header .brand-text,
.brand-text{
  min-width:0;
}
.app-shell-header .brand.is-centered .brand-text h1{font-size:17px}
.app-shell-header .brand-text h1,
.app-shell-header .brand h1,
.brand-text h1,
.brand h1{
  margin:0;
  font-size:18px;
  font-weight:900;
  line-height:1.2;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.app-shell-header .brand-text p,
.brand-text p{
  margin:2px 0 0;
  color:var(--muted,#9eabc0);
  font-size:12px;
  line-height:1.5;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.header-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex:0 0 auto;
}
.icon-btn,
.app-shell-header .icon-btn{
  width:40px;
  height:40px;
  border:none;
  border-radius:14px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:var(--surface, #141922);
  color:var(--text, #f4f6fb);
  border:1px solid var(--line, #263041);
  box-shadow:var(--shadow-soft, 0 6px 14px rgba(0,0,0,.18));
  cursor:pointer;
  transition:.18s ease;
  text-decoration:none;
}
.icon-btn:hover,
.app-shell-header .icon-btn:hover{
  background:var(--primary, #219673);
  color:var(--text-on-accent, #fff);
  border-color:var(--primary, #219673);
}
.app-shell-header .drawer-opener{flex:0 0 auto}

/* ===== Bottom nav ===== */
.bottom-nav{
  position:fixed;
  bottom:0;
  left:0;
  right:0;
  z-index:80;
  padding:10px 10px calc(10px + env(safe-area-inset-bottom));
  background:color-mix(in srgb, var(--bg, #0f1218) 92%, transparent);
  backdrop-filter:blur(18px);
  border-top:1px solid var(--line, #263041);
}
.bottom-wrap{
  max-width:760px;
  margin:auto;
  display:grid;
  grid-template-columns:repeat(5,minmax(0,1fr));
  gap:8px;
}
.app-bottom-nav .bottom-wrap{grid-template-columns:repeat(5,minmax(0,1fr)) !important}
.nav-item{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:5px;
  padding:10px 4px;
  border-radius:15px;
  color:var(--muted, #9eabc0);
  font-size:11px;
  font-weight:800;
  transition:all .2s;
  background:transparent;
  border:1px solid transparent;
  font-family:inherit;
  text-decoration:none;
}
.nav-item i{font-size:14px;line-height:1}
.nav-item.active{
  background:var(--surface, #141922);
  color:var(--primary, #219673);
  border-color:color-mix(in srgb, var(--primary, #219673) 45%, var(--line, #263041));
  box-shadow:var(--shadow-soft, 0 6px 14px rgba(0,0,0,.18));
}
.app-bottom-nav .nav-item span{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* ===== Sidebar drawer ===== */
.app-drawer{position:fixed;inset:0;z-index:150;display:none}
.app-drawer.open{display:block}
.app-drawer-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.48);backdrop-filter:blur(4px)}
.app-drawer-panel{position:absolute;top:0;right:0;bottom:0;width:min(86vw,360px);background:linear-gradient(180deg,var(--surface,#141922),var(--surface-2,#1b2230));border-left:1px solid var(--line,#263041);box-shadow:-10px 0 34px rgba(0,0,0,.25);padding:16px 14px calc(16px + env(safe-area-inset-bottom));overflow:auto}
.app-drawer-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px}
.drawer-brand{display:flex;align-items:center;gap:12px;min-width:0}
.drawer-brand img{width:48px;height:48px;border-radius:16px;object-fit:cover;border:1px solid var(--line,#263041);background:var(--surface,#141922)}
.drawer-brand strong{display:block;font-size:16px}
.drawer-brand span{display:block;font-size:12px;color:var(--muted,#9eabc0);line-height:1.6}
.drawer-links{display:grid;gap:10px}
.drawer-link{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 14px;border-radius:18px;background:linear-gradient(90deg,color-mix(in srgb,var(--surface-2,#1b2230) 65%, transparent), var(--surface,#141922));border:1px solid var(--line,#263041);color:var(--text,#f4f6fb);text-decoration:none;box-shadow:var(--shadow-soft,0 6px 14px rgba(0,0,0,.18))}
.drawer-link.is-active{border-color:color-mix(in srgb, var(--primary,#219673) 45%, var(--line,#263041));background:linear-gradient(135deg,color-mix(in srgb,var(--primary,#219673) 18%, var(--surface,#141922)), var(--surface-2,#1b2230))}
.drawer-link-main{display:flex;align-items:center;gap:12px;min-width:0}
.drawer-link-icon{width:40px;height:40px;display:inline-flex;align-items:center;justify-content:center;border-radius:14px;background:color-mix(in srgb,var(--surface,#141922) 65%, var(--surface-2,#1b2230));border:1px solid var(--line,#263041);color:var(--primary,#219673);flex:0 0 auto}
.drawer-link-text{min-width:0}
.drawer-link-text strong{display:block;font-size:14px;line-height:1.4}
.drawer-link-text span{display:block;font-size:11px;color:var(--muted,#9eabc0);line-height:1.6}

/* keep old sheet styles harmless if any page still uses them elsewhere */
.more-sheet{position:fixed;inset:0;z-index:120;display:none}
.more-sheet.open{display:block}
.more-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.38);backdrop-filter:blur(2px)}
.more-panel{position:absolute;left:12px;right:12px;bottom:18px;background:var(--surface, #141922);border:1px solid var(--line, #263041);border-radius:28px 28px 20px 20px;box-shadow:0 30px 60px rgba(0,0,0,.22);padding:12px 12px calc(12px + env(safe-area-inset-bottom))}
.drag{width:44px;height:6px;border-radius:999px;background:var(--line, #263041);margin:2px auto 12px}
.more-grid{display:grid;gap:10px}
.more-link{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 14px;border-radius:18px;background:linear-gradient(90deg,color-mix(in srgb,var(--surface-2, #1b2230) 65%, transparent), var(--surface, #141922));border:1px solid var(--line, #263041)}
.more-link .meta{display:flex;align-items:center;gap:10px}
.more-link i{width:18px;text-align:center}
.more-link strong{display:block;font-size:14px}
.more-link span{display:block;font-size:11px;color:var(--muted, #9eabc0)}

@media (max-width:420px){
  .app-bottom-nav .nav-item{font-size:10px !important;padding-inline:2px !important}
  .app-bottom-nav .nav-item i{font-size:14px !important}
  .top-header{padding-top:max(14px, env(safe-area-inset-top))}
}


/* ===== Hard fix for header consistency across pages ===== */
.app-shell-header.top-header{
  min-height:74px !important;
}
.app-shell-header .header-top{
  display:grid !important;
  grid-template-columns:minmax(0,1fr) auto !important;
  align-items:center !important;
  gap:12px !important;
}
.app-shell-header .brand-row{
  display:flex !important;
  align-items:center !important;
  gap:10px !important;
  min-width:0 !important;
  flex-wrap:nowrap !important;
}
.app-shell-header .brand{
  display:inline-flex !important;
  align-items:center !important;
  flex-direction:row !important;
  gap:10px !important;
  min-width:0 !important;
  flex-wrap:nowrap !important;
}
.app-shell-header .brand > img,
.app-shell-header .brand img{
  width:44px !important;
  height:44px !important;
  min-width:44px !important;
  max-width:44px !important;
  min-height:44px !important;
  max-height:44px !important;
  object-fit:cover !important;
  flex:0 0 44px !important;
}
.app-shell-header .brand-text{
  display:block !important;
  min-width:0 !important;
  overflow:hidden !important;
}
.app-shell-header .brand-text h1,
.app-shell-header .brand-text p{
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
}
.app-shell-header .header-actions{
  display:flex !important;
  align-items:center !important;
  gap:8px !important;
  flex-wrap:nowrap !important;
}
@media (max-width:480px){
  .app-shell-header.top-header{min-height:70px !important}
  .app-shell-header .brand > img,
  .app-shell-header .brand img{
    width:42px !important;
    height:42px !important;
    min-width:42px !important;
    max-width:42px !important;
    min-height:42px !important;
    max-height:42px !important;
    flex-basis:42px !important;
  }
  .app-shell-header .brand-text h1{font-size:17px !important}
  .app-shell-header .brand-text p{font-size:12px !important}
}


.app-shell-header .brand-text{display:flex !important;flex-direction:column !important;justify-content:center !important;}
.app-shell-header .brand-row, .app-shell-header .brand{max-width:100% !important;}
.app-shell-header .brand-text h1, .app-shell-header .brand-text p{display:block !important;}


/* ===== Header actions dropdown ===== */
.header-menu{
  position:relative;
}
.header-menu > summary{
  list-style:none;
}
.header-menu > summary::-webkit-details-marker{
  display:none;
}
.header-menu-panel{
  position:absolute;
  top:calc(100% + 10px);
  inset-inline-end:0;
  left:auto;
  right:0;
  min-width:240px;
  max-width:min(280px, calc(100vw - 24px));
  padding:10px;
  display:none;
  background:linear-gradient(180deg,var(--surface,#141922),var(--surface-2,#1b2230));
  border:1px solid var(--line,#263041);
  border-radius:18px;
  box-shadow:0 16px 40px rgba(0,0,0,.24);
  z-index:999;
}
.header-menu[open] .header-menu-panel{
  display:grid;
  grid-auto-flow:row;
  gap:8px;
}
.header-menu-item{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:10px;
  width:100%;
  min-height:48px;
  padding:12px 14px;
  border-radius:14px;
  background:var(--surface,#141922);
  color:var(--text,#f4f6fb);
  border:1px solid var(--line,#263041);
  text-decoration:none;
  font:inherit;
  cursor:pointer;
  appearance:none;
  -webkit-appearance:none;
}
.header-menu-item:hover{
  border-color:color-mix(in srgb, var(--primary,#219673) 45%, var(--line,#263041));
  color:var(--primary,#219673);
}
.header-menu-item .meta{
  display:flex;
  align-items:center;
  gap:10px;
  flex:1;
  min-width:0;
}
.header-menu-item .meta i{
  width:18px;
  text-align:center;
}
.header-menu-item span{
  display:block;
  font-size:13px;
  font-weight:800;
  line-height:1.4;
}
.header-menu-item small{
  display:block;
  color:var(--muted,#9eabc0);
  font-size:11px;
  font-weight:600;
  line-height:1.5;
  white-space:normal;
}

.home-header-menu > summary.icon-btn{
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
}
button.header-menu-item{
  -webkit-appearance:none !important;
  appearance:none !important;
  box-sizing:border-box !important;
  text-align:initial !important;
  background:var(--surface,#141922) !important;
  color:var(--text,#f4f6fb) !important;
  border:1px solid var(--line,#263041) !important;
}
.header-menu-item,
.header-menu-item *{
  box-sizing:border-box;
}
.header-menu-item .meta > div{
  min-width:0;
  flex:1;
}
.header-menu-item .meta i{
  flex:0 0 18px;
}

@media (min-width:900px){
  .app-bottom-nav .bottom-wrap{
    max-width:980px !important;
    grid-template-columns:repeat(5,minmax(0,1fr)) !important;
  }
  .app-bottom-nav .more-trigger{
    display:flex !important;
  }
}


/* ===== Homepage header dropdown ===== */
.header-dropdown{
  position:relative;
  display:flex;
  align-items:center;
}
.header-dropdown-toggle{
  position:relative;
  z-index:2;
}
.header-dropdown-panel{
  position:absolute;
  top:calc(100% + 10px);
  inset-inline-end:0;
  left:0;
  right:auto;
  width:min(320px, calc(100vw - 24px));
  max-width:min(320px, calc(100vw - 24px));
  display:none;
  padding:10px;
  overflow:hidden;
  background:linear-gradient(180deg,var(--surface,#141922),var(--surface-2,#1b2230));
  border:1px solid var(--line,#263041);
  border-radius:18px;
  box-shadow:0 18px 42px rgba(0,0,0,.30);
  z-index:1200;
}
.header-dropdown.is-open .header-dropdown-panel{
  display:grid;
  grid-template-columns:minmax(0,1fr);
  gap:8px;
}
.header-dropdown-item{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:10px;
  width:100%;
  min-height:52px;
  padding:12px 14px;
  border-radius:14px;
  background:var(--surface,#141922);
  color:var(--text,#f4f6fb);
  border:1px solid var(--line,#263041);
  text-decoration:none;
  font:inherit;
  cursor:pointer;
  appearance:none;
  -webkit-appearance:none;
}
.header-dropdown-item:hover{
  border-color:color-mix(in srgb, var(--primary,#219673) 45%, var(--line,#263041));
  color:var(--primary,#219673);
}
.header-dropdown-item .meta{
  display:flex;
  align-items:center;
  gap:10px;
  flex:1;
  min-width:0;
}
.header-dropdown-item .meta > div{
  min-width:0;
  flex:1;
}
.header-dropdown-item .meta i{
  width:18px;
  text-align:center;
  flex:0 0 18px;
}
.header-dropdown-item span,
.header-dropdown-item small{
  display:block;
  text-align:right;
}
.header-dropdown-item span{
  font-size:13px;
  font-weight:800;
  line-height:1.45;
}
.header-dropdown-item small{
  color:var(--muted,#9eabc0);
  font-size:11px;
  font-weight:600;
  line-height:1.5;
  white-space:normal;
}
@media (max-width:480px){
  .header-dropdown-panel{
    width:min(300px, calc(100vw - 20px));
  }
}

.header-dropdown-item{
  width:100% !important;
  max-width:100% !important;
  box-sizing:border-box !important;
}
.header-dropdown-item .meta{
  width:100%;
}
.home-header-menu,
#homeHeaderMenu{
  z-index:1400;
}
