/* ============================================================
   OIO7 工具与小游戏 · 全局样式
   明/暗双主题 · 响应式 · 无外部依赖
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;
  --header-h: 56px;
  --accent-1: #4f7cff;
  --accent-2: #a78bfa;
  --accent-3: #2dd4bf;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070a12;
  --bg-grad-1: rgba(79, 124, 255, 0.10);
  --bg-grad-2: rgba(167, 139, 250, 0.08);
  --text: #e8ecf4;
  --text-dim: #9aa5b8;
  --card: rgba(255, 255, 255, 0.035);
  --card-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.05);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --glow: 0 0 0 1px rgba(79, 124, 255, 0.25), 0 8px 40px rgba(79, 124, 255, 0.12);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-grad-1: rgba(79, 124, 255, 0.08);
  --bg-grad-2: rgba(167, 139, 250, 0.08);
  --text: #1c2333;
  --text-dim: #5c6a85;
  --card: rgba(255, 255, 255, 0.75);
  --card-hover: rgba(255, 255, 255, 0.98);
  --border: rgba(28, 35, 51, 0.09);
  --input-bg: #ffffff;
  --shadow: 0 10px 30px rgba(28, 35, 51, 0.08);
  --glow: 0 0 0 1px rgba(79, 124, 255, 0.20), 0 8px 30px rgba(79, 124, 255, 0.15);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(60% 50% at 15% 0%, var(--bg-grad-1), transparent 60%),
    radial-gradient(50% 45% at 85% 10%, var(--bg-grad-2), transparent 60%);
  pointer-events: none;
}

a { color: inherit; text-decoration: none; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

::selection { background: rgba(79, 124, 255, 0.35); }

/* 主题过渡 */
body.theme-switching *,
body.theme-switching *::before,
body.theme-switching *::after {
  transition: background-color 0.25s ease, color 0.25s ease,
    border-color 0.25s ease, fill 0.25s ease !important;
}

/* ---------- 星空粒子背景 ---------- */
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.logo-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.logo-mark img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(30, 60, 160, 0.35);
}

.logo .logo-sub {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-dim);
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  border: 1px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.icon-btn:hover {
  background: var(--card-hover);
  color: var(--text);
  border-color: var(--border);
}

.icon-btn svg { width: 19px; height: 19px; }

/* 主题图标切换 */
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ---------- 首页 Hero ---------- */
.hero {
  padding: clamp(48px, 9vw, 96px) 20px 32px;
  text-align: center;
  max-width: 900px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(2rem, 5.5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  background: linear-gradient(120deg, var(--text) 30%, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero .slogan {
  margin-top: 14px;
  font-size: clamp(0.9rem, 2.2vw, 1.05rem);
  font-weight: 600;
  letter-spacing: 0.12em;
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero .tagline {
  margin-top: 10px;
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  color: var(--text-dim);
  min-height: 1.8em;
}

.hero .tagline .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent-1);
  vertical-align: -0.12em;
  margin-left: 2px;
  animation: blink 0.9s step-end infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* ---------- 栏目与卡片 ---------- */
.section {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.section-head .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.section-head .dot.tools { background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); box-shadow: 0 0 12px rgba(79,124,255,.6); }
.section-head .dot.games { background: linear-gradient(135deg, #f59e0b, #ef4444); box-shadow: 0 0 12px rgba(245,158,11,.5); }

.section-head h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.section-head .count {
  font-size: 0.75rem;
  color: var(--text-dim);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 10px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px 20px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 0.25s ease, box-shadow 0.25s ease,
    background 0.25s ease, border-color 0.25s ease;
  opacity: 0;
  transform: translateY(24px);
}

.card.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    border-color: color-mix(in srgb, var(--accent-1) 45%, var(--border));
    box-shadow: var(--glow);
    transform: translateY(-4px);
  }
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent-1) 12%, transparent),
    transparent 55%);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.card:hover::after { opacity: 1; }

.card .icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.card .icon svg { width: 24px; height: 24px; }

.card .icon.c-blue { background: rgba(79, 124, 255, 0.14); color: #7aa2ff; }
.card .icon.c-purple { background: rgba(167, 139, 250, 0.14); color: #c4b0ff; }
.card .icon.c-teal { background: rgba(45, 212, 191, 0.13); color: #5eead4; }
.card .icon.c-amber { background: rgba(245, 158, 11, 0.14); color: #fbbf24; }
.card .icon.c-red { background: rgba(239, 68, 68, 0.14); color: #f87171; }
.card .icon.c-green { background: rgba(74, 222, 128, 0.13); color: #4ade80; }

[data-theme="light"] .card .icon.c-blue { background: rgba(79, 124, 255, 0.10); color: #3b6ff5; }
[data-theme="light"] .card .icon.c-purple { background: rgba(167, 139, 250, 0.12); color: #7c5ce0; }
[data-theme="light"] .card .icon.c-teal { background: rgba(45, 212, 191, 0.12); color: #0d9488; }
[data-theme="light"] .card .icon.c-amber { background: rgba(245, 158, 11, 0.14); color: #d97706; }
[data-theme="light"] .card .icon.c-red { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
[data-theme="light"] .card .icon.c-green { background: rgba(74, 222, 128, 0.14); color: #16a34a; }

.card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  transform: translateZ(20px);
}

.card p {
  font-size: 0.85rem;
  color: var(--text-dim);
  flex: 1;
  transform: translateZ(14px);
}

.card .go {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s, gap 0.2s;
}

.card:hover .go {
  color: var(--accent-1);
  gap: 8px;
}

.card .badge {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 0.68rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 8px;
  background: var(--card);
}

/* ---------- 页脚与吉祥物 ---------- */
.site-footer {
  margin-top: 40px;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.8rem;
}

.mascot-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  height: 64px;
}

.mascot {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  font-size: 34px;
  line-height: 1;
  transition: transform 0.15s ease;
}

.mascot.bounce { animation: mascot-jump 0.6s ease; }
.mascot.walk { animation: mascot-walk 0.9s ease-in-out infinite alternate; }

@keyframes mascot-jump {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-34px) scale(1.1, 0.9); }
  55% { transform: translateY(0) scale(0.95, 1.05); }
  70% { transform: translateY(-10px) scale(1.02, 0.98); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes mascot-walk {
  0% { transform: translateX(-6px) rotate(-4deg); }
  100% { transform: translateX(6px) rotate(4deg); }
}

.bubble {
  position: absolute;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.mascot-wrap.active .bubble {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

.mascot-wrap { position: relative; }

/* ---------- 工具页通用 ---------- */
.tool-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.tool-head { margin-bottom: 24px; }

.tool-head .crumb {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.tool-head .crumb a:hover { color: var(--accent-1); }

.tool-head h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.tool-head p { color: var(--text-dim); font-size: 0.9rem; margin-top: 4px; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.panel h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel h2::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
}

textarea, input[type="text"], input[type="number"], input[type="password"], select {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.88rem;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

textarea { min-height: 160px; resize: vertical; line-height: 1.55; }

textarea:focus, input:focus, select:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.18);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 16px rgba(79, 124, 255, 0.3);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  border: none;
}

.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.ghost:hover { background: var(--card-hover); filter: none; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.result {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-height: 48px;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
  max-height: 420px;
  overflow-y: auto;
}

.result.ok { border-color: rgba(74, 222, 128, 0.4); }
.result.err { border-color: rgba(239, 68, 68, 0.5); color: #f87171; }

[data-theme="light"] .result.err { color: #dc2626; }

.hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 8px;
  line-height: 1.7;
}

/* 表单行 */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* 复选框 */
.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.check-grid label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85rem;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--input-bg);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  min-height: 38px;
  transition: border-color 0.2s, background 0.2s;
}

.check-grid input { display: none; }

.check-grid label:has(input:checked) {
  border-color: var(--accent-1);
  background: rgba(79, 124, 255, 0.12);
  color: var(--text);
}

/* 范围滑块 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-1) var(--fill, 50%), var(--border) var(--fill, 50%));
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--accent-1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--accent-1);
  cursor: pointer;
}

/* 颜色选择器 */
input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  padding: 4px;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 8px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 8px; }

/* 强度条 */
.strength {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}

.strength i {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  transition: background 0.2s;
}

.strength i.on { background: var(--c, #f87171); }

.strength-label { font-size: 0.78rem; color: var(--text-dim); margin-top: 6px; }

/* 复制按钮浮动 */
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.72rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  padding: 4px 10px;
  transition: color 0.2s, border-color 0.2s;
}

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

.copy-btn.copied { color: #4ade80; border-color: rgba(74, 222, 128, 0.5); }

.result-wrap { position: relative; }

/* 时间戳工具当前时间 */
.now-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--mono);
  font-size: 0.9rem;
  background: var(--input-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
}

.now-bar .live { color: var(--accent-3); }

/* ---------- 游戏入口页样式(内嵌游戏上方导航) ---------- */
.game-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.game-topbar a.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: color 0.2s, border-color 0.2s;
}

.game-topbar a.back:hover { color: var(--accent-1); border-color: var(--accent-1); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .hero { padding-top: 40px; }
  .section { padding: 20px 14px; }
  .tool-main { padding: 24px 14px 40px; }
  .panel { padding: 16px; }
  .logo .logo-sub { display: none; }
  .now-bar { flex-direction: column; align-items: flex-start; gap: 4px; }
  .btn { flex: 1; }
  .btn-row .btn:only-child { flex: none; }
}

@media (max-width: 380px) {
  .card { padding: 18px 16px; }
}

/* 减少动态效果偏好 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .card { opacity: 1; transform: none; }
}
