/* ============================================================
   万能工具箱 · 样式表
   设计语言：暖色系 / 大圆角矩形 / 柔和阴影 / 无蓝紫渐变
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f6f2ea;
  --bg-2: #efe8db;
  --card: #fffdf7;
  --field: #faf7f0;
  --text: #26221a;
  --muted: #837a6a;
  --border: #e7ddcc;
  --accent: #059669;
  --accent-deep: #047857;
  --accent-soft: #d1fae5;
  --hot: #f97316;
  --hot-2: #e11d48;
  --gold: #f59e0b;
  --good: #16a34a;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(90, 60, 20, .06);
  --shadow-lg: 0 14px 34px rgba(120, 75, 20, .14);
  --grad: linear-gradient(135deg, #f97316 0%, #e11d48 52%, #f59e0b 100%);
  --radius: 18px;
}

html.dark {
  --bg: #191610;
  --bg-2: #221d15;
  --card: #241f17;
  --field: #2c261c;
  --text: #efe7d8;
  --muted: #a89c88;
  --border: #3a3225;
  --accent: #34d399;
  --accent-deep: #6ee7b7;
  --accent-soft: #15382c;
  --good: #4ade80;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 14px 34px rgba(0, 0, 0, .45);
}

[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 顶部暖色氛围光晕（非蓝紫） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1100px 480px at 88% -8%, rgba(249, 115, 22, .10), transparent 62%),
    radial-gradient(900px 420px at -6% 4%, rgba(245, 158, 11, .09), transparent 60%);
  pointer-events: none;
}
html.dark body::before {
  background:
    radial-gradient(1100px 480px at 88% -8%, rgba(249, 115, 22, .07), transparent 62%),
    radial-gradient(900px 420px at -6% 4%, rgba(245, 158, 11, .05), transparent 60%);
}

::selection { background: #fde68a; color: #422006; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.mono { font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", Menlo, monospace; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 20px;
}
.logo { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo-icon {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex: none;
  box-shadow: 0 6px 16px rgba(225, 29, 72, .25);
}
.logo-text h1 {
  font-size: 21px;
  line-height: 1.25;
  font-weight: 800;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo-text p { font-size: 12px; color: var(--muted); white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: flex-end; min-width: 0; }

.search-box {
  flex: 1;
  max-width: 430px;
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.search-icon { font-size: 15px; opacity: .7; }
.search-box input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 14px; min-width: 0; }
.search-box input::placeholder { color: var(--muted); }

.icon-btn {
  width: 42px; height: 42px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  transition: transform .15s;
}
.icon-btn:hover { transform: translateY(-1px); }

/* ---------------- 分类筛选 ---------------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.chip {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13.5px;
  color: var(--text);
  display: flex; align-items: center; gap: 6px;
  box-shadow: var(--shadow);
  transition: all .15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip-n {
  font-size: 11px;
  opacity: .85;
  background: color-mix(in srgb, currentColor 14%, transparent);
  padding: 1px 7px;
  border-radius: 999px;
}

/* ---------------- 工具卡片网格 ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 14px;
  margin-top: 18px;
  padding-bottom: 20px;
}
.card {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  animation: fadeUp .3s both;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.card:active { transform: translateY(-1px) scale(.99); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card .icon {
  width: 46px; height: 46px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 23px;
  flex: none;
  transition: transform .18s ease;
}
.card:hover .icon { transform: scale(1.08) rotate(-3deg); }
.card-info { min-width: 0; }
.card-info h3 { font-size: 15px; font-weight: 700; }
.card-info p {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.empty { grid-column: 1 / -1; text-align: center; padding: 70px 0; color: var(--muted); font-size: 15px; }

/* 图标底色（暖色系） */
.tint-rose { background: #ffe4e6; }
.tint-orange { background: #ffedd5; }
.tint-amber { background: #fef3c7; }
.tint-yellow { background: #fef9c3; }
.tint-green { background: #dcfce7; }
.tint-emerald { background: #d1fae5; }
.tint-stone { background: #f1efe9; }
.tint-red { background: #fee2e2; }
.tint-lime { background: #ecfccb; }
html.dark .tint-rose { background: #4a2430; }
html.dark .tint-orange { background: #4a3018; }
html.dark .tint-amber { background: #463a18; }
html.dark .tint-yellow { background: #45401a; }
html.dark .tint-green { background: #1d3b28; }
html.dark .tint-emerald { background: #1c3d2e; }
html.dark .tint-stone { background: #35322b; }
html.dark .tint-red { background: #48222a; }
html.dark .tint-lime { background: #35401d; }

/* ---------------- 工具详情页 ---------------- */
#tool-view { margin-top: 22px; padding-bottom: 30px; }
.tool-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.tool-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tool-emoji {
  width: 48px; height: 48px;
  border-radius: 15px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex: none;
  box-shadow: 0 6px 16px rgba(225, 29, 72, .22);
}
.tool-title h2 { font-size: 19px; }
.tool-title p { font-size: 12.5px; color: var(--muted); }
#tool-body {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.fade-in { animation: fadeUp .28s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- 表单控件 ---------------- */
.label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.label-row { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 6px; }
.label-row .label { margin: 0; }
.inp {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
textarea.inp { resize: vertical; min-height: 90px; line-height: 1.6; }
textarea.inp.mono, .inp.mono { font-size: 13px; }
select.inp {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  cursor: pointer;
}
input[type="color"].inp { padding: 4px; height: 44px; cursor: pointer; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.warm { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(225, 29, 72, .28); }
.btn.warm:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { padding: 5px 11px; font-size: 12px; border-radius: 9px; }
.btn-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.btn-row.mt0 { margin-top: 0; }

/* 复选 / 单选胶囊 */
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pill {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  background: var(--card);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); font-weight: 600; }

/* ---------------- 通用布局 ---------------- */
.io-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.io-grid .col { min-width: 0; }
.panel {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-top: 16px;
}
.panel h4 { font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.result {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 56px;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 13.5px;
  line-height: 1.7;
}
.result.mono { font-size: 12.5px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.stat {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  text-align: center;
}
.stat-num { font-size: 20px; font-weight: 800; color: var(--accent); word-break: break-all; }
.stat-num.small { font-size: 14px; }
.stat-label { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.status { font-size: 13px; font-weight: 600; }
.status.ok { color: var(--good); }
.status.err { color: var(--danger); }
.err { color: var(--danger); font-size: 12.5px; margin-top: 6px; }
.ok { color: var(--good); }
.hint { color: var(--muted); font-size: 12px; }
.hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
mark { background: #fde68a; color: #713f12; border-radius: 3px; padding: 0 2px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.table th, .table td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th:first-child, .table td:first-child { text-align: left; }
.table th {
  position: sticky; top: 0;
  background: var(--field);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  z-index: 1;
}
.scroll-table {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--field);
  padding: 0 10px;
  margin-top: 4px;
}

/* ---------------- 计算器 ---------------- */
.calc { max-width: 400px; margin: 0 auto; }
.calc-display {
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 18px;
  text-align: right;
  margin-bottom: 14px;
  min-height: 84px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.calc-hist { font-size: 12px; color: var(--muted); min-height: 18px; word-break: break-all; }
.calc-expr { font-size: clamp(18px, 5vw, 26px); font-weight: 700; word-break: break-all; font-family: ui-monospace, Consolas, monospace; }
.calc-pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.calc-btn {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 13px;
  padding: 12px 0;
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: all .12s;
}
.calc-btn:hover { border-color: var(--accent); }
.calc-btn:active { transform: scale(.94); }
.calc-btn.op { color: var(--hot-2); font-weight: 700; }
.calc-btn.fn { font-size: 12.5px; color: var(--accent-deep); }
.calc-btn.eq {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
  grid-column: span 2;
  box-shadow: 0 6px 16px rgba(225, 29, 72, .28);
}
.calc-list-item { padding: 5px 8px; border-radius: 8px; cursor: pointer; }
.calc-list-item:hover { background: var(--accent-soft); }

/* ---------------- 时间类 ---------------- */
.big-time {
  font-family: ui-monospace, Consolas, monospace;
  font-size: clamp(30px, 6vw, 54px);
  font-weight: 800;
  text-align: center;
  letter-spacing: 2px;
  color: var(--accent);
}
.big-time.small { font-size: clamp(22px, 4vw, 34px); }
.time-unit { font-size: 12px; color: var(--muted); text-align: center; letter-spacing: 6px; margin-top: 2px; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.countdown-done { animation: blink 1s infinite; color: var(--danger); }

.clock-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--field);
  margin-top: 10px;
  flex-wrap: wrap;
}
.clock-city { font-weight: 700; font-size: 14px; }
.clock-offset, .clock-date { font-size: 11.5px; color: var(--muted); }
.clock-right { margin-left: auto; text-align: right; }
.clock-time { font-family: ui-monospace, Consolas, monospace; font-size: 19px; font-weight: 700; color: var(--accent); }

/* ---------------- 结果标签 ---------------- */
.out-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.out-chip {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent-deep);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 13px;
  font-family: ui-monospace, Consolas, monospace;
}

/* ---------------- 颜色工具 ---------------- */
.swatch {
  width: 100%;
  height: 120px;
  border-radius: 16px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: background .2s;
}
.swatch-txt {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; gap: 14px;
  flex-wrap: wrap;
  padding: 0 12px;
}
.pal-row { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; align-items: flex-start; }
.pal-title { font-size: 12px; color: var(--muted); min-width: 74px; line-height: 44px; font-weight: 600; }
.pal-swatch { width: 64px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); cursor: pointer; transition: transform .15s; background: var(--card); }
.pal-swatch:hover { transform: translateY(-3px); }
.pal-swatch .c { height: 44px; }
.pal-swatch .h { font-size: 10px; text-align: center; padding: 4px 2px; color: var(--muted); font-family: ui-monospace, monospace; }

/* ---------------- 密码 ---------------- */
.pw-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  margin-top: 12px;
}
.pw-text { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: 16px; word-break: break-all; font-weight: 600; }
.strength-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 10px; }
.strength-fill { height: 100%; border-radius: 999px; background: var(--danger); transition: width .3s, background .3s; }

/* ---------------- 图片 ---------------- */
.img-preview {
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 100%;
  max-height: 220px;
  display: block;
  margin-top: 12px;
  object-fit: contain;
  background: repeating-conic-gradient(var(--field) 0 25%, var(--card) 0 50%) 0 0 / 16px 16px;
}
.drop-hint {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s;
  margin-top: 8px;
}
.drop-hint:hover { border-color: var(--accent); }
.drop-hint input { display: none; }
.checker {
  background: repeating-conic-gradient(var(--field) 0 25%, var(--card) 0 50%) 0 0 / 18px 18px;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

/* ---------------- 提示与页脚 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #1c1917;
  color: #f5f0e6;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  z-index: 100;
  animation: fadeUp .25s ease;
  max-width: 88vw;
  text-align: center;
}
.footer {
  padding: 26px 20px 44px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.9;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; }
  .search-box { order: 3; max-width: none; flex-basis: 100%; }
}

@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .io-grid { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .card { padding: 14px; gap: 10px; }
  .card .icon { width: 40px; height: 40px; font-size: 20px; border-radius: 12px; }
  .card-info h3 { font-size: 14px; }
  .card-info p { font-size: 11.5px; }
  #tool-body { padding: 16px; border-radius: 18px; }
  .tool-head { gap: 10px; }
  .tool-emoji { width: 42px; height: 42px; font-size: 21px; border-radius: 13px; }
  .tool-title h2 { font-size: 17px; }
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: none;
  }
  .chips::-webkit-scrollbar { display: none; }
}

@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .topbar-inner { padding: 12px 16px; }
  .card { flex-direction: column; }
  .logo-text p { white-space: normal; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
