@media (max-width: 820px) {
  :root {
    --row-h: 44px;
    --console-h: 168px;
  }

  html,
  body,
  #root {
    height: 100%;
    min-height: 100%;
  }

  body {
    overflow: hidden;
  }

  .app {
    height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "topbar"
      "sidebar"
      "main"
      "console";
  }

  .topbar {
    min-height: 0;
    height: auto;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px 12px;
    padding: 10px 12px;
  }

  .brand {
    flex: 1 1 136px;
    min-width: 136px;
  }

  .brand__mark {
    width: 24px;
    height: 21px;
  }

  .brand__name {
    font-size: 15px;
  }

  .brand__name small {
    font-size: 8px;
    letter-spacing: 0.16em;
  }

  .topbar__sep {
    display: none;
  }

  .devid {
    order: 3;
    flex: 1 1 100%;
    min-width: 0;
    padding-top: 8px;
    border-top: 2px solid var(--line);
  }

  .devid .v {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar__status {
    flex: 1 1 100%;
    margin-left: 0;
    gap: 8px;
    flex-wrap: wrap;
  }

  .topbar__status .btn {
    flex: 1 1 132px;
  }

  .conn {
    flex: 1 1 150px;
    justify-content: center;
    padding: 8px 10px;
  }

  .iconbtn {
    width: 38px;
    height: 38px;
  }

  .sidebar {
    display: block;
    min-height: 0;
    overflow: hidden;
    border-right: 0;
    border-bottom: 2px solid var(--line);
  }

  .proj-switch,
  .sidebar__foot {
    display: none;
  }

  .nav {
    flex: none;
    min-height: 0;
    flex-direction: row;
    gap: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav__item {
    flex: 0 0 auto;
    width: auto;
    min-width: 106px;
    min-height: 42px;
    justify-content: center;
    gap: 7px;
    padding: 9px 11px;
    border-color: var(--line);
    background: var(--surface-2);
  }

  .nav__item.on {
    color: var(--ink);
    border-color: var(--accent);
    background: var(--accent);
  }

  .nav__num,
  .nav__item .nav__badge {
    display: none;
  }

  .nav__txt {
    font-size: 11px;
    letter-spacing: 0.08em;
  }

  .main {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background-size: 36px 36px;
  }

  .section {
    max-width: none;
    padding: 18px 12px 84px;
  }

  .section__head {
    display: block;
    padding-bottom: 14px;
    margin-bottom: 16px;
  }

  .section__head .tag {
    margin-bottom: 10px;
    font-size: 10px;
    letter-spacing: 0.16em;
  }

  .section__head h1 {
    font-size: clamp(30px, 10vw, 40px);
  }

  .section__head p {
    max-width: none;
    font-size: 14.5px;
    line-height: 1.55;
  }

  .section__head .head-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 8px;
    margin-top: 14px;
    margin-left: 0;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .card + .card {
    margin-top: 12px;
  }

  .card__bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }

  .card__bar .right {
    width: 100%;
    margin-left: 0;
  }

  .card__body,
  .card__body.pad-lg {
    padding: 14px;
  }

  .btn {
    min-width: 0;
    padding-inline: 12px;
    white-space: normal;
    text-align: center;
    line-height: 1.15;
  }

  .btn-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 8px;
  }

  .btn-row .btn,
  .head-actions .btn {
    width: 100%;
  }

  .control,
  .select select {
    font-size: 16px;
  }

  .connect-hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .connect-hero__viz {
    min-height: 132px;
    max-height: 150px;
    border-right: 0;
    border-bottom: 2px solid var(--line);
    padding: 28px 18px 0;
  }

  .connect-hero__body {
    padding: 16px;
    gap: 14px;
  }

  .tracks {
    grid-template-columns: 1fr;
  }

  .trk {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
    border-right: 0;
  }

  .trk__num,
  .trk__name {
    height: 36px;
  }

  .trk__name {
    font-size: 16px;
  }

  .ph-card__bar {
    padding: 12px;
  }

  .ph-card__bar .meta {
    width: 100%;
    margin-left: 0;
  }

  .ph-card__body {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px;
  }

  .sys-row {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    border-right: 0;
  }

  .sys-row .ctl {
    width: 100%;
    min-width: 0;
    margin-left: 0;
  }

  .dropzone {
    padding: 26px 16px;
  }

  .fw-step {
    align-items: flex-start;
    padding: 11px 12px;
  }

  .json {
    max-height: 260px;
    font-size: 11px;
    line-height: 1.65;
    padding: 12px;
  }

  .console {
    height: min(42vh, var(--console-h));
  }

  .app[data-console=closed] .console {
    height: 40px;
  }

  .console__bar {
    height: 40px;
    gap: 8px;
    padding: 0 10px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .console__bar h2 {
    font-size: 10px;
    letter-spacing: 0.12em;
    white-space: nowrap;
  }

  .console__bar .count,
  .console__bar .chk {
    display: none;
  }

  .console__bar .right {
    margin-left: auto;
    gap: 6px;
  }

  .console__body {
    padding: 8px 10px;
    font-size: 11px;
    line-height: 1.55;
  }

  .logline {
    gap: 8px;
  }

  .toast-wrap {
    left: 12px;
    right: 12px;
    bottom: 54px;
  }

  .toast {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 420px) {
  .topbar {
    gap: 8px;
  }

  .conn {
    flex-basis: 100%;
  }

  .nav__item {
    min-width: 94px;
  }

  .nav__txt {
    font-size: 10px;
  }

  .trk {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .trk .btn {
    grid-column: 2;
    width: 100%;
  }

  .sys-row .k {
    width: 100%;
  }
}
