/* Shared rhythm, controls and short-task surfaces. */
:root {
  --onto-space-1: 4px; --onto-space-2: 8px; --onto-space-3: 12px;
  --onto-space-4: 16px; --onto-space-5: 24px; --onto-space-6: 32px;
  --onto-radius-control: 12px; --onto-radius-surface: 18px;
  --onto-type-label: 14px; --onto-type-body: 16px;
  --onto-keyboard-inset: 0px; --onto-viewport-height: 100dvh;
}
:is(.ok-app,.setup-layout,.onto-auth-page,.onto-landing) .btn {
  border-radius: var(--onto-radius-control); min-height: 46px;
  gap: var(--onto-space-2); font-size: var(--onto-type-label); line-height: 1.5;
}
:is(.ok-content,.setup-panel,.onto-auth-panel,.onto-sheet) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]):not([type=file]),select,textarea) {
  min-height: 48px; font-size: var(--onto-type-body); line-height: 1.5;
  border-radius: var(--onto-radius-control); scroll-margin: 24px;
  max-width: 100%; box-sizing: border-box;
}
:is(.ok-content,.setup-panel,.onto-auth-panel) .setup-field { margin-bottom: var(--onto-space-5); }
:is(.ok-content,.setup-panel,.onto-auth-panel) .setup-field > :is(span,label) { font-size: var(--onto-type-label); line-height: 1.5; }
.ok-content :is(.inline-actions,.qj-actions,.ok-service-actions) { gap: var(--onto-space-3); }
.ok-content :is(.card,.qj-panel,.qj-offer) { border-radius: var(--onto-radius-surface); }
:is(.btn,.ok-back,.ok-text-button) > svg { width: 20px; height: 20px; flex: none; stroke-width: 1.5; }
.onto-field-error { display: block; margin: 8px 0 0; color: #9a3327; font-size: 14px; line-height: 1.5; }
.onto-form-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
:is(input,select,textarea)[aria-invalid=true] { border-color: #a8372c !important; box-shadow: 0 0 0 1px #a8372c; }
.onto-preference { display: flex; justify-content: space-between; align-items: center; gap: 24px; min-height: 56px; padding: 12px 0; }
.onto-preference strong,.onto-preference small { display: block; line-height: 1.5; }
.onto-preference small { color: var(--ux-muted); font-size: 13px; margin-top: 4px; }
.onto-preference input { width: 24px; height: 24px; accent-color: #217f79; flex: none; }

#onto-feedback {
  position: fixed; z-index: 110; bottom: calc(104px + env(safe-area-inset-bottom) + var(--onto-keyboard-inset));
  left: 50%; translate: -50% 0; width: max-content; max-width: min(540px,calc(100% - 32px));
  display: flex; align-items: center; gap: 20px; padding: 12px 16px 12px 20px;
  border: 1px solid #31575c; border-radius: 16px; background: #062f35; color: #fff;
  box-shadow: 0 8px 28px #062f3529; font-size: 14px; line-height: 1.5;
}
#onto-feedback[hidden] { display: none; }
#onto-feedback[data-kind=error] { border-color: #efb9a8; }
.onto-undo { min-width: 60px; min-height: 44px; border: 0; border-radius: 10px; background: #a4e9df; color: #062f35; font: inherit; font-weight: 600; padding: 10px 14px; flex: none; }
.onto-undo:disabled { opacity: .65; }
.onto-undo:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.onto-sheet { color: var(--ux-ink); width: min(560px,calc(100% - 40px)); padding: 0; margin: auto; border: 1px solid var(--ux-line); border-radius: 24px; background: var(--ux-paper); max-height: min(85dvh,var(--onto-viewport-height)); overflow: auto; overscroll-behavior: contain; box-shadow: 0 24px 80px #062f3533; }
.onto-sheet::backdrop { background: #062f3566; backdrop-filter: blur(3px); }
.onto-sheet-open { overflow: hidden; }
.onto-sheet form { padding: 28px; margin: 0; }
.onto-sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.onto-sheet-head h2 { font-size: 25px; font-weight: 500; line-height: 1.2; letter-spacing: -.03em; margin: 0; }
.onto-sheet-head p { color: var(--ux-muted); margin: 8px 0 0; font-size: 14px; line-height: 1.5; }
.onto-sheet-close { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 1px solid var(--ux-line); border-radius: 50%; background: #fff; color: var(--ux-ink); font: inherit; font-size: 26px; }
.onto-sheet :is(input,select,textarea) { width: 100%; border: 1px solid #bdceca; padding: 12px; background: #fff; color: var(--ux-ink); }
.onto-sheet .setup-field { display: block; margin-bottom: 16px; }
.onto-sheet .setup-field > span { display: block; margin-bottom: 8px; font-size: 14px; }
.onto-sheet .ok-note { font-size: 14px; color: var(--ux-muted); line-height: 1.6; }
.onto-sheet-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--ux-line); }
.onto-sheet .btn { min-height: 48px; border-radius: 12px; }
.onto-sheet-error { padding: 14px; border-left: 3px solid #a8372c; color: #8e3025; background: #fff0e9; font-size: 14px; line-height: 1.5; }
.onto-sheet-discard { margin-top: 20px; border-top: 1px solid var(--ux-line); padding-top: 12px; }
.onto-sheet-discard p { font-size: 15px; line-height: 1.5; }
.onto-sheet-discard .btn { margin: 0 8px 8px 0; }
.onto-sheet-handle { display: none; }
.onto-sheet :focus-visible { outline: 3px solid #217f79; outline-offset: 3px; }
.onto-sheet h2:focus { outline: none; }
@media (max-width: 640px) {
  .onto-sheet { position: fixed; inset: auto 0 var(--onto-keyboard-inset); margin: 0; width: 100%; max-width: 100%; max-height: min(90dvh,calc(var(--onto-viewport-height) - 12px)); border-radius: 24px 24px 0 0; border-bottom: 0; }
  .onto-sheet form { padding: 0 22px calc(22px + env(safe-area-inset-bottom)); }
  .onto-sheet-handle { display: block; height: 26px; margin: 0 -10px 10px; position: relative; touch-action: none; }
  .onto-sheet-handle::after { content: ''; position: absolute; width: 36px; height: 4px; border-radius: 4px; background: #b2c4c1; top: 12px; left: calc(50% - 18px); }
  .onto-sheet-actions .btn { flex: 1; }
  .modal-backdrop { align-items: flex-end; padding: 0; z-index: 105; }
  .modal-backdrop .modal { width: 100%; max-height: min(90dvh,var(--onto-viewport-height)); border-radius: 24px 24px 0 0; padding: 26px 22px calc(26px + env(safe-area-inset-bottom)); }
  .modal .close { min-width: 44px; min-height: 44px; }
  .onto-keyboard-open :is(.ok-bottom,.ux-global-nav) { visibility: hidden; pointer-events: none; }
  .onto-keyboard-open .ok-content { padding-bottom: 40px; }
  #onto-feedback { bottom: calc(94px + env(safe-area-inset-bottom) + var(--onto-keyboard-inset)); gap: 12px; }
}
@media (prefers-reduced-motion: no-preference) {
  .onto-sheet[open] { animation: onto-sheet-arrive 180ms cubic-bezier(.2,.7,.2,1); }
  .modal-backdrop .modal { animation: onto-sheet-arrive 180ms cubic-bezier(.2,.7,.2,1); }
  details.ok-disclosure[open] > :not(summary) { animation: onto-reveal 140ms ease-out; }
  @keyframes onto-sheet-arrive { from { opacity: .5; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
  @keyframes onto-reveal { from { opacity: .5; } to { opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) {
  .onto-sheet,.modal,.onto-undo,details.ok-disclosure > * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .onto-sheet,#onto-feedback { border: 1px solid CanvasText; background: Canvas; color: CanvasText; }
  .onto-undo { border: 1px solid ButtonText; background: ButtonFace; color: ButtonText; }
}
