:root {
  --bg: #faf5ef;
  --card: #fffcf8;
  --border: #e8ddd0;
  --text: #3d2e22;
  --muted: #8f7a66;
  --accent: #e07830;
  --accent-hover: #c96828;
  --accent-soft: rgba(224, 120, 48, 0.14);
  --accent-border: rgba(224, 120, 48, 0.35);
  --success: #5d9149;
  --danger: #d14d42;
  --field-bg: #fff6ee;
  --shadow: rgba(120, 80, 40, 0.08);
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(255, 200, 140, 0.45), transparent),
    radial-gradient(ellipse 70% 50% at 100% 80%, rgba(255, 220, 180, 0.35), transparent),
    radial-gradient(ellipse 50% 40% at 0% 50%, rgba(255, 235, 210, 0.4), transparent);
}

/* ── 顶部导航布局 ── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 56px;
  box-shadow: 0 2px 16px var(--shadow);
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
  padding: 0.5rem 0;
}

.topnav-brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.topnav-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.tool-search {
  position: relative;
  flex-shrink: 0;
  width: 220px;
  margin-left: auto;
}

.tool-search-input {
  width: 100%;
  padding: 0.45rem 0.75rem 0.45rem 2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238f7a66' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.06a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 0.55rem center;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}

.tool-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.tool-search-input::placeholder {
  color: var(--muted);
}

.tool-search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  width: 320px;
  max-width: min(320px, 90vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px var(--shadow);
  max-height: 360px;
  overflow-y: auto;
  z-index: 60;
}

.tool-search-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.tool-search-item:last-child {
  border-bottom: none;
}

.tool-search-item:hover,
.tool-search-item.active {
  background: var(--accent-soft);
  text-decoration: none;
}

.tool-search-item-icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.tool-search-item-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.tool-search-item-body strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.tool-search-item-body span {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.tool-search-item-body em {
  font-size: 0.72rem;
  color: var(--accent);
  font-style: normal;
}

.tool-search-empty {
  padding: 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.topnav-menu {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  overflow-x: auto;
  padding: 0.35rem 0;
  scrollbar-width: thin;
}

.topnav-menu::-webkit-scrollbar {
  height: 4px;
}

.topnav-link {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.topnav-link:hover {
  background: var(--field-bg);
  color: var(--text);
  text-decoration: none;
}

.topnav-link.active {
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid var(--accent-border);
}

.topnav-icon {
  font-size: 0.9rem;
  line-height: 1;
}

.main {
  flex: 1;
  width: 100%;
  padding: 1.5rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── 底部 ── */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--card);
  padding: 1.5rem 1.25rem;
}

.site-footer-inner {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

.site-footer-copy {
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer-copy a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.site-footer-copy a:hover {
  color: var(--accent);
  text-decoration: none;
}

.page-header,
.content-area {
  width: 100%;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.content-area.content-wide {
  max-width: 720px;
}

@media (max-width: 640px) {
  .topnav {
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  .topnav-brand {
    order: 1;
  }

  .tool-search {
    order: 2;
    width: auto;
    flex: 1;
    max-width: 180px;
    margin-left: auto;
  }

  .tool-search-results {
    left: auto;
    right: 0;
    width: min(320px, 92vw);
  }

  .topnav-menu {
    order: 3;
    width: 100%;
    flex: none;
  }

  .main {
    padding: 1rem 0.75rem 1.5rem;
  }

  .topnav-link span:last-child {
    font-size: 0.8rem;
  }
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── 首页 ── */
.home-welcome {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1.25rem;
  text-align: center;
}

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

.tool-grid-compact .tool-card {
  padding: 1rem;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 12px var(--shadow);
}

.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(224, 120, 48, 0.15);
  text-decoration: none;
}

.tool-card .icon {
  font-size: 1.5rem;
  line-height: 1;
}

.tool-card h2 {
  font-size: 1rem;
  font-weight: 600;
}

.tool-card p {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.category-card .category-count {
  font-size: 0.75rem;
  color: var(--accent);
  margin-top: 0.25rem;
}

.category-desc {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.home-section {
  margin-bottom: 2rem;
}

.home-section:last-child {
  margin-bottom: 0;
}

.home-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.home-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.home-section-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.home-section-link {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.home-section-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.home-section-desc {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.85rem;
}

.bjx-tabs {
  margin-bottom: 1rem;
}

.bjx-tip {
  margin-top: 1rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  line-height: 1.5;
}

.bjx-tip code {
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.8rem;
  padding: 0.1rem 0.35rem;
  background: var(--card);
  border-radius: 4px;
  color: var(--accent);
}

/* ── 工具页 ── */
.page-header {
  margin-bottom: 1.25rem;
  text-align: center;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 600;
}

.page-header p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 0.35rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px var(--shadow);
}

.field {
  margin-bottom: 1rem;
}

.field:last-child {
  margin-bottom: 0;
}

label,
.label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}

textarea {
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.85rem;
  min-height: 120px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
}

input.mono,
textarea.mono {
  font-family: "Cascadia Code", "Consolas", monospace;
}

input[readonly] {
  cursor: default;
}

input[type="number"] {
  width: 5rem;
  flex: none;
  text-align: center;
}

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.option label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  margin: 0;
}

.option input[type="checkbox"] {
  accent-color: var(--accent);
}

.length-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.length-row span {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn {
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.5rem 0.9rem;
  transition: border-color 0.15s, color 0.15s;
}

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

.btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  margin-top: 0.25rem;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.55rem 1rem;
  margin-top: 0.5rem;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--accent);
}

.btn-copy {
  flex-shrink: 0;
  padding: 0 0.85rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.btn-copy.copied {
  color: var(--success);
  border-color: var(--success);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.75rem;
  text-align: center;
}

.msg-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.msg-ok {
  color: var(--success);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.output-box {
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.85rem;
  word-break: break-all;
  min-height: 2.5rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--field-bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
}

.tab.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--card);
  border: 1px solid var(--success);
  border-radius: 8px;
  color: var(--success);
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s, opacity 0.25s;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

kbd {
  font-family: inherit;
  font-size: 0.75rem;
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  color: var(--muted);
}
