.compact-control,
.compact-tool-name,
.compact-drawing-title,
#boardDrawer:not([open]) {
  display: none;
}

@media screen and (max-width: 1024px), screen and (max-width: 1440px) and (any-pointer: coarse) {
  .app { height: 100vh; height: 100dvh; min-height: 0; }
  .workspace { flex-direction: column; }
  .canvas-column { order: 0; min-height: 0; }
  .topbar {
    height: calc(54px + env(safe-area-inset-top));
    flex: none;
    gap: 6px;
    padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  }
  .brand { gap: 6px; font-size: 20px; flex: none; }
  .brand small, .document-heading, #helpBtn { display: none; }
  .brandmark { width: 30px; height: 30px; border-radius: 8px; }
  .brandmark svg { width: 22px; }
  .header-actions { margin-left: auto; gap: 2px; }
  .header-actions .btn { min-height: 44px; white-space: nowrap; }
  .header-actions .signup-trigger, .header-actions #exportBtn { font-size: 13px; padding: 0 10px; }
  .header-actions #exportBtn span { display: inline; }
  .header-actions :is(#drawingsBtn, #accountBtn) { justify-content: center; min-width: 44px; padding: 0 8px; }
  .drawings-menu { top: 100%; right: max(8px, env(safe-area-inset-right)); width: min(310px, calc(100vw - 16px)); max-height: calc(100dvh - 68px); overflow-y: auto; }

  .tool-panel {
    position: static;
    order: 1;
    width: 100%;
    padding: 4px max(6px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    overflow: visible;
    border: 0;
    border-top: 1px solid #d5e2dc;
    background: white;
  }
  .tool-panel > .panel-eyebrow, .tool-panel-bottom, .tool-panel > .tool-options,
  .tools .tool-divider, .tools kbd, .tools :is([data-tool="text"], [data-tool="pan"], [data-tool="freehand"]),
  .workspace > .details-panel { display: none; }
  .tools { display: grid; width: 100%; max-width: 720px; margin: 0 auto; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .tools .tool {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 52px;
    padding: 4px 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 9px;
    font-size: 12px;
    line-height: 1.15;
  }
  .tools .tool .icon { width: 21px; height: 21px; }
  .tools .tool span { display: inline; }
  .tools .tool .wide-tool-name { display: none; }
  .tools .tool:is([data-tool="text"], [data-tool="pan"], [data-tool="freehand"]) { display: none; }

  .canvas-toolbar { flex: none; height: 48px; padding: 0 max(7px, env(safe-area-inset-right)) 0 max(7px, env(safe-area-inset-left)); gap: 2px; }
  .history-actions { gap: 0; }
  .canvas-toolbar .history-actions .icon-btn,
  .zoom-controls .icon-btn { width: 44px; height: 44px; }
  .canvas-toolbar .toggle-btn, .canvas-toolbar #detailsBtn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; min-width: 44px; padding: 0 8px; font-size: 13px; gap: 5px;
  }
  .canvas-toolbar .toggle-btn .icon, .canvas-toolbar #detailsBtn .icon { display: inline; width: 15px; height: 15px; }
  .canvas-toolbar .toolbar-divider { margin: 0 4px; }
  .canvas-toolbar .desktop-label, .canvas-toolbar #deleteBtn { display: none; }
  .canvas-topline { min-height: 44px; height: auto; padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); gap: 8px; }
  .sheet-caption { display: flex; min-width: 0; align-items: baseline; gap: 9px; }
  .compact-drawing-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; text-transform: none; letter-spacing: 0; color: var(--ink); }
  #sheetCaption { flex: none; font-size: 9px; }
  .sheet-count { display: none; }
  .canvas-topline .try-example-btn { flex: none; min-height: 44px; padding: 0 4px; font-size: 12px; border: 0; background: transparent; }
  .stage {
    display: flex; flex-direction: column; padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
    overscroll-behavior: contain; touch-action: none;
  }
  .stage.manual-view { padding: var(--pan-y) var(--pan-x); }
  .paper-wrap { flex: none; margin: auto; }
  .example-guide { margin: 0 10px 5px; padding: 0 8px; gap: 6px; flex-wrap: nowrap; }
  .example-guide > div { min-width: 0; flex: 1; }
  .example-guide strong { font-size: 12px; }
  .example-guide p { display: none; }
  .example-guide .text-btn, .example-guide .icon-btn { min-width: 44px; min-height: 44px; }

  .canvas-bottom {
    flex-flow: row nowrap; align-items: center; min-height: 48px; gap: 5px;
    padding: 2px max(7px, env(safe-area-inset-right)) 2px max(7px, env(safe-area-inset-left));
  }
  .tool-hint { display: flex; flex: 1; align-items: center; min-width: 0; gap: 6px; font-size: 12px; line-height: 1.3; color: #425952; }
  .tool-hint .hint-dot { display: none; }
  .tool-hint #toolSettingsBtn, .tool-hint .finish-btn { display: inline-flex; flex: none; align-items: center; justify-content: center; min-height: 44px; padding: 0 9px; font-size: 13px; font-weight: 600; }
  .tool-hint [hidden], #boardDrawer [hidden] { display: none !important; }
  .zoom-controls { align-self: center; gap: 0; padding: 0; }
  .zoom-controls .zoom-value { height: 44px; min-width: 46px; font-size: 12px; }
  .zoom-controls .zoom-value::before { content: 'Fit '; color: var(--accent); }
  .zoom-controls :is(.toolbar-divider, #fitBtn) { display: none; }

  #boardDrawer[open] {
    display: flex; flex-direction: column;
    position: fixed; inset: auto 0 0; margin: 0 auto;
    width: min(100%, 600px); max-width: 100%; padding: 0;
    max-height: min(82dvh, 760px); overflow: hidden;
    color: var(--ink); border: 1px solid #d8e3dd; border-bottom: 0; border-radius: 18px 18px 0 0;
    background: white; box-shadow: 0 -12px 48px #183c3728;
  }
  .board-gesture-tip { display: none; }
  #boardDrawer[data-panel="more"] .board-gesture-tip { display: block; margin: 0; padding: 12px 16px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: #49645a; font-size: 13px; }
  #boardDrawer::backdrop { background: #18332e58; }
  .board-drawer-header { display: flex; flex: none; justify-content: space-between; align-items: center; gap: 12px; min-height: 60px; padding: 6px 16px; border-bottom: 1px solid var(--line); }
  .board-drawer-header h2 { margin: 0; font-size: 20px; letter-spacing: -.45px; }
  #closeBoardDrawer { min-width: 58px; min-height: 44px; color: var(--accent); font-weight: 650; }
  #boardDrawerBody { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  #boardDrawer .tool-options, #boardDrawer .details-panel {
    position: static; display: block; width: auto; max-height: none; margin: 0; padding: 0; overflow: visible; border: 0; box-shadow: none; background: white;
  }
  #boardDrawer .details-scroll { padding: 0; overflow: visible; }
  #boardDrawer .panel-title, #boardDrawer .tool-options > .panel-eyebrow:first-child, #boardDrawer .option-dismiss { display: none; }
  #boardDrawer .tool, #boardDrawer .text-btn, #boardDrawer .btn, #boardDrawer .size-reset, #boardDrawer .icon-btn { min-height: 44px; }
  #boardDrawer .icon-btn { min-width: 44px; }
  #boardDrawer[data-panel="more"] #boardDrawerBody { display: grid; gap: 4px; }
  #boardDrawer[data-panel="more"] #boardDrawerBody > button { justify-content: flex-start; width: 100%; padding: 10px 12px; font-size: 15px; text-align: left; }
  #boardDrawer .tool > span { display: inline; }
  #boardDrawer kbd { display: none; }
  #boardDrawer .size-heading label, #boardDrawer label, #boardDrawer .weld-type-heading { font-size: 13px; }
  #boardDrawer :is(select,textarea,input:not([type="range"])), #modal :is(select,textarea,input:not([type="checkbox"]):not([type="radio"])) { font-size: 16px; min-height: 44px; }
  #boardDrawer input[type="range"] { min-height: 36px; }
  #boardDrawer .weld-type-choices button { font-size: 14px; }
  #boardDrawer .symbol-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 7px; }
  #boardDrawer .symbol-choice { min-height: 65px; font-size: 12px; }
  #boardDrawer .detail-section { margin: 0 0 12px; }
  #modal { max-width: calc(100% - 16px); max-height: calc(100dvh - 16px); }
  #modal .modal-footer { flex-wrap: wrap; }
  #modal .modal-head .icon-btn, #modal .modal-footer .btn { min-height: 44px; min-width: 44px; }
}

@media screen and (max-width: 520px) {
  .brand { font-size: 18px; }
  .brand .brandmark { display: none; }
  .header-actions :is(#accountBtn, #drawingsBtn) span { display: none; }
  .header-actions #exportBtn .icon { display: none; }
  .header-actions #exportBtn { padding: 0 8px; }
  #sheetCaption { display: none; }
  .tool-hint:has(#finishBtn:not([hidden])) #toolHint { display: none; }
}
@media screen and (max-width: 440px) {
  .header-actions #exportBtn span { display: none; }
  .header-actions #exportBtn::after { content: 'PDF'; }
  .header-actions #exportBtn .icon { display: inline; width: 14px; height: 14px; }
  .header-actions #exportBtn { gap: 4px; }
  .header-actions .signup-trigger { padding: 0 6px; }
}
@media screen and (max-width: 374px) {
  .tool-hint:has(#toolSettingsBtn:not([hidden])) #toolHint { display: none; }
  .brand .brandmark { display: grid; }
  .brand > span:not(.brandmark) { display: none; }
}
@media screen and (max-width: 350px) {
  .brand { font-size: 16px; }
  .topbar { padding-left: 5px; padding-right: 5px; gap: 2px; }
  .header-actions { gap: 0; }
  .header-actions .signup-trigger, .header-actions #exportBtn { font-size: 12px; }
  .canvas-toolbar .toolbar-divider { display: none; }
  .canvas-toolbar .toggle-btn, .canvas-toolbar #detailsBtn { padding: 0 5px; gap: 3px; }
}
@media screen and (max-width: 1024px) and (max-height: 520px) {
  .topbar { height: calc(45px + env(safe-area-inset-top)); }
  .canvas-topline { display: none; }
  .canvas-toolbar { height: 44px; }
  .tools .tool { flex-direction: row; gap: 6px; min-height: 44px; }
  .tool-panel { padding-top: 2px; padding-bottom: max(2px, env(safe-area-inset-bottom)); }
  #boardDrawer[open] { max-height: 94dvh; }
}
