.research-shell-host {
  display: none;
}

.mobile-paper-search-menu {
  display: none;
}

@media (max-width: 820px), (pointer: coarse) and (max-height: 600px) {
  html.mobile-layout-active #mobile-primary-navigation:has(#mobile-paper-search-menu:not([hidden])) {
    --mobile-navigation-columns: 4;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  #mobile-paper-search-menu:not([hidden]) {
    display: contents;
  }
}

.research-shell-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

html:not([data-research-shell="ready"]) .reader-heading-row {
  display: flex;
}

html[data-research-shell="ready"] .workspace-modebar,
html[data-research-shell="ready"] #data-tool-switch {
  display: none;
}

html[data-research-shell="ready"] #assistant-toggle {
  display: none;
}

html[data-research-shell="ready"] .research-shell-host:not([hidden]) {
  display: block;
  min-width: 0;
  background: var(--ui-surface);
}

.research-shell {
  color: var(--ui-text);
  font-size: var(--ui-font-metadata, 12px);
  line-height: var(--ui-line-body, 1.5);
}

.research-shell-picker {
  display: none;
}

.research-shell-areas,
.research-shell-panels {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 8px 4px;
}

.research-shell-panels {
  border-top: 1px solid var(--ui-border);
}

.research-shell-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 52px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ui-text-soft);
  font: inherit;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.research-shell-button svg,
.research-shell-picker svg {
  flex: none;
  width: 20px;
  height: 20px;
}

.research-shell-label {
  max-width: 100%;
  white-space: nowrap;
}

.research-shell-button:hover {
  background: var(--ui-surface-subtle);
}

.research-shell-button[aria-current="page"] {
  background: var(--ui-surface-subtle);
  color: var(--ui-primary);
  font-weight: 600;
}

.research-shell-button:focus-visible,
.research-shell-select:focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: -2px;
}

.research-shell-button:disabled,
.research-shell-select:disabled {
  cursor: wait;
  opacity: .55;
}

.data-workspace[data-tool="presentations"] > .presentations-panel {
  margin-top: 0;
  border: 0;
}

.data-workspace[data-tool="presentations"] > .presentations-panel > summary {
  display: none;
}

.data-workspace[data-tool="presentations"] > .presentations-panel > .presentations-body {
  padding-top: 0;
}

@media (min-width: 821px) {
  html:not(.mobile-layout-active)[data-research-shell="ready"] .research-shell-layout {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }

  html:not(.mobile-layout-active)[data-research-shell="ready"] .research-shell-host {
    position: sticky;
    top: 0;
    max-height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: 1px solid var(--ui-border);
  }

  html:not(.mobile-layout-active)[data-research-shell="ready"] .research-shell-layout > .workspace {
    --research-library-width: clamp(180px, 18vw, 240px);
    --research-notes-width: clamp(240px, 24vw, 320px);
    min-width: 0;
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
    grid-template-columns: minmax(0, 1fr);
  }

  html:not(.mobile-layout-active)[data-research-shell="ready"] .research-shell-layout > .workspace > .data-workspace {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  html:not(.mobile-layout-active)[data-research-shell="ready"] .research-shell-layout > .workspace[data-library-visible="true"] {
    grid-template-columns: var(--research-library-width) minmax(0, 1fr);
  }
}

@media (min-width: 1101px) {
  html:not(.mobile-layout-active)[data-research-shell="ready"] .research-shell-layout > .workspace[data-notes-visible="true"] {
    grid-template-columns: minmax(0, 1fr) var(--research-notes-width);
  }

  html:not(.mobile-layout-active)[data-research-shell="ready"] .research-shell-layout > .workspace[data-library-visible="true"][data-notes-visible="true"] {
    grid-template-columns: var(--research-library-width) minmax(0, 1fr) var(--research-notes-width);
  }
}

@media (max-width: 820px), (pointer: coarse) and (max-height: 600px) {
  .research-shell-layout {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  html[data-research-shell="ready"] .research-shell-host {
    flex: none;
    width: 100%;
    overflow: hidden;
    border-bottom: 1px solid var(--ui-border);
  }

  html[data-research-shell="ready"] .research-shell-host:not(:has(.research-shell-picker)),
  html[data-research-shell="ready"] .research-shell-layout:has(> .workspace:is([data-mobile-pane="library"], [data-mobile-pane="notes"], [data-mobile-pane="assistant"])) > .research-shell-host {
    display: none;
  }

  .research-shell-picker {
    display: grid;
    grid-template-columns: 20px minmax(0, 72px) minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin: 0;
    padding: 4px 12px;
  }

  .research-shell-picker-caption {
    color: var(--ui-text-soft);
    font-size: 12px;
    line-height: 16px;
  }

  .research-shell-select {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 8px;
    border: 1px solid var(--ui-border);
    border-radius: 4px;
    background: var(--ui-surface);
    color: var(--ui-text);
    font: inherit;
    font-size: 13px;
    line-height: 20px;
    cursor: pointer;
  }

  .research-shell-areas,
  .research-shell-panels {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .research-shell-button {
    transition: none;
  }
}
