:root {
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-sidebar: rgba(13, 19, 33, 0.95);
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-subtle: rgba(22, 31, 50, 0.5);
  --bg-input: rgba(15, 23, 42, 0.9);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-focus: #6366f1;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.28);
  --accent-light: #818cf8;
  --accent-bg: rgba(99, 102, 241, 0.12);
  
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.12);
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.12);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 290px;
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-sidebar: rgba(255, 255, 255, 0.95);
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-subtle: rgba(241, 245, 249, 0.85);
  --bg-input: #ffffff;
  
  --border-color: rgba(0, 0, 0, 0.08);
  --border-subtle: rgba(0, 0, 0, 0.04);
  --border-focus: #4f46e5;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent-primary: #4f46e5;
  --accent-hover: #4338ca;
  --accent-glow: rgba(79, 70, 229, 0.2);
  --accent-light: #6366f1;
  --accent-bg: rgba(79, 70, 229, 0.08);
  
  --shadow-card: 0 10px 30px -10px rgba(15, 23, 42, 0.08), 0 0 1px 1px rgba(0, 0, 0, 0.04);
}

/* Light Theme Specific Component Overrides */
[data-theme="light"] .portal-header {
  background: rgba(255, 255, 255, 0.88);
}

[data-theme="light"] .brand-name {
  background: linear-gradient(to right, #0f172a, #334155);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .sidebar {
  background: var(--bg-sidebar);
}

[data-theme="light"] .sidebar-search-input {
  background: #ffffff;
  border-color: var(--border-color);
  color: var(--text-primary);
}

[data-theme="light"] .sidebar-search-input:focus {
  background: #ffffff;
}

[data-theme="light"] .nav-item {
  color: var(--text-secondary);
}

[data-theme="light"] .nav-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}

[data-theme="light"] .nav-item.active {
  background: var(--accent-bg);
  color: var(--accent-primary);
  border-color: rgba(79, 70, 229, 0.25);
}

[data-theme="light"] .nav-item.active .nav-icon {
  color: var(--accent-primary);
}

[data-theme="light"] .btn-secondary {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
  border-color: var(--border-color);
}

[data-theme="light"] .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .result-item {
  background: #f8fafc;
  border-color: var(--border-color);
}

[data-theme="light"] .result-val {
  color: #4338ca;
}

[data-theme="light"] .input-control:focus {
  background: #ffffff;
}

[data-theme="light"] .drop-zone {
  background: rgba(241, 245, 249, 0.6);
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .preview-container {
  background: #f1f5f9;
  border-color: var(--border-color);
}

[data-theme="light"] .toast-msg {
  background: #0f172a;
  border-color: #334155;
  color: #fff;
}

/* Theme Toggle Button Icons */
[data-theme="light"] #themeToggleBtn .theme-icon-sun {
  display: none !important;
}
[data-theme="light"] #themeToggleBtn .theme-icon-moon {
  display: block !important;
}
[data-theme="dark"] #themeToggleBtn .theme-icon-sun {
  display: block !important;
}
[data-theme="dark"] #themeToggleBtn .theme-icon-moon {
  display: none !important;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
}

/* 背景光晕装饰 */
.bg-decorations {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.aurora-orb-1 {
  position: absolute;
  top: -15%;
  left: 15%;
  width: 55vw;
  height: 55vw;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, rgba(99, 102, 241, 0) 70%);
  filter: blur(90px);
  border-radius: 50%;
}

.aurora-orb-2 {
  position: absolute;
  top: 40%;
  right: -10%;
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.1) 0%, rgba(168, 85, 247, 0) 70%);
  filter: blur(100px);
  border-radius: 50%;
}

/* 顶部导航 Header */
.portal-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  height: 64px;
}

.header-inner {
  max-width: 1680px;
  height: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.menu-toggle-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 0.45rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.menu-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.7rem;
  padding: 2px 7px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 999px;
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}

/* 主布局架构：侧边栏 + 独立工作区 */
.app-layout {
  display: flex;
  min-height: calc(100vh - 64px);
  max-width: 1680px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* 侧边栏导航 */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
  overflow-y: auto;
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 5px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* 侧边栏搜索框 */
.sidebar-search {
  position: relative;
}

.sidebar-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.sidebar-search-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem 0.55rem 2.25rem;
  font-size: 0.82rem;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.sidebar-search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
  background: rgba(20, 30, 55, 0.95);
}

/* 工具分组与项目 */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.4rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: #ffffff;
  background: var(--accent-bg);
  border-color: rgba(99, 102, 241, 0.35);
  font-weight: 600;
}

.nav-item.active .nav-icon {
  color: var(--accent-light);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: var(--transition);
}

.nav-item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-tools-found {
  display: none;
  padding: 1.5rem 0.75rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* 侧边栏遮罩 (移动端) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 45;
  opacity: 0;
  transition: opacity 0.25s ease;
}

/* 主工作区 Workspace */
.workspace {
  flex: 1;
  min-width: 0;
  padding: 2.25rem 3rem 6rem;
  position: relative;
}

/* 专属工具舞台 Tool Stage */
.tool-stage {
  display: none;
  animation: stageFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tool-stage.active {
  display: block;
}

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

/* 工具舞台头部 */
.stage-header {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5rem;
}

.stage-top-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stage-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stage-breadcrumb-cat {
  color: var(--accent-light);
  font-weight: 600;
}

.stage-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.stage-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stage-title svg {
  color: var(--accent-primary);
  flex-shrink: 0;
}

.stage-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 900px;
}

/* 工作区卡片 */
.workspace-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.85rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.workspace-card + .workspace-card {
  margin-top: 1.5rem;
}

.card-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.85rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* 响应式多栏布局 */
.split-workspace-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
}

.split-workspace-aside {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 2rem;
}

/* 表单与输入控件 */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.form-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-control, textarea.input-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
  resize: vertical;
  line-height: 1.5;
}

.input-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: rgba(22, 33, 58, 0.95);
}

select.input-control {
  cursor: pointer;
  padding-right: 2rem;
}

/* 按钮组与通用按钮 */
.btn-row {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-sm {
  padding: 0.38rem 0.75rem;
  font-size: 0.78rem;
}

/* 结果卡片网格与项 */
.result-grid-hash {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.85rem;
}

.result-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: rgba(10, 15, 28, 0.7);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.result-item:hover {
  border-color: rgba(99, 102, 241, 0.3);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.result-val {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: #a5b4fc;
  word-break: break-all;
  user-select: all;
  line-height: 1.4;
}

/* 拖拽上传区 */
.drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-lg);
  padding: 2.25rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.08);
}

.drop-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
}

/* 进度条 */
.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  display: none;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #10b981);
  width: 0%;
  transition: width 0.15s ease;
}

/* 预览容器 */
.preview-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  background: rgba(5, 8, 16, 0.6);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  overflow: hidden;
  position: relative;
}

.preview-container img, .preview-container svg {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
}

/* 提示气泡 Toast */
.toast-msg {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1e293b;
  border: 1px solid #334155;
  color: #fff;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  font-size: 0.88rem;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-msg.show {
  opacity: 1;
  transform: translateY(0);
}

/* 媒体查询响应式适配 */
@media (max-width: 1100px) {
  .split-workspace-aside {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .menu-toggle-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
    background: #0d1322;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
  }

  .workspace {
    padding: 1.5rem 1.25rem 5rem;
  }

  .split-workspace-2col {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

@media (max-width: 640px) {
  .stage-title {
    font-size: 1.45rem;
  }
  .stage-desc {
    font-size: 0.88rem;
  }
  .workspace-card {
    padding: 1.25rem;
  }
}
