@media (min-width: 721px) {
  body { height: 100dvh; overflow: hidden; }
  header { position: relative; top: auto; }
  main {
    width: 100%;
    height: calc(100dvh - 78px - env(safe-area-inset-top));
    padding: 18px 22px 22px;
    overflow: hidden;
  }

  .hero,
  .runtime,
  .command-grid { display: none; }

  .mobile-terminal {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(290px, 27vw, 390px);
    grid-template-rows: auto minmax(0, 1fr);
    width: min(1500px, 100%);
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #07111e;
    box-shadow: 0 24px 70px #02070d80;
  }

  .mobile-quick {
    grid-column: 1 / -1;
    display: flex;
    gap: 9px;
    min-width: 0;
    padding: 11px 13px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    background: #081522;
    scrollbar-width: none;
  }
  .mobile-quick::-webkit-scrollbar { display: none; }
  .mobile-quick button {
    flex: 0 0 auto;
    min-width: 104px;
    min-height: 40px;
    padding: 9px 16px;
    border: 1px solid #294761;
    border-radius: 7px;
    background: #0b1b2c;
    color: #cfe6fb;
    font-size: 12px;
    font-weight: 650;
  }
  .mobile-quick button:hover { border-color: #47789e; background: #10243a; }
  .mobile-quick button:active { transform: translateY(1px); }

  .mobile-focus {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
    min-height: 0;
    padding: 14px;
    overflow: hidden;
    overscroll-behavior: contain;
    background: linear-gradient(145deg, #07121f, #06101b);
  }

  .terminal-empty {
    height: 100%;
    display: grid;
    place-content: center;
    border: 1px dashed #24425d;
    border-radius: 10px;
    color: var(--cyan);
    font: 11px ui-monospace;
    letter-spacing: .18em;
  }

  .terminal-card {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 22px;
    border-radius: 10px;
    background: #091827;
    box-shadow: inset 0 0 46px #0b29472e;
  }
  .terminal-card .task-name { font-size: 18px; }
  .terminal-card .result {
    min-height: 120px;
    max-height: min(48vh, 520px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    font-size: 13px;
    line-height: 1.7;
  }
  .terminal-card .approval-detail { max-height: 260px; }
  .terminal-card .follow { position: sticky; bottom: 0; padding-top: 10px; background: linear-gradient(180deg, transparent, #091827 30%); }
  .terminal-card .follow input { min-height: 42px; }

  .mobile-task-list {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    min-height: 0;
    padding: 9px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    border-left: 1px solid var(--line);
    background: #050d17;
  }
  .mobile-task-row {
    width: 100%;
    min-height: 62px;
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    text-align: left;
  }
  .mobile-task-row + .mobile-task-row { margin-top: 4px; }
  .mobile-task-row:hover { background: #091827; }
  .mobile-task-row.selected { border-color: #315777; background: #0c1d2f; }
  .mobile-task-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .mobile-task-row small { color: var(--muted); font: 9px ui-monospace; white-space: nowrap; }

  .state-lamp { width: 10px; height: 10px; margin: auto; border: 2px solid #43627e; border-radius: 50%; }
  .mobile-task-row.completed .state-lamp { border: 0; background: var(--green); box-shadow: 0 0 9px #66dda080; }
  .mobile-task-row.waiting_approval .state-lamp { border: 0; background: var(--amber); box-shadow: 0 0 11px #ffc46baa; animation: terminal-breathe 1.2s ease-in-out infinite; }
  .mobile-task-row.running .state-lamp { width: 14px; height: 14px; border-color: #244a67; border-top-color: var(--cyan); border-right-color: var(--cyan); animation: terminal-spin .85s linear infinite; }
  .mobile-task-row.queued .state-lamp { border: 0; background: var(--blue); animation: terminal-breathe 1.5s ease-in-out infinite; }
  .mobile-task-row.failed .state-lamp { border: 0; background: var(--red); }
}

@media (min-width: 721px) and (max-width: 980px) {
  main { padding: 12px; }
  .mobile-terminal { grid-template-columns: minmax(0, 1fr) 290px; border-radius: 10px; }
  .terminal-card { padding: 17px; }
}
