.page {
  display: flex;
  flex-direction: column;
  min-height: var(--app-height);
  height: var(--app-height);
  overflow: hidden;
  background: #fff;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  padding: 0;
}

.pageHeader {
  flex-shrink: 0;
  width: 100%;
  margin: 0;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 14px max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #eef0f3;
  background: #fafbfc;
}

.pageTitle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
}

.pageTitle h1 {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  line-height: 1.2;
}

.pageTitle p {
  margin-top: 2px;
  font-size: 12px;
  color: #8b95a8;
}

.shell {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.layout {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  overflow: hidden;
}

.sidebar {
  flex-shrink: 0;
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 12px;
  padding-left: max(12px, env(safe-area-inset-left));
  background: #f4f6f9;
  border-right: 1px solid #e5e7eb;
}

.navBtn {
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #4b5563;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
}

.navBtn:hover {
  background: rgba(255, 255, 255, 0.72);
  color: #111827;
}

.navBtnActive {
  background: #fff;
  color: #2563eb;
  border-color: #e5e7eb;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.navBtn:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

.panes {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) 14px;
}

.pane {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
}

.paneActive {
  display: flex;
}

.panel {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panelHeader {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  row-gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #eef0f3;
  background: #fafbfc;
}

.panelHeader h2 {
  font-size: 14px;
  line-height: 1.3;
  font-weight: 600;
  color: #111827;
}

.panelHeader p {
  margin-top: 3px;
  font-size: 11px;
  color: #8b95a8;
  word-break: break-all;
}

.panelHeaderActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.headerBtnActive {
  border-color: #2563eb;
  color: #2563eb;
  background: #eff6ff;
}

.markdownPreview {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: #fff;
}

.markdownBody {
  max-width: none;
  min-height: 100%;
  box-sizing: border-box;
  padding: 24px 28px;
}

.markdownBody :global(pre.assistant-pre) {
  margin: 0.5em 0 0.6em;
  padding: 0;
  background: transparent;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.45;
}

.markdownBody :global(pre.assistant-pre code.hljs) {
  display: block;
  padding: 16px;
  background: #f6f8fa;
  border: none;
  color: inherit;
  font-size: 13px;
  line-height: 1.45;
  word-break: normal;
  tab-size: 2;
}

.primaryBtn,
.secondaryBtn,
.linkBtn {
  height: 30px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.linkBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #374151;
  background: #fff;
  border: 1px solid #d1d5db;
}

.linkBtn:hover {
  background: #f3f4f6;
}

.primaryBtn {
  color: #fff;
  background: #2563eb;
  border: 1px solid #2563eb;
}

.primaryBtn:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.primaryBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.secondaryBtn {
  color: #374151;
  background: #fff;
  border: 1px solid #d1d5db;
}

.secondaryBtn:hover {
  background: #f3f4f6;
}

.textarea {
  display: block;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px;
  border: none;
  outline: none;
  resize: none;
  color: #111827;
  background: #fff;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
  overflow: auto;
}

.textarea:focus {
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.18);
}

.textareaInvalid:focus {
  box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.35);
}

.jsonError {
  flex: 0 0 auto;
  padding: 8px 14px;
  color: #b91c1c;
  background: #fef2f2;
  border-top: 1px solid #fecaca;
  font-size: 13px;
  line-height: 1.45;
}

.formBody {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fieldLabel {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}

.textInput {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.textInput:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.fieldHint {
  margin: 0;
  font-size: 12px;
  color: #8b95a8;
  line-height: 1.5;
}

.avatarPreviewRow {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatarPreview {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}

.previewHint {
  font-size: 12px;
  color: #9ca3af;
}

.status {
  flex-shrink: 0;
  min-height: 30px;
  padding: 7px 14px 9px;
  border-top: 1px solid #eef0f3;
  color: #8b95a8;
  font-size: 12px;
}

.statusOk {
  color: #15803d;
}

.statusError {
  color: #b91c1c;
}

.list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.empty {
  padding: 20px 10px;
  color: #9ca3af;
  font-size: 12px;
  text-align: center;
}

.emptyCompact {
  padding: 10px 4px 2px;
  text-align: left;
}

.skillItem,
.mcpServerItem,
.extensionItem {
  padding: 10px 10px 9px;
  border: 1px solid #edf0f4;
  border-radius: 8px;
  background: #fff;
}

.skillItem + .skillItem,
.mcpServerItem + .mcpServerItem,
.extensionItem + .extensionItem {
  margin-top: 7px;
}

.extensionGroup + .extensionGroup {
  margin-top: 16px;
}

.extensionGroupHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.extensionGroupHeader h3 {
  margin: 0;
  color: #111827;
  font-size: 13px;
  font-weight: 600;
}

.extensionGroupHeader span {
  color: #9ca3af;
  font-size: 11px;
  flex-shrink: 0;
}

.extensionGroupList {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

@media (max-width: 960px) {
  .extensionGroupList {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .extensionGroupList {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.envGrid {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #edf0f4;
  border-radius: 8px;
  overflow: hidden;
}

.envRow {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid #f3f4f6;
}

.envRow:last-child {
  border-bottom: none;
}

.envRow:nth-child(even) {
  background: #fafbfc;
}

.envLabel {
  flex-shrink: 0;
  width: 100px;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}

.envValue {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #111827;
  word-break: break-all;
  background: none;
}

.terminalPanel {
  min-height: 420px;
}

.terminalPanel .panelHeader {
  border-bottom-color: #30363d;
}

.terminalPanel .panelHeader p {
  color: #8b949e;
}

.extensionHeader {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.extensionTitleRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.extensionItem .itemName {
  flex: 1;
  min-width: 0;
}

.extensionSubtitle {
  color: #9ca3af;
  font-size: 10px;
  line-height: 1.35;
  word-break: break-word;
}

.extensionGroupList .extensionItem + .extensionItem {
  margin-top: 0;
}

.skillItemDisabled {
  opacity: 0.72;
  background: #fafbfc;
}

.skillActions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.skillToggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.skillToggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.skillToggleUi {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.15s;
  flex-shrink: 0;
}

.skillToggleUi::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18);
  transition: transform 0.15s;
}

.skillToggle input:checked + .skillToggleUi {
  background: #2563eb;
}

.skillToggle input:checked + .skillToggleUi::after {
  transform: translateX(16px);
}

.skillToggle input:disabled + .skillToggleUi {
  opacity: 0.55;
}

.skillToggleLabel {
  font-size: 12px;
  color: #64748b;
  min-width: 42px;
}

.titleRow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.itemName {
  min-width: 0;
  color: #111827;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.itemMeta {
  flex-shrink: 0;
  color: #9ca3af;
  font-size: 10px;
}

.itemDesc {
  margin-top: 5px;
  color: #4b5563;
  font-size: 12px;
  line-height: 1.45;
}

.itemPath {
  margin-top: 6px;
  color: #9ca3af;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.4;
  word-break: break-all;
}

.mcpToolList {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

@media (max-width: 960px) {
  .mcpToolList {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .mcpToolList {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .mcpToolList {
    grid-template-columns: 1fr;
  }
}

.mcpServerHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.mcpServerMain {
  min-width: 0;
}

.mcpServerSub {
  margin-top: 3px;
  color: #9ca3af;
  font-size: 10px;
}

.mcpServerBadges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 6px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 10px;
  line-height: 1;
}

.mcpToolItem {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #f1f3f6;
  border-radius: 7px;
  background: #fbfcfe;
}

.mcpToolItem[open] {
  background: #fff;
}

.mcpToolSummary {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  cursor: pointer;
  list-style: none;
}

.mcpToolSummaryActions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

.mcpToolItemDisabled {
  opacity: 0.72;
  background: #fafbfc;
}

.mcpToolSummary::-webkit-details-marker {
  display: none;
}

.mcpToolName {
  color: #111827;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mcpToolDesc {
  margin-top: 6px;
  color: #6b7280;
  font-size: 11px;
  line-height: 1.4;
}

.mcpParamList {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.mcpParamList code {
  padding: 2px 6px;
  border-radius: 5px;
  background: #fff;
  border: 1px solid #edf0f4;
  color: #374151;
  font-family: var(--font-mono);
  font-size: 10px;
  word-break: break-all;
}

.extensionCounts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.extensionCounts span {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 11px;
  line-height: 1;
}

.extensionDetails {
  margin-top: 8px;
  border-top: 1px solid #f1f3f6;
  padding-top: 7px;
}

.extensionDetails > summary {
  cursor: pointer;
  color: #6b7280;
  font-size: 11px;
  user-select: none;
}

.extensionDetails > summary:hover {
  color: #2563eb;
}

.nameList {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  font-size: 11px;
  color: #8b95a8;
}

.nameList > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.nameList code {
  padding: 2px 6px;
  border-radius: 5px;
  background: #f8fafc;
  border: 1px solid #edf0f4;
  color: #374151;
  font-family: var(--font-mono);
  font-size: 10px;
  word-break: break-all;
}

@media (max-width: 768px) {
  .pageHeader {
    align-items: center;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .pageTitle h1 {
    font-size: 17px;
  }

  .layout {
    flex-direction: column;
    min-height: 0;
  }

  .sidebar {
    width: 100%;
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 6px;
    padding: 8px max(10px, env(safe-area-inset-left)) 8px max(10px, env(safe-area-inset-right));
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

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

  .navBtn {
    flex: 0 0 auto;
    width: auto;
    min-width: auto;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    padding: 9px 14px;
    font-size: 13px;
    scroll-snap-align: start;
  }

  .panes {
    flex: 1;
    min-height: 0;
    padding: 10px max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right));
  }

  .panel {
    border-radius: 10px;
  }

  .panelHeader {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .panelHeaderActions {
    width: 100%;
    justify-content: flex-end;
  }

  .panelHeader h2 {
    font-size: 15px;
  }

  .panelHeader p {
    font-size: 11px;
    line-height: 1.45;
    word-break: break-word;
  }

  .markdownBody {
    padding: 16px 14px;
  }

  .envRow {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 10px 12px;
  }

  .envLabel {
    width: auto;
  }

  .mcpServerHead {
    flex-direction: column;
    align-items: stretch;
  }

  .mcpServerBadges {
    justify-content: flex-start;
  }

  .titleRow {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .skillActions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .extensionTitleRow {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px;
  }

  .terminalPanel {
    min-height: min(420px, calc(var(--app-height) - 180px));
  }

  .textarea {
    font-size: 12px;
    padding: 12px;
  }

  .formBody {
    padding: 12px;
  }

  .list {
    padding: 6px;
  }
}

@media (max-width: 480px) {
  .extensionGroupList {
    grid-template-columns: 1fr;
  }

  .navBtn {
    padding: 8px 12px;
    font-size: 12px;
  }

  .primaryBtn,
  .secondaryBtn,
  .linkBtn {
    height: 34px;
    padding: 0 14px;
    font-size: 13px;
  }

  .panelHeaderActions {
    flex-wrap: wrap;
  }

  .panelHeaderActions .primaryBtn,
  .panelHeaderActions .secondaryBtn {
    flex: 1 1 auto;
    min-width: 88px;
  }
}
