/* ============================================================================
   在线工具站 —— 共享样式
   设计令牌取自主站 who-young.top：
     · 背景渐变来自主站 src/css.css 的 .index-bg-pattern
     · 颜色来自主站 tailwind.config.js 的 theme.extend.colors
     · 容器宽度、页眉页脚结构、间距节奏均对齐主站
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --primary:   #3B82F6;
  --secondary: #10B981;
  --accent:    #EC4899;
  --dark:      #1E293B;

  --gray-700: #374151;
  --gray-600: #4B5563;
  --gray-500: #6B7280;
  --gray-400: #9CA3AF;
  --gray-300: #D1D5DB;
  --gray-200: #E5E7EB;
  --gray-100: #F3F4F6;

  --soft-blue:     #E1F5FE;
  --soft-green:    #E8F5E9;
  --soft-pink:     #FFEBEE;
  --soft-lavender: #F3E5F5;
  --soft-gray:     #F5F7FA;

  --radius-sm: 10px;
  --radius:    16px;
  --radius-lg: 24px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow:    0 10px 15px -3px rgba(15, 23, 42, .10), 0 4px 6px -4px rgba(15, 23, 42, .10);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, .12), 0 8px 10px -6px rgba(15, 23, 42, .10);

  /* 与主站 tailwind container 在 xl 断点下的宽度一致 */
  --container: 1280px;
  --gutter: 16px;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", "Courier New", monospace;
}

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

/* ── 背景渐变 ─────────────────────────────────────────────────────────────
   刻意【不用】background-attachment: fixed —— 那会让浏览器每次滚动都重绘
   整屏渐变，是典型的滚动卡顿来源。改成固定在视口上的伪元素，
   浏览器会把它放进独立合成层，滚动时零重绘。
   ──────────────────────────────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(135deg,
      #00FFCC 0%, #39C5BB 25%, #66CCFF 50%, #99CCFF 75%, #FFABBC 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  /* 垂直三段式布局，保证内容不足一屏时页脚也被压在底部，
     不会在页脚下方露出一条渐变背景 */
  display: flex;
  flex-direction: column;
  color: var(--dark);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  overflow-x: hidden;
}

main { flex: 1 0 auto; }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; text-wrap: balance; }
p { margin: 0; }

/* ── 容器 ───────────────────────────────────────────────────────────────── */
.wrap,
.nav-inner {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
.wrap-narrow { max-width: 960px; }

/* ── 页眉 ───────────────────────────────────────────────────────────────── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
  transition: background .25s, box-shadow .25s;
}
.navbar.is-scrolled { background: #fff; box-shadow: 0 4px 6px -1px rgba(15, 23, 42, .1); }

.nav-decoration {
  height: 4px; width: 100%;
  background: linear-gradient(90deg, #3B82F6 0%, #EC4899 50%, #10B981 100%);
}

.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; padding-bottom: 12px;
}
.nav-left { display: flex; align-items: center; gap: 20px; min-width: 0; }

/* 语言选择器：规格对齐主站 bg-white border-gray-300 rounded-md px-3 py-1.5 text-sm */
.language-selector {
  background: #fff; border: 1px solid var(--gray-300); color: var(--dark);
  border-radius: 6px; padding: 6px 12px; font-size: .875rem; line-height: 1.5;
  cursor: pointer; transition: box-shadow .2s, border-color .2s;
}
.language-selector:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, .3);
}
.language-selector-dark { background: #1E293B; border-color: #334155; color: var(--gray-300); }

/* 桌面端放页眉，移动端收进折叠菜单 —— 与主站一致 */
.lang-desktop { display: none; }
.lang-mobile { display: block; width: 100%; padding-top: 12px; }
.lang-mobile .language-selector { width: 100%; }
@media (min-width: 801px) {
  .lang-desktop { display: block; }
  .lang-mobile { display: none; }
}

/* 与主站 text-2xl font-bold 对齐 */
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 1.5rem; font-weight: 700; line-height: 1.4;
  letter-spacing: -.01em;
}
.brand i { color: var(--primary); font-size: 1.5rem; transition: transform .3s; }
.brand:hover i { transform: rotate(12deg); }
.brand small {
  font-size: .72rem; font-weight: 500; color: var(--gray-400);
  letter-spacing: .04em; margin-left: 2px;
  padding: 2px 8px; border: 1px solid var(--gray-200); border-radius: 999px;
  transform: translateY(1px);
}

.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a {
  position: relative; color: var(--gray-600); font-size: .95rem;
  transition: color .2s;
}
.nav-links a:hover, .nav-links a.is-active { color: var(--dark); }
.nav-links a::after {
  content: ''; position: absolute; left: 0; bottom: -4px; height: 2px; width: 0;
  background: currentColor; transition: width .3s ease;
}
.nav-links a:hover::after, .nav-links a.is-active::after { width: 100%; }
.nav-links a.back { color: var(--primary); display: inline-flex; align-items: center; gap: 5px; }

.menu-toggle {
  display: none; background: none; border: 0; cursor: pointer;
  font-size: 1.25rem; padding: 4px 6px; line-height: 1;
}

@media (max-width: 800px) {
  .menu-toggle { display: block; }
  .brand { font-size: 1.25rem; }
  .brand i { font-size: 1.25rem; }
  .brand small { display: none; }
  .nav-links {
    position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 0;
    background: #fff; box-shadow: var(--shadow-lg);
    padding: 4px var(--gutter) 12px;
    opacity: 0; transform: translateY(-8px); pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
  }
  .nav-links.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
  .nav-links a { padding: 13px 0; border-bottom: 1px solid var(--gray-100); font-size: 1rem; }
  .nav-links a:last-child { border-bottom: 0; }
  .nav-links a::after { display: none; }
}

/* ── 按钮 ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  background: #fff; border: 1px solid var(--gray-200); color: var(--dark);
  font-size: .875rem; line-height: 1.4; white-space: nowrap;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.btn:hover { border-color: var(--gray-300); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { box-shadow: 0 8px 18px -4px rgba(59, 130, 246, .5); }
.btn-sm { padding: 6px 12px; font-size: .82rem; }

/* ── 卡片 ───────────────────────────────────────────────────────────────────
   悬停只过渡 transform。
   box-shadow 的过渡会每帧触发大面积重绘，是「悬停发粘」的主因 —— 这里
   让阴影直接切换、只让位移做动画，观感立刻跟手。
   ──────────────────────────────────────────────────────────────────────── */
.card {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  transition: transform .2s cubic-bezier(.2, .8, .2, 1);
}
.card-hover:hover { transform: translateY(-6px); }
.card-hover:active { transform: translateY(-3px); }

/* ── 通用徽标 ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: 999px;
  background: rgba(59, 130, 246, .12); color: var(--primary);
  font-size: .85rem; font-weight: 500; line-height: 1.5;
}

/* ── 首页 hero（规格对齐主站 index） ─────────────────────────────────────
   主站：max-w-3xl 左对齐 / h1 clamp(2.5rem,8vw,5rem) leading-tight /
        段落 clamp(1rem,2vw,1.25rem) / 两个 px-8 py-3 的圆角按钮 / 右侧两个模糊光斑
   ──────────────────────────────────────────────────────────────────────── */
/* 与主站一致：hero 占满一屏并垂直居中。
   否则下一个分节的标题会从首屏底部露出一截，看着像页面没排好。
   只用 padding-top/bottom —— 用 padding 简写会把 .wrap 的左右内边距清零，
   窄屏下正文就贴到屏幕边缘了。 */
.hero {
  position: relative; overflow: hidden;
  min-height: 100vh;
  display: flex; align-items: center;
  padding-top: 96px; padding-bottom: 48px;
}
/* 移动端浏览器地址栏会收放，100vh 会偏大；dvh 更贴合实际可视高度 */
@supports (min-height: 100dvh) {
  .hero { min-height: 100dvh; }
}
.hero-glow { position: absolute; top: 0; right: 0; width: 55%; height: 100%; pointer-events: none; }
.hero-glow::before, .hero-glow::after {
  content: ''; position: absolute; border-radius: 50%; filter: blur(64px);
}
.hero-glow::before { top: 72px; right: 0; width: 16rem; height: 16rem; background: rgba(59, 130, 246, .30); }
.hero-glow::after  { bottom: 24px; right: 8rem; width: 20rem; height: 20rem; background: rgba(236, 72, 153, .26); }

.hero > .wrap { position: relative; }
.hero .badge { margin-bottom: 20px; }
.hero h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
  line-height: 1.15; letter-spacing: -.02em;
  margin-bottom: 24px;
}
.hero .grad {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero p {
  /* 中文单行 35~40 字最舒服；46rem 太长会导致换行点难看 */
  max-width: 42rem;
  color: var(--gray-600);
  font-size: clamp(1rem, 2vw, 1.2rem); line-height: 1.75;
  margin-bottom: 32px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 16px; }

/* 主站 CTA 按钮规格：px-8 py-3 rounded-full shadow-lg hover:-translate-y-1 */
.btn-hero {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 32px; border-radius: 999px;
  font-size: 1rem; font-weight: 500;
  transition: transform .2s ease, box-shadow .2s ease;
}
.btn-hero:hover { transform: translateY(-4px); }
.btn-hero-primary { background: var(--primary); color: #fff; box-shadow: 0 10px 15px -3px rgba(59, 130, 246, .35); }
.btn-hero-primary:hover { box-shadow: 0 20px 25px -5px rgba(59, 130, 246, .45); }
.btn-hero-ghost {
  background: #fff; color: var(--dark); border: 1px solid var(--gray-100);
  box-shadow: 0 10px 15px -3px rgba(15, 23, 42, .12);
}
.btn-hero-ghost:hover { box-shadow: 0 20px 25px -5px rgba(15, 23, 42, .18); }

/* ── Section：对齐主站的 badge + h2 + 描述 三段式 ───────────────────────── */
/* 首屏已经被 hero 占满，这里留出与主站分节相当的上间距 */
.section { padding-top: 80px; padding-bottom: 16px; }
.section-head { text-align: center; max-width: 44rem; margin: 0 auto 56px; }
.section-head .badge { margin-bottom: 16px; }
.section-head h2 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  line-height: 1.25; letter-spacing: -.015em;
  margin-bottom: 20px;
}
.section-head p { color: var(--gray-600); font-size: 1.05rem; line-height: 1.75; }

.grid { display: grid; gap: 24px; }
@media (min-width: 760px) { .grid.cols-2 { grid-template-columns: repeat(2, 1fr); } }

.tool-card { display: flex; flex-direction: column; padding: 28px; height: 100%; }
.tool-card .icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; margin-bottom: 18px;
}
.tool-card h3 { font-size: 1.25rem; margin-bottom: 10px; }
.tool-card p {
  color: var(--gray-600); font-size: .95rem; line-height: 1.75;
  margin-bottom: 20px; flex: 1 1 auto;
}
.tool-card .go {
  color: var(--primary); font-weight: 500; font-size: .95rem;
  display: inline-flex; align-items: center; gap: 6px;
  transition: transform .2s ease;
}
.tool-card:hover .go { transform: translateX(6px); }
.bg-blue { background: var(--soft-blue); color: var(--primary); }
.bg-pink { background: var(--soft-pink); color: var(--accent); }
.bg-green { background: var(--soft-green); color: var(--secondary); }
.bg-lav  { background: var(--soft-lavender); color: #8B5CF6; }

/* ── 工具页外壳 ─────────────────────────────────────────────────────────── */
/* 同理：只用纵向 padding，横向交给 .wrap（页面里写的是 class="tool-shell wrap"） */
.tool-shell { padding-top: 108px; padding-bottom: 40px; }
.tool-head { text-align: center; max-width: 40rem; margin: 0 auto 24px; }
.tool-head .badge { margin-bottom: 14px; }
.tool-head h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); margin-bottom: 10px; }
.tool-head p { color: var(--gray-600); font-size: .96rem; line-height: 1.75; }

.tool-card-main {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  overflow: hidden; display: flex; flex-direction: column;
  height: calc(100vh - 268px); min-height: 420px;
}

.tool-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 14px; background: var(--soft-gray);
  border-bottom: 1px solid var(--gray-200);
}
.tool-bar .spacer { flex: 1 1 auto; }
.tool-bar .stat { color: var(--gray-500); font-size: .8rem; font-variant-numeric: tabular-nums; }
.tool-bar select {
  padding: 6px 10px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  background: #fff; font-size: .82rem; cursor: pointer; max-width: 12rem;
}

.panes { flex: 1 1 auto; display: flex; min-height: 0; }
.pane { flex: 1 1 50%; min-width: 0; display: flex; flex-direction: column; }
.pane + .pane { border-left: 1px solid var(--gray-200); }
.pane-label {
  padding: 7px 14px; font-size: .72rem; letter-spacing: .08em;
  color: var(--gray-400); border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fff;
}
.pane-label .side { text-transform: none; letter-spacing: 0; font-size: .76rem; }
.pane-label .busy { color: var(--primary); }

.editor {
  flex: 1 1 auto; width: 100%; border: 0; outline: none; resize: none;
  padding: 16px 18px; font-family: var(--mono);
  font-size: .875rem; line-height: 1.8;
  background: #fff; color: var(--dark); tab-size: 2;
}
.editor::placeholder { color: var(--gray-400); }

.preview { flex: 1 1 auto; overflow: auto; padding: 18px 20px; }
.preview.is-drop { background: var(--soft-blue); }

@media (max-width: 880px) {
  .tool-shell { padding-top: 96px; }
  .tool-card-main { height: auto; }
  .panes { flex-direction: column; }
  .pane { min-height: 44vh; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--gray-200); }
}

/* ── 提示 / 错误 ─────────────────────────────────────────────────────────── */
.notice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: .875rem; line-height: 1.7;
}
.notice i { margin-top: 4px; flex: 0 0 auto; }
.notice-info  { background: var(--soft-blue); color: #0369A1; }
.notice-warn  { background: #FEF3C7; color: #92400E; }
.notice-error { background: var(--soft-pink); color: #9F1239; }
.notice code {
  font-family: var(--mono); font-size: .85em;
  background: rgba(0, 0, 0, .06); padding: 1px 5px; border-radius: 4px;
}
.notice + .notice { margin-top: 10px; }
/* 少量间距工具类，避免在 HTML 里写行内 style */
.mt-xs { margin-top: 4px; }
.mt-sm { margin-top: 16px; }
.mt-lg { margin-top: 36px; }
.hidden { display: none !important; }

/* ── Markdown 渲染排版 ───────────────────────────────────────────────────── */
.md-body {
  font-size: .95rem; line-height: 1.85; color: var(--gray-700);
  word-wrap: break-word; overflow-wrap: anywhere;
}
.md-body > *:first-child { margin-top: 0; }
.md-body > *:last-child { margin-bottom: 0; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  color: var(--dark); margin: 1.8em 0 .7em; text-wrap: balance;
}
.md-body h1 { font-size: 1.65em; padding-bottom: .3em; border-bottom: 1px solid var(--gray-200); }
.md-body h2 { font-size: 1.35em; padding-bottom: .25em; border-bottom: 1px solid var(--gray-200); }
.md-body h3 { font-size: 1.15em; }
.md-body h4 { font-size: 1em; }
.md-body p { margin: 0 0 1.1em; }
.md-body ul, .md-body ol { margin: 0 0 1.1em; padding-left: 1.5em; }
.md-body li { margin: .35em 0; }
.md-body li > ul, .md-body li > ol { margin: .35em 0; }
.md-body a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.md-body a:hover { text-decoration-thickness: 2px; }
.md-body strong { font-weight: 700; color: var(--dark); }
.md-body blockquote {
  margin: 0 0 1.1em; padding: .7em 1.1em; color: var(--gray-600);
  border-left: 4px solid var(--primary); background: var(--soft-gray);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.md-body blockquote p:last-child { margin-bottom: 0; }
.md-body code {
  font-family: var(--mono); font-size: .87em;
  background: var(--gray-100); padding: .15em .4em; border-radius: 5px;
}
.md-body pre {
  margin: 0 0 1.1em; padding: 14px 16px; overflow: auto;
  background: #F6F8FA; border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
}
.md-body pre code {
  background: none; padding: 0; font-size: .85em; line-height: 1.65;
}
.md-body table {
  border-collapse: collapse; margin: 0 0 1.1em; font-size: .9em;
  display: block; width: max-content; max-width: 100%; overflow-x: auto;
}
.md-body th, .md-body td { border: 1px solid var(--gray-200); padding: 8px 13px; text-align: left; }
.md-body th { background: var(--soft-gray); font-weight: 600; color: var(--dark); }
/* 不写 tbody —— 有的 Markdown 渲染器不生成 tbody，用 tr 更稳 */
.md-body tr:nth-child(even) td { background: #FAFBFC; }
.md-body hr { border: 0; border-top: 1px solid var(--gray-200); margin: 2.2em 0; }
.md-body img { border-radius: var(--radius-sm); margin: .4em 0; }
.md-body input[type="checkbox"] { margin-right: .45em; vertical-align: -1px; }
.md-body .task-list-item { list-style: none; margin-left: -1.3em; }

/* ── Mermaid 画布 ────────────────────────────────────────────────────────── */
.mmd-canvas { display: flex; align-items: center; justify-content: center; min-height: 100%; }
.mmd-canvas svg { max-width: 100%; height: auto; }
.mmd-empty { color: var(--gray-400); font-size: .9rem; text-align: center; padding: 48px 16px; }

/* ── 页脚（结构对齐主站：所有内容都在容器内） ───────────────────────────── */
.site-footer {
  background: var(--dark); color: #fff;
  padding: 48px 0; margin-top: 56px;
  flex: 0 0 auto;
}
.foot-top {
  display: flex; flex-wrap: wrap; gap: 24px 32px;
  justify-content: space-between; align-items: center;
}
.foot-top .brand { color: #fff; }
.foot-desc { color: var(--gray-400); font-size: .9rem; margin-top: 8px; }
.foot-nav { display: flex; flex-wrap: wrap; gap: 16px 32px; }
.foot-nav a { color: var(--gray-400); font-size: .95rem; transition: color .2s; }
.foot-nav a:hover { color: #fff; }

/* 分隔线在容器内部 —— 主站是 border-t + px-4，所以左右各缩进一个 gutter */
.foot-bottom {
  border-top: 1px solid #334155;
  margin-top: 32px; padding-top: 32px;
  display: flex; flex-wrap: wrap; gap: 12px 24px;
  justify-content: space-between; align-items: center;
}
.foot-bottom p { color: var(--gray-500); font-size: .85rem; }
.foot-bottom-right { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.to-top {
  color: var(--gray-400); font-size: .85rem;
  display: inline-flex; align-items: center; gap: 5px;
  transition: color .2s;
}
.to-top:hover { color: #fff; }

@media (max-width: 640px) {
  .site-footer { padding: 40px 0; margin-top: 40px; }
  .foot-top { flex-direction: column; align-items: flex-start; }
  .foot-bottom { margin-top: 24px; padding-top: 24px; }
}
