/* ============================================================
   tools.meblg.com — 设计系统（Bootstrap 5 之上）
   ============================================================ */

:root {
  --brand: #2563eb;
  --brand-600: #1d4ed8;
  --brand-50: #eff6ff;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --border: #e5e9f0;
  --text: #1f2937;
  --muted: #6b7280;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .06);
  --header-h: 64px;
}

* { -webkit-tap-highlight-color: transparent; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  padding-top: var(--header-h);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-600); }

/* ---------- 顶栏 ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1030;
}
.site-header .inner {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { color: var(--brand); }
.brand .mark {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  color: #fff; border-radius: 9px; font-size: 15px;
}

.top-nav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.top-nav > .nav-item { position: relative; }
.top-nav .nav-link {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: #374151;
  font-size: 14px;
  white-space: nowrap;
}
.top-nav .nav-link:hover,
.top-nav .nav-item.show > .nav-link {
  background: var(--brand-50);
  color: var(--brand);
}
.top-nav .dropdown-menu {
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-sm);
  padding: 6px;
  font-size: 14px;
  min-width: 220px;
}
.top-nav .dropdown-item {
  border-radius: 6px;
  padding: 7px 10px;
  color: #374151;
}
.top-nav .dropdown-item:hover { background: var(--brand-50); color: var(--brand); }
.top-nav .dropdown-divider { margin: 6px 4px; }

.header-search {
  position: relative;
  width: 230px;
  flex: 0 0 auto;
}
.header-search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f3f5f9;
  font-size: 14px;
  outline: none;
  transition: .18s;
}
.header-search input:focus {
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.header-search .ico {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px;
}
.header-search .panel {
  position: absolute; top: 46px; left: 0; right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); max-height: 360px; overflow: auto; display: none; z-index: 5;
}
.header-search .panel a {
  display: block; padding: 8px 12px; color: var(--text); font-size: 14px;
}
.header-search .panel a:hover { background: var(--brand-50); }

.header-toggle {
  display: none;
  width: 40px; height: 40px;
  border: 1px solid var(--border); background: #fff; border-radius: 10px;
  align-items: center; justify-content: center;
}

/* ---------- 主体 ---------- */
.page-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}
.page-head { margin-bottom: 18px; }
.page-head h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -.01em;
}
.page-head .desc { color: var(--muted); font-size: 14px; margin: 0; }
.breadcrumb { font-size: 13px; margin: 0 0 10px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--brand); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-body { padding: 20px 22px; }
.card-title { font-size: 16px; font-weight: 650; margin: 0 0 14px; }

/* 工具页表单 */
.tool-form .form-label { font-weight: 600; font-size: 14px; color: #374151; }
.tool-form .form-control,
.tool-form .form-select {
  border-color: var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.tool-form .form-control:focus,
.tool-form .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.tool-form textarea.form-control { min-height: 160px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.result-box {
  background: #f8fafc;
  border: 1px dashed #d7dee8;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 54px;
}
.result-box:empty::before {
  content: "结果会显示在这里";
  color: #9aa3af;
  font-family: inherit;
}

/* 工具导航（首页/页脚） */
.tool-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.tool-item {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: .16s;
}
.tool-item:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  color: var(--brand);
}
.tool-item .t { display: block; font-weight: 600; font-size: 14px; }
.tool-item .d { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 26px 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::before {
  content: ""; width: 3px; height: 15px; border-radius: 2px; background: var(--brand);
}

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: 40px;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 32px 0 24px;
}
.site-footer .inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.footer-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
}
.footer-col h3 {
  font-size: 13px; font-weight: 700; color: #374151;
  margin: 0 0 10px; letter-spacing: .02em;
}
.footer-col a {
  display: block; padding: 3px 0; color: var(--muted); font-size: 13px;
}
.footer-col a:hover { color: var(--brand); }
.footer-bottom {
  margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 13px;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between;
}

/* 足迹 */
.history-bar {
  max-width: 1200px; margin: 0 auto; padding: 8px 16px 0;
  color: var(--muted); font-size: 13px;
}
.history-bar a { color: var(--muted); margin-right: 10px; }
.history-bar a:hover { color: var(--brand); }

/* 回到顶部 */
.gotop {
  position: fixed; right: 20px; bottom: 24px;
  width: 42px; height: 42px; border-radius: 12px;
  background: #fff; border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: none; align-items: center; justify-content: center;
  color: var(--muted); z-index: 1020;
}
.gotop:hover { color: var(--brand); border-color: #c7d2fe; }

/* 旧类兼容（迁移期） */
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.panel-body { padding: 18px 20px; }
.panel-heading { padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 650; }
.btn-default { background: #fff; border-color: var(--border); color: var(--text); }
.btn-default:hover { background: #f3f5f9; border-color: #d7dee8; }

/* 响应式 */
@media (max-width: 991.98px) {
  .header-search { display: none; }
  .header-toggle { display: inline-flex; }
  .top-nav {
    position: fixed; top: var(--header-h); left: 0; right: 0;
    background: #fff; border-bottom: 1px solid var(--border);
    flex-direction: column; align-items: stretch;
    padding: 8px; display: none;
    max-height: calc(100vh - var(--header-h)); overflow: auto;
  }
  .top-nav.open { display: flex; }
  .top-nav .dropdown-menu { position: static !important; transform: none !important; box-shadow: none; border: 0; padding-left: 12px; }
  .page-wrap { padding: 18px 12px 32px; }
  .card-body { padding: 16px; }
}

/* ---------- 工具索引（页脚导航）---------- */
.tool-index {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 30px 0 16px;
  margin-top: 36px;
}
.tool-index .inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.footer-col a { word-break: break-word; line-height: 1.5; }
.history-bar { max-width: 1200px; margin: 0 auto; padding: 16px 16px 0; }

@media (max-width: 767.98px) {
  .footer-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .tool-index { padding: 22px 0 10px; }
}

/* ============================================================
   BS3 组件兼容层（旧模板结构在 BS5 下仍可用）
   ============================================================ */
.nav-tabs {
  display: flex; flex-wrap: wrap; gap: 2px;
  padding-left: 0; margin: 0 0 16px; list-style: none;
  border-bottom: 1px solid var(--border);
}
.nav-tabs > li { float: none; margin: 0; }
.nav-tabs > li > a {
  display: block; padding: 9px 14px; color: var(--muted);
  border: 1px solid transparent; border-bottom: 0;
  border-radius: 9px 9px 0 0; font-size: 14px;
}
.nav-tabs > li > a:hover { background: var(--brand-50); color: var(--brand); }
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover {
  background: #fff; border-color: var(--border); color: var(--brand);
  font-weight: 600; position: relative; top: 1px;
}

.list-inline { padding-left: 0; list-style: none; margin: 0; }
.list-inline > li { display: inline-block; }

.accordion { display: block; }
.accordion-group {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 12px; overflow: hidden;
}
.accordion-toggle { display: block; padding: 12px 16px; color: var(--text); }
.accordion-toggle:hover { background: #f8fafc; }
.collapse { display: none; }
.collapse.in, .collapse.show { display: block; }

.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.panel-heading { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 650; }
.panel-body { padding: 18px; }
.panel-title { font-size: 16px; margin: 0; font-weight: 650; }

.alert { border-radius: var(--radius-sm); border: 1px solid transparent; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.table { width: 100%; border-collapse: collapse; }
.table > tbody > tr > td, .table > tbody > tr > th,
.table > thead > tr > td, .table > thead > tr > th {
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.table-striped > tbody > tr:nth-of-type(odd) > td { background: #fafbfc; }
.table-hover > tbody > tr:hover > td { background: #f3f6fb; }
.table-bordered { border: 1px solid var(--border); }
.table-bordered > tbody > tr > td, .table-bordered > thead > tr > th { border: 1px solid var(--border); }

.btn { border-radius: var(--radius-sm); font-size: 14px; }
.btn-default { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-default:hover { background: #f3f5f9; border-color: #d7dee8; color: var(--text); }
.btn-success { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-success:hover { background: var(--brand-600); border-color: var(--brand-600); }

.form-control {
  display: block; width: 100%; padding: .5rem .75rem; font-size: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text);
}
.form-control:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-group { margin-bottom: 16px; }
.control-label { font-weight: 600; font-size: 14px; }
.input-group { display: flex; }
.input-group-addon {
  padding: .5rem .75rem; background: #f8fafc; border: 1px solid var(--border);
  border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); color: var(--muted); font-size: 14px;
}
.input-group .form-control { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.label { display: inline-block; padding: .2em .55em; border-radius: 6px; font-size: 12px; font-weight: 600; }
.label-default { background: #eef1f5; color: #475569; }
.label-success { background: #dcfce7; color: #166534; }
.label-info { background: #dbeafe; color: #1e40af; }
.label-warning { background: #fef3c7; color: #92400e; }
.label-danger { background: #fee2e2; color: #991b1b; }

.img-responsive { max-width: 100%; height: auto; }
.well { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.close { float: right; font-size: 20px; line-height: 1; opacity: .5; }
.close:hover { opacity: .8; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ---------- 首页 Hero ---------- */
.hero {
  position: relative;
  padding: 44px 0 36px;
  text-align: center;
}
.hero h1 {
  font-size: 34px; font-weight: 800; letter-spacing: -.02em;
  margin: 0 0 10px;
  background: linear-gradient(120deg, #1f2937 20%, var(--brand) 80%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .lead { color: var(--muted); font-size: 15px; margin: 0 0 24px; }
.hero-search { position: relative; max-width: 560px; margin: 0 auto; }
.hero-search input {
  width: 100%; height: 50px; padding: 0 18px;
  border: 1px solid var(--border); border-radius: 14px;
  background: #fff; font-size: 15px; outline: none;
  box-shadow: var(--shadow-sm); transition: .18s;
}
.hero-search input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
.hero-panel {
  position: absolute; top: 56px; left: 0; right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-md); max-height: 340px; overflow: auto; display: none; z-index: 20;
  text-align: left;
}
.hero-panel a { display: block; padding: 10px 16px; color: var(--text); font-size: 14px; }
.hero-panel a:hover { background: var(--brand-50); color: var(--brand); }
.hero-tags { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.hero-tags a {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--muted); font-size: 13px;
}
.hero-tags a:hover { border-color: #c7d2fe; color: var(--brand); background: var(--brand-50); }

/* 分类卡片 */
.cat-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.cat-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px;
}
.cat-card h3 {
  font-size: 14px; font-weight: 700; margin: 0 0 10px; color: #111827;
  display: flex; align-items: center; gap: 8px;
}
.cat-card h3::before {
  content: ""; width: 3px; height: 13px; border-radius: 2px; background: var(--brand);
}
.cat-card a { display: block; padding: 4px 0; color: var(--muted); font-size: 13.5px; }
.cat-card a:hover { color: var(--brand); }
.cat-card a.more { margin-top: 8px; color: var(--brand); font-weight: 600; }

@media (max-width: 575.98px) {
  .hero { padding: 26px 0 22px; }
  .hero h1 { font-size: 26px; }
  .cat-grid { grid-template-columns: 1fr; }
}
