/* ========================================
   DevTools - 开发者工具箱
   ======================================== */

/* -- Reset & Base -- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.hidden { display: none !important; }

/* 移动端防闪烁（FOUC）：首屏绘制前 <html> 已带 is-mobile / is-mobile-tool，
   直接隐藏桌面布局、显示对应移动端视图，避免先渲染 PC 版再切换。
   优先级高于 .hidden (!important) 靠 id/class 组合实现。 */
html.is-mobile .app { display: none !important; }
html.is-mobile #mobile-gate { display: flex !important; }
html.is-mobile-tool .app { display: flex !important; }
html.is-mobile-tool .sidebar { display: none !important; }
html.is-mobile-tool #mobile-gate { display: none !important; }

:root {
  --sidebar-width: 220px;
  --sidebar-bg: #f8f9fa;
  --sidebar-active-bg: #e7f0ff;
  --sidebar-active-text: #1a73e8;
  --sidebar-border: #e0e0e0;
  --content-bg: #ffffff;
  --page-bg: #f1f3f4;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-muted: #9aa0a6;
  --border-color: #e0e0e0;
  --input-bg: #ffffff;
  --input-border: #dadce0;
  --input-focus: #1a73e8;
  --btn-primary-bg: #1a73e8;
  --btn-primary-hover: #1557b0;
  --btn-bg: #ffffff;
  --btn-border: #dadce0;
  --btn-hover-bg: #f1f3f4;
  --diff-add-bg: #e6ffed;
  --diff-add-text: #1a7f37;
  --diff-remove-bg: #ffebe9;
  --diff-remove-text: #cf222e;
  --success: #1a7f37;
  --danger: #cf222e;
  --warning: #f9a825;
  --code-bg: #f8f9fa;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', 'Monaco', 'Courier New', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --radius: 8px;
  --radius-sm: 4px;
  --diff-split: 0.5;
  --json-split: 0.5;
  --split-handle-width: 8px;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--page-bg);
}

/* -- Layout -- */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--sidebar-border);
}

.logo-icon {
  font-size: 22px;
  color: var(--btn-primary-bg);
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: auto;
}

.sidebar-toggle:hover {
  border-color: var(--btn-primary-bg);
  color: var(--btn-primary-bg);
  background: var(--sidebar-active-bg);
}

.sidebar-toggle-floating {
  display: none;
  width: 20px;
  height: 20px;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}

/* Collapsed sidebar state */
.app.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border-right: none;
}

.app.sidebar-collapsed .sidebar .sidebar-toggle {
  display: none;
}

.app.sidebar-collapsed .sidebar-toggle-floating {
  display: inline-flex;
}

.app.sidebar-collapsed .content {
  padding-right: 16px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.nav-item:hover {
  background: #e8eaed;
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 500;
}

.nav-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.version {
  font-size: 12px;
  color: var(--text-muted);
}

.hint-text {
  font-size: 11px;
  color: var(--text-muted);
}

/* ========================================
   Tool Panel Switching (JS-driven with hash routing)
   ======================================== */
.tool-panel.active {
  display: flex;
  overflow-y: auto;
}

/* ========================================
   Content
   ======================================== */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 8px 24px;
  background: var(--page-bg);
}

.tool-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.tool-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
  min-height: 18px;
}

.tool-header h1 {
  display: none; /* h1 removed — everything now in .tool-desc */
}

.tool-desc {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0 0 0 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Diff-specific: tool-header inside diff-top-bar (no bottom margin) */
#tool-diff .tool-header {
  margin-bottom: 0;
  padding: 0;
}

.diff-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 0;
  padding: 0;
  min-height: 18px;
}

.diff-top-bar .diff-toggle-bar {
  padding: 0;
}

.diff-top-bar .tool-header {
  margin-left: auto;
  justify-content: flex-end;
}

/* ========================================
   Card
   ======================================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border-color);
}

.card h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* ========================================
   Current Time Card (Timestamp)
   ======================================== */
.current-time-card .current-row {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
}

.current-item {
  flex: 1;
}

.current-item label,
.current-time-display label,
.result-item label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.value-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.current-item code,
.current-time-display code,
.result-item code {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--code-bg);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  border: 1px solid var(--input-border);
  display: inline-block;
  word-break: break-all;
}

.current-time-display {
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

/* ========================================
   Input & Result
   ======================================== */
.input-group {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--input-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

.input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

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

.result {
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
}

.result-item {
  margin-bottom: 12px;
}

.result-item:last-child {
  margin-bottom: 0;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  padding: 10px 20px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius);
  background: var(--btn-bg);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-weight: 500;
}

.btn:hover {
  background: var(--btn-hover-bg);
  border-color: #c4c7cc;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: #ffffff;
  border-color: var(--btn-primary-bg);
}

.btn-primary:hover {
  background: var(--btn-primary-hover);
  border-color: var(--btn-primary-hover);
}

.btn-danger-outline {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}

.btn-danger-outline:hover {
  background: #fff0f0;
}

.btn-xs {
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 3px;
}

.btn-xs:hover {
  background: var(--btn-primary-bg);
  color: #fff;
  border-color: var(--btn-primary-bg);
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ========================================
   JSON Tool
   ======================================== */
.json-editor-row {
  display: flex;
  flex: 1;
  gap: 0;
  min-height: 0;
  align-items: stretch;
}

.json-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}
.json-panel:first-child { flex: 0 0 calc(var(--json-split) * 100% - 16px); min-width: 0; }
.json-panel:last-child  { flex: 0 0 calc((1 - var(--json-split)) * 100% - 16px); min-width: 0; }

.json-split-handle { margin: 0 12px; }

.json-panel pre {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  margin: 0;
}

#tool-json .card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
  padding: 12px 16px;
}

/* Compact toolbar for JSON */
#tool-json .toolbar {
  margin-bottom: 8px;
  gap: 6px;
}

#tool-json .btn {
  padding: 5px 14px;
  font-size: 13px;
}

#tool-json.tool-panel {
  overflow: hidden;
}

.json-panel > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.code-input {
  width: 100%;
  flex: 1;
  min-height: 180px;
  padding: 14px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--code-bg);
  resize: none;
  overflow: auto;
  outline: none;
  tab-size: 2;
}

.code-input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.code-input::placeholder,
.code-output::placeholder {
  color: var(--text-muted);
}

.code-output {
  display: block;
  flex: 1;
  min-height: 180px;
  max-width: 100%;
  padding: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--code-bg);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.status-bar {
  display: flex;
  align-items: center;
  margin-top: 8px;
  padding: 6px 16px 6px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-sans);
}

#json-status-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

.status-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.12);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.85;
  padding: 2px 10px;
  margin-left: auto;
  border-radius: 3px;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.status-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.12);
}

.status-bar.success {
  background: #e6ffed;
  color: var(--success);
  border: 1px solid #b7dfc5;
}

.status-bar.error {
  background: #ffebe9;
  color: var(--danger);
  border: 1px solid #ffc1ba;
}

/* JSON Syntax Highlighting */
.json-key { color: #d63384; }
.json-string { color: #0d7c3e; }
.json-number { color: #1a73e8; }
.json-boolean { color: #9c27b0; }
.json-null { color: var(--text-muted); }
.json-bracket { color: var(--text-secondary); }

/* ========================================
   JSON Interactive Tree View
   ======================================== */
.json-tree {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.8;
  user-select: text;
  white-space: normal;
}
.json-tree-node {
  /* container, no extra padding */
}
.json-tree-header {
  white-space: nowrap;
  cursor: default;
}
.json-tree-header:hover {
  background: rgba(0, 0, 0, 0.03);
}
.json-tree-toggle {
  display: inline-block;
  width: 16px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  color: var(--text-muted);
  font-size: 10px;
  flex-shrink: 0;
  transition: transform 0.12s;
}
.json-tree-toggle:hover {
  color: #333;
}
.json-tree-children {
  padding-left: 20px;
}
.json-tree-footer {
  white-space: nowrap;
}
/* Collapsed state */
.json-tree-node.json-collapsed > .json-tree-children,
.json-tree-node.json-collapsed > .json-tree-footer {
  display: none;
}
.json-tree-node.json-collapsed > .json-tree-header > .json-tree-count {
  display: inline;
}
.json-tree-node > .json-tree-header > .json-tree-count {
  display: none;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
  margin-left: 6px;
}
/* Tree syntax colors (same palette as flat view) */
.json-tree-key   { color: #d63384; }
.json-tree-string { color: #0d7c3e; }
.json-tree-number { color: #1a73e8; }
.json-tree-boolean { color: #9c27b0; }
.json-tree-null   { color: var(--text-muted); font-style: italic; }
.json-tree-bracket { color: var(--text-secondary); }
.json-tree-comma  { color: var(--text-muted); }
.json-tree-row {
  /* each key-value or array-item line */
}

/* ========================================
   Diff Tool
   ======================================== */
.diff-panels {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.diff-panel {
  flex: 1;
  min-width: 0;
}

.diff-panel > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.label-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
}

.label-badge.original {
  background: #ffebe9;
  color: var(--diff-remove-text);
}

.label-badge.add {
  background: #e6ffed;
  color: var(--diff-add-text);
}

.diff-textarea {
  width: 100%;
  min-height: 160px;
  padding: 14px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--input-bg);
  resize: vertical;
  outline: none;
  tab-size: 2;
}

.diff-textarea:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.diff-panel-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.file-upload-btn {
  display: inline-block;
  padding: 6px 14px;
  border: 1px dashed var(--input-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--btn-primary-bg);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
}

.file-upload-btn:hover {
  border-color: var(--btn-primary-bg);
  background: var(--sidebar-active-bg);
}

.file-name {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diff-stats {
  padding: 6px 12px;
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 13px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.diff-stats .add { color: var(--diff-add-text); }
.diff-stats .remove { color: var(--diff-remove-text); }
.diff-stats .same { color: var(--text-secondary); }

/* ---- Diff loading spinner ---- */
.diff-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.diff-loading.hidden { display: none; }

.diff-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--btn-primary-bg);
  border-radius: 50%;
  animation: diff-spin 0.7s linear infinite;
}

@keyframes diff-spin {
  to { transform: rotate(360deg); }
}

/* ---- Side-by-side diff view ---- */

#tool-diff .card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 12px;
}

.diff-toggle-bar {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ---- JSON tree expand/collapse ---- */
.json-tree-ctrl {
  border: 1px solid #e67e22 !important;
  color: #e67e22 !important;
  background: #fff8f0 !important;
  font-weight: 600 !important;
  transition: all 0.15s ease;
}
.json-tree-ctrl:hover {
  background: #e67e22 !important;
  color: #fff !important;
  border-color: #e67e22 !important;
}

.diff-toggle-btn {
  padding: 6px 20px !important;
  font-size: 13px !important;
  border: 1px solid var(--btn-primary-bg) !important;
  color: var(--btn-primary-bg) !important;
  background: var(--sidebar-active-bg) !important;
  border-radius: var(--radius) !important;
  font-weight: 500;
  transition: all 0.15s ease;
}

.diff-toggle-btn:hover {
  background: var(--btn-primary-bg) !important;
  color: #fff !important;
  border-color: var(--btn-primary-bg) !important;
}

#diff-result-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#diff-result-container.hidden {
  display: none;
}

.diff-result-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;            /* anchor for the absolutely-positioned split handle */
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ONE unified scrolling surface for the WHOLE diff table — a SINGLE vertical
   scrollbar. There is never a scrollbar per row. The two columns are locked to a
   fixed share of the width (table-layout:fixed + <col> widths), so BOTH columns
   stay visible side-by-side at all times and a long JSON line can NEVER push the
   other column off-screen. Long lines WRAP inside their own column
   (white-space:pre-wrap) so the full content is always readable and needs no
   horizontal scrollbar at all. And each <tr> forces its two <td>s to the SAME
   height automatically — the browser guarantees it — so rows can NEVER desync
   no matter how long or how many lines one side wraps to. This finally kills
   BOTH the old "misaligned from record X" bug AND the "scrollbar on every long
   row" bug. */
.diff-scroll-wrapper {
  flex: 1;
  min-height: 0;
  overflow-y: auto;             /* ONE vertical scrollbar for the whole table */
  overflow-x: hidden;           /* long lines wrap, so no horizontal scrollbar */
  background: #fafbfc;
}

.diff-table {
  table-layout: fixed;          /* col widths come from <col>, NOT content — a
                                   long line can't stretch the column (or the
                                   neighbour) wider, so both columns stay visible */
  width: 100%;
  border-collapse: collapse;
}
.diff-table col.diff-col-left  { width: calc(var(--diff-split) * 100%); }
.diff-table col.diff-col-right { width: calc((1 - var(--diff-split)) * 100%); }

.diff-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--code-bg);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-align: center;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-color);
}

/* Each <td> holds its line directly. Long JSON lines WRAP within the column
   (white-space:pre-wrap + word-break:break-all) so the entire content is always
   visible with no per-row horizontal scrollbar. The row's two <td>s are forced
   to equal height by the <tr>, so left/right stay perfectly aligned
   structurally even when one side wraps to more lines than the other. */
.diff-table td {
  vertical-align: top;
  border-bottom: 1px solid #f0f0f0;
  padding: 2px 14px;
  white-space: pre-wrap;        /* wrap long lines inside the column */
  word-break: break-all;        /* break unbreakable JSON tokens too */
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.8;
  overflow: hidden;
}
.diff-table td.modified { background: #fff0f0; }
.diff-table td.removed  { background: #ffebe9; }
.diff-table td.added    { background: #e6ffed; }
.diff-table td.empty    { background: #f5f6f7; }
/* 左右两行 key 名仅在大小写上不同：整行加黄色左边框警示，避免误读成纯值修改 */
.diff-table tr.case-mismatch td { box-shadow: inset 3px 0 0 #f0a000; }
.diff-table tr.case-mismatch td.modified { background: #fff7e6; }
.case-warn {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 11px;
  line-height: 1.6;
  color: #8a5a00;
  background: #fff0c2;
  border: 1px solid #f0c060;
  border-radius: 4px;
  vertical-align: middle;
  white-space: nowrap;
}


/* ---- Draggable split handle (universal) ---- */
.diff-split-handle,
.json-split-handle {
  width: var(--split-handle-width);
  flex-shrink: 0;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  user-select: none;
}

.diff-split-handle span,
.json-split-handle span {
  display: block;
  width: 2px;
  height: 32px;
  border-radius: 1px;
  background: var(--border-color);
  transition: background 0.15s, height 0.15s;
}

.diff-split-handle:hover span,
.json-split-handle:hover span,
.diff-split-handle.dragging span,
.json-split-handle.dragging span {
  background: var(--input-focus);
  height: 48px;
}

.diff-split-handle::before,
.json-split-handle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  right: -4px;
}

/* The split handle is an overlay that sits ON the column boundary. Its
   background is transparent so it never hides the leftmost pixels of the right
   column (or the rightmost pixels of the left column); only the 2px center line
   (.diff-split-handle span) is visible as a divider. The invisible ::before
   extends the clickable hit area without covering any content. */
.diff-result-view > .diff-split-handle {
  position: absolute;
  left: calc(var(--diff-split) * 100% - var(--split-handle-width) / 2);
  top: 0;
  bottom: 0;
  z-index: 3;
  background: transparent;
}

/* Inline word diff highlighting */
.diff-word-remove {
  background: #ffc1ba;
  text-decoration: line-through;
  border-radius: 2px;
  padding: 0 1px;
}

.diff-word-add {
  background: #b7dfc5;
  border-radius: 2px;
  padding: 0 1px;
}

/* ========================================
   QR Code Generator
   ======================================== */
.qr-main-card {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 16px;
}

.qr-main-card .card {
  height: 100%;
}

.qr-layout {
  display: flex;
  gap: 28px;
  height: 100%;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.qr-input-section {
  flex: 0 0 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qr-preview-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  padding: 40px 24px 24px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  min-height: 0;
  overflow: hidden;
}

.qr-preview-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.qr-preview-container {
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  max-width: 100%;
}

.qr-preview-container canvas {
  display: block;
  max-width: 100%;
  max-height: 480px;
  width: auto;
  height: auto;
}

#qr-logo-preview {
  position: absolute;
  border-radius: 4px;
  background: #fff;
  padding: 4px;
}

/* QR type tabs */
.qr-type-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
}

.qr-type-tab {
  flex: 1;
  text-align: center;
  padding: 5px 4px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  background: var(--page-bg);
  border: 1px solid var(--btn-border);
  color: var(--text-secondary);
  transition: all 0.15s;
  white-space: nowrap;
}

.qr-type-tab:hover { border-color: var(--input-focus); color: var(--input-focus); }
.qr-type-tab input { display: none; }
.qr-type-tab.active { background: var(--input-focus); color: #fff; border-color: var(--input-focus); }

/* QR inputs */
.qr-input-group { display: flex; flex-direction: column; gap: 8px; }
.qr-textarea { width: 100%; border: 1px solid var(--input-border); border-radius: 8px; padding: 10px 12px; font-size: 14px; resize: vertical; font-family: inherit; min-height: 80px; }
.qr-textarea:focus { outline: none; border-color: var(--input-focus); }

.qr-row { display: flex; flex-direction: column; gap: 4px; }
.qr-row label { font-size: 12px; color: var(--text-secondary); }

/* QR options */
.qr-options { display: flex; flex-wrap: wrap; gap: 10px; }
.qr-option-row { display: flex; flex-direction: column; gap: 4px; min-width: 90px; }
.qr-option-row > label { font-size: 12px; color: var(--text-secondary); }

.qr-color-wrap { display: flex; align-items: center; gap: 6px; }
.qr-color-input { width: 28px; height: 28px; border: 1px solid var(--input-border); border-radius: 4px; padding: 0; cursor: pointer; }
.qr-color-wrap code { font-size: 12px; color: var(--text-muted); }

/* QR actions */
.qr-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.qr-logo-btn { font-size: 12px; cursor: pointer; color: var(--input-focus); padding: 6px 12px; border: 1px dashed var(--input-focus); border-radius: 6px; }
.qr-logo-btn:hover { background: var(--sidebar-active-bg); }

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c4c7cc;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9aa0a6;
}

/* ========================================
   Sidebar About Card
   ======================================== */
.sidebar-about {
  position: relative;
  margin: auto 12px 8px;
  padding: 12px 14px 10px;
  background: #f0f4ff;
  border-radius: 6px;
  border: 1px solid #d6e4ff;
  font-size: 11px;
  line-height: 1.55;
  color: #5f6b7a;
}

.sidebar-about p {
  margin: 0;
}

.sidebar-about-cta {
  margin-top: 6px !important;
  font-size: 11px;
  color: #6b7a8d;
}

.sidebar-about-cta strong {
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.sidebar-about-close {
  position: absolute;
  top: 2px;
  right: 4px;
  background: none;
  border: none;
  color: #a0aab4;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color 0.15s;
}

.sidebar-about-close:hover {
  color: #555;
}

.sidebar-about.hidden {
  display: none;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 480px) {
  .sidebar {
    width: 56px;
    min-width: 56px;
  }

  .logo-text,
  .nav-item span:not(.nav-icon),
  .sidebar-footer,
  .hint-text {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 12px;
  }

  .sidebar-header {
    justify-content: center;
  }

  .content {
    padding: 8px 16px;
  }

  .json-editor-row {
    flex-direction: column;
  }

  .diff-panels {
    flex-direction: column;
  }

  .current-time-card .current-row {
    flex-direction: column;
    gap: 12px;
  }

  .qr-layout { flex-direction: column; overflow-y: auto; gap: 16px; }
  .qr-input-section { flex: none; width: 100%; }
  .qr-preview-section { width: 100%; padding: 20px 12px; flex: none; }
  .qr-preview-container { margin: 0 auto; }

  .sidebar-about { display: none; }
}

/* ========================================
   移动端引导页 (Mobile Gate)
   ======================================== */
.mobile-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px 20px;
  background: linear-gradient(160deg, #f0f4ff 0%, #f8f9fa 40%, #e7f0ff 100%);
  font-family: var(--font-sans);
}

.mobile-gate.hidden {
  display: none;
}

.mobile-gate-inner {
  max-width: 380px;
  width: 100%;
  text-align: center;
  animation: gateFadeIn 0.6s ease-out;
}

@keyframes gateFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.gate-avatar {
  font-size: 42px;
  margin-bottom: 10px;
  line-height: 1;
}

.gate-title {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.gate-desc {
  font-size: 13px;
  line-height: 1.7;
  color: #5f6368;
  margin-bottom: 12px;
  text-align: left;
}

.gate-desc strong {
  color: #1a73e8;
}

.gate-url-box {
  background: #fff;
  border: 1px dashed #1a73e8;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 24px;
  text-align: center;
}

.gate-url-label {
  display: block;
  font-size: 12px;
  color: #9aa0a6;
  margin-bottom: 6px;
}

.gate-url {
  font-size: 18px;
  font-weight: 600;
  color: #1a73e8;
  background: none;
  padding: 0;
  letter-spacing: 0.5px;
}

.gate-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #dadce0, transparent);
  margin: 14px 0;
}

.gate-section-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 10px;
  text-align: left;
}

.gate-feature {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border-radius: 10px;
  margin-bottom: 8px;
  text-align: left;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.gate-feature-icon {
  font-size: 22px;
  flex-shrink: 0;
  margin-top: 1px;
}

.gate-feature-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #5f6368;
  line-height: 1.6;
}

.gate-feature-text strong {
  font-size: 14px;
  color: #202124;
}

.gate-btn {
  display: block;
  width: 100%;
  padding: 14px 0;
  background: linear-gradient(135deg, #1a73e8, #1557b0);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  margin-top: 24px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(26,115,232,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.gate-btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 6px rgba(26,115,232,0.3);
}

.gate-btns {
  display: flex; margin-top: 24px;
}
.gate-btns .gate-btn {
  flex: 1; margin: 0 5px; padding: 14px 8px; font-size: 14px;
}

/* ========================================
   移动端二维码模式 (Mobile QR Mode)
   ======================================== */
.app.mobile-qr-mode .sidebar {
  display: none;
}

.app.mobile-qr-mode .content {
  margin-left: 0;
  width: 100%;
  padding: 0;
}

.app.mobile-qr-mode .tool-header {
  padding: 16px 16px 8px;
  margin-bottom: 0;
}

.app.mobile-qr-mode .tool-header .sidebar-toggle-floating {
  display: none;
}

.app.mobile-qr-mode .card {
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 0;
}

.app.mobile-qr-mode .qr-main-card {
  padding: 12px 16px 24px;
}

.app.mobile-qr-mode .qr-preview-container {
  max-width: 320px;
  width: 100%;
}

.app.mobile-qr-mode .qr-options {
  flex-wrap: wrap;
}

/* 移动端 QR 按钮 2×2 等分网格 */
.app.mobile-qr-mode .qr-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.app.mobile-qr-mode .qr-actions button,
.app.mobile-qr-mode .qr-actions .qr-logo-btn {
  width: 100%;
  text-align: center;
  margin: 0;
}

/* 微信浏览器下载提示条 */
.wechat-download-tip {
  display: none;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: #fff3cd;
  border: 1px solid #f0c040;
  border-radius: 8px;
  font-size: 13px;
  color: #856404;
  line-height: 1.6;
}

.wechat-download-tip.show {
  display: block;
}

/* Mobile QR back button */
.mobile-qr-back {
  display: none;
  font-size: 13px;
  color: #1a73e8;
  text-decoration: none;
  padding: 12px 16px 0;
  background: transparent;
  border: none;
  cursor: pointer;
}

.app.mobile-qr-mode .mobile-qr-back {
  display: block;
}

/* 二维码工具移动端专用 header */
.mobile-qr-header {
  display: none;
  padding: 14px 16px 6px;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
}

.mobile-qr-header a {
  color: #1a73e8;
  text-decoration: none;
  font-size: 14px;
}

.mobile-qr-header a:hover {
  text-decoration: underline;
}

.app.mobile-qr-mode .mobile-qr-header {
  display: block;
}

/* 移动端密码页面适配 */
.app.mobile-qr-mode #tool-pwdgen .card {
  border-radius: 0; box-shadow: none; margin-bottom: 0;
}
.app.mobile-qr-mode #tool-pwdgen .tool-header {
  padding: 8px 16px; margin-bottom: 0;
}

/* ========== 密码生成 ========== */
.password-display {
  display: flex; align-items: center;
}
.password-text {
  flex: 1; font-family: 'Courier New', Consolas, monospace;
  font-size: 24px; background: #f0f4f8; border: 2px solid #c0c7cf;
  border-radius: 8px; padding: 14px 16px; letter-spacing: 3px;
  text-align: center; word-break: break-all; line-height: 1.4;
  color: #1a3a5c; min-height: 54px; display: flex; align-items: center;
  justify-content: center; transition: border-color 0.2s;
}
.password-text:hover { border-color: #4a90d9; }
.password-actions {
  display: flex; gap: 10px; margin-top: 14px; justify-content: center;
}
.password-actions .btn {
  min-width: 140px; flex: 0 0 auto;
}
.btn-copy-password {
  background: #4a90d9; color: #fff; border: none;
  border-radius: 8px; padding: 14px 20px; font-size: 15px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
  min-width: 74px; min-height: 44px; transition: background 0.2s;
}
.btn-copy-password:hover { background: #3a7bc8; }
.btn-copy-password.copied { background: #22c55e; }
.btn-primary.copied { background: #22c55e; border-color: #22c55e; }
.setting-row {
  display: flex; align-items: flex-start; gap: 16px; margin-top: 16px;
  flex-wrap: wrap;
}
.setting-label {
  font-size: 13px; color: #666; min-width: 64px; padding-top: 6px;
  font-weight: 500;
}
.slider-group {
  display: flex; align-items: center; gap: 8px; flex: 1;
}
.slider-wrap {
  flex: 1; position: relative; display: flex; align-items: center;
}
.range-slider {
  width: 100%; height: 6px; -webkit-appearance: none; appearance: none;
  background: #d0d7e0; border-radius: 3px; outline: none;
}
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: #4a90d9; cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.slider-badge {
  display: inline-block; min-width: 40px; text-align: center;
  font-size: 15px; font-weight: 700; color: #4a90d9;
  background: #e8f0fe; border-radius: 6px; padding: 2px 8px;
}
.checkbox-group {
  display: flex; flex-wrap: wrap; gap: 8px 20px; flex: 1;
}
/* 移动端强制"数字"换行 */
@media (max-width: 768px) {
  .checkbox-label.break-row { width: 100%; flex-basis: 100%; }
}
.checkbox-label {
  font-size: 14px; color: #444; cursor: pointer; display: flex;
  align-items: center; gap: 4px; user-select: none;
}
.checkbox-label input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: #4a90d9; cursor: pointer;
}
.btn-sm {
  padding: 6px 12px; font-size: 14px; font-weight: 700;
  background: #e0e6ed; color: #555; border: 1px solid #c0c7cf;
  border-radius: 6px; cursor: pointer; min-width: 32px; min-height: 32px;
  transition: background 0.2s;
}
.btn-sm:hover { background: #d0d7e0; }

/* ========================================
   首页导航 (Home Navigation)
   ======================================== */
.home-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}

.home-header {
  text-align: center;
  margin-bottom: 40px;
}

.home-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.home-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.home-cards {
  display: flex;
  flex-direction: column;
  gap: 32px;
  margin-bottom: 48px;
}

.home-group-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* 开发者工具卡片：略小，靠尺寸与留白弱化区分 */
.home-card--dev {
  padding: 24px 20px;
}

.home-card--dev .home-card-icon {
  font-size: 26px;
}

.home-card--dev .home-card-name {
  font-size: 16px;
}

.home-card--dev .home-card-desc {
  font-size: 14px;
  color: var(--text-muted);
}

/* 开发者工具分组：与大众工具之间留出更大空白，弱化视觉权重 */
.home-group--dev {
  margin-top: 12px;
}

.home-card {
  display: block;
  padding: 34px 28px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
}

.home-card:hover {
  border-color: var(--btn-primary-bg);
  box-shadow: 0 2px 12px rgba(26, 115, 232, 0.12);
  transform: translateY(-2px);
}

.home-card-icon {
  display: inline-block;
  font-size: 32px;
  line-height: 1;
  vertical-align: middle;
  margin-right: 14px;
}

.home-card-name {
  display: inline;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  vertical-align: middle;
}

.home-card-desc {
  display: block;
  margin-top: 14px;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.home-footer {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.8;
  padding: 24px 0;
}

@media (max-width: 768px) {
  .home-page { padding: 40px 24px 56px; }
  .home-title { font-size: 26px; }
  .home-subtitle { font-size: 15px; }
  .home-cards { gap: 28px; }
  .home-group-cards { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .home-card { padding: 28px 24px; }
  .home-card-icon { font-size: 28px; }
  .home-card-name { font-size: 17px; }
  .home-card-desc { font-size: 14px; }
}

@media (max-width: 480px) {
  .home-page { padding: 32px 16px 48px; }
  .home-title { font-size: 24px; }
  .home-subtitle { font-size: 14px; }
  .home-cards { gap: 24px; }
  .home-group-cards { grid-template-columns: 1fr; gap: 12px; }
  .home-card { padding: 24px 20px; }
  .home-card-icon { font-size: 26px; }
  .home-card-name { font-size: 16px; }
  .home-card-desc { font-size: 14px; }
}
