/* Compound interest calculator: page layout on top of the shared /style.css. Scoped to body.ci.
   Compact controls (label and value on one line, a full-width slider below; tap a value to type an
   exact number). Currency, compounding and Reset sit behind "More options".
   Desktop: the controls sit in a panel beside the graph. "Wider chart" (js/chart-tools.js, data-wide-move)
   and narrower screens put them under the graph instead: two by two, or in one row of four when wide. */

.ci .hero-head { display: block; padding-block: 26px 6px; }
.ci .hero-head h1 { font-size: var(--step-3); max-width: none; margin-top: 6px; }
.ci .workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 14px; }
.ci .stage { display: contents; }
.ci .workspace .answer { order: 1; }
.ci .workspace .landscape { order: 2; }
.ci .workspace .ctl { order: 3; }
.ci .workspace .stats { order: 4; }
.ci .answer { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 18px; }
.ci .answer .label { flex-basis: 100%; }
.ci .answer .big { font-size: clamp(2.8rem, 2rem + 2.6vw, 4.2rem); }
.ci .answer .big.is-ahead { color: var(--slate); }
.ci .answer-line { padding-bottom: 6px; max-width: 52ch; }
.ci .landscape { padding-top: 10px; }
.ci .legend-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 24px; padding-top: 8px; }
.ci .legend { pointer-events: none; }
.ci .legend span { display: inline-flex; align-items: center; gap: 7px; }
/* "Save image" shares the legend's line on wide screens */
@media (min-width: 761px) {
  .ci .landscape { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 18px; align-items: center; }
  .ci .landscape > .chart-box { grid-column: 1 / -1; }
  .ci .landscape > .save-row { margin: 0; padding-top: 8px; }
}

/* Stats under the controls */
.ci .stats { margin-top: 26px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 640px) { .ci .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ci .stat { align-content: start; }
.ci .stat .sub { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ci .stat-gold .v { color: var(--gold); }
.ci .stat-rust .v { color: var(--rust); }

/* Compact controls */
.ci .ctl { margin-top: 14px; border-top: 1px solid var(--ink); padding-top: 12px; min-width: 0; }
.ci .ctl-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px 40px; }
.ci .ctl-f { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; min-width: 0; }
.ci .ctl-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.ci .ctl-top label, .ci .cv { font-size: 0.9rem; line-height: 1.5; font-weight: 600; }
.ci .ctl-top label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ci .cv { flex: none; display: inline-flex; align-items: baseline; color: var(--ink); border-bottom: 1px dotted var(--muted); cursor: text; font-variant-numeric: normal; }
.ci .cv:focus-within { border-bottom: 1px solid var(--ink); }
.ci .cv span, .ci .money.cv span { position: static; transform: none; color: inherit; font-size: inherit; pointer-events: none; }
.ci .cv .u-w { margin-left: 0.25em; }
.ci .ctl .cv input, .ci .ctl .money.cv input { line-height: inherit; height: auto; width: 4ch; min-height: 0; border: 0; border-radius: 0; padding: 0; margin: 0; background: transparent; color: inherit; font: inherit; font-variant-numeric: normal; text-align: right; }
.ci .ctl .cv input:focus { outline: none; }
.ci .cv input[aria-invalid="true"] { color: var(--rust); }
.ci .ctl .slider { width: 100%; height: 34px; }
/* Touch: the slider keeps the finger even when it drifts up or down (no page scroll from a slider row). */
@media (pointer: coarse) { .ci .ctl .slider { height: 40px; touch-action: none; } }
.ci .ctl .field-err { line-height: 1.3; margin-top: -4px; padding-bottom: 4px; }

/* "More options": currency, compounding, Reset */
.ci .ctl-more { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 6px; }
.ci .ctl-more summary { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; cursor: pointer; list-style: none; font-size: 0.86rem; color: var(--muted); }
.ci .ctl-more summary::-webkit-details-marker { display: none; }
.ci .ctl-sum { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci .ctl-more-l { flex: none; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.ci .ctl-more[open] .ctl-sum { visibility: hidden; }
.ci .ctl-more[open] .ctl-more-l::after { content: " \2212"; text-decoration: none; display: inline-block; margin-left: 4px; }
.ci .ctl-opts { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 28px; padding: 2px 0 12px; }
.ci .ctl-opt { display: grid; gap: 6px; min-width: 0; }
.ci .ctl-opt select { width: 15rem; max-width: 100%; }
.ci .ctl-opt .ci-seg { width: 26rem; max-width: 100%; }
.ci .ctl-panel-head { margin-left: auto; flex-wrap: nowrap; }
.ci .ctl-more .privacy { margin: 0 0 12px; }
.ci .ctl-more .saved-note, .ci .ctl-more .shared-note { margin: 0 0 12px; font-size: var(--step--1); }

.ci .ctl-ph, .ci .ctl-legend { display: none; }

/* Desktop: the classic "Your numbers" panel beside the graph, with a slider beside each box.
   js (arrange) moves currency and Reset to the top and compounding under the rate. */
@media (min-width: 961px) {
  .ci .workspace:not(.is-chart-wide) { grid-template-columns: minmax(0, 1fr) 380px; column-gap: 40px; align-items: start; }
  .ci .workspace:not(.is-chart-wide) .stage { display: grid; min-width: 0; grid-column: 1; grid-row: 1; }
  .ci .workspace:not(.is-chart-wide) .ctl { grid-column: 2; grid-row: 1; margin-top: 0; background: transparent; border: 0; border-left: 1px solid var(--line); border-radius: 0; padding: 14px 0 16px 28px; }   /* open, ruled on the left, as on the other calculators */
  .ci .workspace:not(.is-chart-wide) .ctl-ph { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--ink); }
  .ci .workspace:not(.is-chart-wide) .ctl-ph h2 { font-size: 1.45rem; }
  .ci .workspace:not(.is-chart-wide) .ctl-ph .btn-row { flex-wrap: wrap; gap: 8px; }
  .ci .workspace:not(.is-chart-wide) .ctl-ph .ctl-opt { flex: 1 1 0; min-width: 0; }
  .ci .workspace:not(.is-chart-wide) .ctl-ph .ctl-opt .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ci .workspace:not(.is-chart-wide) .ctl-ph .ctl-opt select { width: 100%; }
  .ci .workspace:not(.is-chart-wide) .ctl-ph .ctl-panel-head { margin-left: 0; flex-wrap: nowrap; }
  .ci .workspace:not(.is-chart-wide) .ctl-ph .shared-note { flex-basis: 100%; margin: 0; font-size: var(--step--1); }
  .ci .workspace:not(.is-chart-wide) .ctl-grid { grid-template-columns: minmax(0, 1fr); row-gap: 6px; }
  .ci .workspace:not(.is-chart-wide) .ctl-legend { display: block; font-family: var(--font-display); font-size: 1.05rem; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
  .ci .workspace:not(.is-chart-wide) .ctl-grid > .ctl-legend:first-child { border-top: 0; margin-top: 0; }
  .ci .workspace:not(.is-chart-wide) .ctl-f { grid-template-columns: minmax(0, 1fr) 7.2rem; column-gap: 14px; row-gap: 4px; align-items: center; }
  .ci .workspace:not(.is-chart-wide) .ctl-top { display: contents; }
  .ci .workspace:not(.is-chart-wide) .ctl-top label { grid-column: 1 / -1; font-size: 0.8rem; }
  .ci .workspace:not(.is-chart-wide) .ctl .slider { grid-column: 1; grid-row: 2; height: 42px; }
  .ci .workspace:not(.is-chart-wide) .cv { grid-column: 2; grid-row: 2; min-height: 42px; align-items: center; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); font-size: 1rem; font-weight: 400; }
  .ci .workspace:not(.is-chart-wide) .cv:focus-within { border-color: var(--ink); }
  .ci .workspace:not(.is-chart-wide) .cv .sym { color: var(--muted); margin-right: 3px; }
  .ci .workspace:not(.is-chart-wide) .cv span[aria-hidden]:not(.sym) { color: var(--muted); }
  .ci .workspace:not(.is-chart-wide) .ctl .cv input { width: 100% !important; flex: 1 1 auto; min-width: 0; text-align: left; }
  .ci .workspace:not(.is-chart-wide) .ctl .field-err { grid-column: 1 / -1; margin-top: 0; }
  .ci .workspace:not(.is-chart-wide) .ctl-grid > .ctl-opt { gap: 6px; }
  .ci .workspace:not(.is-chart-wide) .ctl-opt .ci-seg { width: 100%; }
  .ci .workspace:not(.is-chart-wide) .ctl-more { display: none; }
  .ci .workspace:not(.is-chart-wide) .ctl > .privacy { margin-top: 10px; }
  .ci .workspace:not(.is-chart-wide) .ctl > .saved-note { margin: 8px 0 0; font-size: var(--step--1); }
}

.ci .ci-seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; height: 42px; }
.ci .ci-seg button { border: 0; background: var(--paper); color: var(--muted); font-weight: 600; font-size: 0.86rem; cursor: pointer; padding: 0 6px; }
.ci .ci-seg button + button { border-left: 1px solid var(--line); }
.ci .ci-seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* Main graph: stacked parts up to the goal */
.ci .chip-goal { border-color: var(--ink); border-top-width: 1.5px; border-top-style: dashed; }
.ci .chip-cmp0 { border-color: var(--muted); border-top-width: 1.5px; border-top-style: dashed; }
.chart-box .goal-line { stroke: var(--ink); stroke-width: 1.3; stroke-dasharray: 5 4; }
.chart-box .goal-l { font-size: 12px; font-weight: 700; fill: var(--ink); }
.chart-box .halo { paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.chart-box .start-dot { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
.chart-box .empty-msg { font-family: var(--font-display); font-style: normal; font-size: 15px; fill: var(--muted); }
.chart-box .l-flat { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart-box .you-dot { fill: var(--gold); stroke: var(--paper); stroke-width: 2.5; }
.chart-box .mk-dot { fill: var(--paper); stroke: var(--gold); stroke-width: 1.5; }
.chart-box .mk-l { font-size: 11.5px; fill: var(--muted); }
.chart-box .you-l { font-size: 13px; font-weight: 700; fill: var(--gold); }

/* Second graph: monthly amount against time */
.ci .trade { padding-top: 64px; display: grid; gap: 14px; }
.ci .trade-msg { font-size: 1.05rem; max-width: 70ch; }
.ci .trade-msg b { font-weight: 700; }
.ci .trade-msg .g { color: var(--gold); }
.ci .trade-box { border-top: 1px solid var(--ink); padding-top: 6px; }
.ci .trade-legend { margin-top: -4px; }
.ci .trade-legend span { display: inline-flex; align-items: center; gap: 7px; }
/* Year by year */
.ci #years { padding-top: 56px; }
.ci #years h2 { margin-bottom: 14px; }
.ci .yt-scroll { overflow-x: auto; }
.ci .yt { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.95rem; border-top: 1px solid var(--ink); }
.ci .yt th, .ci .yt td { padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.ci .yt th:first-child { text-align: left; }
.ci .yt th:last-child, .ci .yt td:last-child { padding-right: 0; }
.ci .yt thead th { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.ci .yt tbody th { font-weight: 600; }
.ci .yt td.g { color: var(--gold); }
.ci .yt tr.is-goal { background: var(--surface-2); }
.ci .yt tr.is-target { background: var(--surface-2); }
.ci .yt-note { margin-top: 10px; }

/* Reading: one content width, heading left and text right on wide screens */
.ci .prose, .ci .disclaimer { max-width: none; }
@media (min-width: 900px) {
  .ci .section.prose { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); column-gap: 48px; row-gap: 0; align-items: start; }
  .ci .section.prose > h2 { grid-column: 1; grid-row: 1 / span 30; }
  .ci .section.prose > :not(h2) { grid-column: 2; margin-bottom: 16px; }
}
.ci .sources { font-size: var(--step--1); color: var(--muted); }

@media (max-width: 960px) {
  .ci .ctl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
}
@media (max-width: 600px) {
  .ci .hero-head { padding-block: 18px 0; }
  .ci .hero-head h1 { font-size: 1.6rem; }
  .ci .hero-head .eyebrow { display: none; }
  .ci .answer .big { font-size: 2.9rem; }
  .ci .answer-line { font-size: 0.85rem; flex-basis: 100%; padding-bottom: 0; }
  .ci .landscape { padding-top: 6px; }
  .ci .legend-row { gap: 6px 14px; padding-top: 6px; }
  .ci .legend { gap: 2px 14px; font-size: 0.8rem; }
  .ci .ctl-grid { column-gap: 20px; }
  .ci .ctl-top { gap: 6px; }
  .ci .ctl-top label, .ci .cv { font-size: 0.82rem; }
  .ci .ctl-opts { display: grid; grid-template-columns: minmax(0, 1fr); }
  .ci .ctl-opt select, .ci .ctl-opt .ci-seg { width: 100%; }
  .ci .ctl-panel-head { margin-left: 0; }
  .ci .yt { font-size: 0.84rem; }
  .ci .yt th, .ci .yt td { padding-right: 8px; }
  .ci .yt .wide { display: none; }
}

/* While a number is invalid, keep the last result but fade it. */
.ci .is-stale .landscape, .ci .is-stale .stats { opacity: 0.35; transition: opacity 0.15s; }

/* Interest split: simple interest (light gold) and interest on interest (deep gold) */
.ci .sw-simple, .ci .sw-oni { height: 10px; border: 0; border-radius: 2px; background: var(--gold-area); }
.ci .sw-simple { opacity: 0.42; }
.ci .sw-oni { opacity: 0.85; }
.chart-box .a-put { fill: var(--muted); fill-opacity: 0.16; }
.chart-box .a-simple { fill: var(--gold-area); fill-opacity: 0.42; }
.chart-box .a-oni { fill: var(--gold-area); fill-opacity: 0.85; }
.chart-box .b-simple { fill: var(--gold-area); fill-opacity: 0.42; }
.chart-box .b-oni { fill: var(--gold-area); }
.chart-box .dep-line { stroke: var(--ink); stroke-width: 1.3; stroke-dasharray: 5 4; fill: none; }
.chart-box .cross-l { font-size: 12px; font-weight: 700; fill: var(--gold); }
.ci .stat-deep .v { color: var(--gold); }
.ci .bars-legend span { display: inline-flex; align-items: center; gap: 7px; }
