.monex-charts,
.monex-charts * {
  box-sizing: border-box;
}

.monex-charts [hidden] {
  display: none !important;
}

.monex-charts {
  --monex-navy: #294560;
  --monex-ink: #102f49;
  --monex-blue: #3f7a96;
  --monex-muted: #647786;
  --monex-border: rgba(63, 122, 150, .2);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  container-type: inline-size;
  container-name: monex-chart;
  margin: 0;
  /* Element default container — FINAL (recorded): app padding + flat
     #ffffff. The decorative Blue Card style belongs to the inner chart
     card/frame via the blue="true" modifier, not this container. */
  padding: clamp(22px, 3.4vw, 46px);
  background: #ffffff;
  color: var(--monex-ink);
  font-family: "Open Sans", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

.monex-charts button,
.monex-charts input {
  margin: 0;
  font: inherit;
  letter-spacing: normal;
  text-transform: none;
}

.monex-charts__visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.monex-charts__intro {
  max-width: 820px;
  margin: 0 0 30px;
  padding: 0;
}

/*
 * Phase 2h — title / description typography reads from CSS custom properties
 * with the previous hard-coded values as fallbacks, so instances that don't
 * set the corresponding shortcode attribute or Design control render byte-
 * identically to pre-2h. Instances that DO set them (via inline style on the
 * chart root — see Monex_Charts_Plugin::render_shortcode) override just the
 * property whose attribute was populated.
 */
.monex-charts .monex-charts__display-title {
  margin: 0;
  /* Fallbacks = the app's .chart-page-heading h1 initial values. */
  color: var(--monex-title-color, #102f49);
  font-family: var(--monex-title-font-family, inherit);
  font-size: var(--monex-title-font-size, clamp(2rem, 4vw, 3.65rem));
  font-weight: var(--monex-title-font-weight, 600);
  letter-spacing: -.055em;
  line-height: 1;
}

.monex-charts.monex-charts--bold-title .monex-charts__display-title {
  font-weight: var(--monex-title-font-weight, 800);
}

.monex-charts .monex-charts__description {
  margin: 10px 0 0;
  /* Fallbacks = the app's .chart-page-heading p initial values. */
  color: var(--monex-description-color, #607382);
  font-family: var(--monex-description-font-family, inherit);
  font-size: var(--monex-description-font-size, clamp(0.95rem, 1.4vw, 1.08rem));
  font-weight: var(--monex-description-font-weight, 400);
  line-height: 1.55;
}

.monex-charts__topbar {
  display: flex;
  align-items: center;
  min-height: 0;
  margin: 0 0 34px;
  padding: 0;
  border: 0;
  background: transparent;
}

.monex-charts__summary {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
}

.monex-charts__summary-label {
  margin: 0;
  color: #758896;
  font-size: 11.52px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.monex-charts__headline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
}

.monex-charts__headline > strong {
  color: var(--monex-ink);
  font-size: clamp(30px, 2.7vw, 41.6px);
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -.04em;
}

.monex-charts__headline > span {
  font-size: clamp(15.2px, 1.5vw, 18.4px);
  font-weight: 650;
}

.monex-charts .is-positive { color: #4fb36d; }
.monex-charts .is-negative { color: #c25c4c; }

.monex-charts__subline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  color: var(--monex-muted);
  font-size: 13.76px;
  line-height: 1.4;
}

.monex-charts__subline > span {
  display: inline-flex;
  align-items: center;
}

.monex-charts__stat,
.monex-charts__unit {
  padding: 5px 9px;
  border-radius: 7px;
  background: rgba(126, 166, 185, .11);
}

.monex-charts__stat b {
  margin-left: 4px;
  color: var(--monex-navy);
  font-weight: 700;
}

.monex-charts__timestamp {
  padding-inline: 3px;
}

.monex-charts__controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  margin: 0 0 34px;
  padding: 0;
}

.monex-charts__controls-left {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 6px; /* 12px between wrapped rows, 6px between clusters */
  align-items: center;
  min-width: 0;
}

.monex-charts__comparison-loading { display:inline-block; width:10px; height:10px; margin-left:8px; border-radius:50%; border:2px solid rgba(63,122,150,.4); border-top-color:transparent; animation:monex-charts-spin 720ms linear infinite; }
.monex-charts__comparison-loading[hidden] { display:none; }
@keyframes monex-charts-spin { to { transform:rotate(360deg); } }

/* Chart 01 (commodity-selector variant): the Compare cluster drops to
   its own row under the ranges/modes clusters, left-aligned and at its
   natural width. The ::after element is a zero-height full-width flex
   line break ordered between the top-row clusters (order 0) and the
   Compare cluster (order 2), so the pill wraps without stretching. */
.monex-charts__controls--selector .monex-charts__controls-left { flex-wrap: wrap; }
.monex-charts__controls--selector .monex-charts__controls-left::after { content: ""; flex-basis: 100%; height: 0; order: 1; }
.monex-charts__controls--selector .monex-charts__comparisons { order: 2; }

.monex-charts__controls-right {
  display: grid;
  gap: 18px;
  justify-items: end;
  min-width: 0;
}

.monex-charts__ranges,
.monex-charts__modes,
.monex-charts__commodities {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 52px;
  padding: 5px;
  border: 1px solid rgba(63, 122, 150, .18);
  border-radius: 12px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 10px 26px rgba(41, 69, 96, .07);
}

.monex-charts__commodities {
  display: grid;
  grid-template-columns: repeat(4, minmax(76px, 1fr));
  width: min(404px, 100%);
}

.monex-charts__controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 40px;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  outline: 0;
  background: transparent;
  box-shadow: none;
  color: #536777;
  font-size: 13.44px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.monex-charts__controls button:hover:not(:disabled) {
  border: 0;
  color: var(--monex-navy);
  background: rgba(126, 166, 185, .12);
}

.monex-charts__controls button.is-active {
  color: #fff;
  background: var(--monex-blue);
  box-shadow: 0 7px 16px rgba(63, 122, 150, .22);
}

.monex-charts__commodities button {
  min-width: 0;
  padding-inline: 13px;
}

.monex-charts__commodities button.is-active {
  background: var(--monex-navy);
  box-shadow: 0 7px 16px rgba(41, 69, 96, .22);
}

.monex-charts__pdf {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px !important;
  padding: 0 !important;
}

.monex-charts__pdf svg {
  width: 20px;
  height: 20px;
}

.monex-charts__pdf:disabled {
  opacity: .48;
  cursor: wait;
}

.monex-charts__pdf.is-working svg {
  animation: monex-pdf-pulse .8s ease-in-out infinite alternate;
}

@keyframes monex-pdf-pulse { to { transform: translateY(3px); } }

.monex-charts__dates {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.monex-charts__dates label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #6b7f8e;
  font-size: 12.32px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.monex-charts__dates input {
  /* appearance:none normalizes iOS Safari, which otherwise collapses
     styled date inputs and centers the value. A calendar glyph is
     painted as a background so iOS (which renders no indicator) and
     Android/Chrome show the same affordance. */
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  width: 148px;
  min-width: 0;
  height: 50px;
  min-height: 50px;
  padding: 0 34px 0 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7f8e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cline x1='16' y1='3' x2='16' y2='7'/%3E%3Cline x1='8' y1='3' x2='8' y2='7'/%3E%3Cline x1='3' y1='11' x2='21' y2='11'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  border: 1px solid var(--monex-border);
  border-radius: 12px;
  outline: 0;
  background: rgba(255, 255, 255, .78);
  box-shadow: none;
  color: var(--monex-navy);
  font-size: 13.44px;
  font-weight: 700;
}

.monex-charts__dates input::-webkit-date-and-time-value {
  text-align: left;
  line-height: 48px;
}

.monex-charts__dates input::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.monex-charts__dates label { position: relative; }

.monex-charts__dates button[data-action="apply"] {
  height: 50px;
  min-height: 50px;
  min-width: 76px;
  padding-inline: 18px;
  border: 1px solid var(--monex-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, .74);
  color: var(--monex-navy);
}

.monex-charts__frame {
  position: relative;
  min-height: 470px;
  margin: 0;
  padding: 12px 12px 18px;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 26px 54px rgba(151, 147, 184, .1), inset 0 1px 0 rgba(255, 255, 255, .72);
}

/*
 * Phase 2h — Blue Card Style, universal variant. Root modifier class replaces
 * the previous SSR wrapper (which was advanced-only). Applied via shortcode
 * attribute blue="true" or Breakdance Card Style > Blue Card Style toggle.
 * Only the background + border differ from default; padding, radius, and
 * box-shadow inherit from the .monex-charts__frame rule above.
 */
.monex-charts--blue .monex-charts__frame {
  background: radial-gradient(circle at 78% 12%, #7ea6b929, #0000 34%), linear-gradient(145deg, #f7f9ff 0%, #eef2fb 100%);
  border: 1px solid #3f7a9629;
}

.monex-charts__state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  color: var(--monex-muted);
  font-weight: 700;
  text-align: center;
}

.monex-charts__state.is-error { color: #a23f39; }

.monex-charts__plot {
  position: relative;
  min-height: 440px;
  padding: 70px 26px 0;
  outline: none;
  cursor: crosshair;
  touch-action: pan-y;
  user-select: none;
}

.monex-charts__plot:focus-visible {
  border-radius: 8px;
  box-shadow: 0 0 0 3px rgba(63, 122, 150, .24);
}

.monex-charts__svg {
  display: block;
  width: 100%;
  height: 340px;
}

.monex-charts__plot-bg {
  fill: rgba(255, 255, 255, .34);
  stroke: rgba(63, 122, 150, .2);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.monex-charts__grid {
  stroke: rgba(63, 122, 150, .18);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.monex-charts__axis {
  fill: #6b7f8e;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
}

.monex-charts__current-guide {
  stroke: rgba(63, 122, 150, .42);
  stroke-width: 1;
  stroke-dasharray: 6 7;
  vector-effect: non-scaling-stroke;
}

.monex-charts__watermark {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 240px;
  width: clamp(74px, 10vw, 118px);
  aspect-ratio: 137.837 / 214.562;
  background: url("https://www.monex.com/wp-content/uploads/2023/06/monex-logo.svg") center / contain no-repeat;
  opacity: .075;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.monex-charts__footer {
  display: flex;
  justify-content: space-between;
  padding: 16px 0 0;
  color: #6b7f8e;
  font-size: 12px;
  font-weight: 600;
}

.monex-charts__hover-line {
  position: absolute;
  z-index: 3;
  width: 1px;
  border-left: 1px dashed rgba(41, 69, 96, .48);
  pointer-events: none;
}

.monex-charts__hover-dot {
  position: absolute;
  z-index: 4;
  width: 12px;
  height: 12px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--monex-navy);
  box-shadow: 0 3px 10px rgba(16, 47, 73, .28);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.monex-charts__tooltip {
  position: absolute;
  z-index: 5;
  display: grid;
  gap: 2px;
  min-width: 220px;
  padding: 14px 16px;
  border: 1px solid rgba(41, 69, 96, .12);
  border-radius: 6px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 12px 26px rgba(16, 47, 73, .16);
  backdrop-filter: blur(10px);
  color: var(--monex-ink);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
}

.monex-charts__tooltip.is-left { transform: translate(0, calc(-100% - 14px)); }
.monex-charts__tooltip.is-right { transform: translate(-100%, calc(-100% - 14px)); }
.monex-charts__tooltip.is-below { transform: translate(-50%, 14px); }
.monex-charts__tooltip.is-left.is-below { transform: translate(0, 14px); }
.monex-charts__tooltip.is-right.is-below { transform: translate(-100%, 14px); }
.monex-charts__tooltip small {
  color: #72818c;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}
.monex-charts__tooltip strong {
  margin-bottom: 2px;
  color: #102f49;
  font-size: 16px;
  line-height: 1.25;
  white-space: nowrap;
}
.monex-charts__tooltip span {
  color: var(--monex-navy);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.38;
  white-space: nowrap;
}
.monex-charts__tooltip span.is-positive { color: #2e9666; font-weight: 700; }
.monex-charts__tooltip span.is-negative { color: #b9544a; font-weight: 700; }

.monex-charts-error {
  padding: 12px 16px;
  border-left: 4px solid #b54f47;
  background: #fff1f0;
  color: #7a302b;
}

/*
 * Phase 2g — Container-width responsive layout. All three breakpoint blocks
 * below are @container queries against the chart's own root, not @media
 * viewport queries. This means a chart inside a narrow Breakdance column on
 * a wide desktop viewport collapses to its compact layout based on its
 * actual rendered width, not the browser viewport size. Container-type is
 * declared on .monex-charts (see the root rule at the top of this file).
 * Same breakpoint values as the previous viewport-only rules to preserve
 * visual behavior on genuinely narrow viewports.
 */

@container monex-chart (max-width: 1050px) {
  .monex-charts__controls { grid-template-columns: minmax(0, 1fr); }
  .monex-charts__controls-right { justify-items: start; }
  .monex-charts__controls--selector .monex-charts__dates { justify-content: flex-start; }
}

/* Compact tooltip on narrow charts: smaller type and padding so the
   six-row OHLC/Change body fits the reduced headroom; width capped to
   the chart so the horizontal clamp has room to work. */
@container monex-chart (max-width: 720px) {
  .monex-charts__tooltip { min-width: 0; max-width: min(300px, 86cqw); padding: 9px 11px; gap: 1px; }
  .monex-charts__tooltip strong { font-size: 14px; }
  .monex-charts__tooltip small { font-size: 10.5px; }
  .monex-charts__tooltip span { font-size: 12px; }
}

@container monex-chart (max-width: 720px) {
  .monex-charts__intro { margin-bottom: 24px; }
  .monex-charts .monex-charts__display-title { font-size: var(--monex-title-font-size, 28px); }
  .monex-charts .monex-charts__description { font-size: var(--monex-description-font-size, 14px); line-height: 1.5; }
  .monex-charts__topbar { margin-bottom: 28px; }
  .monex-charts__headline { gap: 8px; }
  .monex-charts__headline > strong { font-size: 35.2px; }
  .monex-charts__headline > span { font-size: 15.2px; }
  .monex-charts__subline { gap: 8px 10px; font-size: 12.8px; }
  .monex-charts__controls { gap: 12px; margin-bottom: 28px; }
  .monex-charts__controls-left,
  .monex-charts__controls-right { display: grid; width: 100%; min-width: 0; }
  .monex-charts__ranges,
  .monex-charts__modes,
  .monex-charts__commodities { width: 100%; height: 54px; padding: 5px; }
  .monex-charts__ranges { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .monex-charts__modes { display: grid; grid-template-columns: 1fr 1fr 44px; }
  .monex-charts__commodities { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .monex-charts__controls button { min-width: 0; height: 44px; min-height: 44px; padding-inline: 5px; font-size: 12.16px; }
  .monex-charts__dates { display: grid; grid-template-columns: 1fr 1fr auto; width: 100%; gap: 7px; }
  .monex-charts__dates label { display: block; min-width: 0; }
  .monex-charts__dates label span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
  .monex-charts__dates input { width: 100%; min-width: 0; height: 44px; padding-inline: 7px; border-radius: 10px; font-size: 11.5px; }
  .monex-charts__dates button[data-action="apply"] { min-width: 58px; min-height: 44px; height: 44px; padding-inline: 10px; border-radius: 10px; }
  .monex-charts__frame { min-height: 390px; padding: 10px 8px 14px; }
  .monex-charts__plot { min-height: 365px; padding: 42px 5px 0; }
  .monex-charts__svg { height: 290px; }
  .monex-charts__watermark { top: 187px; }
  .monex-charts__axis { font-size: 10px; }
  .monex-charts__footer { padding-top: 12px; font-size: 10px; }
}

/*
 * Phase 2b tightening (now container-scoped as of Phase 2g). Sits after the
 * 720 block so its declarations win the cascade on all containers ≤768px.
 * Chart SVG geometry itself is chosen by the JS bundle at render time
 * (viewBox becomes 500x340 with preserveAspectRatio unset); this block only
 * handles CSS: whitespace between controls and plot, intrinsic SVG aspect,
 * watermark position. NO transforms, NO overflow tricks — real geometry
 * lives in JS.
 */
@container monex-chart (max-width: 768px) {
  .monex-charts__topbar { margin-bottom: 16px; }
  .monex-charts__controls { margin-bottom: 14px; }
  .monex-charts__frame { min-height: 0; padding: 6px 8px 10px; }
  .monex-charts__plot { min-height: 0; padding: 14px 4px 0; }
  .monex-charts__svg { height: auto; width: 100%; aspect-ratio: 500 / 340; }
  .monex-charts__watermark { top: 40%; width: clamp(60px, 18vw, 92px); }
  .monex-charts__footer { padding-top: 6px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .monex-charts__controls button { transition: none; }
  .monex-charts__pdf.is-working svg { animation: none; }
}



/* =========================================================
   PERFORMANCE COMPARISONS
   Dow / S&P buttons generated by monex-charts.js
   ========================================================= */

.monex-charts__comparisons {
  display: inline-flex;
  align-items: center;
  gap: 5px;

  min-width: 0;
  height: 46px;
  padding: 4px 5px;

  border: 1px solid rgba(63, 122, 150, .18);
  border-radius: 12px;

  background: rgba(255, 255, 255, .88);
  box-shadow: 0 10px 26px rgba(41, 69, 96, .07);
  backdrop-filter: blur(8px);
}

.monex-charts__comparisons-label {
  padding: 0 7px 0 6px;
  color: #6b7f8e;
  font-size: 11.52px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.monex-charts__comparisons button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 82px;
  height: 36px;
  padding: 0 13px;

  border: 0;
  border-radius: 8px;
  outline: 0;

  background: transparent;
  box-shadow: none;

  color: #536777;
  font: inherit;
  font-size: 12.8px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;

  cursor: pointer;

  transition:
    color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.monex-charts__comparisons button:hover:not(:disabled) {
  color: var(--monex-navy);
  background: rgba(126, 166, 185, .12);
}

.monex-charts__comparison-swatch {
  display: inline-block;
  flex: 0 0 auto;
  width: 12px;
  height: 4px;
  margin-right: 8px;
  border-radius: 2px;
  vertical-align: middle;
}

.monex-charts__tooltip-comparison {
  display: flex;
  align-items: center;
}
.monex-charts__tooltip-comparison b { margin-left: auto; padding-left: 14px; }

.monex-charts__comparisons button.is-active {
  color: #fff;
  background: var(--monex-blue);
  box-shadow: 0 7px 16px rgba(63, 122, 150, .22);
}

.monex-charts__comparisons button:focus-visible {
  outline: 3px solid rgba(63, 122, 150, .25);
  outline-offset: 2px;
}

@container monex-chart (max-width: 768px) {
  .monex-charts__comparisons {
    position: relative;
    top: auto;
    right: auto;

    display: grid;
    grid-template-columns: auto repeat(2, minmax(0, 1fr));

    width: 100%;
    height: 48px;
    margin: 0 0 6px;
    padding: 4px;

    gap: 3px;
  }

  .monex-charts__comparisons-label {
    padding-inline: 4px;
    font-size: 9.5px;
  }

  .monex-charts__comparisons button {
    min-width: 0;
    height: 38px;
    padding-inline: 5px;
    font-size: 11px;
  }

  .monex-charts__plot {
    padding-top: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .monex-charts__comparisons button {
    transition: none;
  }
}