:root {
  color-scheme: dark;
}

.co-nav,
.co-nav-links {
  gap: clamp(0.5rem, 2vw, 1.5rem);
}

.co-nav-actions {
  gap: clamp(0.25rem, 1vw, 0.75rem);
}

.co-nav-actions > *,
.co-nav-links,
.co-brand svg {
  flex-shrink: 0;
}

.co-nav-links,
.co-brand,
.co-nav-brief,
.co-nav-saved {
  white-space: nowrap;
}

.co-brand {
  font-family: Manrope, system-ui, sans-serif;
}

.co-language-control {
  position: relative;
  display: inline-flex;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding-inline: 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: #c8d2e0;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.co-language-control:hover,
.co-language-control:focus-within {
  border-color: var(--gold);
  color: var(--gold);
}

.co-language-control:focus-within {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.co-language-control svg {
  width: 15px;
  height: 15px;
}

.co-language-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  opacity: 0;
}

.co-region-picker {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--muted);
}

.co-region-picker button:hover {
  color: var(--gold);
}

.co-region-picker button[aria-pressed="true"],
.co-nav-saved[aria-pressed="true"] {
  background: rgba(237, 197, 130, 0.14);
  color: var(--gold);
}

.co-nav-saved {
  border-color: var(--line);
  color: var(--muted);
}

.co-nav-saved:hover,
.co-nav-saved[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--gold);
}

.co-region-mobile-row {
  display: none;
}

.co-mobile-menu {
  max-height: calc(100vh - 85px);
  max-height: calc(100dvh - 85px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.co-search-input {
  min-width: 0;
  font-size: 16px;
}

.co-market {
  position: relative;
  z-index: 2;
  margin-top: -1.5rem;
}

.co-market-panel {
  display: grid;
  min-width: 0;
}

.co-market-heading {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.95rem 1.25rem;
}

.co-market-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 0;
}

.co-market-item {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: clamp(0.375rem, 1vw, 0.625rem);
  padding: 0.875rem clamp(0.5rem, 1.1vw, 0.875rem);
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.co-market-item:nth-child(2n),
.co-market-item:last-child {
  border-right: 0;
}

.co-market-item:last-child {
  grid-column: span 2;
}

.co-market-name {
  overflow-wrap: normal;
  word-break: normal;
}

.co-market-figures > span {
  white-space: nowrap;
}

.co-market-value {
  font-size: clamp(1.05rem, calc(1.8vw + 0.1rem), 1.5rem);
}

.co-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
  color: inherit;
}

.co-dialog[open] {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.co-dialog::backdrop {
  background: rgba(3, 8, 20, 0.82);
  backdrop-filter: blur(4px);
}

body.co-modal-open {
  overflow: hidden;
}

.co-dialog-panel {
  min-width: 0;
  max-width: 760px;
  max-height: 94vh;
  max-height: 94dvh;
  border-radius: 20px 20px 0 0;
}

.co-dialog-digest .co-dialog-panel {
  max-width: 700px;
}

.co-dialog-info[open] {
  align-items: center;
  padding: 1rem;
}

.co-dialog-info .co-dialog-panel {
  max-width: 520px;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  border-radius: 16px;
}

.co-dialog-body {
  min-height: 0;
  padding-bottom: max(var(--co-dialog-padding, 1.75rem), env(safe-area-inset-bottom));
  overflow-wrap: break-word;
}

.co-dialog-reader {
  --co-dialog-padding: 2rem;
}

.co-dialog-info {
  --co-dialog-padding: 1.5rem;
}

.co-dialog-body:focus-visible {
  outline-offset: -3px;
}

.co-dialog-body h2:focus,
#edition-heading:focus {
  outline: none;
}

.co-toast {
  width: max-content;
  max-width: calc(100% - 2rem);
  text-align: center;
}

html:lang(zh-Hans) {
  --co-sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC";
  --co-serif: "Songti SC", "Noto Serif CJK SC", SimSun;
}

html:lang(zh-Hant) {
  --co-sans: "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC";
  --co-serif: "Songti TC", "Noto Serif CJK TC", PMingLiU;
}

html:lang(zh) body {
  font-family: Manrope, var(--co-sans), system-ui, sans-serif;
  line-height: 1.72;
  word-break: normal;
}

html:lang(zh) :is(h1, h2, h3, .font-display) {
  font-family: "Instrument Serif", var(--co-serif), var(--co-sans), serif;
}

html:lang(zh) .fs-hero {
  font-size: clamp(2.1rem, 7.4vw, 4.35rem);
  line-height: 1.16;
}

html:lang(zh) .eyebrow {
  letter-spacing: 0.1em;
}

@media (max-width: 639px) {
  .co-nav {
    gap: 0.35rem;
  }

  .co-nav-icon,
  .co-language-control {
    height: 36px;
  }

  .co-nav-icon {
    width: 34px;
  }

  .co-nav-saved {
    gap: 4px;
    padding-inline: 0.45rem;
  }

  .co-region-desktop {
    display: none;
  }

  .co-region-mobile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
  }

  .co-market-symbol {
    width: 24px;
    height: 24px;
  }

  .co-close-button,
  .co-save-button,
  .co-reader-save {
    min-height: 36px;
  }

  .co-close-button,
  .co-save-button {
    min-width: 36px;
  }
}

@media (max-width: 340px) {
  .co-brand {
    gap: 0.375rem;
  }

  .co-language-control {
    padding-inline: 6px;
  }
}

@media (min-width: 640px) {
  .co-market-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .co-market-item:nth-child(2n) {
    border-right: 1px solid var(--line);
  }

  .co-market-item:nth-child(3n),
  .co-market-item:last-child {
    border-right: 0;
  }

  .co-dialog[open] {
    align-items: center;
    padding: 1.5rem;
  }

  .co-dialog-panel {
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: 20px;
  }
}

@media (min-width: 768px) {
  .co-dialog-reader {
    --co-dialog-padding: 2.5rem;
  }

  .co-market {
    margin-top: -2rem;
  }

  .co-market-panel {
    grid-template-columns: clamp(10.5rem, 16vw, 13.75rem) minmax(0, 1fr);
  }

  .co-market-heading {
    border-right: 1px solid var(--line);
  }

  .co-market-item:nth-child(-n + 3) {
    border-top: 0;
  }
}

@media (min-width: 1024px) {
  .co-market-panel {
    grid-template-columns: clamp(12rem, 16vw, 13.75rem) minmax(0, 1fr);
  }

  .co-market-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .co-market-item:nth-child(n) {
    grid-column: auto;
    border-top: 0;
    border-right: 1px solid var(--line);
  }

  .co-market-item:last-child {
    border-right: 0;
  }
}
