/* 公共样式 - 在线工具集 */
:root {
  --bg: #f8fafc;
  --surface: #fff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #dbeafe;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --transition: all 0.3s ease;
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --accent-light: #1e3a8a;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -2px rgba(0,0,0,0.25);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5), 0 10px 10px -5px rgba(0,0,0,0.4);
  }
}

/* 手动切换暗色模式 */
body.dark-mode {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --accent-light: #1e3a8a;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -2px rgba(0,0,0,0.25);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5), 0 10px 10px -5px rgba(0,0,0,0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* 头部 */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.logo {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--text);
  text-decoration: none;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo:hover {
  color: var(--accent);
  transform: translateY(-2px);
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 1.5rem;
  padding: 0.5rem 0;
  transition: var(--transition);
  position: relative;
}

.nav a:hover {
  color: var(--accent);
}

.nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: var(--transition);
}

.nav a:hover::after {
  width: 100%;
}

/* 主题切换按钮 */
.theme-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 1.5rem;
  padding: 0.5rem;
  border-radius: 50%;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle-btn:hover {
  color: var(--accent);
  background: var(--accent-light);
  transform: rotate(180deg);
}

/* 暗色模式下的主题切换按钮 */
body.dark-mode .theme-toggle-btn {
  color: var(--accent);
}

/* 主内容 */
.site-main {
  flex: 1;
  padding: 2rem 0;
}

.site-main h1 {
  margin: 0 0 0.5rem;
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 1rem;
}

.lead {
  margin: 0 0 2rem;
  color: var(--text-muted);
  font-size: 1.1rem;
  text-align: center;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

/* 搜索功能 */
.search-container {
  display: flex;
  max-width: 600px;
  margin: 0 auto 3rem;
  gap: 0.5rem;
  padding: 0 1rem;
}

.search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-btn {
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

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

/* 响应式搜索 */
@media (max-width: 480px) {
  .search-container {
    flex-direction: column;
  }
  
  .search-btn {
    width: 100%;
  }
}

/* 分类与工具列表 */
.tool-category {
  margin-bottom: 3rem;
}

.tool-category h2 {
  margin: 0 0 1.5rem;
  font-size: 1.25rem;
  color: var(--text-muted);
  font-weight: 600;
  padding-left: 0.5rem;
  border-left: 4px solid var(--accent);
}

.tool-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.tool-list li {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.favorite-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
  box-shadow: var(--shadow);
  z-index: 10;
}

.favorite-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
  transform: scale(1.1);
}

.favorite-btn.favorited {
  background: var(--accent);
  color: white;
}

.favorite-btn.favorited:hover {
  background: var(--accent-hover);
}

.tool-list li::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent);
  transition: left 0.6s ease;
}

.tool-list li:hover::before {
  left: 100%;
}

.tool-list li:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-xl);
  border-color: var(--accent);
}

.tool-list a {
  display: block;
  padding: 1.5rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.tool-list a:hover {
  background: var(--accent-light);
  text-decoration: none;
}

.tool-list strong {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.tool-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.tool-list .placeholder {
  color: var(--text-muted);
}

/* 工具页通用 */
.tool-page h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.tool-page .back {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.tool-page .back:hover {
  color: var(--accent);
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.tool-card h3 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
  width: 100%;
  max-width: 400px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.form-group input[type="file"] {
  padding: 0.35rem 0;
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.w-full {
  max-width: 100% !important;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 120px;
}

/* 按钮 */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
}

/* 预览与结果区 */
.preview-box {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-box img {
  max-width: 100%;
  max-height: 320px;
  display: block;
}

.preview-box canvas {
  max-width: 100%;
  display: block;
}

/* 预览区 - 固定高度 + 滚动条，图片保持原始尺寸 */
.preview-box--scroll {
  height: 320px;
  overflow: auto;
}

.preview-box--scroll img {
  max-width: none;
  max-height: none;
}

.preview-placeholder {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* 页脚 */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  margin-top: auto;
}

.site-footer p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .site-main h1 {
    font-size: 2rem;
  }
  
  .lead {
    font-size: 1rem;
    padding: 0 1rem;
  }
  
  .tool-list {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .tool-list li {
    margin: 0 0.5rem;
  }
  
  .tool-list a {
    padding: 1.25rem;
  }
  
  .tool-category {
    margin-bottom: 2rem;
  }
  
  .site-header .container {
    padding: 0.75rem 1rem;
  }
  
  .logo {
    font-size: 1.25rem;
  }
  
  .nav a {
    margin-left: 1rem;
  }
}

@media (max-width: 480px) {
  .site-main {
    padding: 1.5rem 0;
  }
  
  .site-main h1 {
    font-size: 1.75rem;
  }
  
  .lead {
    font-size: 0.9rem;
  }
  
  .tool-list a {
    padding: 1rem;
  }
  
  .tool-list strong {
    font-size: 1rem;
  }
  
  .tool-desc {
    font-size: 0.85rem;
  }
}

/* 复选框组 */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

/* 密码列表 */
.password-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.password-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.password-text {
  font-family: monospace;
  word-break: break-all;
}

/* 倒计时显示 */
.countdown-display {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.countdown-item {
  text-align: center;
}

.countdown-number {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  font-family: monospace;
}

.countdown-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

@media (max-width: 480px) {
  .countdown-display {
    gap: 1rem;
  }
  
  .countdown-number {
    font-size: 1.5rem;
  }
  
  .countdown-label {
    font-size: 0.8rem;
  }
}
