/* ===== 全局 ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Helvetica Neue", "Segoe UI", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
  color: #1f2329;
  background: #f7f8fa;
}
a { color: #2f6fed; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 全屏布局骨架 ===== */
.layout { display: flex; height: 100vh; overflow: hidden; }

/* 左侧导航侧栏 */
.sidebar {
  width: 234px;
  flex: 0 0 234px;
  background: #fff;
  border-right: 1px solid #e4e7eb;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 16px 18px;
  font-weight: 700;
  font-size: 18px;
  color: #1f2329;
  border-bottom: 1px solid #e4e7eb;
  white-space: nowrap;
}
.sidebar .brand span { color: #2f6fed; }
.sidebar .cat {
  padding: 14px 18px 6px;
  font-size: 11px;
  font-weight: 700;
  color: #98a2ad;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.sidebar a.tool-link {
  display: block;
  padding: 8px 18px;
  font-size: 14px;
  color: #3a4250;
}
.sidebar a.tool-link:hover { background: #f2f5fb; color: #2f6fed; text-decoration: none; }
.sidebar a.tool-link.active { background: #eef3fe; color: #2f6fed; font-weight: 600; }

/* 右侧主区 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tool-head {
  padding: 13px 22px;
  border-bottom: 1px solid #e4e7eb;
  background: #fff;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.tool-head h1 { margin: 0; font-size: 19px; }
.tool-head p { margin: 0; color: #6b7280; font-size: 13px; }
.tool-jump { display: none; margin-left: auto; }

/* 工作区 */
.work { flex: 1; min-height: 0; display: flex; }
.work.util { flex-direction: column; overflow: auto; padding: 22px; }
.util-panel { max-width: 1080px; width: 100%; margin: 0 auto; }

/* 双栏（转换类） */
.panes { flex: 1; display: flex; min-height: 0; }
.pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e4e7eb;
}
.pane:last-child { border-right: 0; }
.pane-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid #e4e7eb;
  background: #fafbfc;
}
.pane-title { font-size: 13px; color: #4f5862; font-weight: 600; }
.dir-tabs { display: flex; gap: 4px; }
.dir-tabs button, .mini-btn {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid #d9dde3;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  color: #4f5862;
}
.dir-tabs button.active { background: #2f6fed; border-color: #2f6fed; color: #fff; }
.mini-btn:hover { border-color: #2f6fed; color: #2f6fed; }
.pane textarea, .pane pre {
  flex: 1;
  width: 100%;
  border: 0;
  margin: 0;
  padding: 14px;
  font-size: 13px;
  line-height: 1.65;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  background: #fff;
  resize: none;
  overflow: auto;
  white-space: pre;
  color: #1f2329;
}
.pane textarea:focus { outline: none; }
.pane textarea.err, .pane pre.err, #ts-output.err, #re-output.err, #color-output.err {
  color: #d4380d;
  background: #fff2f0;
}

/* 工具类面板控件 */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; color: #4f5862; font-weight: 600; margin-bottom: 6px; }
.field textarea, .field input[type="text"], .field input[type="url"], .field input[type="number"],
.field input[type="date"], .field input[type="datetime-local"], .field select,
.row select {
  width: 100%;
  border: 1px solid #d9dde3;
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: #1f2329;
}
.field select, .row select { min-height: 40px; }
.field textarea { min-height: 150px; resize: vertical; font-family: "SFMono-Regular", Consolas, Menlo, monospace; line-height: 1.6; }
.field textarea:focus, .field input:focus, .field select:focus, .row select:focus { outline: none; border-color: #2f6fed; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.btn {
  font-size: 14px;
  padding: 9px 18px;
  border: 0;
  border-radius: 8px;
  background: #2f6fed;
  color: #fff;
  cursor: pointer;
}
.btn:hover { background: #245ad1; }
.note { color: #6b7280; font-size: 13px; }
.mono { font-family: "SFMono-Regular", Consolas, Menlo, monospace; }
#ts-output, #uuid-output, #re-output, #wc-output, #color-output,
#dt-zone-output, #dt-diff-output, #dt-add-output, #dt-batch-output, #dt-cron-output,
#qr-parse-output {
  width: 100%;
  border: 1px solid #d9dde3;
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  background: #fff;
  min-height: 90px;
  resize: vertical;
}
#ts-now, #now { color: #2f6fed; font-size: 13px; word-break: break-all; }

/* ===== 复合工具 ===== */
.tool-card {
  background: #fff;
  border: 1px solid #e4e7eb;
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 16px;
}
.tool-card h2 { margin: 0 0 14px; font-size: 16px; }
.tool-grid { display: grid; gap: 12px; }
.tool-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tool-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tool-grid.four { grid-template-columns: 1.5fr 1fr 1fr 1fr; }
.check-label { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 14px; font-size: 13px; color: #4f5862; }
.datetime-panel textarea, .qr-panel textarea { min-height: 84px; margin-top: 10px; }
.qr-preview {
  min-height: 270px;
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #d9dde3;
  border-radius: 8px;
  background: #fafbfc;
}
.qr-preview canvas, .qr-preview img { max-width: 100%; height: auto; image-rendering: pixelated; }

/* ===== 底部广告栏（可关闭） ===== */
.ad {
  position: relative;
  flex: 0 0 50px;
  height: 50px;
  border-top: 1px solid #e4e7eb;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#ad-close {
  position: absolute;
  top: 3px;
  right: 6px;
  width: 18px;
  height: 18px;
  line-height: 16px;
  text-align: center;
  font-size: 13px;
  color: #98a2ad;
  background: #f2f3f5;
  border: 1px solid #e4e7eb;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  z-index: 6;
}
#ad-close:hover { color: #4f5862; background: #e9ebee; }
.ad-label {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  letter-spacing: .5px;
  color: #b0b6be;
  pointer-events: none;
  z-index: 5;
}
body.ad-hidden .ad { display: none; }

/* ===== 首页 ===== */
.home-main { flex: 1; overflow: auto; padding: 30px 26px 40px; }
.home-main h1 { font-size: 26px; margin: 0 0 6px; }
.home-main .sub { color: #6b7280; margin: 0 0 26px; font-size: 15px; max-width: 800px; }
.home-cat { margin-bottom: 26px; }
.home-cat > h2 { font-size: 15px; color: #4f5862; margin: 0 0 12px; }
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.home-card {
  background: #fff;
  border: 1px solid #e4e7eb;
  border-radius: 10px;
  padding: 16px;
  transition: box-shadow .15s, border-color .15s;
}
.home-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); border-color: #c9d3e0; text-decoration: none; }
.home-card .t { font-weight: 600; color: #1f2329; font-size: 15px; }
.home-card .d { color: #6b7280; font-size: 13px; margin-top: 6px; line-height: 1.5; }

/* ===== 响应式 ===== */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { display: none; }
  .tool-jump { display: inline-block; }
  .panes { flex-direction: column; }
  .pane { border-right: 0; border-bottom: 1px solid #e4e7eb; }
  .pane:last-child { border-bottom: 0; }
  .pane textarea, .pane pre { min-height: 32vh; }
  .tool-grid.two, .tool-grid.three, .tool-grid.four { grid-template-columns: 1fr; }
}

/* ===== Mermaid 编辑器 ===== */
.mermaid-page { background: #f5f7fa; color: #212930; overflow: hidden; }
.mermaid-app { height: 100vh; display: flex; flex-direction: column; min-width: 0; }
.mermaid-header { height: 58px; flex: 0 0 58px; display: flex; align-items: center; gap: 18px; padding: 0 22px; background: #fff; color: #26313c; border-bottom: 1px solid #e7ebef; }
.mermaid-brand { color: #26313c; font-size: 18px; font-weight: 700; white-space: nowrap; }
.mermaid-brand span { color: #70a2ff; }
.mermaid-brand:hover { text-decoration: none; }
.mermaid-title { font-size: 15px; color: #46515c; border-left: 1px solid #dde3e9; padding-left: 18px; }
.mermaid-header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.mermaid-style-control, .mermaid-export-control { position: relative; }
.mermaid-header-btn, .mermaid-primary-btn { height: 34px; border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: 0 13px; cursor: pointer; color: #f4f6f8; background: transparent; font-size: 13px; }
.mermaid-header-btn { color: #46515c; border-color: #d9e0e7; background: #fff; }
.mermaid-header-btn:hover { background: #f0f5ff; border-color: #7da5ef; }
.mermaid-primary-btn { border-color: #3d7eff; background: #3978ef; font-weight: 600; }
.mermaid-primary-btn:hover { background: #2f6bd9; }
.style-swatch { display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 50%; vertical-align: 1px; }
.mermaid-menu { position: absolute; z-index: 20; top: calc(100% + 8px); right: 0; width: 150px; display: none; padding: 7px; border: 1px solid #dfe4ea; border-radius: 8px; background: #fff; box-shadow: 0 12px 28px rgba(25,35,45,.16); }
.style-menu { width: 238px; }
.mermaid-menu.open { display: block; }
.mermaid-menu button { width: 100%; border: 0; border-radius: 5px; padding: 8px 9px; text-align: left; background: transparent; color: #3d4752; cursor: pointer; font-size: 13px; }
.mermaid-menu button:hover { color: #2865d6; background: #f0f5ff; }
.menu-caption { padding: 5px 9px 4px; color: #9aa3ad; font-size: 11px; }
.menu-caption-spaced { margin-top: 6px; border-top: 1px solid #edf0f3; padding-top: 10px; }
.style-palette { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; padding: 3px 2px 2px; }
.style-option { display: flex !important; align-items: center; gap: 6px; padding: 6px 5px !important; font-size: 11px !important; }
.style-option.active { color: #2865d6 !important; background: #f0f5ff !important; }
.style-option-swatch { width: 30px; height: 19px; flex: 0 0 30px; border: 2px solid var(--style-border); border-radius: 4px; background: var(--style-surface); box-shadow: inset 0 -3px 0 var(--style-line); }
.export-menu-divider { height: 1px; margin: 5px 3px; background: #edf0f3; }
.mermaid-workspace { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(360px, 43%) 1fr; }
.mermaid-editor-panel, .mermaid-preview-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #fff; }
.mermaid-editor-panel { border-right: 1px solid #dde3e9; }
.mermaid-panel-header { height: 48px; flex: 0 0 48px; position: relative; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid #e7ebef; background: #fbfcfd; }
.mermaid-panel-heading { display: flex; align-items: center; min-width: 0; }
.mermaid-panel-title { font-size: 13px; font-weight: 600; color: #3b4651; }
.mermaid-status { margin-left: 10px; color: #87919c; font-size: 11px; }
.mermaid-status.error { color: #d4380d; }
.mermaid-code-actions, .preview-actions { display: flex; align-items: center; gap: 4px; }
.template-picker { position: relative; margin-left: 10px; margin-right: 6px; }
.template-picker-button { height: 28px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; line-height: 1; border: 1px solid #d9e0e7; border-radius: 5px; padding: 0 8px; background: #fff; color: #5b6671; cursor: pointer; font-size: 12px; }
.template-picker-button:hover { border-color: #7da5ef; color: #2865d6; }
.template-picker-count { color: #a0a9b2; font-size: 11px; }
.template-picker-caret { display: block; width: 14px; height: 14px; flex: 0 0 14px; fill: none; stroke: #89949f; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.template-picker-button[aria-expanded="true"] .template-picker-caret { transform: rotate(180deg); }
.template-dropdown { position: absolute; z-index: 21; top: calc(100% + 8px); left: -2px; display: none; width: 176px; max-height: 420px; overflow-y: auto; padding: 7px 5px; border: 1px solid #edf0f4; border-radius: 7px; background: #fff; box-shadow: 0 8px 22px rgba(25,35,45,.13); }
.template-dropdown::-webkit-scrollbar { width: 4px; }
.template-dropdown::-webkit-scrollbar-thumb { border-radius: 4px; background: #c3c9d0; }
.template-dropdown.open { display: block; }
.template-dropdown-title { display: none; }
.icon-btn { border: 0; min-width: 28px; height: 28px; border-radius: 5px; background: transparent; color: #75808a; cursor: pointer; font-size: 17px; line-height: 1; }
.icon-btn:hover { color: #2f6fed; background: #edf3ff; }
.zoom-level { min-width: 42px; text-align: center; color: #75808a; font-size: 12px; }
.mermaid-editor-body { min-height: 0; flex: 1 1 0; display: flex; overflow: hidden; background: #fff; }
.line-numbers { flex: 0 0 44px; overflow: hidden; padding: 14px 8px 14px 0; border-right: 1px solid #f0f2f4; background: #fbfcfd; color: #a5adb7; text-align: right; font: 13px/1.65 "SFMono-Regular", Consolas, monospace; user-select: none; }
.line-numbers span { display: block; height: 21px; }
#mermaid-code { flex: 1; width: 0; min-width: 0; border: 0; outline: 0; resize: none; padding: 14px 16px; color: #26313c; background: #fff; font: 13px/1.65 "SFMono-Regular", Consolas, monospace; tab-size: 2; white-space: pre; overflow: auto; }
#mermaid-code::selection { background: #dbe8ff; }
.mermaid-template-bar { flex: 0 0 226px; overflow: auto; border-top: 1px solid #e7ebef; background: #fbfcfd; padding: 13px 15px 16px; }
.template-bar-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; color: #46515c; font-size: 13px; font-weight: 600; }
.template-count { color: #9ba4ad; font-size: 11px; font-weight: 400; }
.template-grid { display: flex; flex-direction: column; gap: 1px; }
.template-card { min-height: 34px; display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 9px; border: 0; border-radius: 5px; padding: 5px 8px; background: #fff; color: #5e6874; cursor: pointer; font-size: 12px; text-align: left; }
.template-card:hover { border-color: transparent; color: #2865d6; background: #f4f7ff; box-shadow: none; }
.template-icon { width: 18px; color: var(--template-color); font-size: 18px; line-height: 20px; text-align: center; }
.template-name { white-space: nowrap; }
.mermaid-preview-panel { background: #f8fafc; }
.mermaid-preview-stage { min-height: 0; flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 34px; cursor: grab; touch-action: none; overscroll-behavior: contain; background-color: #f8fafc; background-image: radial-gradient(#d9e0e8 .8px, transparent .8px); background-size: 16px 16px; }
.mermaid-preview-stage.is-dragging { cursor: grabbing; user-select: none; }
.mermaid-svg-container { min-width: 100%; display: flex; align-items: center; justify-content: center; }
.mermaid-svg-container svg { max-width: 100%; height: auto; transition: none; transform-origin: center center; will-change: transform; }
.mermaid-preview-stage { overflow: hidden; user-select: none; }
.mermaid-preview-stage.is-dragging .mermaid-svg-container svg { transition: none; }
.preview-empty { position: absolute; z-index: 1; text-align: center; color: #9aa4ae; font-size: 13px; pointer-events: none; }
.preview-empty-mark { width: 48px; height: 48px; margin: 0 auto 12px; display: grid; place-items: center; border: 1px solid #b8c6d6; border-radius: 12px; color: #6e8dc2; font-size: 22px; font-weight: 700; }
.preview-empty[hidden] { display: none; }
.mermaid-error { min-height: 30px; padding: 0 18px 10px; color: #d4380d; font: 12px/1.5 "SFMono-Regular", Consolas, monospace; }
.mermaid-mobile-tabs { display: none; }
.mermaid-toast { position: fixed; left: 50%; bottom: 28px; z-index: 30; transform: translate(-50%, 12px); padding: 9px 15px; border-radius: 6px; color: #fff; background: rgba(29,39,50,.9); font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.mermaid-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .mermaid-page { overflow: auto; }
  .mermaid-app { min-height: 100vh; height: auto; }
  .mermaid-header { height: 54px; flex-basis: 54px; padding: 0 14px; gap: 10px; }
  .mermaid-title { font-size: 13px; padding-left: 10px; }
  .mermaid-brand { font-size: 16px; }
  .mermaid-header-btn, .mermaid-primary-btn { padding: 0 9px; }
  .mermaid-mobile-tabs { display: flex; height: 42px; flex: 0 0 42px; background: #fff; border-bottom: 1px solid #dde3e9; }
  .mermaid-mobile-tabs button { flex: 1; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #7a858f; font-size: 13px; cursor: pointer; }
  .mermaid-mobile-tabs button.active { border-bottom-color: #3978ef; color: #2865d6; font-weight: 600; }
  .mermaid-workspace { display: block; height: calc(100vh - 96px); }
  .mermaid-editor-panel, .mermaid-preview-panel { display: none; height: 100%; border-right: 0; }
  .mermaid-editor-panel.mobile-active, .mermaid-preview-panel.mobile-active { display: flex; }
  .mermaid-editor-panel { border-bottom: 1px solid #dde3e9; }
  .mermaid-editor-body { flex: 1; }
  .mermaid-template-bar { flex-basis: 190px; }
  .template-grid { grid-template-columns: repeat(4, minmax(65px, 1fr)); }
  .mermaid-preview-stage { padding: 20px 12px; }
}

.site-footer { display: none; }
.site-footer .footer-inner { max-width: 1080px; margin: 0 auto; padding: 18px 16px 6px; }
.site-footer .footer-title { display: block; font-size: 13px; color: #888; margin-bottom: 8px; }
.site-footer .footer-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.site-footer .footer-tools a { font-size: 13px; color: #2f6fed; text-decoration: none; }
.site-footer .footer-tools a:hover { text-decoration: underline; }
.site-footer .footer-copy { max-width: 1080px; margin: 0 auto; padding: 8px 16px 20px; font-size: 12px; color: #aaa; }
.site-footer .footer-copy a { color: #2f6fed; text-decoration: none; }
@media (max-width: 768px) {
  .site-footer { display: block; }
}
