:root {
  --bg: #eef1f6;
  --panel: #ffffff;
  --panel-2: #f6f8fb;
  --text: #1c2537;
  --muted: #6b7690;
  --line: #dde3ee;
  --accent: #2364d2;
  --accent-2: #12a06b;
  --accent-3: #e07b1f;
  --danger: #cf3d3d;
  --sidebar: #141b2b;
  --sidebar-text: #c8d1e2;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 27, 43, .06), 0 8px 24px rgba(20, 27, 43, .06);
  --shadow-lift: 0 2px 6px rgba(20, 27, 43, .08), 0 16px 36px rgba(20, 27, 43, .12);
  --ring: 0 0 0 3px rgba(35, 100, 210, .16);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.shell { display: flex; height: 100vh; }

.sidebar {
  width: 280px;
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-text);
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 16px 14px; }
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2f7df6, #12a06b);
  color: #fff; font-weight: 800; font-size: 19px;
  border-radius: 10px;
}
.brand-text { min-width: 0; line-height: 1.35; }
.brand-text strong { display: block; color: #fff; font-size: 15px; white-space: nowrap; }
.brand-text span { font-size: 11px; color: #7f8aa3; }
.search-box { padding: 0 14px 12px; }
.search-box input {
  width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid rgba(255,255,255,.12); border-radius: 7px;
  background: rgba(255,255,255,.07); color: #fff;
  outline: none;
}
.search-box input::placeholder { color: #8a94aa; }
.search-box input:focus { border-color: rgba(255,255,255,.35); }
.tool-nav { flex: 1 1 auto; overflow-y: auto; padding: 0 10px 12px; }
.tool-nav::-webkit-scrollbar, .view::-webkit-scrollbar { width: 8px; height: 8px; }
.tool-nav::-webkit-scrollbar-thumb, .view::-webkit-scrollbar-thumb { background: rgba(120,135,165,.35); border-radius: 8px; }
.nav-group { margin: 2px 0 10px; }
.nav-group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 5px; color: #94a0b8;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
}
.nav-group-head b { font-weight: 700; }
.nav-group-head span { margin-left: auto; color: #5e6b84; }
.nav-link {
  display: flex; align-items: center; gap: 9px;
  width: 100%; min-height: 36px; padding: 7px 10px;
  border: 0; border-radius: 7px;
  background: transparent; color: #cbd4e5;
  text-align: left; white-space: nowrap; overflow: hidden;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.on { background: var(--accent); color: #fff; }
.nav-link { transition: background .15s, color .15s, transform .12s; }
.nav-link:hover { transform: translateX(2px); }
.nav-link.on:hover { background: #1f5fbf; transform: none; }
.nav-link .ico { width: 20px; flex: 0 0 20px; text-align: center; opacity: .9; font-size: 15px; }
.nav-link .name { overflow: hidden; text-overflow: ellipsis; }
.privacy-note {
  display: flex; align-items: center; gap: 7px;
  margin: 8px 14px 14px; padding: 9px 10px;
  border: 1px solid rgba(255,255,255,.08); border-radius: 8px;
  color: #8b96ad; font-size: 11px;
}
.privacy-note .dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #43d18d; }
.app-dl {
  display: block; margin: 0 14px 14px; padding: 9px 12px;
  border: 1px solid rgba(255,255,255,.16); border-radius: 8px;
  background: rgba(255,255,255,.06); color: #dbe4f5;
  font-size: 12px; text-align: center; text-decoration: none;
}
.app-dl:hover { background: rgba(255,255,255,.12); color: #fff; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; flex: 0 0 58px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.crumb .sep { color: #9aa4b8; }
.crumb .t-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.text-link { color: var(--muted); font-size: 12px; }
.text-link:hover { color: var(--accent); }
.icon-btn {
  width: 36px; height: 36px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--panel); color: var(--text);
  font-size: 16px; line-height: 1;
}
.icon-btn:hover { border-color: #aebad0; }
.menu-btn { display: none; }
.view { flex: 1 1 auto; overflow-y: auto; outline: none; }
.scrim {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(10,16,28,.45);
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.page-wrap { max-width: 1060px; margin: 0 auto; padding: 28px 24px 60px; }
.hero {
  display: flex; align-items: center; gap: 18px;
  padding: 22px 24px;
  border: 1px solid var(--line); border-radius: 10px;
  background: linear-gradient(120deg, #ffffff 0%, #eef4ff 100%);
  box-shadow: var(--shadow);
}
.hero-icon {
  width: 54px; height: 54px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2f7df6, #12a06b);
  border-radius: 12px; color: #fff; font-size: 25px;
}
.hero h1 { margin: 0; font-size: 22px; line-height: 1.3; }
.hero p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.hero-btn {
  display: inline-flex; align-items: center; gap: 8px;
  margin-left: auto; padding: 10px 16px;
  border-radius: 8px;
  background: #2364d2; color: #fff;
  font-size: 13px; font-weight: 600; text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(35,100,210,.28);
  transition: transform .15s, box-shadow .15s, background .15s;
}
.hero-btn:hover { background: #1a53b3; color: #fff; transform: translateY(-1px); box-shadow: 0 12px 28px rgba(35,100,210,.36); }
.hero-btn:active { transform: translateY(0); box-shadow: none; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 18px; }
.tool-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px; min-height: 112px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); cursor: pointer;
  text-align: left; color: var(--text);
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.tool-card:hover { border-color: #a9bade; box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.tool-card .t-ico {
  width: 40px; height: 40px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 9px; font-size: 20px;
  background: #edf3ff; color: var(--accent);
  transition: transform .16s, background .16s;
}
.tool-card:hover .t-ico { background: #e3edff; transform: scale(1.08) rotate(-3deg); }
.tool-card .t-body { min-width: 0; }
.tool-card .t-name { font-size: 14px; font-weight: 700; }
.tool-card .t-desc { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tool-card .t-tag { display: inline-block; margin-top: 8px; padding: 1px 8px; border-radius: 99px; background: #e8f7ef; color: #0c7a4b; font-size: 11px; }
.tool-card .t-tag.server { background: #fff1e3; color: #a15c13; }
.coming-note {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border: 1px dashed #c6d0e1; border-radius: var(--radius);
  background: #fbfcfe; color: #69748b; font-size: 13px;
}

.tool-head { margin-bottom: 16px; }
.tool-head h2 { margin: 0; font-size: 20px; }
.tool-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 13px;
}
.panel-head .hint { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 12px; }
.panel-body { padding: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 12px; align-items: center; }
.row:last-child { margin-bottom: 0; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 150px; }
.field label { font-size: 12px; color: var(--muted); }
.field input[type=number], .field input[type=text], .field input[type=file], .field select {
  min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--panel); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input[type=number]:focus, .field input[type=text]:focus, .field select:focus, textarea.code:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.dropzone {
  display: grid; place-items: center; min-height: 170px;
  padding: 20px; border: 1.5px dashed #b9c5d9; border-radius: var(--radius);
  background: var(--panel-2); text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: #f0f6ff; }
.dropzone { transition: border-color .16s, background .16s, transform .12s; }
.dropzone:hover { transform: translateY(-1px); }
.dropzone .dz-title { font-size: 15px; font-weight: 700; }
.dropzone .dz-sub { margin-top: 5px; color: var(--muted); font-size: 12px; }
.dropzone input[type=file] { display: none; }
.file-list { margin-top: 12px; display: grid; gap: 7px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; font-size: 13px;
}
.file-item .fi-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .fi-size { color: var(--muted); font-size: 11px; }
.file-item .fi-x { border: 0; background: none; color: #a0a9ba; padding: 2px 6px; }
.file-item .fi-x:hover { color: var(--danger); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 7px 16px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--panel); color: var(--text); font-size: 13px;
  box-shadow: 0 1px 2px rgba(20,27,43,.04);
  transition: transform .12s, box-shadow .15s, border-color .15s, background .15s;
}
.btn:hover { border-color: #aab6cd; box-shadow: 0 4px 12px rgba(20,27,43,.08); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, #2f7df6, #1d5fd0); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(35,100,210,.24); }
.btn.primary:hover { background: #1a53b3; }
.btn.success { background: linear-gradient(135deg, #16b877, #0f9a63); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(18,160,107,.22); }
.btn.success:hover { background: #0d8756; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.progress { height: 8px; border-radius: 99px; background: #e2e7f0; overflow: hidden; margin: 12px 0 6px; }
.progress > i { display: block; width: 0%; height: 100%; border-radius: 99px; background: var(--accent); transition: width .2s; }
.status { font-size: 12px; color: var(--muted); }
.status.error { color: var(--danger); }
.status.ok { color: var(--accent-2); }
.status.busy { color: #a15c13; }
.downloads { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.result-box {
  margin-top: 12px; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #f9fbfe;
}
.page-grid { display: grid; gap: 8px; max-height: 380px; overflow-y: auto; padding-right: 2px; }
.page-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 7px; background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
.page-row:hover { border-color: #b7c6e4; box-shadow: 0 2px 8px rgba(20,27,43,.06); }
.page-row .pg-no { width: 34px; flex: 0 0 auto; text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; }
.page-row .pg-bar { flex: 1 1 auto; height: 8px; border-radius: 99px; background: #edf0f6; overflow: hidden; }
.page-row .pg-bar > i { display: block; height: 100%; border-radius: 99px; background: #cbd8f0; }
.page-row .pg-btns { display: flex; gap: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border: 1px solid var(--line); border-radius: 99px;
  background: #fff; color: var(--muted); font-size: 12px; user-select: none;
  transition: border-color .12s, background .12s, color .12s;
}
.chip:hover { border-color: #b3c3e2; color: var(--text); }
.chip input { accent-color: var(--accent); }
.toggle-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.switch { position: relative; width: 38px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; inset: 0; margin: 0; }
.switch i {
  position: absolute; inset: 0; border-radius: 99px;
  background: #ccd3e1; transition: background .15s;
}
.switch i::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + i { background: var(--accent-2); }
.switch input:checked + i::after { transform: translateX(16px); }
textarea.code {
  width: 100%; min-height: 190px; padding: 12px;
  border: 1px solid var(--line); border-radius: 7px;
  background: #f6f8fc; color: #28334c;
  font: 12.5px/1.6 var(--mono);
  resize: vertical; tab-size: 2;
}
.split-pane { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.preview { max-width: 100%; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.preview-img { max-width: 100%; display: block; border-radius: 7px; }
.canvas-host { display: grid; place-items: center; background: repeating-conic-gradient(#f1f3f8 0% 25%, #fff 0% 50%) 0 0 / 22px 22px; border: 1px solid var(--line); border-radius: 7px; min-height: 120px; }
.canvas-host canvas { max-width: 100%; }
.sample-box { padding: 10px 12px; border-radius: 7px; background: #fff; border: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; }
.kbd { padding: 1px 6px; border: 1px solid #ccd3e1; border-bottom-width: 2px; border-radius: 5px; background: #fff; color: #5b667c; font: 11px var(--mono); }

/* Theme: dark */
body.dark {
  --bg: #10141f; --panel: #1b2233; --panel-2: #141a28;
  --text: #e7ebf5; --muted: #93a0ba; --line: #2a344b;
  --sidebar: #0b0f19;
}
body.dark .hero { background: linear-gradient(120deg, #1b2233, #172236); }
body.dark .dropzone, body.dark textarea.code, body.dark .result-box, body.dark .sample-box, body.dark .canvas-host { background: #141a28; }
body.dark .file-item, body.dark .page-row, body.dark .chip { background: #1e2639; }
body.dark .page-row .pg-bar { background: #2a344b; }
body.dark .icon-btn { background: var(--panel); }

@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .2s; width: min(84vw, 320px); }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-grid; }
  .split-pane { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .topbar { padding: 0 12px; }
  .page-wrap { padding: 18px 14px 46px; }
  .tool-grid { grid-template-columns: 1fr 1fr; }
  .hero { padding: 16px; }
  .hero-btn { margin-left: 0; }
  .field { flex: 1 1 100%; }
}
