.custom-ratio-trigger {
  justify-self: end; min-height: 24px; padding: 0 3px;
  border: 0; border-radius: 5px; background: transparent; color: var(--muted);
  font: inherit; font-size: calc(11px + var(--app-font-increase, 1pt)); cursor: pointer;
}
.custom-ratio-trigger:disabled { opacity: 0.5; cursor: not-allowed; }
.custom-ratio-dialog {
  width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  margin: auto; padding: 24px; overflow: auto;
  border: 1px solid var(--line-strong); border-radius: 18px;
  background: var(--composer-card-solid); color: var(--text); box-shadow: var(--shadow-floating);
}
.custom-ratio-dialog::backdrop { background: var(--overlay); }
.custom-ratio-form { display: grid; gap: 14px; }
.custom-ratio-title { margin: 0; font-size: calc(16px + var(--app-font-increase, 1pt)); font-weight: 650; }
.custom-ratio-help, .custom-ratio-constraints, .custom-ratio-error,
.custom-ratio-dimensions, .custom-ratio-warning { margin: 0; line-height: 1.6; word-break: keep-all; }
.custom-ratio-help { margin-top: -8px; color: var(--muted); font-size: calc(12px + var(--app-font-increase, 1pt)); }
.custom-ratio-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border-radius: 10px; background: var(--choice-selected-bg); }
.custom-ratio-mode {
  min-height: 34px; padding: 6px 12px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--muted); font: inherit; font-size: calc(12px + var(--app-font-increase, 1pt)); cursor: pointer;
}
.custom-ratio-mode[aria-pressed="true"] { border-color: var(--line); background: var(--composer-card-solid); color: var(--text); }
.custom-ratio-fields { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 12px; }
.custom-ratio-field { display: grid; min-width: 0; gap: 7px; color: var(--muted); font-size: calc(12px + var(--app-font-increase, 1pt)); }
.custom-ratio-input {
  width: 100%; min-width: 0; min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--composer-solid); color: var(--text); font: inherit; font-size: calc(14px + var(--app-font-increase, 1pt)); font-variant-numeric: tabular-nums;
}
.custom-ratio-input[aria-invalid="true"] { border-color: var(--danger-line); }
.custom-ratio-separator { align-self: end; padding-bottom: 10px; color: var(--muted); }
.custom-ratio-constraints { color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); }
.custom-ratio-error { color: var(--danger-text); font-size: calc(12px + var(--app-font-increase, 1pt)); }
.custom-ratio-preview { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-subtle); }
.custom-ratio-dimensions { color: var(--text); font-size: calc(13px + var(--app-font-increase, 1pt)); font-weight: 600; font-variant-numeric: tabular-nums; }
.custom-ratio-warning { color: var(--warning); font-size: calc(12px + var(--app-font-increase, 1pt)); }
.custom-ratio-error[hidden], .custom-ratio-preview[hidden], .custom-ratio-warning[hidden] { display: none; }
.custom-ratio-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.custom-ratio-actions button { min-height: 36px; padding: 7px 16px; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: calc(12px + var(--app-font-increase, 1pt)); font-weight: 600; cursor: pointer; }
.custom-ratio-cancel { background: var(--composer-card-solid); color: var(--text); }
.custom-ratio-actions .custom-ratio-apply { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.custom-ratio-apply:disabled { opacity: 0.45; cursor: not-allowed; }
.custom-ratio-trigger:focus-visible, .custom-ratio-dialog button:focus-visible,
.custom-ratio-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ratio-picker-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ratio-picker-number { flex-shrink: 0; }
@media (hover: hover) and (pointer: fine) {
  .custom-ratio-trigger:not(:disabled):hover { color: var(--text); background: var(--surface-hover); }
  .custom-ratio-mode:not([aria-pressed="true"]):hover, .custom-ratio-cancel:hover { background: var(--surface-hover); color: var(--text); }
  .custom-ratio-apply:not(:disabled):hover { background: var(--accent-hover); }
}
@media (max-width: 380px) {
  .custom-ratio-dialog { padding: 18px; }
}
