.calc-label { display: block; }
.calc-amount { display: flex; align-items: baseline; gap: 7px; }
#calc-panel #gross-input {
  box-sizing: border-box; width: 17ch; max-width: calc(100% - 5ch); min-height: 44px;
  border: 0; border-bottom: 1px solid var(--gray); border-radius: 0;
  background: transparent; color: var(--ink); padding: 2px 0;
  font: 550 clamp(20px, 3vw, 28px)/1.35 var(--sans); font-variant-numeric: tabular-nums;
}
.calc-presets { display: flex; flex-wrap: wrap; gap: 0 18px; }
.calc-presets button {
  min-height: 44px; color: var(--rust); font: 550 13px/1.4 var(--sans);
  text-decoration: underline; text-underline-offset: 3px;
}
.calc-error { margin-top: 5px; color: #99364f; font-size: 13px; }
#calc-explanation { max-width: 72ch; color: var(--gray); font-size: 15px; line-height: 1.68; }
.chart[role="slider"] { touch-action: pan-y; }
.chart .chart-tip { max-width: 100%; white-space: nowrap; }
.chart-tip[hidden], .calc-error[hidden] { display: none; }

.offers-table td:nth-child(3), .offers-table td.ask { overflow-wrap: anywhere; }
#compare-panel .fw-compare-table td { overflow-wrap: anywhere; }

@media (max-width: 600px) {
  /* Local offers may ask up to 1,000,000.00 HYPE. */
  .offers-table .price-col { width: 25%; }
  #modal-body .fw-insight-table td { overflow-wrap: anywhere; }
  .calc-bottom > div, .form-pair > .field { min-width: 0; }
  .calc-bottom strong { overflow-wrap: anywhere; }
}

@media (max-width: 390px) {
  .offers-table :is(th,td):first-child { width: 28%; }
  .offers-table :is(th,td):last-child { width: 32px; }
  .offers-table .bookmark-cell .fav { width: 32px; }
}

@media (max-width: 820px) and (pointer: coarse) {
  /* Preserve the current scale when an iPhone or tablet focuses a field. */
  .search input, .filters select, #calc-pool, .field :is(input, select, textarea),
  #compare-panel .fw-compare-picks select { font-size: 16px; }
}

@media (forced-colors: active) {
  .offers-table tbody tr.is-selected td:first-child {
    box-shadow: none;
    border-inline-start: 2px solid Highlight;
  }
}

/* The browser owns showModal(), close(), focus restoration and Escape. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes fee-dialog-enter {
    from { opacity: .88; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
  }

  #modal[open] { animation: fee-dialog-enter 120ms ease-out; }

  /* Interactivity keeps the departing sheet out of focus order while it paints. */
  @supports (transition-behavior: allow-discrete) and (overlay: auto) and (interactivity: inert) {
    #modal {
      opacity: 0;
      transform: translateY(2px);
      interactivity: inert;
      pointer-events: none;
      transition: opacity 90ms ease-out, transform 90ms ease-out,
        display 90ms allow-discrete, overlay 90ms allow-discrete;
    }

    #modal[open] {
      animation: none;
      opacity: 1;
      transform: translateY(0);
      interactivity: auto;
      pointer-events: auto;
    }

    #modal:not([open])::backdrop { pointer-events: none; background-color: transparent; }

    @starting-style {
      #modal[open] { opacity: .88; transform: translateY(3px); }
    }
  }
}

#title:focus { outline: none; }
#empty-action { margin-top: 12px; }
#history-panels {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(250px, 1fr);
  gap: clamp(24px, 4vw, 50px); padding-top: 20px; border-top: 2px solid var(--ink);
}
#overview { min-width: 0; }
#history-panels .market-total { margin-top: 15px; }
#history-panels .chart { height: 180px; }
#lower-market { max-width: 780px; padding-top: 20px; border-top: 2px solid var(--ink); }
.offer-editor .field-error, .offer-editor .offer-message {
  color: var(--rust); font-size: 13px; line-height: 1.5;
}
.offer-editor .offer-message { margin-top: 10px; }
.offer-editor .offer-preview { margin-top: 18px; font-size: 14px; line-height: 1.55; }
.offer-editor .field [aria-invalid="true"], #calc-panel #gross-input[aria-invalid="true"] {
  border-color: #99364f; border-bottom-width: 2px;
}
.offer-editor .field-error { color: #99364f; font-weight: 500; }
.offer-editor .form-pair { align-items: start; }
.offer-editor .note { margin-top: 6px; }
.range-labels span:last-child { overflow-wrap: anywhere; text-align: right; min-width: 0; }

@media (max-width: 600px) {
  #history-panels { grid-template-columns: 1fr; }
  #history-panels .chart { height: 155px; }
  .details-grid dd { overflow-wrap: anywhere; }
  .switch button { min-width: 36px; min-height: 36px; }
  .offer-editor .field input, .offer-editor .field select { min-height: 42px; }
  .dialog-actions .primary, .dialog-actions .secondary { min-height: 40px; }
}

@media (max-width: 390px) {
  .offers-table th.price-col { width: 91px; }
}

@media (forced-colors: active) {
  .offer-editor .field [aria-invalid="true"], #calc-panel #gross-input[aria-invalid="true"] {
    border: 2px solid CanvasText;
  }
  .chart line { stroke: GrayText; }
  .chart text { fill: CanvasText; }
  .history-bars rect { fill: CanvasText; }
  .history-bars rect[fill="#554c69"] { fill: Highlight; stroke: Highlight; }
}

body.modal-open { overflow: hidden; }
#modal { overscroll-behavior: contain; }

.detail-pool { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; }
.detail-watch {
  padding: 6px 0; color: var(--rust); font: 550 14px/1.4 var(--sans);
  text-decoration: underline; text-underline-offset: 3px;
}

.compare-assumption {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 11px;
  margin: 0 0 16px;
}
.compare-assumption label { color: var(--gray); font-size: 13px; }
@media (max-width: 820px) and (pointer: coarse) {
  .compare-assumption select { min-height: 40px; font-size: 16px; }
}

#undo-removal {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px;
  padding: 12px 0; margin-bottom: 16px; border-block: 1px solid var(--rule);
}
#undo-removal button, .offer-removal button {
  min-height: 36px; color: var(--rust); font: 550 14px/1.4 var(--sans);
  text-decoration: underline; text-underline-offset: 3px;
}
#undo-removal #dismiss-remove { color: var(--gray); }
.offer-removal { margin-top: 22px; border-top: 1px solid var(--rule); padding-top: 12px; }
.offer-removal p { line-height: 1.5; }
.offer-removal button + button { margin-inline-start: 14px; }

#book-pager {
  display: flex; justify-content: flex-end; align-items: center; gap: 12px;
  padding-block: 10px; border-bottom: 1px solid var(--rule); font-size: 14px;
}
#page-range { margin-inline-end: auto; color: var(--gray); }
#book-pager button { min-height: 40px; color: var(--rust); text-underline-offset: 3px; }
#book-pager button:not(:disabled):hover { text-decoration: underline; }
#book-pager button:disabled { color: var(--gray); opacity: .65; cursor: default; }

.dialog-status:not(:empty) {
  margin: 12px 20px 0; padding-block: 6px;
  border-bottom: 1px solid var(--rule); color: var(--ink); font-size: 14px;
}

.market-lead { margin-top: 32px; padding: 0; max-width: 72ch; }
.market-lead h2, .market-notes h2 { font: 500 21px/1.3 var(--serif); }
.market-lead p, .market-notes p { margin: 7px 0; line-height: 1.6; }
.market-notes { margin-top: 36px; }
.market-notes article { display: grid; grid-template-columns: minmax(180px,1fr) minmax(0,2fr); gap: 20px; border-top: 1px solid var(--rule); padding: 16px 0; }
.market-notes article p { margin-top: 0; max-width: 76ch; }
.market-notes h3 { font: 550 17px/1.45 var(--sans); }
.market-lead a, .market-notes a { color: var(--rust); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 650px) { .market-notes article { grid-template-columns: 1fr; gap: 6px; } }
