/* ── responsive.css — Responsive breakpoints + mobile layout ── */

/* Tablet / Mobile — max 768px */
@media (max-width: 768px) {

  .workspace {
    grid-template-columns: 0 1fr !important;
  }

  .workspace.show-sidebar {
    grid-template-columns: 260px 1fr !important;
  }

  .sidebar-panel {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    z-index: 400;
    width: 100%;
    max-width: 320px;
    background: var(--surface);
    border-right: 1px solid var(--outline);
    box-shadow: var(--shadow-2);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .show-sidebar .sidebar-panel,
  .sidebar-panel.visible {
    transform: translateX(0);
  }

  .composer {
    padding: 10px;
  }

  .composer-input-wrap {
    padding: 6px;
  }

  #taskInput {
    font-size: 14px;
  }

  .composer-actions {
    gap: 4px;
  }

  .chat-message {
    max-width: 95%;
  }

  .chat-message.user {
    max-width: 90%;
  }

  .chat-message .content {
    padding: 10px 14px;
  }

  .chat-message .sender {
    font-size: 12px;
  }

  .settings-dialog {
    width: 100% !important;
    height: 100% !important;
    max-height: 100vh !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }

  .settings-dialog .content {
    padding: 16px !important;
  }

  .project-dropdown {
    width: 280px;
    right: auto;
    left: 0;
  }

  .sidebar-header {
    padding: 12px 16px;
  }

  .explorer-item {
    padding: 4px 8px;
    font-size: 13px;
  }

  .editor-area {
    padding: 8px;
  }

  .editor-toolbar {
    padding: 4px 8px;
    gap: 4px;
  }

  .agent-panel {
    width: 300px;
    right: -300px;
  }

  .agent-panel.open {
    right: 0;
  }

  .preview-toolbar {
    flex-wrap: wrap;
    gap: 4px;
  }

  .preview-toolbar button {
    font-size: 12px;
    padding: 6px 10px;
  }

  .toast-stack {
    right: 8px;
    left: 8px;
    max-width: none;
  }

  /* App list responsive */
  .apps-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  .top-app-bar {
    padding: 0 8px;
    gap: 4px;
  }

  .brand h1 {
    font-size: 14px;
  }

  .brand-mark-img {
    width: 21px;
    height: 24px;
  }

  .workspace {
    grid-template-columns: 0 1fr !important;
  }

  .workspace.show-sidebar {
    grid-template-columns: 260px 1fr !important;
  }

  .chat-message {
    max-width: 100%;
  }

  .chat-message.user {
    max-width: 100%;
  }

  #taskInput {
    min-height: 40px;
  }

  .composer-actions {
    flex-wrap: wrap;
  }
}

/* Tablet portrait */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar-panel {
    width: 240px;
  }

  .workspace {
    grid-template-columns: 240px 1fr;
  }

  .agent-panel {
    width: 320px;
  }

  .chat-message {
    max-width: 90%;
  }

  .apps-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Improved scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--outline-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* sr-only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Active Plan Container */
.active-plan-container {
  display: flex;
  flex-direction: column;
  margin: 0 14px 8px;
}

.active-plan-container.hidden {
  display: none;
}

.active-plan-card {
  margin: 0;
  padding: 0;
  box-shadow: none;
  border: 1px solid var(--outline);
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.active-plan-header {
  position: relative;
  background: var(--surface);
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--outline);
  cursor: pointer;
  user-select: none;
}

.active-plan-header:hover {
  background: var(--surface-1);
}

.active-plan-header.collapsed {
  border-bottom: none;
}

.active-plan-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.active-plan-header .todo-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 12px;
}

.active-plan-chevron {
  color: var(--muted);
  font-size: 16px !important;
  transition: transform 0.2s;
}

.active-plan-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.active-plan-close:hover {
  background: var(--hover-overlay);
  color: var(--text);
}

.active-plan-list {
  max-height: 180px;
  overflow-y: auto;
  padding: 8px 12px;
}

.active-plan-list.hidden {
  display: none;
}

.active-plan-header-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
}

.spinui-file-link,
.agent-file-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--outline);
  background: var(--surface-1);
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.2;
}

.spinui-file-link:hover,
.agent-file-link:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--primary);
}

.spinui-file-link .codicon,
.agent-file-link .codicon {
  font-size: 11px !important;
}

/* Plan review mode — standard harness inline checklist */
.active-plan-card.is-review {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--outline));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--primary) 14%, transparent),
    0 8px 24px color-mix(in srgb, var(--text) 6%, transparent);
}

.active-plan-card.is-review .active-plan-list {
  max-height: min(56vh, 480px);
  padding: 12px 14px 14px;
  overflow-y: auto;
}

.active-plan-card.is-review .active-plan-header {
  cursor: default;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}

.active-plan-card.is-review .active-plan-header:hover {
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}

.active-plan-card.is-review .active-plan-chevron {
  display: none;
}

.active-plan-card.is-review .active-plan-title {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.plan-review-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 6px;
}

.plan-review-badge {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--outline));
  border-radius: 6px;
  padding: 2px 7px;
}

.plan-review-hint {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.plan-step-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plan-step-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 4px;
  margin: 0 -4px;
  border-radius: 8px;
  transition: background 0.12s ease;
}

.plan-step-row:hover {
  background: color-mix(in srgb, var(--text) 3.5%, transparent);
}

.plan-step-row.is-done .plan-step-input {
  color: var(--muted);
  text-decoration: line-through;
}

.plan-step-check,
.plan-step-move,
.plan-step-remove,
.plan-add-step {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.plan-step-check {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: color-mix(in srgb, var(--primary) 70%, var(--muted));
}

.plan-step-check .codicon {
  font-size: 16px !important;
}

.plan-step-row.is-done .plan-step-check {
  color: var(--primary);
}

.plan-step-check:hover,
.plan-step-move:hover,
.plan-step-remove:hover {
  color: var(--text);
  background: var(--hover-overlay);
}

.plan-step-remove:hover {
  color: var(--red, #c44);
}

.plan-step-input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 13px;
  line-height: 1.4;
}

.plan-step-input:hover {
  background: var(--surface);
  border-color: var(--outline);
}

.plan-step-input:focus {
  outline: none;
  background: var(--surface);
  border-color: color-mix(in srgb, var(--primary) 55%, var(--outline));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 16%, transparent);
}

.plan-step-moves {
  display: inline-flex;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.plan-step-row:hover .plan-step-moves,
.plan-step-row:focus-within .plan-step-moves {
  opacity: 1;
}

.plan-step-move,
.plan-step-remove {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.plan-step-move .codicon,
.plan-step-remove .codicon {
  font-size: 12px !important;
}

.plan-step-move:disabled {
  opacity: 0.28;
  cursor: default;
}

.plan-add-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px dashed var(--outline);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
}

.plan-add-step:hover {
  color: var(--text);
  background: var(--hover-overlay);
  border-style: solid;
  border-color: color-mix(in srgb, var(--primary) 35%, var(--outline));
}

.plan-add-step .codicon {
  font-size: 13px !important;
}

.plan-review-meta {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
}

.plan-review-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--outline);
  flex-wrap: wrap;
}

.plan-review-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.plan-btn {
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.plan-btn-primary {
  background: var(--text);
  color: var(--surface);
}

.plan-btn-primary:hover {
  opacity: 0.92;
}

.plan-btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--outline);
}

.plan-btn-secondary:hover {
  background: var(--surface-1);
}

body.plan-review-pending #composer {
  opacity: 0.72;
}

body.plan-review-pending #taskInput:disabled {
  cursor: not-allowed;
}


/* ── Mobile & Desktop Optimization Screen ── */

.mobile-warning-screen {
  display: none;
}

@media (max-width: 1024px) {
  .mobile-warning-screen {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--surface-1);
    color: var(--text);
    z-index: 100000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    text-align: center;
    overflow-y: auto;
    font-family: var(--font-body);
  }

  /* Hide background interface to focus cleanly on the warning */
  .shell,
  #serverOfflineBanner,
  .toast-stack,
  .global-loading,
  dialog {
    display: none !important;
  }

  body {
    overflow: hidden !important;
    height: 100vh !important;
    width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .mobile-warning-content {
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    animation: mobileFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .mobile-warning-illustration {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius-xl, 24px);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-1);
  }

  .mobile-warning-illustration svg {
    width: 120px;
    height: 120px;
    display: block;
  }

  .mobile-warning-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.2;
  }

  .mobile-warning-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--muted);
    margin: 0;
    padding: 0 8px;
  }

  .mobile-warning-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--outline);
    padding: 10px 16px;
    border-radius: var(--radius-md, 12px);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.4;
  }

  .mobile-warning-badge .codicon {
    font-size: 16px !important;
    color: var(--blue);
  }
}

@keyframes mobileFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
