/* =========================================================================
   通用 UI 样式 · 直角简约风格
   设计语言：中性灰表面 + 1px 描边 + 2px 直角圆角，
   强调色只出现在关键操作上；自动适配浅色/深色模式（prefers-color-scheme）
   ========================================================================= */

/* ------------------------------------------------------------------ 设计令牌 */
:root {
  color-scheme: light;

  /* 表面与背景 */
  --bg: #f6f7f9;            /* 页面底色 */
  --surface: #ffffff;       /* 卡片 / 输入框表面 */
  --surface-2: #fafbfc;     /* 次级表面（标签底、代码底） */
  --surface-3: #f1f3f4;     /* 三级表面（hover 底、开关底） */
  --hover: rgba(60, 64, 67, 0.06);
  --active: rgba(60, 64, 67, 0.1);

  /* 描边 */
  --line: #e0e3e7;          /* 常规 1px 描边 */
  --line-strong: #c9ced6;   /* hover 加深描边 / 滚动条 */

  /* 文字（三级灰阶） */
  --text: #1f2328;          /* 主要文字 */
  --text-2: #5f6368;        /* 次要文字 / 说明 */
  --text-3: #8b9198;        /* 弱化文字 / 占位符 */

  /* 强调色（只用于关键操作与选中态） */
  --accent: #1a73e8;
  --accent-hover: #1765cc;
  --accent-soft: #e8f0fe;   /* 选中底色 */
  --accent-line: #c6dafc;

  /* 语义色（软底 + 深字，用于标签 / 提示） */
  --danger: #d93025;
  --danger-soft: #fce8e6;
  --ok: #188038;
  --ok-soft: #e6f4ea;
  --warn: #9a6700;
  --warn-soft: #fef7e0;

  /* 形状与阴影：直角 + 极轻阴影 */
  --radius: 2px;
  --shadow-1: 0 1px 2px rgba(60, 64, 67, 0.08), 0 1px 3px rgba(60, 64, 67, 0.06);
  --shadow-2: 0 6px 18px rgba(60, 64, 67, 0.14), 0 2px 6px rgba(60, 64, 67, 0.08);

  --font: "Segoe UI", "Roboto", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", system-ui,
    -apple-system, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #1b1b1b;
    --surface: #242424;
    --surface-2: #2b2b2b;
    --surface-3: #323232;
    --hover: rgba(255, 255, 255, 0.06);
    --active: rgba(255, 255, 255, 0.1);

    --line: #3a3a3a;
    --line-strong: #4a4a4a;

    --text: #e6e6e6;
    --text-2: #b0b4b9;
    --text-3: #868b91;

    /* 深色下强调色提亮、语义色改软底半透明 */
    --accent: #8ab4f8;
    --accent-hover: #a4c5f9;
    --accent-soft: rgba(138, 180, 248, 0.14);
    --accent-line: rgba(138, 180, 248, 0.32);

    --danger: #f28b82;
    --danger-soft: rgba(242, 139, 130, 0.14);
    --ok: #81c995;
    --ok-soft: rgba(129, 201, 149, 0.14);
    --warn: #fdd663;
    --warn-soft: rgba(253, 214, 99, 0.14);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 10px 26px rgba(0, 0, 0, 0.5);
  }
}

/* ------------------------------------------------------------------ 基础重置 */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
[hidden] {
  display: none !important;
}
svg {
  display: block;
}
code,
pre {
  font-family: var(--mono);
}

/* 滚动条：方形 + 描边色，与直角语言一致 */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 2px solid var(--bg);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ------------------------------------------------------------------ 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover {
  background: var(--surface-3);
  border-color: var(--line-strong);
  text-decoration: none;
}
.btn:active {
  background: var(--active);
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}
/* 主操作按钮：全站唯一的大面积强调色 */
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
@media (prefers-color-scheme: dark) {
  .btn.primary {
    color: #1b1b1b;
    font-weight: 500;
  }
}
/* 危险操作：文字红、hover 才上红底 */
.btn.danger {
  color: var(--danger);
  border-color: var(--line);
}
.btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}
/* 幽灵按钮：无边框，用于次要入口 */
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover {
  background: var(--hover);
  border-color: transparent;
}
/* 图标按钮 */
.btn.icon {
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn.icon:hover {
  background: var(--hover);
  color: var(--text);
}
.btn.sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

/* ------------------------------------------------------------------ 表单 */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > label {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}
.input,
.select,
.textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--line-strong);
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}
.textarea {
  height: auto;
  min-height: 72px;
  padding: 8px 10px;
  resize: vertical;
  line-height: 1.6;
}
/* 下拉框：自绘箭头，禁用原生外观 */
.select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
.hint {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.65;
}
.hint b {
  color: var(--text-2);
  font-weight: 500;
}

/* 开关：方形轨道 + 方形滑块，与直角语言一致 */
.switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex: none;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface-3);
  transition: background 0.14s ease, border-color 0.14s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-3);
  transition: transform 0.14s ease, background 0.14s ease;
}
.switch[aria-checked="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.switch[aria-checked="true"]::after {
  transform: translateX(16px);
  background: var(--accent);
}

/* 分段控件（tab 式切换） */
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.seg-item {
  height: 32px;
  padding: 0 16px;
  font-size: 13px;
  color: var(--text-2);
  border-right: 1px solid var(--line);
  transition: background 0.12s ease, color 0.12s ease;
}
.seg-item:last-child {
  border-right: none;
}
.seg-item:hover {
  background: var(--hover);
}
.seg-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

/* ------------------------------------------------------------------ 卡片与布局 */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.card > h3 {
  margin: 0;
  padding: 14px 18px;
  font-size: 13.5px;
  font-weight: 500;
  border-bottom: 1px solid var(--line);
}
.card .card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px;
}
/* 设置行：左标题+说明，右侧控件 */
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.row-between .t {
  font-size: 13px;
  font-weight: 500;
}
.row-between .d {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-3);
}
/* 顶部工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.toolbar .spacer {
  flex: 1;
}
.toolbar .count {
  font-size: 12px;
  color: var(--text-3);
}

/* ------------------------------------------------------------------ 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  white-space: nowrap;
}
.tag.ok {
  background: var(--ok-soft);
  border-color: transparent;
  color: var(--ok);
}
.tag.warn {
  background: var(--warn-soft);
  border-color: transparent;
  color: var(--warn);
}
.tag.bad {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}
.tag.blue {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

/* ------------------------------------------------------------------ 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 33, 36, 0.4);
}
@media (prefers-color-scheme: dark) {
  .modal {
    background: rgba(0, 0, 0, 0.6);
  }
}
.modal-card {
  width: min(460px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
.modal-card.wide {
  width: min(640px, 100%);
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 0;
}
.modal-head h2 {
  flex: 1;
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 6px;
}
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 18px;
}
.modal-foot .spacer {
  flex: 1;
}

/* ------------------------------------------------------------------ Toast 轻提示 */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  max-width: 460px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--text-3);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  font-size: 12.5px;
  color: var(--text);
  animation: toastIn 0.16s ease;
}
.toast.ok {
  border-left-color: var(--ok);
}
.toast.bad {
  border-left-color: var(--danger);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------------------------------------------ 加载与空状态 */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.empty-state {
  padding: 72px 24px;
  text-align: center;
  color: var(--text-3);
}
.empty-state .ic {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-3);
}
.empty-state h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
}
.empty-state p {
  margin: 0 0 14px;
  font-size: 12.5px;
}

/* ------------------------------------------------------------------ 通用工具类 */
.mono {
  font-family: var(--mono);
}
.muted {
  color: var(--text-3);
}
.text-ok {
  color: var(--ok);
}
.text-bad {
  color: var(--danger);
}
.text-warn {
  color: var(--warn);
}

/* ==================================================================
   共享页面骨架（topbar / page / footer / toast）
   所有工具页面共同使用；页面内同名内联定义会覆盖此处默认值
   ================================================================== */


/* ---------- 主体容器 ---------- */
.page,
.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.page-head h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
}
.page-head p {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-2);
}

/* ---------- 按钮行 ---------- */
.btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- 页脚 ---------- */
.footer {
  border-top: 1px solid var(--line);
}
.footer-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-3);
}
.footer a {
  color: var(--text-2);
  text-decoration: none;
}
.footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}
@media (max-width: 760px) {
  .footer-inner {
    justify-content: center;
    text-align: center;
  }
}

/* ---------- Toast ---------- */
.toast {
  max-width: 460px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--text-3);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  font-size: 12.5px;
  color: var(--text);
  z-index: 90;
}
.toast.ok,
.toast-ok {
  border-left-color: var(--ok);
}
.toast.bad {
  border-left-color: var(--danger);
}
/* 容器模式（.toasts 内滚动堆叠，由动画进场） */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toasts .toast {
  animation: toastIn 0.16s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
/* 单例模式（直接挂 body，配合 .show 显隐） */
body > .toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 6px);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
body > .toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 品牌 logo 方块（toolbar / topbar 通用） ---------- */
.mark {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--accent);
  flex-shrink: 0;
}
