:root {
  --accent: #007aff;
  --accent-hover: #0066cc;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --toggle-on: #34c759;
  --bg-window: rgba(246, 246, 248, 0.78);
  --bg-card: #ffffff;
  --bg-inset: rgba(0, 0, 0, 0.05);
  --border: rgba(0, 0, 0, 0.1);
  --text: #1d1d1f;
  --muted: #86868b;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-win: 0 22px 60px rgba(0, 0, 0, 0.28), 0 0 0 0.5px rgba(0, 0, 0, 0.12);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Helvetica Neue", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(at 0% 0%, #ffc4a0 0%, transparent 40%),
    radial-gradient(at 100% 0%, #a9c5ff 0%, transparent 42%),
    radial-gradient(at 60% 100%, #d6b3ff 0%, transparent 48%),
    linear-gradient(135deg, #fff5ef 0%, #eef2ff 50%, #f7ecff 100%);
  background-attachment: fixed;
  padding: 28px 16px;
}
[v-cloak] { display: none; }

/* ---- 浮窗式窗口 ---- */
#app {
  max-width: 920px;
  margin: 0 auto;
  background: var(--bg-window);
  backdrop-filter: blur(40px) saturate(1.7);
  -webkit-backdrop-filter: blur(40px) saturate(1.7);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-win);
  overflow: hidden;
}

/* ---- 工具栏 / 标题栏 ---- */
.titlebar {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px;
  background: rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 600; white-space: nowrap; }
.brand .logo {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, #007aff, #5ac8fa);
  color: #fff; display: grid; place-items: center; font-size: 14px;
  box-shadow: 0 1px 3px rgba(0, 122, 255, 0.45);
}

.content { padding: 22px 20px 48px; }
section h2 { margin-bottom: 15px; font-size: 18px; font-weight: 600; }

/* ---- 首页卡片选择 ---- */
.home { padding: 6px 0; }
.home-title { font-size: 22px; font-weight: 700; margin-bottom: 22px; text-align: center; }
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px;
}
.tool-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  text-align: left; padding: 20px; cursor: pointer;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card); transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.tool-card:hover {
  transform: translateY(-3px); border-color: rgba(0, 122, 255, 0.4);
  box-shadow: 0 8px 22px rgba(0, 122, 255, 0.16);
}
.card-icon {
  font-size: 30px; line-height: 1; width: 46px; height: 46px;
  display: grid; place-items: center; border-radius: 11px;
  background: var(--bg-inset);
}
.card-title { font-size: 16px; font-weight: 600; color: var(--text); }
.card-desc { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ---- 工具详情页 ---- */
.back-btn {
  margin-left: auto; background: var(--bg-inset); color: var(--text);
  border: none; padding: 5px 14px; border-radius: 7px; cursor: pointer; font-size: 13px;
  font-family: inherit; transition: background 0.12s ease;
}
.back-btn:hover { background: rgba(0, 0, 0, 0.1); }
.tool-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.tool-head .tool-icon {
  font-size: 24px; width: 40px; height: 40px;
  display: grid; place-items: center; border-radius: 9px; background: var(--bg-inset);
}
.tool-head h2 { margin-bottom: 0; }

section {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 22px; margin-bottom: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.row { margin-bottom: 14px; }
.row label { display: block; margin-bottom: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.row.inline { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.row.inline label { margin-bottom: 0; display: inline-flex; align-items: center; gap: 6px; }

input, textarea, select {
  width: 100%; padding: 8px 11px;
  border: 1px solid #d2d2d7; border-radius: 7px;
  font-size: 14px; outline: none; background: #fff; color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  font-family: inherit;
}
.row.inline input, .row.inline select { width: auto; }
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.5; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---- 开关（macOS 风格，开启为绿色）---- */
.switch-group label {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 13px; user-select: none;
}
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px;
  background: rgba(0, 0, 0, 0.16); transition: background 0.2s ease;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}
.switch input:checked + i { background: var(--toggle-on); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---- 按钮（macOS 风格）---- */
button {
  border: none; padding: 6px 16px; border-radius: 7px;
  font-size: 14px; cursor: pointer; font-family: inherit;
  transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.06s ease;
}
button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4); }
button.primary:active { transform: scale(0.98); }
button.small { padding: 4px 12px; font-size: 13px; }
button.primary.small { padding: 4px 12px; font-size: 13px; }
button.ghost { background: var(--bg-inset); color: var(--text); }
button.ghost:hover { background: rgba(0, 0, 0, 0.1); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.6s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result {
  background: #f5f5f7; color: #1d1d1f; padding: 16px;
  border-radius: 9px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-all;
  overflow-x: auto; margin-top: 12px; border: 1px solid var(--border);
}
.result-wrap { margin-top: 16px; }
.result-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: #ff3b30; margin-top: 10px; font-size: 14px; }
.strength { font-weight: 700; }
.strength.strong { color: #34c759; }
.strength.mid { color: #ff9500; }
.strength.weak { color: #ff3b30; }

/* ---- 表格 ---- */
table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
th, td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
th { background: var(--bg-inset); font-weight: 600; }
tbody tr:hover { background: rgba(0, 122, 255, 0.04); }

/* ---- 常用正则表达式库 ---- */
.lib-block { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 18px; }
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.lib-head h3 { font-size: 15px; font-weight: 600; }
.lib-group { margin-bottom: 18px; }
.lib-title {
  font-size: 13px; font-weight: 600; color: var(--accent);
  margin-bottom: 10px; padding-left: 10px; border-left: 3px solid var(--accent);
}
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.lib-item {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--bg-inset); border: 1px solid transparent; border-radius: 9px;
  padding: 9px 12px; cursor: pointer; transition: all 0.14s ease;
}
.lib-item:hover { border-color: rgba(0, 122, 255, 0.4); background: var(--accent-soft); }
.lib-name { font-size: 12px; color: var(--text); font-weight: 500; }
.lib-pat {
  font-size: 11.5px; color: #0a6ccc; word-break: break-all; white-space: normal;
}

.ml { margin-left: 8px; }

@media (max-width: 640px) {
  body { padding: 0; }
  #app { border-radius: 0; }
  .titlebar { padding: 10px 14px; }
  .card-grid, .lib-grid { grid-template-columns: 1fr; }
}