/* =========================================================
   OkTools · 全局样式（对标 metool.online：简洁冷色、分区卡片瀑布流）
   ========================================================= */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1a1d24;
  --muted: #697586;
  --border: #e8eaee;
  --border-strong: #d8dce2;
  --accent: #2563eb;
  --accent-2: #0ea5e9;
  --accent-soft: rgba(37, 99, 235, .10);
  --danger: #ef4444;
  --ok: #10b981;
  --shadow: 0 1px 2px rgba(20, 24, 35, .04), 0 8px 24px rgba(20, 24, 35, .05);
  --shadow-hover: 0 4px 12px rgba(20, 24, 35, .08), 0 18px 40px rgba(37, 99, 235, .12);
  --radius: 16px;
  --radius-sm: 11px;
  --radius-lg: 22px;
  --maxw: 1200px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #0d0f13;
  --surface: #16191f;
  --surface-2: #1e222b;
  --text: #e6e8ee;
  --muted: #98a2b3;
  --border: #262b34;
  --border-strong: #333a45;
  --accent: #60a5fa;
  --accent-2: #38bdf8;
  --accent-soft: rgba(96, 165, 250, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-hover: 0 6px 18px rgba(0, 0, 0, .4), 0 20px 44px rgba(37, 99, 235, .22);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

/* 视觉隐藏但可被 click() 触发（避免 hidden 属性在部分浏览器拦截文件对话框） */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 14px; box-shadow: 0 4px 14px var(--accent-soft);
}
.brand-name { font-size: 18px; letter-spacing: .2px; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; font-size: 18px; transition: transform .2s, box-shadow .2s, border-color .2s;
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }

/* ---------- Hero ---------- */
.hero { padding: 60px 0 30px; text-align: center; }
.hero h1 { font-size: clamp(28px, 4vw, 44px); margin: 0 0 14px; letter-spacing: -.5px; font-weight: 800; line-height: 1.18; }
.hero p { color: var(--muted); margin: 0 auto; max-width: 560px; font-size: 15.5px; }
.hero .ip-line { margin-top: 14px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Search (已移除，保留占位避免误用) ---------- */
.search-box { display: none; }

/* ---------- Category chips (quick jump) ---------- */
.cat-chips { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; margin: 22px 0 4px; }
.cat-chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  padding: 7px 15px; border-radius: 999px; cursor: pointer; font-size: 13.5px; font-weight: 500;
  transition: all .18s ease; font-family: inherit;
}
.cat-chip:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.cat-chip.active { color: #fff; border-color: transparent; background: linear-gradient(120deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 18px var(--accent-soft); }

/* ---------- Category sections ---------- */
.cat-section { padding: 30px 0 8px; scroll-margin-top: 76px; }
.cat-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.cat-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.cat-head .cat-count { font-size: 12.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 3px 11px; border-radius: 999px; font-variant-numeric: tabular-nums; }

/* ---------- Tool grid ---------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.card {
  position: relative; text-align: left; cursor: pointer; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); transition: transform .25s cubic-bezier(.16, 1, .3, 1), box-shadow .25s, border-color .25s;
  display: flex; flex-direction: column; gap: 10px; overflow: hidden;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.card .tile {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  font-size: 24px; color: #fff;
  background: linear-gradient(135deg, var(--c1, var(--accent)), var(--c2, var(--accent-2)));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--c1, var(--accent)) 35%, transparent);
  transition: transform .3s cubic-bezier(.16, 1, .3, 1);
}
.card .tile svg { width: 26px; height: 26px; }
.card:hover .tile { transform: scale(1.07); }
.card h3 { margin: 2px 0 0; font-size: 15.5px; font-weight: 650; }
.card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .cat-tag {
  align-self: flex-start; font-size: 11px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; margin-top: auto;
}

.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* ---------- Tool view (左侧导航 + 右侧内容) ---------- */
.tool-view { padding: 26px 0 60px; }
.tool-layout { display: flex; gap: 28px; align-items: flex-start; }
.tool-sidebar {
  width: 232px; flex-shrink: 0; position: sticky; top: 82px;
  max-height: calc(100vh - 100px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px; padding-right: 6px;
}
/* 面包屑导航（替代返回按钮） */
.crumb { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.crumb a { color: var(--muted); text-decoration: none; transition: color .15s; }
.crumb a:hover { color: var(--accent); }
.crumb .sep { color: var(--border-strong); }
.crumb .cur { color: var(--text); font-weight: 600; }
.side-group { display: flex; flex-direction: column; gap: 4px; }
.side-group-title { font-size: 11.5px; font-weight: 700; letter-spacing: .4px; color: var(--muted); text-transform: uppercase; padding: 0 10px 6px; }
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 11px;
  text-decoration: none; color: var(--text); font-size: 13.5px; transition: background .15s, color .15s;
}
.side-link:hover { background: var(--surface-2); }
.side-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-ico {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(135deg, var(--c1, var(--accent)), var(--c2, var(--accent-2)));
  color: #fff; box-shadow: 0 3px 8px color-mix(in srgb, var(--c1, var(--accent)) 30%, transparent);
}
.side-ico svg { width: 16px; height: 16px; }
.side-link.active .side-ico { box-shadow: 0 4px 12px var(--accent-soft); }
.side-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tool-main { flex: 1; min-width: 0; }
.tool-head { display: flex; gap: 16px; align-items: center; margin-bottom: 22px; }
.tool-head .tile {
  width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center;
  font-size: 28px; color: #fff; box-shadow: 0 8px 20px color-mix(in srgb, var(--c1, var(--accent)) 30%, transparent);
  background: linear-gradient(135deg, var(--c1, var(--accent)), var(--c2, var(--accent-2)));
}
.tool-head .tile svg { width: 30px; height: 30px; }
.tool-head h1 { margin: 0; font-size: 24px; }
.tool-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- Generic components used inside tools ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.panel h4 { margin: 0 0 14px; font-size: 14px; font-weight: 650; color: var(--text);
  display: flex; align-items: center; gap: 8px; }
.panel h4 .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.tight { gap: 8px; }
.col { display: flex; flex-direction: column; gap: 12px; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
input[type="text"], input[type="number"], textarea, select {
  font-family: inherit; font-size: 14px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; outline: none;
  transition: border-color .2s, box-shadow .2s; width: 100%;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.55; font-family: var(--mono); font-size: 13px; }

/* JSON 工具：输入放大 + 输出大框（不超出屏幕、可滚动、语法高亮） */
.code-in { min-height: 180px; }
.code-out {
  margin: 0; padding: 16px 18px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 13px; line-height: 1.6; tab-size: 2;
  white-space: pre; overflow: auto;
  min-height: 58vh;
  max-height: calc(100vh - 220px);
  max-width: 100%;
}
.code-out code { font-family: inherit; }
/* 高亮配色（亮色） */
.jk-key { color: var(--accent); }
.jk-str { color: #16a34a; }
.jk-num { color: #c2410c; }
.jk-bool { color: #db2777; }
.jk-null { color: #6b7280; font-style: italic; }
/* 高亮配色（暗色） */
[data-theme="dark"] .jk-str { color: #34d399; }
[data-theme="dark"] .jk-num { color: #fbbf24; }
[data-theme="dark"] .jk-bool { color: #f472b6; }
[data-theme="dark"] .jk-null { color: #94a3b8; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23697586' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 10px 16px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; font-weight: 550;
  transition: all .18s ease; font-family: inherit; white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.btn:active { transform: translateY(0) scale(.98); }
.btn.primary { color: #fff; border-color: transparent; background: linear-gradient(120deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 18px var(--accent-soft); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.hint { font-size: 12.5px; color: var(--muted); }
.ok { color: var(--ok); }
.danger-text { color: var(--danger); }
.badge { display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.switch input { display: none; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }

.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; border: 1px solid var(--border); }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 8px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 550; transition: all .2s; font-family: inherit; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
  padding: 26px; text-align: center; color: var(--muted); cursor: pointer; transition: all .2s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.dropzone .big { font-size: 30px; display: block; margin-bottom: 6px; }
.url-load { display: flex; gap: 8px; margin-top: 10px; }
.url-load input { flex: 1; }
.url-status.err { color: var(--danger); }
.preview-wrap { margin-top: 14px; }
.preview-wrap img { max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th, table.tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.tbl th { color: var(--muted); font-weight: 600; }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }

.result {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; word-break: break-all;
}
.result.code { font-family: var(--mono); white-space: pre-wrap; }

/* 时间戳工具：结果行（每行可复制） */
.ts-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.ts-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ts-k { width: 92px; flex: none; color: var(--muted); font-size: 12.5px; }
.ts-v { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; line-height: 1.4; word-break: break-all; color: var(--text); }
.ts-copy { flex: none; font-size: 12px; padding: 5px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer; transition: all .15s; font-family: inherit; }
.ts-copy:hover { color: var(--accent); border-color: var(--accent); }
.ts-copy:active { transform: scale(.96); }
@media (max-width: 520px) { .ts-row { flex-wrap: wrap; } .ts-k { width: auto; } .ts-copy { margin-left: auto; } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 22px 0; color: var(--muted); font-size: 13px; text-align: center; margin-top: 30px; }

/* ---------- Responsive（适配大小屏幕） ---------- */
/* 超宽屏：限制最大宽度，避免内容拉得过散 */
@media (min-width: 1500px) {
  :root { --maxw: 1320px; }
}
/* 平板 / 小笔记本 */
@media (max-width: 1024px) {
  .hero { padding: 48px 0 26px; }
  .tool-sidebar { width: 210px; }
}
/* 窄屏：左侧导航栏改为分组竖向堆叠、每组内工具自动换行（全部可见，不截断不溢出） */
@media (max-width: 860px) {
  .tool-layout { flex-direction: column; gap: 14px; }
  .tool-sidebar {
    width: 100% !important;
    flex-direction: column !important; gap: 10px !important;
    padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); box-shadow: var(--shadow);
    padding-right: 0 !important;
    /* 小屏改为静态定位：sticky 会让导航栏在工具滚动时浮在顶部，遮挡下方工具内容 */
    position: static !important;
    top: auto !important; z-index: auto !important;
    max-height: none !important; overflow: visible !important;
  }
  .side-group { display: flex !important; flex-wrap: wrap !important; gap: 6px; width: 100%; flex-direction: row !important; }
  .side-group-title {
    display: block !important; width: 100% !important; margin: 0 0 2px;
    font-size: 11px; font-weight: 600; letter-spacing: .4px; color: var(--muted);
    padding: 0 !important; text-transform: none !important;
  }
  .side-link {
    display: inline-flex !important; align-items: center; gap: 5px; white-space: nowrap;
    flex: 0 0 auto !important; padding: 5px 9px !important; font-size: 12.5px !important;
    border-radius: 9px !important; max-width: 135px !important; width: auto !important;
  }
  .side-name { overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; }
  .side-ico { width: 20px !important; height: 20px !important; border-radius: 6px !important; flex-shrink: 0 !important; }
  .side-ico svg { width: 12px !important; height: 12px !important; }
}
/* 手机 */
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 36px 0 20px; }
  .hero h1 { font-size: clamp(24px, 7vw, 34px); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 200px)); gap: 12px; justify-content: center; }
  .card { padding: 16px; }
  .card .tile { width: 40px; height: 40px; font-size: 20px; border-radius: 12px; }
  .card .tile svg { width: 21px; height: 21px; }
  .row { gap: 8px; }
  .tool-head h1 { font-size: 20px; }
}
/* 小手机：卡片居中、近乎单列，避免挤压 */
@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 170px)); gap: 10px; justify-content: center; }
  .card { padding: 14px; }
  .card h3 { font-size: 14px; }
  .card p { font-size: 12px; }
  .crumb { font-size: 12px; }
}

/* ---------- 入场动画（参考 metool 3d：错峰渐显上浮） ---------- */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.card.reveal { animation: cardIn .45s cubic-bezier(.16, 1, .3, 1) both; animation-delay: calc(var(--i, 0) * 35ms); }

/* 分类标题也轻微渐入 */
.cat-section .cat-head { animation: fadeUp .4s ease both; }

/* 尊重「减少动画」无障碍偏好 */
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .card.reveal, .cat-section .cat-head, .fade { animation: none !important; }
  .card:hover, .btn:hover, .card:hover .tile { transform: none; }
}

/* fade-in（通用视图/hero 入场） */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade { animation: fadeUp .35s ease both; }
