/* Attachment preview shares the MVO workbench; native document content stays intact. */
@media screen {
  html.mvo-attachment-open { overflow: hidden; }

  #mvo-attachment-drawer {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(960px, calc(100vw - 96px));
    max-width: none;
    height: 100%;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 16px 0 0 16px;
    background: var(--mvo-page);
    color: var(--mvo-ink);
    box-shadow: -12px 0 48px #0f172a30;
    overflow: hidden;
  }

  #mvo-attachment-drawer[open] { display: flex; flex-direction: column; }
  #mvo-attachment-drawer::backdrop { background: #0f172a52; }

  .mvo-attachment-header {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 12px;
    min-height: 76px;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid var(--mvo-line);
  }

  .mvo-attachment-header h2 {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mvo-attachment-header svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mvo-attachment-symbol {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    height: 40px;
    border-radius: 10px;
    color: var(--mvo-link);
    background: var(--mvo-soft);
  }

  .mvo-attachment-header button,
  #mvo-attachment-retry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    color: var(--mvo-link);
    background: var(--mvo-soft);
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
  }

  .mvo-attachment-header button:hover,
  #mvo-attachment-retry:hover { background: #d9edf9; }
  .mvo-attachment-header button:focus-visible,
  #mvo-attachment-retry:focus-visible { outline: 2px solid var(--mvo-link); outline-offset: 2px; }

  #mvo-attachment-close {
    flex: 0 0 44px;
    padding: 0;
    color: var(--mvo-muted);
    background: transparent;
  }

  .mvo-attachment-body { position: relative; flex: 1; min-height: 0; }
  .mvo-attachment-feedback { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 28px; text-align: center; }
  #mvo-attachment-status { max-width: 38ch; margin: 0; color: var(--mvo-muted); line-height: 1.7; }
  #mvo-attachment-preview { position: relative; display: block; width: 100%; height: 100%; border: 0; background: #fff; }

  /* Native tools remain functional; the file name/download already live in the drawer header. */
  body.mvo-attachment-document #layout-content > .header { min-height: 56px; height: 56px; padding: 0 16px; }
  body.mvo-attachment-document #layout-content > .header .header-title,
  body.mvo-attachment-document #toolbar-menu > li:has(> a.download) { display: none; }
  body.mvo-attachment-document #toolbar-menu { margin-left: 0; }

  @media (min-width: 769px) {
    body.mvo-attachment-document #layout-content > .header {
      height: auto;
      min-height: 64px;
      padding: 10px 16px;
      align-items: center;
      justify-content: flex-start;
    }
    body.mvo-attachment-document #layout-content > .header > #toolbar-menu:not(.popupmenu) {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 4px;
      margin: 0;
      padding: 0;
      white-space: normal;
      text-align: left;
    }
    body.mvo-attachment-document #layout-content > .header > #toolbar-menu:not(.popupmenu) > li:not(:has(> a.download)) { display: flex; align-items: center; flex: 0 0 auto; height: 40px; }
    body.mvo-attachment-document #layout-content > .header > #toolbar-menu:not(.popupmenu) > li.spacer { width: 1px; height: 20px; margin: 0 8px; background: var(--mvo-line); }
    body.mvo-attachment-document #layout-content > .header > #toolbar-menu:not(.popupmenu) a {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      flex: 0 0 auto;
      gap: 8px;
      float: none;
      height: 40px;
      min-width: 40px;
      max-width: none;
      margin: 0;
      padding: 0 12px;
      border-radius: 7px;
      color: var(--mvo-muted);
      line-height: 1.3;
      overflow: visible;
      white-space: nowrap;
    }
    /* Elastic fixes the icon height for its vertical toolbar with !important. */
    body.mvo-attachment-document #layout-content > .header > #toolbar-menu:not(.popupmenu) a::before { display: block; flex: 0 0 auto; height: auto !important; font-size: 16px; line-height: 1; }
    body.mvo-attachment-document #layout-content > .header > #toolbar-menu:not(.popupmenu) span.inner { padding: 0; font-size: 12px; font-weight: 600; line-height: 1.3; }
    body.mvo-attachment-document #layout-content > .header > #toolbar-menu:not(.popupmenu) .dropbutton { display: flex; align-items: center; height: 40px; }
    body.mvo-attachment-document #layout-content > .header > #toolbar-menu:not(.popupmenu) a.dropdown { min-width: 24px; padding: 0 5px; }
    body.mvo-attachment-document #layout-content > .header > #toolbar-menu:not(.popupmenu) a:not(.disabled):hover { color: var(--mvo-link); background: var(--mvo-soft); }
    body.mvo-attachment-document #layout-content > .header > #toolbar-menu:not(.popupmenu) a:focus-visible { outline: 2px solid var(--mvo-link); outline-offset: 2px; }
    body.mvo-attachment-document #layout-content > .header > #toolbar-menu:not(.popupmenu) a.disabled { color: #8a97a8; opacity: 1; }
  }

  @media (max-width: 768px) {
    #mvo-attachment-drawer { width: 100%; border-radius: 0; box-shadow: none; }
    .mvo-attachment-header { gap: 8px; min-height: 68px; padding: 10px 12px; }
    .mvo-attachment-symbol { display: none; }
    .mvo-attachment-header button { padding: 0 12px; }
    #mvo-attachment-close { padding: 0; }
    body.mvo-attachment-document #layout-content > .header { padding: 0 12px; }
  }
}
