/* Shared native sheets; width stays in layout coordinates during pinch. */
:root {
  --sheet-edge-top: max(8px, env(safe-area-inset-top, 0px));
  --sheet-edge-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  --sheet-edge-left: max(8px, env(safe-area-inset-left, 0px));
  --sheet-edge-right: max(8px, env(safe-area-inset-right, 0px));
}
html.has-software-keyboard { --sheet-edge-bottom: 8px; }
dialog.sheet[open]:not(.is-inline) {
  display: flex; flex-direction: column; min-width: 0;
  overflow: hidden; overflow: clip;
}
dialog.sheet[open]:not(.is-inline) > form {
  display: flex; flex: 1 1 auto; flex-direction: column;
  width: 100%; min-width: 0; min-height: 0; max-height: inherit;
  overflow: hidden; overflow: clip;
}
dialog.sheet[open]:not(.is-inline) .sheet-body {
  flex: 1 1 auto; min-width: 0; min-height: 0;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  scroll-padding-block: 12px;
}
.sheet .form-fields { min-width: 0; grid-template-columns: minmax(0, 1fr); }
.sheet .form-fields label, .sheet .field-pair, .sheet .note-page,
.sheet .sheet-header > div { min-width: 0; }
.sheet .field-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sheet .form-fields input, .sheet .form-fields select, .sheet .note-page input {
  min-width: 0; max-width: 100%; height: auto; min-height: 48px;
}
.sheet input[type="date"] { display: block; }
.note-editor textarea {
  min-width: 0; max-width: 100%; overflow-y: auto;
  min-height: min(240px, max(96px, calc(var(--form-viewport-height, 600px) - 180px)));
  height: min(360px, max(96px, calc(var(--form-viewport-height, 600px) - 260px)));
  max-height: max(96px, calc(var(--form-viewport-height, 600px) - 160px));
}
dialog.sheet[open]:not(.is-inline) .sheet-header,
dialog.sheet[open]:not(.is-inline) .sheet-footer,
dialog.sheet[open]:not(.is-inline) .cover-tabs,
dialog.sheet[open]:not(.is-inline) .social-status,
dialog.sheet[open]:not(.is-inline) .social-preview-hint { flex: 0 0 auto; min-width: 0; }
dialog.sheet[open]:not(.is-inline) .sheet-footer { position: static; flex-wrap: wrap; }
.sheet .form-header {
  display: flex; flex-direction: column; align-items: stretch; gap: 12px;
  border-bottom: 1px solid var(--line); padding-bottom: 14px;
}
.form-header h2 { overflow-wrap: anywhere; }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.form-actions button { min-height: 48px; min-width: 72px; padding: 10px 16px; overflow-wrap: anywhere; }
.form-actions .primary-button { min-width: 100px; }
.sheet .form-header + .sheet-body { padding-top: 18px; }
.sheet .rating-buttons { flex-wrap: wrap; gap: 6px; }
.sheet .rating-buttons button { flex: 0 0 48px; width: 48px; min-width: 48px; height: 48px; padding: 10px; opacity: 0.72; }
.sheet .rating-buttons button.is-on { opacity: 1; }
.sheet .rating-buttons .rating-none {
  flex: 0 0 100%; width: 100%; height: auto; min-height: 48px;
  padding: 6px 0; text-align: left; font-size: 14px; color: var(--muted); opacity: 1;
}
.rating-none[aria-checked="true"] { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
html.has-modal-sheet { overflow: hidden; }
.has-form-viewport dialog.sheet[open]:not(.is-inline) {
  position: fixed; inset: auto; top: var(--form-viewport-y); left: var(--form-viewport-x);
  translate: -50% -50%; margin: 0;
  max-width: calc(var(--form-viewport-width) - 24px);
  max-height: calc(var(--form-viewport-height) - 48px);
}
.has-inline-keyboard .reader-view {
  top: var(--form-viewport-top); bottom: auto;
  height: var(--form-viewport-height); padding-bottom: 12px;
}
.form-viewport-compact dialog.sheet[open]:not(.is-inline) { max-height: calc(var(--form-viewport-height) - 8px); }
.form-viewport-compact dialog.sheet[open]:not(.is-inline) .sheet-header { padding: 6px 14px; }
.form-viewport-compact dialog.sheet[open]:not(.is-inline) .sheet-header h2 { font-size: 22px; line-height: 1.15; }
.form-viewport-compact .sheet .form-header { gap: 4px; }
.form-viewport-compact dialog.sheet[open]:not(.is-inline) .sheet-header > .icon-button { margin: 0; }
.form-viewport-compact dialog.sheet[open]:not(.is-inline) .sheet-body { padding-inline: 14px; padding-bottom: 8px; }
.form-viewport-compact dialog.sheet[open]:not(.is-inline) .sheet-footer { padding: 4px 14px; gap: 8px; }
.form-viewport-compact dialog.sheet[open]:not(.is-inline) .sheet-footer button { min-height: 48px; padding-block: 8px; }
.form-viewport-compact dialog.sheet[open]:not(.is-inline) .cover-tabs { margin: 0 14px 8px; }
.form-viewport-compact dialog.sheet[open]:not(.is-inline) .cover-tabs button { min-height: 48px; }
@media (max-width: 767px) {
  .has-form-viewport dialog.sheet[open]:not(.is-inline) {
    top: calc(var(--form-viewport-top) + var(--sheet-edge-top));
    left: calc(var(--form-viewport-left) + var(--sheet-edge-left));
    translate: none;
    width: calc(var(--form-viewport-width) - var(--sheet-edge-left) - var(--sheet-edge-right));
    max-width: none;
    height: calc(var(--form-viewport-height) - var(--sheet-edge-top) - var(--sheet-edge-bottom));
    max-height: calc(var(--form-viewport-height) - var(--sheet-edge-top) - var(--sheet-edge-bottom));
  }
  .sheet .sheet-header { padding: 16px; }
  .sheet .form-header { padding: 16px; }
  .sheet .form-header h2 { font-size: 26px; line-height: 1.2; }
  .sheet .sheet-body { padding-inline: 16px; }
  .sheet .form-fields label, .sheet .rating-field legend, .sheet .note-page { font-size: 14px; }
  .sheet .field-pair { grid-template-columns: minmax(0, 1fr); gap: 19px; }
  .sheet .sheet-footer { padding: 12px 16px; }
  .sheet .cover-tabs { margin-inline: 16px; gap: 12px; }
}
@media (max-width: 767px), (pointer: coarse) {
  .icon-button { min-width: 48px; min-height: 48px; }
  .primary-button, .secondary-button, .plain-button { min-height: 48px; }
}
/* Very short landscape or enlarged view: scroll the complete panel. */
.form-viewport-tiny dialog.sheet[open]:not(.is-inline) { display: block; overflow: auto; scroll-padding-block: 8px; }
.form-viewport-tiny dialog.sheet[open]:not(.is-inline) > form { display: block; max-height: none; overflow: visible; }
.form-viewport-tiny dialog.sheet[open]:not(.is-inline) .sheet-body { overflow: visible; }
.app-version { color: var(--muted); font-size: 12px; margin-top: 24px; }
.offline-state { min-height: 100svh; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; text-align: center; }
.offline-state h1 { font-size: clamp(30px, 7vw, 48px); }
.offline-state p { max-width: 34ch; color: var(--muted); }
