

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Roboto', system-ui, -apple-system, sans-serif;
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  margin: 0;
  overflow: hidden;
}

/* ─── Ripple ─── */




/* ─── Material Symbols ─── */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ─── App Layout ─── */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh; /* Fallback for older browsers */
  height: 100dvh;
}

/* ─── Top App Bar ─── */
.top-app-bar {
  display: flex;
  align-items: center;
  height: 64px;
  padding: 0 16px;
  background-color: var(--md-sys-color-surface-container);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  gap: 16px;
  z-index: 10;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  width: 224px;
  flex-shrink: 0;
}

.logo-area img {
  height: 32px;
  border-radius: 8px;
}

.app-title {
  font-size: 20px;
  font-weight: 500;
  color: var(--md-sys-color-primary);
}

.search-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 搜索栏专用 MD3 样式 */
.search-field {
  position: relative;
  display: flex;
  align-items: center;
  height: 48px;
  width: 100%;
  max-width: 600px;
  border-radius: 24px;
  background-color: var(--md-sys-color-surface-container-high);
  transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
}

.search-field:focus-within {
  background-color: var(--md-sys-color-surface);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.1);
  max-width: 720px;
}

.search-field .search-icon {
  position: absolute;
  left: 16px;
  font-size: 24px;
  color: var(--md-sys-color-on-surface-variant);
  pointer-events: none;
  transition: color 0.2s;
}

.search-field:focus-within .search-icon {
  color: var(--md-sys-color-primary);
}

/* ─── MD3 Search Bar Input ─── */
.search-input {
  width: 100%;
  height: 100%;
  padding: 0 16px 0 52px;
  border: none;
  outline: none;
  border-radius: 24px;
  background-color: transparent;
  color: var(--md-sys-color-on-surface);
  font-size: 16px;
  font-family: inherit;
}

.search-input::placeholder {
  color: var(--md-sys-color-outline);
}

/* 屏蔽 Edge / Chrome 浏览器默认的搜索框尾部/头部自带组件 */
.search-input::-ms-clear,
.search-input::-ms-reveal {
  display: none;
  width: 0;
  height: 0;
}
.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-results-button,
.search-input::-webkit-search-results-decoration {
  display: none;
}

/* 防止自动填表的背景色污染 MD3 外观 */
.search-input:-webkit-autofill,
.search-input:-webkit-autofill:hover,
.search-input:-webkit-autofill:focus,
.search-input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 50px transparent inset !important;
  -webkit-text-fill-color: var(--md-sys-color-on-surface) !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* 未激活状态下隐藏表内文字，应对密码管理器瞎填 */
.search-input.inactive {
  color: transparent !important;
  text-shadow: none !important;
}

.search-input.inactive::placeholder {
  color: var(--md-sys-color-outline) !important;
}

.search-input.inactive:-webkit-autofill,
.search-input.inactive:-webkit-autofill:hover,
.search-input.inactive:-webkit-autofill:focus,
.search-input.inactive:-webkit-autofill:active {
  -webkit-text-fill-color: transparent !important;
}

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

/* ─── Main Body ─── */
.main-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── Side Navigation ─── */
.side-nav {
  width: 240px;
  background-color: var(--md-sys-color-surface-container);
  display: flex;
  flex-direction: column;
  padding-top: 16px;
  border-right: 1px solid var(--md-sys-color-outline-variant);
  flex-shrink: 0;
}

.nav-spacer { flex: 1; }

.nav-bottom-actions {
  padding: 16px;
  display: flex;
  justify-content: center;
}

/* ─── MD3 Tabs (手写版) ─── */
.md-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
}

.md-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 28px;
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.md-tab:hover {
  background-color: var(--md-sys-state-hover);
  color: var(--md-sys-color-on-surface);
}

.md-tab.active {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
}

.md-tab .material-symbols-outlined {
  font-size: 20px;
}

/* 对话框内的 tab（水平布局） */
.dialog-tabs {
  flex-direction: row;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 0;
  padding: 0;
  gap: 0;
}

.dialog-tabs .md-tab {
  flex: 1;
  border-radius: 0;
  justify-content: center;
  border-bottom: 2px solid transparent;
}

.dialog-tabs .md-tab.active {
  background: transparent;
  color: var(--md-sys-color-primary);
  border-bottom-color: var(--md-sys-color-primary);
}

/* ─── FAB ─── */
.fab {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border: none;
  padding: 16px 20px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.fab:hover {
  box-shadow: 0 6px 12px rgba(0,0,0,0.2);
  transform: translateY(-2px);
}

/* ─── Content Area ─── */
.content-viewport {
  flex: 1;
  background-color: var(--md-sys-color-surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
/* library-view 保留原来的居中 + padding */
#library-view {
  padding: 32px 24px 24px;
  align-items: center;
  overflow-y: auto;
}

/* ─── Card Grid ─── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 1200px;
}

.cmd-card {
  background-color: var(--md-sys-color-surface-container);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.cmd-card:hover {
  background-color: var(--md-sys-color-surface-container-high);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.cmd-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--md-sys-color-on-surface);
}

.cmd-desc {
  font-size: 14px;
  opacity: 0.8;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

.cmd-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-chip {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.cmd-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  opacity: 0.7;
}

/* ─── Pagination ─── */
.pagination {
  margin-top: 32px;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ─── Buttons (手写 MD3) ─── */
.md-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 24px;
  border-radius: 20px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.md-btn-filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.md-btn-filled:hover {
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.md-btn-text {
  background: transparent;
  color: var(--md-sys-color-primary);
  padding: 0 12px;
}

.md-btn-text:hover {
  background-color: var(--md-sys-color-primary-container);
}

.md-icon-button {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: background-color 0.2s;
}

.md-icon-button:hover {
  background-color: var(--md-sys-state-hover);
}

/* ─── MD3 Textfield (手写) ─── */
.md-textfield {
  position: relative;
  height: 56px;
  width: 100%;
  background-color: var(--md-sys-color-surface-variant);
  border-radius: 4px 4px 0 0;
  border-bottom: 1px solid var(--md-sys-color-on-surface-variant);
  transition: background-color 0.2s, border-bottom-color 0.2s;
  display: flex;
  align-items: center;
}

.md-textfield:focus-within {
  border-bottom: 2px solid var(--md-sys-color-primary);
  background-color: var(--md-sys-color-surface-container);
}

.md-input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  padding: 24px 16px 8px; /* Room for floating label */
  font-size: 16px;
  color: var(--md-sys-color-on-surface);
  outline: none;
  font-family: inherit;
}

.md-input-label {
  position: absolute;
  left: 16px;
  top: 18px;
  font-size: 16px;
  color: var(--md-sys-color-on-surface-variant);
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
}

.md-input:focus ~ .md-input-label,
.md-input:not(:placeholder-shown) ~ .md-input-label {
  top: 6px;
  font-size: 12px;
  color: var(--md-sys-color-primary);
}

.md-input:not(:focus):not(:placeholder-shown) ~ .md-input-label {
  color: var(--md-sys-color-on-surface-variant);
}



/* ─── MD3 Dialog ─── */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0,0,0,0.5); /* 遮罩层使用透明黑最稳妥 */
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.dialog-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.md-dialog {
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: 28px;
  padding: 24px;
  min-width: 320px;
  max-width: 560px;
  width: 90vw;
  box-shadow: 0 24px 48px rgba(0,0,0,0.15);
  transform: scale(0.9);
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: var(--md-sys-color-on-surface);
  max-height: 90vh; /* Prevent it from being taller than screen */
}

.dialog-backdrop.show .md-dialog {
  transform: scale(1);
}

.md-dialog-title {
  font-size: 24px;
  font-weight: 400;
}

.md-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.report-preset-chip.active {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  border-color: var(--md-sys-color-error);
}

.detail-body {
  overflow-y: auto;
  padding-right: 8px; /* for scrollbar */
}

/* ─── Loading Spinner ─── */
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--md-sys-color-surface-variant);
  border-top-color: var(--md-sys-color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Icon Button ─── */




/* ─── Dialog (与 panel.css 同款) ─── */












/* ─── Text Input (与 panel.css 同款) ─── */








.md-input:focus ~ .md-input-label,


/* ─── Loading Spinner ─── */






/* ─── Detail Dialog ─── */
.detail-dialog {
  min-width: 60vw;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.detail-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 200px;
}

.detail-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#btn-open-in-app:disabled,
#btn-copy-local-link:disabled {
  opacity: 0.6;
  pointer-events: none;
}

.chip {
  padding: 4px 12px;
  background: var(--md-sys-color-surface-container-highest);
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
}

.detail-desc {
  font-size: 15px;
  line-height: 1.5;
  opacity: 0.9;
}

.code-container {
  background-color: #1a1a1b;
  color: #e4e4e4;
  border-radius: 12px;
  overflow: hidden;
  font-family: 'JetBrains Mono', monospace;
  position: relative;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 16px;
  background-color: #2b2b2c;
  font-size: 13px;
  color: #a0a0a0;
}

.code-header 

.code-container pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  max-height: 40vh;
  font-size: 13px;
  line-height: 1.6;
}

/* ─── MCD Visual UI ─── */
.mcd-ui-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.mcd-chain {
  display: flex;
  flex-direction: column;
  position: relative;
}

.mcd-chain-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mcd-chain-header-icon {
  color: var(--md-sys-color-tertiary);
  font-size: 18px;
}

.mcd-blocks-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px; /* block spacing */
  position: relative;
}

/* Block Item */
.mcd-block-item {
  background: var(--md-sys-color-surface-container-highest);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: background-color 0.2s;
  padding: 8px 12px 8px 16px; 
}

/* Left colored stripe */
.mcd-block-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.mcd-block-item.type-i::before { background-color: #f57c00; } /* Impulse Orange */
.mcd-block-item.type-c::before { background-color: #388e3c; } /* Chain Green */
.mcd-block-item.type-r::before { background-color: #5e35b1; } /* Repeat Purple */
.mcd-block-item.type-h::before { background-color: #546e7a; } /* Chat Blue Grey */

.mcd-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.mcd-block-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

.mcd-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.mcd-badge.type-i { background: rgba(245,124,0,0.1); color: #f57c00; }
.mcd-badge.type-c { background: rgba(56,142,60,0.1); color: #388e3c; }
.mcd-badge.type-r { background: rgba(94,53,177,0.1); color: #5e35b1; }
.mcd-badge.type-h { background: rgba(84,110,122,0.1); color: #546e7a; }

.mcd-badge.cond { background: rgba(255,213,79,0.2); color: #f57f17; }
.mcd-badge.auto { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.mcd-badge.rs { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.mcd-badge.tick { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }

/* Command Core */
.mcd-block-cmd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--md-sys-color-on-surface);
  word-break: break-all;
  white-space: pre-wrap;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.mcd-block-cmd-text {
  flex: 1;
}

/* Raw Legacy Command Line */
.mcd-raw-cmd-item {
  background: var(--md-sys-color-surface-container-highest);
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 8px 12px;
  transition: background-color 0.2s;
}

.mcd-raw-cmd-item:hover .mcd-btn-copy-line {
  opacity: 1;
  transform: scale(1);
}

/* Hover Quick Copy */
.mcd-btn-copy-line {
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.2s;
  background: var(--md-sys-color-surface-variant);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--md-sys-color-on-surface);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mcd-block-item:hover .mcd-btn-copy-line {
  opacity: 1;
  transform: scale(1);
}
.mcd-btn-copy-line:hover {
  background: var(--md-sys-color-outline-variant);
}

/* Comment UI Element */
.mcd-comment-item {
  color: var(--md-sys-color-outline);
  font-size: 12px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-left: 2px solid var(--md-sys-color-outline-variant);
  margin-left: 12px;
  font-style: italic;
}

/* Meta Section in Visual */
.mcd-meta-section {
  background: var(--md-sys-color-surface-container);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--md-sys-color-outline-variant);
}
.mcd-meta-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.mcd-meta-key { font-weight: 600; color: var(--md-sys-color-primary); }
.mcd-meta-val { color: var(--md-sys-color-on-surface); }

.mcd-image-item {
  width: 100%;
  margin: 0;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 12px;
  overflow: hidden;
  background: var(--md-sys-color-surface-container);
}

.mcd-image-preview {
  display: block;
  width: 100%;
  max-height: min(56vh, 640px);
  object-fit: contain;
  background: var(--md-sys-color-surface);
}

.mcd-image-error {
  padding: 18px;
  color: var(--md-sys-color-error);
  text-align: center;
  font-size: 13px;
}

.mcd-image-item.is-error {
  border-color: var(--md-sys-color-error);
}

/* ─── Featured Card ─── */
.featured-card {
  border: 2px solid var(--md-sys-color-primary) !important;
  box-shadow: 0 4px 12px rgba(0, 90, 193, 0.15) !important;
  position: relative;
}

/* 角标和标题同处首行，必须给标题预留宽度，避免长标题压到角标下面。 */
.featured-card .cmd-title {
  padding-right: 112px !important;
}

.featured-card::before {
  content: "精选推荐 ★";
  position: absolute;
  top: 8px;
  right: 8px;
  background: linear-gradient(135deg, #FFD54F, #FF8F00);
  color: #4a3100;
  padding: 5px 10px;
  border: 1px solid rgba(105, 67, 0, 0.18);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(105, 67, 0, 0.18);
  pointer-events: none;
}

/* ─── Action Buttons ─── */
.action-btn-sm {
  width: 32px;
  height: 32px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
}

.action-btn-sm:hover {
  background-color: var(--md-sys-state-hover);
}




/* ─── Captcha Overlay ─── */






/* ─── Profile Text ─── */
.profile-text {
  font-size: 14px;
  font-weight: 500;
}

/* ─── Custom Scrollbar ─── */





/* ─── Toast ─── */
.md-toast {
  background-color: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toast-slide-up 0.3s cubic-bezier(0.2, 0, 0, 1);
  max-width: 400px;
  word-break: break-all;
  margin-top: 10px;
}

@keyframes toast-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
/* ===========================
   Mobile Optimization (MD3)
   =========================== */
@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }
  
  .top-app-bar {
    gap: 8px;
    padding: 0 8px;
    height: 56px;
  }

  .search-area {
    flex: 1;
    min-width: 0;
  }

  .search-field {
    max-width: 100%;
  }

  .logo-area {
    width: auto;
  }

  .app-title {
    display: none;
  }

  .main-body {
    flex-direction: column-reverse;
  }

  .side-nav {
    width: 100%;
    height: auto;
    flex-direction: column;
    padding: 0;
    border-right: none;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    background-color: var(--md-sys-color-surface-container);
    position: relative;
    z-index: 5;
  }
  
  /* 移动端 tab 铺满显示为底部栏的效果 */
  .side-nav .md-tabs {
    flex-direction: row;
    padding: 0;
    justify-content: space-around;
  }

  .side-nav .md-tab {
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    border-radius: 0;
    flex: 1;
    font-size: 12px;
  }
  
  .side-nav .md-tab .material-symbols-outlined {
    font-size: 24px;
  }
  
  .side-nav .md-tab.active {
    background: transparent;
    color: var(--md-sys-color-primary);
  }

  .nav-spacer {
    display: none;
  }

  .nav-bottom-actions {
    position: fixed;
    bottom: 80px;
    right: 16px;
    padding: 0;
    z-index: 100;
  }

  #library-view {
    padding: 16px;
  }

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

  .detail-dialog {
    min-width: 95vw;
  }

  .detail-meta > div {
    flex-wrap: wrap;
  }
}

/* ─── MD3 Snackbar (Toast) ─── */









