/* ===== 万能工具箱 v2 - 精装修版 ===== */
:root {
  --bg: #f0f2f8;
  --surface: #ffffff;
  --surface2: #f6f8fc;
  --text: #1a1a2e;
  --text2: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-light: #eef2ff;
  --primary-gradient: linear-gradient(135deg, #4f46e5, #7c3aed);
  --accent: #f59e0b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 4px 20px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 32px rgba(79,70,229,0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --nav-bg: rgba(255,255,255,0.8);
  --code-bg: #f1f3f5;
}

[data-theme="dark"] {
  --bg: #0c0c1a;
  --surface: #1a1a2e;
  --surface2: #1f1f3a;
  --text: #eaeaf0;
  --text2: #9494b0;
  --border: #2a2a4a;
  --primary: #7c8aff;
  --primary-light: #1a1a40;
  --primary-gradient: linear-gradient(135deg, #7c8aff, #a78bfa);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(124,138,255,0.2);
  --nav-bg: rgba(12,12,26,0.85);
  --code-bg: #1a1a30;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .3s, color .3s;
}

/* ===== Header ===== */
.header {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  height: 64px;
}
.header-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 100%;
}
.logo {
  font-size: 1.25rem; font-weight: 800;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-decoration: none; letter-spacing: -0.5px;
}
.header-right { display: flex; align-items: center; gap: 12px; }
.search-box { position: relative; }
.search-box input {
  width: 220px; padding: 8px 36px 8px 16px;
  border: 1.5px solid var(--border); border-radius: 24px;
  background: var(--surface); color: var(--text);
  font-size: 0.9rem; outline: none;
  transition: all .3s;
}
.search-box input:focus { border-color: var(--primary); width: 280px; box-shadow: 0 0 0 3px var(--primary-light); }
.search-box input::placeholder { color: var(--text2); }
.search-icon {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%); font-size: 0.85rem;
  pointer-events: none; opacity: 0.5;
}
.theme-btn {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 50%; width: 38px; height: 38px;
  cursor: pointer; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s; color: var(--text);
}
.theme-btn:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ===== Layout ===== */
.layout { display: flex; margin-top: 64px; min-height: calc(100vh - 64px); }

/* ===== Sidebar ===== */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: sticky; top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
}
.nav-group { margin-bottom: 4px; }
.nav-group-title {
  padding: 12px 20px 6px;
  font-size: 0.7rem; font-weight: 700;
  color: var(--text2); text-transform: uppercase;
  letter-spacing: 0.8px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 20px 9px 24px;
  color: var(--text); text-decoration: none;
  font-size: 0.88rem; border-radius: 0;
  transition: all .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active {
  background: var(--primary-light); color: var(--primary);
  border-left-color: var(--primary); font-weight: 600;
}

/* ===== Main Content ===== */
.main-content { flex: 1; padding: 28px 32px; max-width: calc(1400px - 220px); }
.tool-panel { display: none; animation: fadeIn .3s ease; }
.tool-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.panel-title {
  font-size: 1.6rem; font-weight: 700; margin-bottom: 4px;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.panel-desc { color: var(--text2); margin-bottom: 20px; font-size: 0.95rem; }

/* ===== Hero Section ===== */
.hero {
  text-align: center; padding: 48px 20px 36px;
}
.hero h1 {
  font-size: 2.4rem; font-weight: 800; margin-bottom: 12px;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}
.hero-desc { color: var(--text2); margin-bottom: 28px; font-size: 1.05rem; }
.hero-search input {
  width: 100%; max-width: 480px; padding: 14px 24px;
  border: 2px solid var(--border); border-radius: 30px;
  font-size: 1rem; background: var(--surface); color: var(--text);
  outline: none; transition: all .3s;
}
.hero-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

/* ===== Tool Grid Cards ===== */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px; padding: 24px 0;
}
.tool-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 16px 20px;
  text-align: center; cursor: pointer;
  transition: all .3s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.tool-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--primary-gradient);
  opacity: 0; transition: opacity .3s;
}
.tool-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}
.tool-card:hover::before { opacity: 1; }
.card-icon { font-size: 2.5rem; margin-bottom: 10px; display: block; }
.card-name { font-weight: 700; margin-bottom: 6px; font-size: 0.95rem; }
.card-desc { font-size: 0.78rem; color: var(--text2); line-height: 1.4; }

/* ===== Form Elements ===== */
.tool-textarea {
  width: 100%; min-height: 150px;
  padding: 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 0.9rem; font-family: "Cascadia Code", "Fira Code", monospace;
  resize: vertical; outline: none;
  transition: all .2s; line-height: 1.6;
}
.tool-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.tool-textarea[readonly] { background: var(--surface2); cursor: default; }

.tool-input {
  padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font-size: 0.9rem;
  outline: none; width: 100%;
  transition: all .2s;
}
.tool-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.tool-select {
  padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font-size: 0.9rem;
  outline: none; cursor: pointer; width: 100%;
  transition: border-color .2s;
}
.tool-select:focus { border-color: var(--primary); }

.btn {
  padding: 11px 24px; border: none;
  border-radius: var(--radius-sm);
  background: var(--primary-gradient);
  color: #fff; font-size: 0.9rem;
  cursor: pointer; transition: all .3s;
  font-weight: 600; letter-spacing: 0.3px;
  box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(79,70,229,0.4); }
.btn:active { transform: translateY(0); }
.btn-sm { padding: 7px 16px; font-size: 0.82rem; box-shadow: none; }
.btn-sm:hover { box-shadow: 0 2px 8px rgba(79,70,229,0.3); }
.btn-outline {
  background: transparent; color: var(--primary);
  border: 1.5px solid var(--primary); box-shadow: none;
}
.btn-outline:hover { background: var(--primary-light); box-shadow: none; }

.btn-group {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 14px 0;
}

.input-row {
  display: flex; gap: 12px; margin-bottom: 14px;
  flex-wrap: wrap;
}
.input-group label {
  display: block; font-size: 0.82rem;
  color: var(--text2); margin-bottom: 5px; font-weight: 600;
}

/* ===== Stats ===== */
.stats-row {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin: 14px 0;
}
.stat-item {
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 12px 18px; text-align: center;
  flex: 1; min-width: 90px;
  border: 1px solid var(--border);
}
.stat-label { display: block; font-size: 0.72rem; color: var(--text2); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.3px; }
.stat-value { font-size: 1.4rem; font-weight: 800; background: var(--primary-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* ===== QR Code ===== */
.qr-result {
  display: flex; justify-content: center;
  margin: 20px 0; padding: 24px;
  background: #fff; border-radius: var(--radius);
  min-height: 200px; align-items: center;
  border: 1px solid var(--border);
}
[data-theme="dark"] .qr-result { background: var(--surface2); }

/* ===== Password ===== */
.pass-result {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface2); padding: 18px 22px;
  border-radius: var(--radius-sm); margin-bottom: 16px;
  font-size: 1.4rem; font-family: monospace; font-weight: 700;
  word-break: break-all; border: 1px solid var(--border);
}
.pass-opts { margin-bottom: 12px; }
.pass-opts label { padding: 6px 12px; background: var(--surface2); border-radius: 6px; border: 1px solid var(--border); }
.pass-strength {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px;
}
.strength-bar {
  height: 8px; border-radius: 4px; flex: 1;
  transition: all .3s;
}

/* ===== Checkbox ===== */
.checkbox-group {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 10px 0;
}
.checkbox-group label {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.88rem; cursor: pointer;
  padding: 6px 12px; background: var(--surface2);
  border-radius: 6px; border: 1px solid var(--border);
  transition: all .2s;
}
.checkbox-group label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}
.checkbox-group input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* ===== Color Preview ===== */
.color-preview {
  width: 100%; height: 100px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border); margin-top: 14px;
  transition: background .3s;
}

/* ===== Timestamp ===== */
.ts-result-box {
  background: var(--surface2); padding: 18px;
  border-radius: var(--radius-sm); margin: 12px 0;
  line-height: 2; border: 1px solid var(--border);
}

/* ===== Markdown ===== */
.md-layout {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; margin-bottom: 16px;
}
.md-input-wrap label, .md-output-wrap label {
  display: block; font-size: 0.82rem;
  color: var(--text2); margin-bottom: 6px; font-weight: 600;
}
.md-textarea { min-height: 450px; }
.md-output {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 20px;
  min-height: 450px; overflow-y: auto;
  line-height: 1.8;
}
.md-output h1, .md-output h2, .md-output h3 { margin: 16px 0 10px; }
.md-output h1 { font-size: 1.6em; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.md-output h2 { font-size: 1.3em; }
.md-output p { margin: 10px 0; }
.md-output ul, .md-output ol { padding-left: 24px; margin: 10px 0; }
.md-output li { margin: 4px 0; }
.md-output pre { background: var(--code-bg); padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; border: 1px solid var(--border); }
.md-output code { background: var(--code-bg); padding: 3px 8px; border-radius: 5px; font-size: 0.85em; }
.md-output blockquote { border-left: 4px solid var(--primary); padding-left: 16px; color: var(--text2); margin: 12px 0; }
.md-output img { max-width: 100%; border-radius: 8px; }

/* ===== Image Compressor ===== */
.img-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px; text-align: center;
  cursor: pointer; transition: all .3s;
  background: var(--surface2);
  margin: 16px 0;
}
.img-dropzone:hover, .img-dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.img-dropzone-icon { font-size: 3rem; margin-bottom: 12px; }
.img-dropzone-text { font-size: 1rem; color: var(--text2); margin-bottom: 8px; }
.img-dropzone-hint { font-size: 0.82rem; color: var(--text2); }
.img-preview { display: flex; gap: 20px; margin: 16px 0; flex-wrap: wrap; }
.img-preview-box {
  flex: 1; min-width: 200px; padding: 16px;
  background: var(--surface2); border-radius: var(--radius-sm);
  border: 1px solid var(--border); text-align: center;
}
.img-preview-box img { max-width: 100%; max-height: 250px; border-radius: 6px; margin-bottom: 8px; }
.img-preview-box .img-info { font-size: 0.82rem; color: var(--text2); }
.quality-slider { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.quality-slider input { flex: 1; accent-color: var(--primary); }

/* ===== Date Calculator ===== */
.date-picker-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 16px 0; }
.date-picker-box { flex: 1; min-width: 200px; }
.date-picker-box label { display: block; font-size: 0.85rem; color: var(--text2); margin-bottom: 6px; font-weight: 600; }
.date-picker-box input[type="date"] {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 0.95rem; outline: none;
  transition: border-color .2s;
}
.date-picker-box input[type="date"]:focus { border-color: var(--primary); }
.date-result-box {
  background: var(--primary-gradient); color: #fff;
  padding: 20px 24px; border-radius: var(--radius-sm);
  margin: 16px 0; text-align: center;
}
.date-result-box .result-big { font-size: 2.2rem; font-weight: 800; }
.date-result-box .result-label { font-size: 0.9rem; opacity: 0.85; margin-top: 4px; }
.date-result-detail { margin-top: 12px; font-size: 0.85rem; opacity: 0.9; }

/* ===== Draw / Lucky ===== */
.draw-container { text-align: center; padding: 32px 0; }
.draw-btn {
  width: 160px; height: 160px; border-radius: 50%;
  background: var(--primary-gradient);
  color: #fff; border: none; font-size: 1.8rem;
  font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 32px rgba(79,70,229,0.35);
  transition: all .3s;
  margin: 16px auto; display: flex; align-items: center;
  justify-content: center;
}
.draw-btn:hover { transform: scale(1.05); box-shadow: 0 12px 40px rgba(79,70,229,0.45); }
.draw-btn:active { transform: scale(0.95); }
.draw-btn.spinning { animation: pulse 0.5s ease infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.draw-result {
  font-size: 2rem; font-weight: 800; margin: 20px 0;
  min-height: 60px;
}
.draw-list { margin: 16px 0; }
.draw-list textarea { min-height: 120px; }

/* ===== Hash ===== */
.hash-row { margin: 12px 0; display: flex; gap: 10px; flex-wrap: wrap; }
.hash-item {
  flex: 1; min-width: 200px; padding: 16px;
  background: var(--surface2); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.hash-item label { display: block; font-size: 0.82rem; color: var(--text2); margin-bottom: 8px; font-weight: 600; }
.hash-value {
  font-family: monospace; font-size: 0.82rem;
  word-break: break-all; line-height: 1.5;
}

/* ===== Ad Placeholder ===== */
.ad-placeholder {
  background: var(--surface2); color: var(--text2);
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 16px; text-align: center; font-size: 0.82rem;
}
.ad-inline { margin: 24px 0; }
.ad-side { margin: 20px 12px; }

/* ===== Footer ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px; background: var(--surface);
  margin-left: 220px;
}
.footer-inner { max-width: 1000px; margin: 0 auto; text-align: center; color: var(--text2); }
.footer-small { font-size: 0.8rem; margin-top: 8px; }
.footer-small a { color: var(--primary); text-decoration: none; }

hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ===== Toast ===== */
.toast-msg {
  position: fixed; bottom: 30px; left: 50%;
  transform: translateX(-50%);
  background: var(--surface); color: var(--text);
  padding: 14px 28px; border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 9999; font-weight: 600;
  border: 1px solid var(--border);
  animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ===== Match List ===== */
.match-list { margin: 8px 0; max-height: 200px; overflow-y: auto; }
.match-item {
  background: var(--surface2); padding: 6px 10px;
  border-radius: 6px; margin: 4px 0;
  font-family: monospace; font-size: 0.82rem;
  border: 1px solid var(--border);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; max-width: 100%; }
  .footer { margin-left: 0; }
  .tool-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tool-card { padding: 18px 12px; }
  .card-icon { font-size: 2rem; }
  .md-layout { grid-template-columns: 1fr; }
  .search-box input { width: 140px; }
  .search-box input:focus { width: 180px; }
  .hero h1 { font-size: 1.6rem; }
  .hero { padding: 32px 16px 24px; }
  .stats-row { gap: 6px; }
  .stat-item { min-width: 70px; padding: 8px 10px; }
  .stat-value { font-size: 1.1rem; }
  .input-row { flex-direction: column; gap: 8px; }
  .pass-result { font-size: 1.1rem; }
  .img-preview { flex-direction: column; }
  .draw-btn { width: 120px; height: 120px; font-size: 1.3rem; }
}
