/* Direction 05: the household story. Existing material and theme tokens remain. */
:root {
  --negative-text: var(--brand);
}
:root[data-theme="dark"] {
  --negative-text: var(--coral);
}
h2,
h3 {
  font-weight: 650;
}
.tiny-label,
.small-label,
.tabs button {
  font-weight: 600;
}
.net-amount,
.schedule-total strong,
.flow-totals strong {
  font-weight: 650;
}
.story-section {
  padding: 96px 0;
  scroll-margin-top: 28px;
}
.story-section .section-heading {
  margin-bottom: 40px;
}
.story-section h2 {
  font-size: clamp(38px, 4.1vw, 62px);
  line-height: 1.06;
  letter-spacing: -0.065em;
}
.story-section h2 em {
  font-weight: 500;
}
.story-section p {
  line-height: 1.75;
}
@keyframes tour-clock {
  to {
    transform: scaleX(1);
  }
}
.history-studio {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.history-top {
  padding: 30px 32px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.history-top h2 {
  font-size: 24px;
  margin-top: 10px;
  letter-spacing: -0.05em;
  line-height: 1.15;
}
.history-top .tabs {
  flex-shrink: 0;
}
.history-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
}
.history-main {
  padding: 28px 28px 20px;
  min-width: 0;
}
.history-current {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.history-current > div:first-child > span {
  font-size: 10px;
  color: var(--muted);
}
.history-current strong {
  display: block;
  font-weight: 650;
  font-size: 38px;
  line-height: 1.25;
  margin-top: 5px;
  letter-spacing: -0.055em;
}
.history-line-key {
  font-size: 10px;
  color: var(--muted);
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
}
.history-line-key > i {
  height: 2px;
  background: var(--ink);
  display: inline-block;
  width: 20px;
}
.history-line-key label {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  cursor: pointer;
}
.history-line-key input {
  accent-color: var(--green);
}
.history-chart {
  height: 300px;
  margin-top: 25px;
  cursor: crosshair;
  touch-action: pan-y;
  outline-offset: 6px;
}
.history-chart svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.history-chart text {
  fill: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
}
.history-chart .picked-month {
  fill: var(--ink);
  font-weight: 750;
}
.history-cursor {
  opacity: 0.7;
}
.history-net {
  display: grid;
  grid-template-columns: 52fr repeat(8, 100fr) 18fr;
  align-items: center;
  gap: 0;
  padding-top: 5px;
}
.history-net > span {
  font-size: 8px;
  color: var(--muted);
}
.history-net button {
  font-size: 9px;
  letter-spacing: -0.03em;
  color: var(--green);
  min-height: 36px;
  border-radius: 6px;
  white-space: nowrap;
}
.history-net button[aria-pressed="true"] {
  background: var(--surface-2);
  font-weight: 700;
}
.history-net .negative {
  color: var(--negative-text);
}
.history-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 14px;
  min-height: 44px;
}
.history-legend button {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  font-size: 10px;
  font-weight: 550;
  transition: opacity 0.2s;
}
.history-legend i,
.history-parts i {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  display: inline-block;
}
.history-legend .faded {
  color: var(--muted);
}
.history-legend .faded i {
  opacity: 0.35;
}
.history-reset {
  color: var(--green);
  margin-left: auto;
}
.history-receipt {
  border-left: 1px solid var(--line);
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  padding: 30px 24px;
}
.history-receipt-title h3 {
  font-size: 28px;
  margin-top: 14px;
  letter-spacing: -0.06em;
}
.history-receipt-title h3 span {
  color: var(--muted);
  font-weight: 450;
}
.history-parts {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.history-parts button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 0;
  font-size: 11px;
  min-height: 37px;
}
.history-parts button[aria-pressed="true"] {
  color: var(--green);
}
.history-parts button > span {
  display: flex;
  align-items: center;
  gap: 8px;
}
.history-parts strong {
  font-weight: 650;
}
.history-own {
  padding: 18px 0;
  font-size: 11px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}
.history-own small {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}
.history-receipt dl {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 11px;
}
.history-receipt dl > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
}
.history-receipt dd {
  font-weight: 650;
  margin: 0;
}
.history-receipt dl > .positive {
  color: var(--green);
}
.history-receipt dl > .negative {
  color: var(--negative-text);
}
.history-receipt dl > div:last-child {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.history-foot {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  padding: 16px 28px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
}
@media (max-width: 1150px) {
  .history-layout {
    grid-template-columns: minmax(0, 1fr) 255px;
  }
  .history-main {
    padding: 24px 20px 18px;
  }
  .history-receipt {
    padding: 26px 18px;
  }
  .history-net button {
    font-size: 8px;
  }
}
@media (max-width: 900px) {
  .story-section {
    padding: 70px 0;
  }
  .history-top {
    padding: 24px;
  }
  .history-layout {
    grid-template-columns: 1fr;
  }
  .history-receipt {
    border-left: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 32px;
    padding: 26px;
  }
  .history-receipt-title {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .history-receipt-title h3 {
    margin-top: 0;
  }
  .history-parts {
    grid-row: 2 / 4;
    border-bottom: 0;
  }
  .history-own {
    padding-bottom: 12px;
  }
  .history-receipt dl {
    padding-top: 0;
  }
  .history-net button {
    font-size: 10px;
  }
  .history-chart {
    height: 300px;
  }
  .history-foot {
    padding: 16px 24px;
  }
}
@media (max-width: 600px) {
  .story-section {
    padding: 56px 0;
  }
  .story-section h2 {
    font-size: 38px;
  }
  .history-top {
    display: block;
    padding: 24px 20px;
  }
  .history-top h2 {
    font-size: 23px;
  }
  .history-top .tiny-label {
    font-size: 8px;
  }
  .history-top .tabs {
    margin-top: 20px;
    width: max-content;
  }
  .history-main {
    padding: 24px 12px 16px;
  }
  .history-current {
    padding: 0 6px;
    gap: 8px;
  }
  .history-current strong {
    font-size: 32px;
  }
  .history-current > div:first-child > span {
    font-size: 9px;
  }
  .history-line-key {
    font-size: 9px;
    gap: 5px;
    grid-template-columns: 15px 1fr;
  }
  .history-line-key > i {
    width: 15px;
  }
  .history-chart {
    height: 235px;
    margin-top: 20px;
  }
  .history-chart text {
    font-size: 23px;
  }
  .history-net button {
    font-size: 8px;
    min-height: 36px;
  }
  .history-net > span {
    font-size: 7px;
  }
  .history-legend {
    gap: 6px 14px;
    padding-left: 6px;
  }
  .history-legend button {
    font-size: 9px;
  }
  .history-receipt {
    padding: 24px 20px;
    gap: 0 20px;
    display: block;
  }
  .history-receipt-title h3 {
    font-size: 28px;
  }
  .history-receipt-title .tiny-label {
    font-size: 8px;
  }
  .history-parts {
    padding: 18px 0 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
    border-bottom: 1px solid var(--line);
  }
  .history-parts button {
    font-size: 10px;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 45px;
  }
  .history-parts button > span {
    gap: 5px;
  }
  .history-parts strong {
    font-size: 11px;
  }
  .history-own {
    padding-top: 18px;
    font-size: 12px;
  }
  .history-receipt dl > div {
    font-size: 11px;
  }
  .history-foot {
    flex-direction: column;
    gap: 6px;
    font-size: 8px;
    padding: 16px 20px;
  }
}

.history-chart {
  position: relative;
}
.history-y-axis,
.history-x-axis {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: 10px;
  color: var(--muted);
}
.history-y-axis > span {
  position: absolute;
  left: 0;
  width: 4.3%;
  text-align: right;
  transform: translateY(-50%);
}
.history-x-axis > span {
  position: absolute;
  bottom: -2px;
  transform: translateX(-50%);
}
.history-x-axis > .picked-month {
  font-weight: 750;
  color: var(--ink);
}
@media (max-width: 600px) {
  .history-y-axis,
  .history-x-axis {
    font-size: 9px;
  }
  .history-y-axis > span {
    width: 5%;
  }
}
