/* Installed PWA/TWA shell and responsive market index refinements. */
.app-tabbar {
  display: none;
}

html.is-app-mode .site-footer {
  display: none;
}

html.is-app-mode .portal-guide,
html.is-app-mode .portal-faq {
  display: none !important;
}

html.is-app-mode body {
  padding-bottom: calc(82px + env(safe-area-inset-bottom));
}

html.is-app-mode .app-tabbar {
  position: fixed;
  z-index: 1100;
  right: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: block;
  width: min(620px, calc(100% - 24px));
  transform: translateX(50%);
  border: 1px solid rgba(64, 84, 79, .13);
  border-radius: 22px;
  background: rgba(255, 253, 248, .94);
  box-shadow: 0 14px 45px rgba(40, 55, 51, .18);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.app-tabbar-inner {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  min-height: 68px;
  padding: 6px;
}

.app-tab {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  border-radius: 16px;
  color: #71807b;
  font-size: 10.5px;
  font-weight: 700;
  text-decoration: none;
  transition: color .18s ease, background-color .18s ease, transform .18s ease;
}

.app-tab:active {
  transform: scale(.96);
}

.app-tab.is-active {
  color: #176f68;
  background: #e9f4f0;
}

.app-tab-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
}

.app-tab-icon svg {
  width: 21px;
  height: 21px;
  stroke-width: 2;
}

/* Latest market news component */
.market-news-section {
  margin: 20px 0;
  padding: 22px;
  border: 1px solid #e5e3dc;
  border-radius: 18px;
  background: #fffdfa;
  box-shadow: 0 8px 30px rgba(45, 59, 55, .05);
}

.market-news-global-shell {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 38px;
}

.market-news-global-shell .market-news-section {
  margin: 0;
}

.market-news-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.market-news-kicker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
  color: #14736b;
  font-size: 11px;
  font-weight: 800;
}

.market-news-kicker svg {
  width: 15px;
  height: 15px;
}

.market-news-title {
  margin: 0;
  color: #1c2b29;
  font-size: 19px;
  font-weight: 900;
}

.market-news-description {
  margin: 5px 0 0;
  color: #72807c;
  font-size: 12px;
}

.market-news-all {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  color: #176f68;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.market-news-all svg {
  width: 15px;
  height: 15px;
}

.market-news-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.market-news-card {
  display: flex;
  min-width: 0;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid #ebe8e0;
  border-radius: 14px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.market-news-card:hover {
  transform: translateY(-2px);
  border-color: #cfe1dc;
  box-shadow: 0 10px 24px rgba(45, 59, 55, .08);
}

.market-news-image {
  overflow: hidden;
  aspect-ratio: 16 / 8.5;
  background: #f0eee8;
}

.market-news-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s ease;
}

.market-news-card:hover .market-news-image img {
  transform: scale(1.025);
}

.market-news-body {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  padding: 13px;
}

.market-news-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: #8a9692;
  font-size: 10.5px;
}

.market-news-category {
  color: #9a6414;
  font-weight: 800;
}

.market-news-card h3 {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: #1c2b29;
  font-size: 13.5px;
  font-weight: 850;
  line-height: 1.85;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.market-news-card p {
  display: -webkit-box;
  overflow: hidden;
  margin: 7px 0 0;
  color: #74817d;
  font-size: 11.5px;
  line-height: 1.9;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* Parent market pages: keep every child inside the viewport. */
body .market-index,
body .market-index * {
  box-sizing: border-box;
}

body .market-index > * {
  min-width: 0;
}

@media (max-width: 900px) {
  body .market-index {
    width: 100% !important;
    max-width: none !important;
    padding-inline: 16px !important;
  }

  body .market-index .g2 {
    grid-template-columns: 1fr !important;
  }

  body .market-index .market-news-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .market-news-global-shell {
    padding: 0 12px 24px;
  }

  html.is-app-mode .market-news-global-shell {
    padding-inline: 10px;
  }

  body .market-index {
    overflow: hidden;
    padding: 10px 12px 30px !important;
  }

  body .market-index .bcrumb {
    margin-bottom: 10px;
    padding-inline: 2px;
  }

  body .market-index .pghd {
    width: 100% !important;
    margin: 0 0 12px !important;
    padding: 18px 16px !important;
    gap: 14px !important;
    border-color: #e4e3dd !important;
    border-radius: 18px !important;
    background: linear-gradient(145deg, #fffefa 0%, #f4f2eb 100%) !important;
    box-shadow: 0 8px 26px rgba(44, 59, 55, .06) !important;
  }

  body .market-index .pghd-right {
    width: 100%;
  }

  body .market-index .pghd-title {
    font-size: clamp(20px, 6vw, 25px) !important;
    line-height: 1.55;
  }

  body .market-index .pghd-sub {
    max-width: 34rem;
    margin-bottom: 10px;
    font-size: 12px !important;
    line-height: 1.9;
  }

  body .market-index .pghd-meta {
    gap: 6px !important;
  }

  body .market-index .pghd-meta-item {
    max-width: 100%;
    padding: 5px 8px !important;
    font-size: 10.5px !important;
  }

  body .market-index .pghd-usd,
  body .market-index .pghd-gold,
  body .market-index .pghd-btc {
    width: 100% !important;
    min-width: 0 !important;
    padding: 15px 18px !important;
    border-radius: 14px !important;
  }

  body .market-index .cmp-wrap,
  body .market-index .sc,
  body .market-index .seo-wrap,
  body .market-index .market-news-section {
    width: 100%;
    max-width: 100%;
  }

  body .market-index .cmp-wrap {
    margin-bottom: 14px !important;
    padding: 14px !important;
    border-radius: 16px !important;
  }

  body .market-index .cmp-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  body .market-index .cmp-card {
    min-width: 0;
    padding: 12px !important;
    border-radius: 13px !important;
  }

  body .market-index .cmp-card-top {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
    gap: 7px !important;
  }

  body .market-index .cmp-chg {
    grid-column: 1 / -1;
    margin: 2px 0 0 !important;
    justify-self: start;
  }

  body .market-index .cmp-price {
    overflow-wrap: anywhere;
    font-size: 15px !important;
  }

  body .market-index .cmp-spark {
    display: none;
  }

  body .market-index .g-section,
  body .market-index .g2 {
    width: 100%;
    margin-bottom: 14px !important;
  }

  body .market-index .sh {
    min-width: 0;
    padding-inline: 2px;
  }

  body .market-index .sc {
    overflow: hidden !important;
    border-color: #e4e3dd !important;
    border-radius: 18px !important;
    background: #fff !important;
    box-shadow: 0 8px 26px rgba(44, 59, 55, .06) !important;
  }

  body .market-index .tbl-toolbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px !important;
    padding: 12px !important;
  }

  body .market-index .tbl-search-wrap {
    grid-column: 1 / -1;
    order: -2 !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 10px 12px !important;
    border: 1px solid #dcded8 !important;
    border-radius: 13px !important;
    background: #faf9f5 !important;
  }

  body .market-index .tbl-search {
    width: 100% !important;
    height: 24px !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 16px !important;
  }

  body .market-index .tbl-search:focus {
    border: 0 !important;
    box-shadow: none !important;
  }

  body .market-index .tbl-count {
    align-self: center;
    justify-self: end;
    order: 2 !important;
  }

  body .market-index--currency .market-filters {
    display: grid !important;
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100% !important;
    overflow: visible !important;
    gap: 5px;
  }

  body .market-index--currency .market-filter {
    min-width: 0;
    padding: 7px 4px !important;
    font-size: 10.5px !important;
    white-space: nowrap;
  }

  body .market-index--currency .cur-tbl thead,
  body .market-index--crypto .cr-tbl thead,
  body .market-index--gold .pt thead {
    display: none;
  }

  body .market-index--currency .cur-tbl,
  body .market-index--currency .cur-tbl tbody,
  body .market-index--crypto .cr-tbl,
  body .market-index--crypto .cr-tbl tbody,
  body .market-index--gold .pt,
  body .market-index--gold .pt tbody {
    display: block;
    width: 100%;
  }

  body .market-index--currency .cur-row,
  body .market-index--crypto .cr-row,
  body .market-index--gold .gold-row {
    display: grid !important;
    width: 100%;
    min-width: 0;
    min-height: 74px;
    grid-template-columns: minmax(128px, 1fr) minmax(86px, .64fr) auto;
    grid-template-areas: "asset price change";
    align-items: center;
    gap: 8px;
    padding: 11px 13px !important;
    border-bottom: 1px solid #ece9e1;
    background: #fff !important;
  }

  body .market-index--crypto .cr-row {
    min-height: 82px;
    grid-template-areas: "asset usd change" "asset price change";
    grid-template-columns: minmax(128px, 1fr) minmax(92px, .68fr) auto;
    grid-template-rows: 1fr 1fr;
    row-gap: 4px;
  }

  body .market-index--currency .cur-row:hover,
  body .market-index--crypto .cr-row:hover,
  body .market-index--gold .gold-row:hover {
    background: #fff !important;
  }

  body .market-index .cur-row.hidden,
  body .market-index .cr-row.hidden,
  body .market-index .g-row.hidden {
    display: none !important;
  }

  body .market-index--currency .cur-row:last-child,
  body .market-index--crypto .cr-row:last-child,
  body .market-index--gold .gold-row:last-child {
    border-bottom: 0;
  }

  body .market-index--currency .cur-row > td,
  body .market-index--crypto .cr-row > td,
  body .market-index--gold .gold-row > td {
    display: flex;
    min-width: 0;
    align-items: center;
    padding: 0 !important;
    border: 0 !important;
  }

  body .market-index .mobile-asset {
    grid-area: asset;
    align-self: center;
  }

  body .market-index .mobile-change {
    grid-area: change;
    align-self: center;
    justify-content: center;
  }

  body .market-index .mobile-price,
  body .market-index .mobile-usd-price {
    grid-area: price;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-content: center;
    column-gap: 5px;
    min-width: 0;
    min-height: 50px;
    padding: 6px 8px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: #f7f5ef !important;
    text-align: right !important;
    direction: rtl !important;
  }

  body .market-index .mobile-price::before,
  body .market-index .mobile-usd-price::before {
    content: attr(data-label);
    grid-column: 1 / -1;
    color: #7a8783;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.4;
  }

  body .market-index .mobile-usd-price {
    grid-area: usd;
  }

  body .market-index .mobile-price::after,
  body .market-index .mobile-usd-price::after {
    content: attr(data-unit);
    align-self: end;
    color: #9a958a;
    font-size: 8.5px;
    font-weight: 650;
    line-height: 1.6;
  }

  body .market-index .mobile-price-value {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: #20302d;
    direction: ltr;
    font-size: 13px;
    font-weight: 850;
    line-height: 1.6;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body .market-index .mobile-price .tp-unit,
  body .market-index .mobile-price .rate-kind {
    display: none !important;
  }

  body .market-index .mobile-unit,
  body .market-index .mobile-chart,
  body .market-index .mobile-secondary-price,
  body .market-index .th-num {
    display: none !important;
  }

  body .market-index .mobile-asset .tc,
  body .market-index .mobile-asset .tc-lnk {
    display: flex !important;
    min-width: 0;
    align-items: center !important;
    flex-direction: row !important;
    gap: 9px !important;
    padding: 0 !important;
    text-align: right !important;
  }

  body .market-index .mobile-asset .tc-info {
    min-width: 0;
    align-items: flex-start !important;
    text-align: right !important;
  }

  body .market-index .mobile-asset .tnm {
    overflow: hidden;
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body .market-index .mobile-asset .tcd {
    overflow: hidden;
    max-width: 100%;
    color: #788681 !important;
    font-size: 9.5px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body .market-index .mobile-asset .market-badge {
    margin-top: 2px;
  }

  body .market-index .mobile-change .chg {
    padding: 4px 6px;
    border-radius: 7px;
    font-size: 10px;
    white-space: nowrap;
  }

  body .market-index .tico {
    flex: 0 0 auto;
  }

  body .market-index--gold .g2-col {
    min-width: 0;
  }

  body .market-index .info-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin: 14px 0 !important;
  }

  body .market-index .info-strip-item {
    min-width: 0;
    padding: 11px !important;
  }

  body .market-index .is-sub {
    line-height: 1.6;
  }

  body .market-index .seo-wrap {
    padding: 20px 16px !important;
    border-radius: 16px !important;
  }

  body .market-index .market-news-section {
    margin: 14px 0;
    padding: 14px;
    border-radius: 16px;
  }

  body .market-index .market-news-head {
    align-items: start;
    margin-bottom: 12px;
  }

  body .market-index .market-news-title {
    font-size: 16px;
  }

  body .market-index .market-news-description {
    display: none;
  }

  body .market-index .market-news-grid {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  body .market-index .market-news-card {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    min-height: 94px;
  }

  body .market-index .market-news-image {
    height: 100%;
    aspect-ratio: auto;
  }

  body .market-index .market-news-body {
    padding: 10px;
  }

  body .market-index .market-news-card p {
    display: none;
  }

  html.is-app-mode body .market-index {
    padding-inline: 10px !important;
  }
}

@media (max-width: 430px) {
  html.is-app-mode .app-tabbar {
    right: 0;
    bottom: 0;
    width: 100%;
    transform: none;
    border-width: 1px 0 0;
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .app-tabbar-inner {
    min-height: 64px;
    padding: 5px 4px;
  }

  body .market-index .cmp-card {
    padding: 10px !important;
  }

  body .market-index .cmp-ico {
    width: 34px !important;
    height: 34px !important;
  }

  body .market-index .cmp-name {
    overflow: hidden;
    font-size: 11px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body .market-index .info-strip {
    grid-template-columns: 1fr !important;
  }

  body .market-index .market-news-card {
    grid-template-columns: 92px minmax(0, 1fr);
  }
}

@media (max-width: 360px) {
  body .market-index--currency .cur-row,
  body .market-index--gold .gold-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "asset change" "price price";
  }

  body .market-index--currency .mobile-price,
  body .market-index--gold .mobile-price {
    min-height: 42px;
  }

  body .market-index--crypto .cr-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "asset change" "usd price";
    grid-template-rows: auto auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-tab,
  .market-news-card,
  .market-news-image img {
    transition: none;
  }
}
