/* Real Mail stays paper + ink + orange. These tokens tune behavior, not the brand. */
:root {
  color-scheme: light;
  --muted: #62675d;
  --focus: #a03923;
  --accent-ink: #a03923;
  --action-ink: #171b14;
  --ring: 0 0 0 1px rgb(39 41 35 / 10%);
  --shadow-surface: var(--ring), 0 2px 5px rgb(39 41 35 / 3%);
  --shadow-dialog: var(--ring), 0 20px 70px rgb(39 41 35 / 17%);
  --press-duration: 120ms;
  --enter-duration: 200ms;
  --exit-duration: 120ms;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}
html { scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
html[data-modal-open] { overflow: hidden; }
body { text-rendering: optimizeLegibility; }
h1, h2, h3 { text-wrap: balance; }
p.description, .fine { text-wrap: pretty; }
.header { padding-top: env(safe-area-inset-top, 0px); min-height: calc(88px + env(safe-area-inset-top, 0px)); }
.wrap { padding-left: max(36px, env(safe-area-inset-left, 0px)); padding-right: max(36px, env(safe-area-inset-right, 0px)); }
footer { padding-bottom: calc(25px + env(safe-area-inset-bottom, 0px)); }
.header nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-underline-offset: 6px; text-decoration-color: var(--orange); }
:where(button, .button, .mode-option) { -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
:where(button, .button) { position: relative; touch-action: manipulation; }
.button, .nav-account, .close, button.text-link {
  transition: transform var(--press-duration) var(--ease-out), background-color 120ms ease, border-color 120ms ease;
}
.button.orange-button { color: var(--action-ink); } /* Preserve orange; increase text contrast. */
.button-label { display: inline-flex; align-items: center; justify-content: center; gap: inherit; }
.busy-indicator { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.busy-indicator .spinner { width: 17px; height: 17px; border-color: currentColor; border-right-color: transparent; }
button[aria-busy="true"] { opacity: .8; cursor: progress; }
button[aria-busy="true"] .button-label { visibility: hidden; }
.button.small, .nav-account, button.text-link, .close { min-height: 44px; }
button.text-link { padding: 10px 2px; }
.close { width: 44px; height: 44px; padding: 0; border-radius: 8px; }
.button.danger { background: var(--accent-ink); border-color: var(--accent-ink); color: white; }
@media (hover: hover) and (pointer: fine) {
  .button:not(:disabled):hover { box-shadow: 0 2px 5px rgb(39 41 35 / 12%); }
  .button.secondary:not(:disabled):hover, .nav-account:not(:disabled):hover, .close:hover { background-color: var(--soft); }
  .text-link:hover { color: var(--accent-ink); border-color: var(--accent-ink); }
  .mode-option:hover, .upload:hover { border-color: #94998d; }
  .result-list li:hover, .order-card:hover { background: #faf9f3; }
}
/* Press wins over hover; never scale whole rows, text inputs, or disabled controls. */
.button:not(:disabled):active, .nav-account:not(:disabled):active, .close:active, button.text-link:not(:disabled):active { transform: scale(.97); }
.panel { border-color: transparent; box-shadow: var(--shadow-surface); }
.summary { border-color: transparent; box-shadow: var(--shadow-surface); }
.summary dd, .summary .number, .selection-count, .preview-id, .order-card strong { font-variant-numeric: tabular-nums; }
.summary .number { letter-spacing: -.045em; }
.summary .fine { font-size: 12px; }
.summary dl div { gap: 12px; }
.summary dd { max-width: 65%; overflow-wrap: break-word; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  min-height: 44px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
label { font-size: 12px; }
::placeholder { color: #73776c; opacity: 1; }
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus { border-color: var(--focus); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
.mode-option:has(:focus-visible), .upload:has(:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }
input:user-invalid, select:user-invalid, textarea:user-invalid { border-color: var(--accent-ink); }
:where(h1,h2,h3,[role=alert])[tabindex="-1"]:focus { outline: none; }
:where(h1,h2,h3)[tabindex="-1"] { scroll-margin-top: 28px; }
.steps { background: #efeee7; }
.step { font-size: 12px; }
.step.active { box-shadow: inset 0 -2px 0 var(--orange); }
.step span { width: 22px; height: 22px; font-size: 10px; flex-shrink: 0; }
.step.active span { color: var(--action-ink); }
.mode-option { border-radius: 10px; padding: 16px 12px; font-size: 13px; transition: border-color 120ms ease, background-color 120ms ease; }
.mode-option small { font-size: 12px; line-height: 1.6; }
.mode-option:has(input:checked) { border-color: var(--orange); box-shadow: inset 0 0 0 1px var(--orange); }
.result-list li { border-radius: 8px; padding-inline: 10px; }
.result-list li:has(input:checked) { background: #fff4eb; }
.result-list label { min-height: 44px; align-items: center; }
.result-list input { margin-top: 0; }
.recipient-title { overflow-wrap: anywhere; }
.recipient-meta { font-size: 12px; }
.proof-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.proof-row > :first-child, .order-card > :first-child { min-width: 0; }
/* Retain DOM/search/accessibility semantics; do not animate thousands of records. */
.proof-row, .order-card { content-visibility: auto; contain-intrinsic-size: auto 90px; }
.proof-row:focus-within, .order-card:focus-within { content-visibility: visible; }
.upload { transition: border-color 120ms ease, background-color 120ms ease; }
.upload[data-dragging="true"] { border-color: var(--orange); background: #fff4eb; outline: 2px solid var(--orange); outline-offset: 3px; }
.upload[data-file-state="ready"] .upload-icon { color: var(--success); }
.upload[data-file-state="checking"] { border-color: var(--orange); background: #fff4eb; }
.upload input::file-selector-button, #guide-file::file-selector-button {
  border: 1px solid var(--line); border-radius: 6px; background: var(--white); color: var(--ink); padding: 10px 12px; margin-right: 10px; font: inherit; cursor: pointer;
}
.upload input { overflow: hidden; }
#new-key > .button { margin-top: 10px; }
.notice.error, [data-dialog-feedback][data-tone="error"] { color: #8c3420; }
[data-dialog-feedback][data-tone="error"] { padding: 12px; border-radius: 8px; background: #fbede7; }
dialog { box-shadow: var(--shadow-dialog); border-color: transparent; max-height: calc(100dvh - 32px); overscroll-behavior: contain; transform-origin: center; }
dialog[open], dialog[open]::backdrop { animation: none; }
dialog::backdrop { background: rgb(37 40 28 / 38%); backdrop-filter: blur(2px); }
#confirm-dialog h2 { padding-right: 6px; }
#confirm-dialog .form-actions { justify-content: flex-end; margin-bottom: 0; }
#proof-dialog { height: min(900px, calc(100dvh - 24px)); }
#proof-dialog h2 { padding-right: 44px; }
#proof-dialog[open] { display: flex; flex-direction: column; gap: 14px; }
#proof-frame { flex: 1; min-height: 120px; height: auto; }
#proof-dialog .fine { margin: 0; }
#proof-link { align-self: flex-start; }
#toast {
  bottom: max(24px, calc(12px + env(safe-area-inset-bottom, 0px)));
  display: flex; align-items: center; gap: 16px; padding: 10px 12px 10px 18px;
  max-width: min(460px, calc(100vw - 32px)); font-size: 13px;
  opacity: 0; transform: translateX(-50%) translateY(8px);
  transition: opacity var(--exit-duration) ease, transform var(--exit-duration) var(--ease-out);
  pointer-events: none; animation: none;
}
#toast[data-visible="true"] { opacity: 1; transform: translateX(-50%) translateY(0); transition-duration: var(--enter-duration); pointer-events: auto; }
#toast[data-tone="error"] { background: #762f21; }
#toast-message { overflow-wrap: anywhere; }
#toast-dismiss { width: 44px; height: 44px; min-width: 44px; border: 0; border-radius: 6px; color: inherit; background: transparent; font-size: 22px; }
#toast-dismiss:focus-visible { outline-color: white; }
#toast-dismiss:active { background: rgb(255 255 255 / 12%); }
@media (max-width: 960px) {
  .wrap { padding-inline: max(24px, env(safe-area-inset-left, 0px)) max(24px, env(safe-area-inset-right, 0px)); }
}
@media (max-width: 700px) {
  .header { height: auto; min-height: calc(76px + env(safe-area-inset-top, 0px)); padding-inline: max(20px, env(safe-area-inset-left, 0px)) max(20px, env(safe-area-inset-right, 0px)); }
  .header nav { gap: 10px; }
  .wrap { padding-inline: max(22px, env(safe-area-inset-left, 0px)) max(22px, env(safe-area-inset-right, 0px)); }
  .step { gap: 5px; padding: 12px 5px; font-size: 11px; }
  .step span { width: 18px; height: 18px; font-size: 9px; }
  .panel { padding: 24px 20px; }
  .field-row, .field-row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .field-row > label:first-child { grid-column: 1 / -1; }
  .field-row.two { grid-template-columns: minmax(0, 1fr); }
  .mode-options { grid-template-columns: minmax(0, 1fr); }
  .mode-option { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 2px 10px; }
  .mode-option input { grid-row: 1 / 3; margin: 0; }
  .mode-option small { grid-column: 2; margin: 0; }
  .form-actions.end > .button { flex: 1; }
  .proof-row { flex-wrap: wrap; gap: 10px; }
  .proof-actions { justify-content: flex-start; }
  .summary { margin-top: 4px; }
  .header .brand { font-size: 24px; }
  dialog { padding: 32px 24px max(24px, env(safe-area-inset-bottom, 0px)); }
}
@media (any-pointer: coarse), (max-width: 700px) {
  input:not([type=checkbox]):not([type=radio]), select, textarea, .upload input { font-size: 16px; }
}
@media (max-width: 360px) {
  .header .brand-icon { width: 27px; height: 27px; margin-right: 6px; }
  .header .brand { font-size: 22px; }
  .header nav { gap: 8px; }
  .nav-account { padding-inline: 8px; }
  .step { flex-direction: column; gap: 4px; }
}
/* Financial actions, selection, typing and keyboard navigation must feel immediate. */
html[data-input="keyboard"] :is(.button,.nav-account,.close,.text-link,.mode-option,.step,#toast) { transition: none; }
html[data-input="keyboard"] :is(.button,.nav-account,.close,.text-link):active { transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  #toast { transform: translateX(-50%); }
  .spinner { animation: none; }
  :is(.button,.nav-account,.close,.text-link,.mode-option,.step,#toast,.upload,input,select,textarea) { transition: none; }
}
.industry-picker > .industry-summary { min-height: 44px; display: flex; align-items: center; margin: 0; font-size: 13px; }
.industry-filter { margin: 12px 0 4px; }
.industry-list { max-height: min(380px, 50dvh); overflow: auto; padding: 4px 0; overscroll-behavior: contain; }
.industry-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.industry-cat-head { display: flex; align-items: center; gap: 2px; min-height: 44px; }
.industry-cat-head > .checkbox { flex: 1; min-width: 0; min-height: 44px; margin: 0; align-items: center; }
.industry-cat-toggle {
  width: 44px; height: 44px; min-width: 44px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); cursor: pointer; flex-shrink: 0;
}
.industry-cat-toggle::before {
  content: ""; display: block; width: 7px; height: 7px; margin: 0 auto;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}
.industry-cat-toggle[aria-expanded="true"]::before { transform: rotate(45deg); margin-top: -2px; }
.industry-cat-meta { flex-shrink: 0; font-size: 12px; padding-right: 6px; }
.industry-cat-body { padding-left: 28px; }
.industry-leaf { min-height: 44px; display: flex; align-items: center; }
.industry-group .checkbox, .industry-leaf .checkbox { min-height: 44px; align-items: center; margin: 0; padding: 2px; }
.industry-group .checkbox span, .industry-leaf .checkbox span { font-size: 13px; font-weight: 500; }
@media (hover: hover) and (pointer: fine) {
  .industry-cat-toggle:hover { background: var(--soft); }
}
