.mobile-preview-resizer,
.mobile-editor-tabs {
  display: none;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 300px minmax(380px, 1fr) 250px;
  }

  .toolbar-actions .button-ghost:nth-of-type(2),
  .toolbar-actions .button-ghost:nth-of-type(3),
  .toolbar-actions .button-ghost:nth-of-type(4) {
    display: none;
  }
}

@media (max-width: 920px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100vh;
  }

  .topbar {
    position: sticky;
    top: 0;
    min-height: 62px;
  }

  .brand {
    min-width: auto;
  }

  .brand > span:last-child,
  .project-name-field,
  .toolbar-actions > :not(#preview-mode):not(#export-all) {
    display: none;
  }

  .workspace {
    display: grid;
    grid-template-columns: 300px minmax(500px, 1fr);
    min-height: calc(100vh - 62px);
  }

  .right-panel {
    grid-column: 1;
    grid-row: 1;
    margin-top: 58vh;
    border-top: 1px solid var(--chrome-border);
    border-left: 0;
  }

  .preview-workspace {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

@media (max-width: 767px) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  .app-shell {
    display: grid;
    grid-template-rows: 52px minmax(0, 1fr);
    width: 100%;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .topbar {
    position: relative;
    top: auto;
    z-index: 50;
    min-height: 52px;
    padding: 0 10px;
    gap: 8px;
  }

  .brand {
    min-width: 36px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }

  .brand > span:last-child,
  .project-name-field,
  .toolbar-divider,
  .scale-control,
  #new-project,
  #save-project,
  #export-json,
  #import-json,
  #preview-mode {
    display: none !important;
  }

  .toolbar-actions {
    gap: 3px;
  }

  .toolbar-actions > * {
    display: none;
  }

  .toolbar-actions #undo,
  .toolbar-actions #redo,
  .toolbar-actions #export-all {
    display: inline-flex;
  }

  .toolbar-actions .icon-button {
    width: 38px;
    height: 38px;
  }

  #export-all {
    min-height: 38px;
    padding: 0 11px;
    font-size: 11px;
  }

  .workspace {
    --mobile-preview-height: 40dvh;
    display: grid;
    grid-template-areas:
      "preview"
      "resizer"
      "mobile-tabs"
      "editor";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--mobile-preview-height) 18px 48px minmax(0, 1fr);
    width: 100%;
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  .app-shell.mobile-keyboard-open .workspace {
    --mobile-preview-height: max(140px, 22dvh) !important;
  }

  .preview-workspace {
    grid-area: preview;
    display: grid;
    grid-template-rows: 38px minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-bottom: 0;
  }

  .preview-bar {
    min-width: 0;
    min-height: 38px;
    padding: 0 11px;
    overflow: hidden;
  }

  .preview-bar > :first-child {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
  }

  .preview-bar > :first-child > span:not(.preview-dot) {
    display: none;
  }

  .preview-bar strong {
    display: none;
  }

  .section-export-actions {
    display: flex !important;
    gap: 3px !important;
    margin-left: auto;
  }

  .section-export-actions .mini-button {
    min-height: 28px;
    padding: 0 5px;
    font-size: 9px;
  }

  .canvas-viewport {
    min-width: 0;
    min-height: 0;
    padding: 10px 12px 18px;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  .canvas-stage {
    width: max-content;
    min-width: 0;
    margin: 0 auto;
    transform-origin: top center;
    transition: none;
  }

  .mobile-preview-resizer {
    grid-area: resizer;
    display: grid;
    place-items: center;
    width: 100%;
    height: 18px;
    padding: 0;
    touch-action: none;
    cursor: row-resize;
    background: #f5f6f4;
    border-top: 1px solid #d8dcda;
    border-bottom: 1px solid #d8dcda;
    outline: none;
  }

  .mobile-preview-resizer span {
    width: 42px;
    height: 4px;
    background: #aeb6b2;
    border-radius: 999px;
  }

  .mobile-preview-resizer:focus-visible span,
  .app-shell.is-mobile-resizing .mobile-preview-resizer span {
    background: var(--chrome-primary);
    box-shadow: 0 0 0 3px rgb(36 75 66 / 13%);
  }

  .app-shell.is-mobile-resizing {
    user-select: none;
  }

  .mobile-editor-tabs {
    grid-area: mobile-tabs;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 5px 8px;
    background: #f8f8f6;
    border-bottom: 1px solid var(--chrome-border);
  }

  .mobile-editor-tabs button {
    min-height: 37px;
    color: #6f787b;
    background: transparent;
    border: 0;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 750;
  }

  .mobile-editor-tabs button.is-active {
    color: var(--chrome-primary);
    background: #e7eeeb;
    box-shadow: inset 0 0 0 1px rgb(36 75 66 / 9%);
  }

  .left-panel,
  .right-panel {
    grid-area: editor;
    grid-column: auto;
    grid-row: auto;
    min-width: 0;
    min-height: 0;
    max-height: none;
    margin: 0;
    border: 0;
  }

  .app-shell[data-mobile-panel="content"] .left-panel,
  .app-shell[data-mobile-panel="style"] .right-panel {
    display: flex;
  }

  .app-shell[data-mobile-panel="content"] .right-panel,
  .app-shell[data-mobile-panel="style"] .left-panel {
    display: none;
  }

  .panel-heading {
    min-height: 50px;
    padding: 9px 14px 7px;
  }

  .panel-heading h1,
  .panel-heading h2 {
    font-size: 16px;
  }

  .panel-scroll {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .main-tabs {
    padding: 0 10px 8px;
  }

  .tab-button {
    min-height: 42px;
    padding: 8px 5px;
  }

  .tab-button.is-active::after {
    bottom: -9px;
  }

  .editor-section,
  .style-editor {
    padding: 12px 10px calc(44px + env(safe-area-inset-bottom));
  }

  .editor-block {
    padding: 13px;
  }

  .field input:not([type="checkbox"]):not([type="color"]),
  .field select,
  .field textarea,
  .tag-input-row input {
    min-height: 44px;
    padding: 10px;
    font-size: 14px;
  }

  .field textarea {
    min-height: 96px;
  }

  .segmented-control button {
    min-height: 40px;
  }

  .node-editor-header {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    min-height: 52px;
  }

  .drag-handle {
    min-width: 36px;
    min-height: 44px;
  }

  .node-header-actions button {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }

  .node-toolbar .button,
  .inline-actions .button {
    min-height: 40px;
  }

  .dialog-backdrop:has(.crop-dialog) {
    align-items: stretch;
    padding: 0;
  }

  .crop-dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    padding: 14px;
    border: 0;
    border-radius: 0;
  }

  .crop-stage {
    --crop-max-height: calc(100dvh - 235px);
  }

  .crop-dialog .dialog-actions {
    padding-bottom: env(safe-area-inset-bottom);
    margin-top: auto;
  }
}

@container timeline-canvas (max-width: 620px) {
  .header-template-split {
    grid-template-columns: 1fr;
  }

  .header-media {
    max-width: 220px;
  }

  .template-alternating::before {
    left: 13px;
  }

  .template-alternating .timeline-entry,
  .template-alternating .timeline-entry:nth-child(even) {
    grid-template-columns: 27px minmax(0, 1fr);
  }

  .template-alternating .timeline-date,
  .template-alternating .timeline-entry:nth-child(even) .timeline-date {
    grid-column: 2;
    grid-row: 1;
    padding: 0 0 8px;
    text-align: left;
  }

  .template-alternating .timeline-marker,
  .template-alternating .timeline-entry:nth-child(even) .timeline-marker {
    grid-column: 1;
    grid-row: 1 / span 2;
    margin-top: 4px;
  }

  .template-alternating .timeline-card,
  .template-alternating .timeline-entry:nth-child(even) .timeline-card {
    grid-column: 2;
    grid-row: 2;
  }
}



