:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --text: #1d2433;
  --sub: #6b7280;
  --line: #e5e7eb;
  --primary: #111827;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: var(--text);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.title { margin: 0 0 8px; font-size: 28px; color: #fff; }
.subtitle { margin: 0 0 22px; color: #ecebff; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  text-decoration: none;
  color: inherit;
  display: block;
}
.card:hover { box-shadow: 0 8px 24px rgba(0, 0, 0, .06); }
.card h3 { margin: 0 0 8px; font-size: 28px; font-weight: 700; }
.card p { margin: 0 0 16px; color: var(--sub); font-size: 18px; }
.card .use { padding-top: 12px; border-top: 1px solid var(--line); color: #374151; }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.work {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.box {
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 320px;
  padding: 10px;
  background: #fcfcfd;
}
.box img, .box canvas {
  max-width: 100%;
  max-height: 420px;
  display: block;
  margin: 0 auto;
}
.box pre {
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

.log {
  margin-top: 12px;
  background: #0b1020;
  color: #d1d5db;
  border-radius: 12px;
  padding: 10px;
  min-height: 90px;
  max-height: 240px;
  overflow: auto;
  font-family: Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

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

/* 子目录图片工具页面侧栏导航 */
.img-layout {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-areas: "sidebar main";
  gap: 18px;
  align-items: start;
  padding: 16px 10px 36px;
}
.img-sidebar { grid-area: sidebar; padding: 16px; position: sticky; top: 16px; }
.img-main { grid-area: main; min-width: 0; }
.img-sidebar .brand { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: #4b5ad9; }
.img-sidebar .desc { font-size: 13px; color: #666; line-height: 1.5; margin-bottom: 14px; }
.img-sidebar .jump-home {
  display: block; width: 100%; text-align: center; text-decoration: none;
  background: #4b5ad9; color: #fff; border-radius: 10px; padding: 10px 12px; font-weight: 600; margin-bottom: 14px;
}
.img-sidebar .group-title { font-size: 13px; color: #666; margin: 12px 0 8px; }
.tool-nav { list-style: none; display: grid; gap: 8px; margin: 0; padding: 0; }
.tool-link {
  display: block; border: 1px solid #ececf2; border-radius: 10px; padding: 10px 12px;
  text-decoration: none; color: #333; font-size: 14px; background: #fff;
}
.tool-link .nav-short { display: none; }
.tool-link.active { border-color: #4b5ad9; background: #eef1ff; color: #3747c7; font-weight: 600; }

.mobile-topbar {
  display: none; position: fixed; left: 0; right: 0; top: 0; z-index: 40; align-items: center; gap: 8px;
  padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: rgba(255, 255, 255, 0.96); border-bottom: 1px solid rgba(0, 0, 0, 0.06); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}
.mobile-topbar .nav-back {
  flex: 0 0 auto; text-decoration: none; color: #4b5ad9; font-weight: 600; font-size: 14px; padding: 6px 8px; border-radius: 8px; background: #eef1ff;
}
.mobile-topbar .nav-title {
  flex: 1; min-width: 0; font-size: 14px; font-weight: 700; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mobile-topbar .nav-more {
  flex: 0 0 auto; border: 1px solid #d6daf5; background: #fff; color: #4b5ad9;
  font-weight: 600; font-size: 13px; padding: 8px 12px; border-radius: 10px; cursor: pointer;
}
.nav-sheet {
  display: none; position: fixed; inset: 0; z-index: 50; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, 0.45);
}
.nav-sheet.open { display: flex; }
.nav-sheet-panel {
  width: 100%; max-height: min(72vh, 520px); background: #fff; border-radius: 18px 18px 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px)); overflow: auto; box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
}
.nav-sheet-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
  padding-bottom: 8px; border-bottom: 1px solid #eee; font-weight: 700; color: #333;
}
.nav-sheet-close {
  border: none; background: #f3f4f6; color: #333; width: 36px; height: 36px; border-radius: 10px; font-size: 18px; line-height: 1; cursor: pointer;
}

@media (max-width: 930px) {
  body { padding-top: calc(56px + env(safe-area-inset-top, 0px)); }
  .mobile-topbar { display: flex; }
  .img-layout { grid-template-columns: 1fr; grid-template-areas: "main"; padding: 6px 4px 22px; }
  .img-sidebar { display: none; }
}
