.chat-content { display: contents; }
.chat-panel.collapsed .chat-content { display: none; }
.sheet-handle, .chat-sheet-backdrop { display: none; }

@media (max-width: 900px) {
  :root { --sheet-peek: calc(72px + env(safe-area-inset-bottom, 0px)); }
  html { height: 100%; overflow: hidden; }
  body { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; overscroll-behavior: none; }
  .app-header { flex: none; height: calc(88px + env(safe-area-inset-top, 0px)); padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-inline: max(12px, env(safe-area-inset-left, 0px)) max(12px, env(safe-area-inset-right, 0px)); }
  .app-layout, .app-layout.chat-floating { display: flex; flex: 1; height: auto; min-height: 0; }
  .workspace, .chat-floating .workspace { flex: 1; order: 0; min-height: 0; height: 100%; padding: 6px 8px 0; overflow: hidden; }
  .workspace-toolbar { min-height: 44px; height: 44px; flex-wrap: nowrap; gap: 3px; }
  .workspace-tab { height: 44px; padding-inline: 9px; font-size: 12px; gap: 5px; }
  .workspace-tab .tab-dot { display: none; }
  .workspace-toolbar .text-button { min-height: 44px; font-size: 12px; padding: 6px 8px; white-space: nowrap; }
  .workspace-toolbar #stage-history { display: inline-flex; }
  .workspace-toolbar #focus-workspace { display: none; }
  .stage-host { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scroll-padding-bottom: 16px; }
  .stage-root { min-height: 100%; }
  .workspace[data-stage=cafe] .stage-root { height: auto; min-height: 100%; }
  .workspace[data-stage=cafe] .stage-root > .browser-window { min-height: 0; flex: none; }
  .workspace .website { flex: none; overflow: visible; }
  .workspace .cafe-nav { padding: 14px 22px; }
  .workspace .cafe-hero { flex: none; min-height: 0; padding: 18px 22px; }
  .workspace .cafe-title { font-size: 30px; line-height: 1.4; }
  .workspace .heading-edit[data-size=small] .cafe-title { font-size: 26px; }
  .workspace .heading-edit[data-size=large] .cafe-title { font-size: 34px; }
  .workspace .hero-kicker { margin-bottom: 16px; font-size: 11px; }
  .workspace .cafe-description { margin: 14px 0 28px; font-size: 12px; line-height: 1.8; }
  .workspace .cafe-actions { gap: 8px; }
  .workspace .cafe-button { font-size: 12px; padding-inline: 12px; gap: 10px; }
  .workspace .cafe-button[data-size=small] { font-size: 11px; padding-inline: 10px; gap: 8px; }
  .workspace .cafe-button[data-size=large] { font-size: 14px; padding-inline: 16px; gap: 10px; }
  .workspace .reservation-note { margin-top: 10px; font-size: 10px; }
  .workspace .cafe-bottom { min-height: 34px; }
  .workspace .coffee-scene { top: 65px; }
  .inspector { margin-top: 8px; padding: 10px 12px; gap: 8px 12px; }
  .inspector-selection select { min-height: 44px; font-size: 14px; }
  .segmented button { min-height: 44px; }
  .stage-root .stage-tools button, .gear-choice { min-height: 44px; }
  .stage-root .tool-label select { min-height: 40px; }
  .workspace-footer { flex: none; min-height: 25px; font-size: 10px; }
  .app-footer { flex: none; height: 44px; margin-bottom: var(--sheet-peek); gap: 8px; padding-inline: 12px; }
  .level-picker select { font-size: 12px; max-width: min(42vw, 250px); min-height: 36px; }
  .app-footer #restart { min-height: 40px; font-size: 11px; }
  .level-dots { display: none; }
  .help-button, .sound-toggle { min-height: 36px; }

  .chat-panel, .chat-floating .chat-panel {
    position: fixed; inset: auto 0 0; z-index: 50; display: flex; flex-direction: column;
    width: 100%; max-width: none; min-width: 0; height: min(760px, calc(100dvh - 64px - env(safe-area-inset-top, 0px)));
    min-height: 0; max-height: none; overflow: hidden; resize: none;
    border: 1px solid #ddcdbf; border-bottom: 0; border-radius: 22px 22px 0 0;
    background: #fffdfa; box-shadow: 0 -5px 24px #61493718;
    transform: translate3d(0, var(--sheet-y, calc(100% - var(--sheet-peek))), 0);
    transition: transform .28s cubic-bezier(.22,.85,.25,1);
  }
  .chat-panel.sheet-open { transform: translate3d(0, var(--sheet-y, 0px), 0); box-shadow: 0 -8px 34px #61493723; }
  .chat-panel.sheet-dragging { transition: none; user-select: none; }
  .chat-content { display: flex; flex: 1; min-height: 0; flex-direction: column; }
  .sheet-handle { display: flex; flex-direction: column; flex: none; width: 100%; height: var(--sheet-peek); padding: 10px 20px calc(10px + env(safe-area-inset-bottom, 0px)); gap: 10px; border: 0; border-radius: 22px 22px 0 0; background: #fffdfa; color: #745941; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
  .sheet-handle:active { cursor: grabbing; }
  .sheet-handle:focus-visible { outline: 3px solid #b77b60; outline-offset: -5px; }
  .sheet-grip { display: block; width: 38px; height: 4px; flex: none; border-radius: 4px; background: #cbbcaf; align-self: center; }
  .sheet-handle-row { display: flex; align-items: center; width: 100%; gap: 9px; min-height: 28px; }
  .sheet-chat-icon { width: 23px; height: 23px; fill: none; stroke: #9a7259; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .sheet-handle strong { font-size: 15px; font-weight: 700; }
  #sheet-client { font-size: 12px; color: #927b69; }
  .sheet-unread { width: 7px; height: 7px; border-radius: 50%; background: #ca7757; flex: none; }
  .sheet-unread[hidden] { display: none; }
  .sheet-anger { margin-left: auto; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--anger); white-space: nowrap; }
  .sheet-chevron { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .28s; }
  .sheet-open .sheet-chevron { transform: rotate(180deg); }
  .chat-panel > .client-header, .chat-content .chat-move-hint { display: none; }
  .chat-content .anger-box { margin: 0 16px; padding: 10px 12px; }
  .chat-content .anger-heading { font-size: 12px; }
  .chat-content .anger-heading strong { font-size: 20px; }
  .chat-content .anger-caption { font-size: 11px; }
  .chat-content .chat-scroll { flex: 1; min-height: 0; max-height: none; padding: 18px 18px 6px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .chat-content .message-body { font-size: 15px; line-height: 1.9; }
  .chat-content .message-meta { font-size: 12px; }
  .chat-content .reference-link { min-height: 44px; font-size: 13px; }
  .chat-content .composer-area { padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .chat-content .composer-label { font-size: 10px; }
  .chat-content .composer { display: flex; align-items: center; gap: 10px; padding: 8px; }
  .chat-content .composer p { margin: 0; font-size: 12px; flex: 1; line-height: 1.7; }
  .chat-content .composer button { min-height: 48px; width: auto; font-size: 13px; padding: 10px 12px; gap: 5px; }
  .chat-sheet-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 45; border: 0; padding: 0; background: #48372b; opacity: var(--sheet-shade, .18); touch-action: none; }
  .chat-sheet-backdrop[hidden] { display: none; }
  input, textarea, .advanced-editor textarea, .advanced-editor select { font-size: 16px; }
  .result-dialog.success .result-actions { gap: 14px; }
  .result-actions button { min-width: 124px; }
}

@media (max-width: 600px) and (max-height: 780px) {
  .workspace .browser-chrome { height: 32px; }
  .workspace .cafe-nav { padding-block: 12px; }
  .workspace .brand-seal { width: 32px; height: 36px; font-size: 22px; }
  .workspace .cafe-brand { font-size: 17px; }
  .workspace .cafe-hero { padding-block: 14px; }
  .workspace .hero-kicker { margin-bottom: 12px; }
  .workspace .reservation-note { margin-top: 8px; }
  .workspace .cafe-bottom { min-height: 30px; }
}

@media (max-width: 900px) and (max-height: 500px) {
  .app-header { height: calc(54px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px); align-items: center; }
  .app-header .identity { margin: 0; }
  .header-request { position: static; margin-right: auto; width: auto; }
  .header-request h2 { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .request-number { display: none; }
  .chat-panel { height: calc(100dvh - 8px); }
  .chat-content .anger-caption, .chat-content .anger-track, .chat-content .composer-label { display: none; }
  .chat-content .anger-box { padding: 6px 12px; }
  .chat-content .composer-area { padding-top: 6px; padding-bottom: 6px; }
}
