:root {
  --bg: #f3f7fd;
  --bg-elev: #ffffff;
  --bg-soft: #edf4ff;
  --border: #c6d5e9;
  --border-soft: #dce6f3;
  --text: #14233d;
  --text-secondary: #475d7b;
  --text-faint: #536984;
  --accent: #0b63ce;
  --accent-soft: rgba(11, 99, 206, 0.10);
  --ok: #1a7f37;
  --warn: #9a6700;
  --danger: #cf222e;
  --dup-bg: rgba(207, 34, 46, 0.12);
  --hit-bg: rgba(26, 127, 55, 0.11);
  --add: #1a7f37;
  --add-soft: rgba(26, 127, 55, 0.13);
  --del: #cf222e;
  --del-soft: rgba(207, 34, 46, 0.10);
  --chg: #9a6700;
  --chg-soft: rgba(154, 103, 0, 0.16);
  --code-bg: #fbfcfe;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --radius: 16px;
  /* 表单控件统一高度：输入框、下拉、按钮在同一行要对齐 */
  --ctl-h: 36px;
  --ed-pad-x: 12px;
  --ed-pad-y: 8px;
  --ed-lh: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1000px 500px at 15% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 62px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  color: var(--accent);
}

.brand-icon {
  font-size: 19px;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 3px;
}

.page-nav {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 3px;
}

.page-nav a,
.page-nav .current {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
}

.page-nav .current {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.page-nav a:hover {
  color: var(--text);
  background: rgba(15, 30, 45, 0.05);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sites {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

.sites a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border: 1px solid var(--border-soft);
  padding: 4px 9px;
  border-radius: 8px;
}

.sites a:hover {
  color: var(--text);
  border-color: var(--border);
}

.container {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 18px 16px;
  overflow: hidden;
}

/* ---------- 汇总页 ---------- */
.summary-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 0;
}

.summary-hero {
  flex: 0 0 auto;
  text-align: center;
}

.summary-hero h1 {
  margin: 0 0 6px;
  font-size: 30px;
  color: var(--accent);
}

.summary-hero p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 1360px;
  flex: 1 1 auto;
  min-height: 0;
  /* 屏幕很高时卡片别被拉太长，整块保持居中 */
  max-height: 560px;
}

.tool-card {
  grid-column: span 3;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  min-width: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

/* 7 张卡片排成两行：第一行 4 张、第二行 3 张，两行都正好占满 */
.tool-card:nth-child(n + 5) {
  grid-column: span 4;
}

.tool-card:hover {
  border-color: var(--accent);
  background: var(--bg-soft);
  transform: translateY(-2px);
}

.tool-card-icon {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.tool-card-body {
  min-width: 0;
}

.tool-card-body h2 {
  margin: 0 0 5px;
  font-size: 17px;
}

.tool-card-body p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.55;
}

.tool-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.tool-card-tags li {
  border-radius: 6px;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
}

.tool-card-arrow {
  position: absolute;
  top: 16px;
  right: 18px;
  font-size: 18px;
  color: var(--text-faint);
  transition: transform 0.15s, color 0.15s;
}

.tool-card:hover .tool-card-arrow {
  color: var(--accent);
  transform: translateX(4px);
}

.site-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 9px 14px;
  color: var(--text-faint);
  font-size: 12px;
  background: var(--bg-elev);
  border-top: 1px solid var(--border-soft);
}

.site-footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

.panel {
  display: none;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  flex: 1 1 auto;
  min-height: 0;
}

.panel.active {
  display: flex;
}

.panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 14px;
}

.panel-head h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.panel-head .desc {
  margin: 0;
  flex: 1 1 420px;
  min-width: 0;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.5;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 0;
  min-height: 0;
}

.toolbar-card {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 12px;
}

.mode-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-label {
  color: var(--text-secondary);
}

.seg {
  display: flex;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 7px;
  padding: 6px 14px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.regex-pattern-group {
  flex: 1 1 420px;
}

.regex-input {
  flex: 1;
  min-width: 220px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  outline: none;
}

.regex-input:focus {
  border-color: var(--accent);
}

.regex-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.regex-flags label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--ctl-h);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 9px;
  padding: 0 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

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

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.primary:disabled,
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.btn.small {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 7px;
}

.text-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}

.editor-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.editor-card.output-card {
  grid-column: 1 / -1;
}

.full-span {
  grid-column: 1 / -1;
}

.ed-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 0 0 auto;
  margin-bottom: 8px;
  min-height: 30px;
}

.ed-name {
  font-weight: 650;
}

.ed-hint {
  color: var(--text-faint);
  font-size: 12px;
  flex: 1;
  min-width: 80px;
}

.ed-hint.error {
  color: var(--danger);
}

.readonly-tag {
  font-style: normal;
  font-size: 11px;
  color: var(--warn);
  border: 1px solid rgba(154, 103, 0, 0.35);
  border-radius: 6px;
  padding: 0 5px;
  margin-left: 5px;
  vertical-align: 1px;
}

.editor {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.editor.output {
  min-height: 0;
}

/* 正则页：文本 / 匹配结果 / 高亮预览 三栏并排，各自内部滚动 */
.text-grid.regex-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
}

/* 字符串页：输入输出左右各一半 */
.text-grid.string-grid {
  grid-template-rows: minmax(0, 1fr);
}

/* Diff 页：上面 A/B 编辑器，下面整行结果 */
.text-grid.diff-grid {
  grid-template-rows: minmax(0, 1fr) minmax(0, 1.6fr);
}

.regex-result-card {
  grid-column: 1 / -1;
}

.regex-grid .regex-result-card {
  grid-column: auto;
}

.regex-result {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--code-bg);
  padding: 10px;
}

.regex-empty,
.regex-error {
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 26px 10px;
}

.regex-error {
  color: var(--danger);
  text-align: left;
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
}

.regex-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.regex-match {
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  background: var(--bg);
  overflow: hidden;
}

.regex-match-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-secondary);
  font-size: 12px;
}

.regex-index {
  color: var(--accent);
  font-weight: 700;
}

.regex-match-text {
  margin: 0;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

.regex-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 10px 8px;
}

.regex-groups span {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  padding: 2px 7px;
}

.json-output-card .editor-card-body {
  flex: 1;
  min-height: 0;
}

.btn-group {
  display: flex;
  gap: 4px;
}

.btn-group .btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- 代码编辑器 ---------- */
.code-editor {
  height: 100%;
  /* 不设最小高度：行高由外层栅格决定，否则会把一屏布局顶破 */
  min-height: 0;
  display: flex;
  cursor: text;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--code-bg);
}

.ce-gutter {
  flex: 0 0 46px;
  width: 46px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
  overflow: hidden;
  user-select: none;
  cursor: text;
}

.ce-gutter-inner {
  position: relative;
  will-change: transform;
}

.ce-line-no {
  height: var(--ed-lh);
  line-height: var(--ed-lh);
  color: #536984;
  text-align: right;
  padding-right: 9px;
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
}

.ce-scroll {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: auto;
  cursor: text;
  scrollbar-color: #c8d1da transparent;
  scrollbar-width: thin;
}

.ce-marks {
  position: absolute;
  top: var(--ed-pad-y);
  left: var(--ed-pad-x);
  z-index: 0;
  pointer-events: none;
}

.ce-mark {
  position: absolute;
  left: 0;
  width: 100%;
  height: var(--ed-lh);
}

.ce-mark.dup {
  background: var(--dup-bg);
}

.ce-mark.hit {
  background: var(--hit-bg);
}

.ce-input {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: var(--ed-pad-y) var(--ed-pad-x);
  border: 0;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  caret-color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
  line-height: var(--ed-lh);
  white-space: pre;
  tab-size: 4;
}

.ce-input.soft {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ce-input:read-only {
  cursor: default;
}

::selection {
  background: var(--accent-soft);
}

/* ---------- JSON 输出 ---------- */
.json-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
}

.json-output-card {
  min-height: 0;
}

.json-output {
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--code-bg);
  overflow: auto;
  position: relative;
  padding: 0;
}

.json-empty {
  color: var(--text-faint);
  padding: 28px 20px;
  text-align: center;
}

.json-error {
  margin: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(207, 34, 46, 0.35);
  background: rgba(207, 34, 46, 0.06);
  color: var(--danger);
  border-radius: 9px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12.5px;
}

.json-rows {
  font-family: var(--mono);
  font-size: 13px;
  line-height: var(--ed-lh);
  min-width: 100%;
}

.jrow {
  display: flex;
  min-height: var(--ed-lh);
  width: max-content;
  min-width: 100%;
}

.jrow:hover {
  background: rgba(15, 30, 45, 0.03);
}

.jrow-hidden {
  display: none;
}

.jln {
  flex: 0 0 46px;
  width: 46px;
  color: #536984;
  text-align: right;
  padding: 0 9px 0 0;
  user-select: none;
  border-right: 1px solid var(--border-soft);
  margin-right: 10px;
  background: var(--bg-soft);
  position: sticky;
  left: 0;
  z-index: 1;
}

.jcontent {
  padding-right: 18px;
  white-space: pre;
}

.j-toggle {
  border: 0;
  background: transparent;
  cursor: pointer;
  width: 18px;
  padding: 0 3px 0 0;
  color: var(--text-faint);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s;
  vertical-align: 1px;
}

.j-toggle.collapsed {
  transform: rotate(-90deg);
}

.j-toggle-placeholder {
  display: inline-block;
  width: 18px;
}

.tk-key {
  color: #0550ae;
}

.tk-str {
  color: #0a6e2d;
}

.tk-num {
  color: #9a6700;
}

.tk-bool {
  color: #8250df;
}

.tk-null {
  color: #cf222e;
}

.tk-punc {
  color: #59636e;
}

.tk-dots {
  color: var(--warn);
  font-style: italic;
}

.tok-collapsed {
  color: var(--text-faint);
}

.compact-row {
  padding: 6px 0;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 20;
}

.toast.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #c8d1da;
  border-radius: 6px;
  border: 2px solid var(--code-bg);
}

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

/* ---------- 表单控件（数学 / 字符串 / 时间戳工具） ---------- */
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 10px;
  flex: 0 0 auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  flex: 0 1 auto;
}

.field.grow {
  /* 基准值要小，否则两三个输入框就撑满一行被迫换行 */
  flex: 1 1 140px;
}

.field-label {
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
}

.input,
.select {
  height: var(--ctl-h);
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}

.select {
  font-family: var(--sans);
  cursor: pointer;
}

.input:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input.small {
  width: 88px;
}

.input.xsmall {
  width: 68px;
}

.check-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--ctl-h);
  color: var(--text-secondary);
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
}

.check-line input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.textarea {
  min-height: 56px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-elev);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

kbd {
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 0 5px;
}

/* ---------- 模块卡片与结果框（数学 / 时间戳工具） ---------- */
.module-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}

/* 6 个模块排成 2 行，每行都占满 12 格 */
.module-grid .col-3 {
  grid-column: span 3;
}

.module-grid .col-4 {
  grid-column: span 4;
}

.module-grid .col-5 {
  grid-column: span 5;
}

.module-grid .col-8 {
  grid-column: span 8;
}

/* 时间戳页只有两张卡，各占一半 */
.module-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
}

.module-grid.two-col .card.module {
  grid-column: auto;
}

.card.module {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  overflow: hidden;
}

/* 卡片内部的两栏（例如日期计算的两组） */
.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-height: 0;
}

.split > * {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.module-head h2 {
  margin: 0 0 1px;
  font-size: 15px;
}

.module-desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.module-desc code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-soft);
  border-radius: 5px;
  padding: 1px 5px;
}

.module-desc.error {
  color: var(--danger);
}

.result-box {
  flex: 1 1 auto;
  min-height: 34px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--code-bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.result-box.muted {
  color: var(--text-faint);
}

.result-box.error {
  border-color: rgba(207, 34, 46, 0.4);
  background: rgba(207, 34, 46, 0.05);
  color: var(--danger);
  font-family: var(--sans);
  font-weight: 600;
}

.result-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.result-foot .hint {
  flex: 1;
  min-width: 120px;
  color: var(--text-faint);
  font-size: 12px;
}

/* 结果与附加信息并排：左边主结果、右边明细 */
.result-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
}

/* 时间戳页的明细行（本地时间 / UTC / 相对现在…） */
.meta-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  gap: 5px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}

.meta-list > div {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.meta-list dt {
  flex: 0 0 68px;
  color: var(--text-secondary);
  font-size: 11.5px;
}

.meta-list dd {
  margin: 0;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
}

/* ---------- 文本 Diff 对比 ---------- */
.diff-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--code-bg);
}

.diff-empty {
  padding: 40px 20px;
  color: var(--text-faint);
  text-align: center;
}

.diff-rows {
  width: max-content;
  min-width: 100%;
  font-family: var(--mono);
  font-size: 13px;
  line-height: var(--ed-lh);
}

.diff-row {
  display: flex;
  min-height: var(--ed-lh);
}

.diff-sign {
  flex: 0 0 30px;
  width: 30px;
  text-align: center;
  color: var(--text-faint);
  user-select: none;
}

.diff-text {
  padding-right: 20px;
  white-space: pre;
}

.diff-row.add {
  background: var(--add-soft);
}

.diff-row.add .diff-sign {
  color: var(--add);
  font-weight: 700;
}

.diff-row.del {
  background: var(--del-soft);
}

.diff-row.del .diff-sign {
  color: var(--del);
  font-weight: 700;
}

.diff-text mark {
  border-radius: 3px;
  color: inherit;
}

.diff-text mark.ins {
  background: rgba(26, 127, 55, 0.3);
}

.diff-text mark.del {
  background: rgba(207, 34, 46, 0.22);
  text-decoration: line-through;
}

.diff-row.fold {
  background: var(--bg-soft);
  color: var(--text-secondary);
  cursor: pointer;
}

.diff-row.fold:hover {
  color: var(--accent);
}

.diff-row.fold .diff-sign {
  color: inherit;
}

.diff-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.diff-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 3px;
  vertical-align: -1px;
}

/* ---------- 正则高亮预览 ---------- */
.regex-preview {
  flex: 1;
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.regex-preview mark {
  border-radius: 3px;
  background: var(--chg-soft);
  color: inherit;
  box-shadow: inset 0 -1px 0 var(--chg);
}

/* ---------- 实时时间卡（时间戳工具） ---------- */
.live-card {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
}

.live-main {
  flex: 1 1 260px;
  min-width: 0;
}

.live-eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.live-time {
  font-size: clamp(20px, 2.6vw, 26px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.live-stamp {
  margin-top: 3px;
  color: var(--text-secondary);
  font-family: var(--mono);
  font-size: 14px;
}

.live-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- 响应式 ---------- */

/* 屏幕不够大或不够高时退回「自然高度 + 页面滚动」：
   一屏塞不下就别硬塞，宁可滚动，也不要把编辑器压到没法用。 */
@media (max-width: 1180px), (max-height: 700px) {
  .container {
    overflow-y: auto;
  }

  .panel,
  .text-grid,
  .json-grid,
  .module-grid,
  .summary-grid {
    flex: 0 0 auto;
  }

  .text-grid,
  .json-grid,
  .module-grid,
  .module-grid.two-col,
  .text-grid.regex-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-rows: min-content;
  }

  .module-grid .col-3,
  .module-grid .col-4,
  .module-grid .col-5,
  .module-grid .col-8 {
    grid-column: span 2;
  }

  .editor-card.output-card,
  .full-span,
  .regex-grid .regex-result-card {
    grid-column: 1 / -1;
  }

  .editor {
    min-height: 200px;
    height: clamp(200px, 38vh, 420px);
  }

  .json-output,
  .regex-result,
  .regex-preview {
    min-height: 240px;
    max-height: 58vh;
  }

  .diff-view {
    min-height: 260px;
    height: 48vh;
  }

  .result-box {
    min-height: 44px;
    max-height: 220px;
  }

  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: min-content;
  }

  .tool-card,
  .tool-card:nth-child(n + 5) {
    grid-column: span 1;
    min-height: 132px;
  }
}

@media (max-width: 980px) {
  .text-grid,
  .json-grid,
  .module-grid,
  .module-grid.two-col,
  .text-grid.regex-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .module-grid .col-3,
  .module-grid .col-4,
  .module-grid .col-5,
  .module-grid .col-8 {
    grid-column: auto;
  }

  .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor-card.output-card {
    grid-column: auto;
  }

  .topbar {
    gap: 10px;
    padding: 0 12px;
    overflow-x: auto;
  }

  .sites {
    display: none;
  }
}

@media (max-width: 620px) {
  .container {
    padding: 12px 10px 16px;
  }

  .toolbar-actions {
    margin-left: 0;
    width: 100%;
  }

  .mode-group {
    flex-wrap: wrap;
  }
}

/* 共用操作保持紧凑，桌面编辑器继续使用容器内滚动。 */
:root { color-scheme: light; }
.brand-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; color: var(--accent); background: var(--accent-soft); font-size: 26px; }
.card, .tool-card { box-shadow: 0 3px 12px rgba(26, 55, 96, .035); }
.page-nav { min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.page-nav a, .page-nav .current { padding: 6px 10px; font-weight: 600; }
.btn { background: var(--bg-elev); font-family: var(--sans); }
.seg { max-width: 100%; flex-wrap: wrap; }
.seg-btn { white-space: nowrap; font-family: var(--sans); }
.btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .j-toggle:focus-visible, .diff-row.fold:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.code-editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ce-input:focus-visible { outline: none; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
.preset-label { display: inline-flex; align-items: center; gap: 8px; color: var(--text-secondary); }
.toast { background: var(--bg-elev); color: var(--text); border-color: var(--border); max-width: calc(100vw - 24px); }
.tk-key { color: var(--accent); }
.jln, .ce-line-no { color: var(--text-faint); }
.result-box.error, .json-error, .regex-error { color: var(--danger); }
.import-file { display: none; }
:root[data-theme="dark"] { color-scheme: dark; --bg: #0d1729; --bg-elev: #16243a; --bg-soft: #1b2e49; --border: #3c5476; --border-soft: #2d4261; --text: #edf4ff; --text-secondary: #bfcee3; --text-faint: #a9bdd8; --accent: #80b8ff; --accent-soft: rgba(128,184,255,.13); --code-bg: #101d31; --ok: #77db9c; --add: #77db9c; --warn: #ffd47a; --chg: #ffd47a; --danger: #ff9ba5; --del: #ff9ba5; }:root[data-theme="dark"] .btn.primary { color: #0d274e; }:root[data-theme="dark"] .tk-str { color: #8ce0ad; }:root[data-theme="dark"] .tk-num { color: #ffd47a; }:root[data-theme="dark"] .tk-bool { color: #c5b0ff; }:root[data-theme="dark"] .tk-null { color: #ff9ba5; }:root[data-theme="dark"] .tk-punc { color: #bfcee3; }:root[data-theme="dark"] .ce-line-no, :root[data-theme="dark"] .ce-gutter { background: var(--bg-soft); }

@media (max-width: 980px) {
  .topbar { height: auto; flex-wrap: wrap; overflow: visible; padding: 10px 12px; }
  .page-nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; }
  .sites { display: flex; }
  .summary-page { justify-content: flex-start; }
  .summary-grid { max-height: none; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .tool-card, .tool-card:nth-child(n+5) { grid-column: auto; }
}
@media (max-width: 620px) {
  .panel-head { align-items: flex-start; gap: 6px; }
  .panel-head h1 { font-size: 22px; }
  .panel-head .desc { flex-basis: 100%; line-height: 1.7; }
  .toolbar-card { align-items: flex-start; gap: 12px; }
  .mode-group { width: 100%; flex-direction: column; align-items: flex-start; gap: 6px; }
  .mode-label { font-size: 12px; }
  .toolbar-actions { flex-wrap: wrap; }
  .btn, .btn.small, .seg-btn { min-height: 38px; height: auto; padding: 7px 10px; }
  .regex-input { width: 100%; min-width: 0; flex: auto; }
  .form-row { gap: 8px; }
  .form-row .field.grow { flex-basis: 100%; }
  .ed-head .ed-hint { order: 3; flex-basis: 100%; }
  .summary-grid { grid-template-columns: minmax(0,1fr); }
  .summary-hero h1 { font-size: 26px; }
  .live-card { align-items: flex-start; flex-wrap: wrap; }
  .live-tools { flex-wrap: wrap; }
  .live-clock { min-width: 0; }
  .live-time { font-size: 24px; overflow-wrap: anywhere; }
  .meta-list dd { overflow-wrap: anywhere; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
