/* Responsive layout for phones and small tablets. */
@media (max-width: 900px) {
  .topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    min-height: 0;
    padding: 14px 16px;
  }

  .brand {
    flex: 1 1 100%;
    justify-self: auto;
  }

  .language-bar {
    order: 2;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
    gap: 8px;
    justify-self: auto;
  }

  .language-bar select {
    width: 100%;
    min-width: 0;
    padding: 11px 9px;
    border-radius: 10px;
    font-size: 14px;
  }

  .swap {
    width: 42px;
    height: 42px;
  }

  .header-actions {
    order: 3;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    justify-self: auto;
  }

  .model-box {
    min-width: 0;
    width: 100%;
    border-radius: 10px;
    padding: 5px 7px 5px 10px;
  }

  .model-box input {
    min-width: 0;
    width: 100%;
  }

  .model-box button {
    flex-shrink: 0;
    border-radius: 8px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .translate-button {
    height: 42px;
    padding: 0 14px;
    border-radius: 10px;
    font-size: 13px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 28px 24px 16px;
  }

  .translation-panel {
    height: auto;
    min-height: 0;
  }

  .translation-panel textarea {
    height: 200px;
    min-height: 180px;
    max-height: 52vh;
    overflow-y: auto;
    resize: none;
    padding: 20px 16px;
    font-size: 16px;
  }

  .output {
    min-height: 180px;
    max-height: 52vh;
    overflow-y: auto;
    padding: 20px 16px;
    font-size: 16px;
  }

  .panel-footer {
    min-height: 58px;
    height: auto;
    padding: 10px 12px;
  }

  .model-status {
    margin: 0 16px 10px;
  }
}

@media (max-width: 480px) {
  .brand {
    font-size: 16px;
  }

  .logo {
    width: 32px;
    height: 32px;
    font-size: 19px;
  }

  .language-bar select {
    font-size: 13px;
  }

  .header-actions {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .header-actions .translate-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .translation-panel {
    min-height: 0;
  }

  .workspace {
    padding: 28px 16px 10px;
  }
}

/* Mobile content areas grow with their content instead of scrolling internally. */
@media (max-width: 900px) {
  .translation-panel {
    height: auto;
    min-height: 0 !important;
  }

  .translation-panel textarea {
    flex: none !important;
    height: auto;
    min-height: 100px !important;
    max-height: none !important;
    overflow-y: hidden;
  }

  .output {
    flex: none !important;
    height: auto !important;
    min-height: 100px !important;
    max-height: none !important;
    overflow: visible;
  }
}

/* Desktop: fit the empty workspace to the visible browser viewport. */
@media (min-width: 901px) {
  main {
    height: calc(100vh - 86px);
    overflow: visible;
  }

  .workspace {
    height: 100%;
    padding: 24px;
  }

  .translation-panel {
    height: calc(100% - 48px);
  }

  .model-status {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 4px;
  }
}