/* 字体定义 */
@font-face {
  font-family: 'LXGW WenKai';
  src: url('./FiraCode-LXK.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'FiraCode LXK';
  src: url('./FiraCode-LXK.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* 公共样式 - 亮色主题 */
:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #3b82f6;
  --primary-600: #2563eb;
  --danger: #dc2626;
  --key: #1d4ed8;
  --str: #047857;
  --num: #b91c1c;
  --bool: #b45309;
  --nil: #7c3aed;
  --punct: #334155;
  --shadow: 0 10px 30px rgba(2,6,23,.12);
  --sidebar-width: 240px;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
/*   background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%); */
  color: var(--text);
  font-family: "FiraCode LXK", "LXGW WenKai", "霞鹜文楷", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", serif;
}

/* 布局 */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: calc(100vh - 56px);
}
.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-overlay { position: fixed; inset: 0; display: none; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); background: #ffffff; position: sticky; top: 0; z-index: 5; }
.menu-btn { 
  display: inline-flex; 
  align-items: center; 
  gap: 8px; 
  padding: 8px 10px; 
  border: 1px solid var(--border); 
  border-radius: 8px; 
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%); 
  cursor: pointer; 
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.menu-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: var(--primary);
}

.menu-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.menu-btn svg {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-btn:hover svg {
  transform: scale(1.1);
}

/* 工具集按钮波纹效果 */
.menu-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(59, 130, 246, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.menu-btn:active::before {
  width: 100px;
  height: 100px;
}
.menu-btn svg { width: 18px; height: 18px; }

/* 折叠态（桌面） */
body.sidebar-collapsed { --sidebar-width: 0px; }

/* 侧栏过渡动画 */
.sidebar {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: var(--sidebar-width);
}

.layout {
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 侧栏内容平滑隐藏 */
.sidebar > * {
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.sidebar .brand {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar .desc {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 侧栏折叠时的文字动画 */
body.sidebar-collapsed .sidebar .brand,
body.sidebar-collapsed .sidebar .desc,
body.sidebar-collapsed .sidebar .nav {
  opacity: 0;
  transform: translateX(-20px);
}
.nav {
  display: grid;
  gap: 6px;
  width: calc(100% - 24px);
  box-sizing: border-box;
}
.nav a {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 100%;
  box-sizing: border-box;
}

.nav a:hover {
  transform: translateX(2px);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}
.nav a.active {
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
}

.main {
  padding: 0; /* 交由子页面处理内边距 */
}
.main iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* 响应式：小屏幕下侧边栏改为抽屉 */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  /* 顶部栏在小屏依然保持显示（与默认一致） */
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    height: calc(100vh - 56px);
    width: 82vw;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow);
    z-index: 20;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(2,6,23,.35); 
    backdrop-filter: saturate(180%) blur(2px); 
    display: none; 
    z-index: 10; 
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .sidebar-overlay.show { 
    display: block; 
    opacity: 1;
  }
  .main { height: calc(100vh - 56px); }
}

/* 工具页通用块 */
.app { max-width: 80%; margin: 32px auto; padding: 0 16px 48px 16px; }
.title { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.title h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .2px; }
.subtitle { color: var(--muted); margin: 6px 0 18px 0; font-size: 13px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .compare-grid { grid-template-columns: 1fr; } }

.panel { background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%); border: 1px solid var(--border); border-radius: 12px;  overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.panel-header .label { font-size: 13px; color: var(--muted); }
.panel-body { padding: 12px; }

textarea { width: 100%; min-height: 200px; resize: vertical; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 12px 12px; font-family: "FiraCode LXK", "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 14px; line-height: 1.55; box-sizing: border-box; outline: none; }
textarea::placeholder { color: #94a3b8; }

.actions { display: flex; align-items: center; gap: 8px; }
.actions .chk { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; user-select: none; }

button { appearance: none; border: 1px solid var(--border); background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%); color: var(--text); padding: 8px 12px; font-size: 13px; border-radius: 10px; cursor: pointer; transition: transform .02s ease-out, background .2s ease; }
button.primary { background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%); border-color: rgba(255,255,255,.12); color: #fff; }
button:active { transform: translateY(1px); }

pre.code {min-height: 320px; margin: 0; padding: 12px; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; overflow: auto; font-family: "FiraCode LXK", "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 13px; line-height: 1.55; tab-size: 2; white-space: pre-wrap; word-break: break-word; color: var(--text); }

.json-key { color: var(--key); }
.json-string { color: var(--str); }
.json-number { color: var(--num); }
.json-boolean { color: var(--bool); }
.json-null { color: var(--nil); }
.json-punct { color: var(--punct); }
.json-value { cursor: pointer; position: relative; }
.json-value:hover { text-decoration: underline dotted; text-underline-offset: 2px; }
.fold { margin-left: 0; }
.fold > summary { list-style: none; cursor: pointer; display: inline-block; user-select: none; }
.fold > summary::-webkit-details-marker { display: none; }
/* .fold > summary::before { content: '▾'; display: inline-block; width: 1em; color: #64748b; transition: transform .15s ease; } */
.fold[open] > summary::before { transform: rotate(0deg); }
.fold:not([open]) > summary::before { transform: rotate(-90deg); }
.muted { color: #64748b; }

.error { color: #b91c1c; background: rgba(220, 38, 38, .08); border: 1px solid rgba(220, 38, 38, .25); padding: 8px 10px; border-radius: 8px; margin-bottom: 10px; white-space: pre-wrap; }

.popover { position: fixed; z-index: 1000; min-width: 260px; max-width: 80vw; background: #ffffff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; }
.popover[hidden] { display: none; }
.pop-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; }
.pop-row + .pop-row { border-top: 1px dashed var(--border); }
.pop-row:hover { background: rgba(2,6,23,.04); }
.pop-label { color: var(--muted); font-size: 12px; }
.pop-value { font-family: "FiraCode LXK", "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 13px; }
.copy-btn { font-size: 12px; padding: 6px 10px; border-radius: 8px; }
.tip { color: var(--muted); font-size: 12px; text-align: right; padding: 6px 8px 0 8px; }
.ok { color: #16a34a; }
.warn { color: #b45309; }
.bad { color: #dc2626; }

.diff-added { color: #16a34a; }
.diff-removed { color: #dc2626; }
.diff-changed { color: #b45309; }
.diff-path { color: #334155; }

/* 行级高亮 */
.code .line { display: block; padding: 2px 8px; margin: 0 -8px; border-radius: 6px; border-left: 3px solid transparent; }
.code .line.diff-added { background: rgba(22,163,74,.12); border-left-color: #16a34a; }
.code .line.diff-removed { background: rgba(220,38,38,.10); border-left-color: #dc2626; }
.code .line.diff-changed { background: rgba(180,83,9,.10); border-left-color: #b45309; }

/* SQL 语法高亮 */
.sql-keyword { color: #1d4ed8; font-weight: 700; }
.sql-func { color: #0d9488; }
.sql-string { color: #b91c1c; }
.sql-number { color: #7c3aed; }
.sql-identifier { color: #0f172a; }
.sql-comment { color: #64748b; font-style: italic; }

#jsonOutput{
  min-height: 320px;
}

