/* ==========================================================================
   Surprise Gift Printables — Global Design System
   Retro paper aesthetic · Zero dependencies · Native HTML/CSS/JS
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --paper: #f4ecd8;
  --paper-dark: #e8dcc0;
  --ink: #2b2417;
  --ink-soft: #5a4f3a;
  --accent: #b3472d;      /* vintage red */
  --accent2: #1f4d3f;     /* ink green */
  --gold: #a8823c;

  --font-heading: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-blackletter: 'Old English Text MT', 'UnifrakturMaguntia', Georgia, serif;
  --font-body: Georgia, serif;
  --font-cn: 'Noto Serif SC', 'Songti SC', SimSun, serif;

  --radius: 10px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(43, 36, 23, 0.15);
  --shadow-md: 0 4px 14px rgba(43, 36, 23, 0.18);
  --shadow-lg: 0 10px 30px rgba(43, 36, 23, 0.25);
  --header-h: 64px;
  --tr: 0.22s ease;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 12px);
}

html, body { max-width: 100%; overflow-x: clip; }
@supports not (overflow-x: clip) { html, body { overflow-x: hidden; } }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--paper);
  /* subtle paper fiber texture */
  background-image:
    radial-gradient(ellipse at 18% 12%, rgba(168, 130, 60, 0.07), transparent 55%),
    radial-gradient(ellipse at 85% 80%, rgba(179, 71, 45, 0.05), transparent 50%),
    repeating-linear-gradient(2deg, transparent 0 3px, rgba(43, 36, 23, 0.012) 3px 4px),
    repeating-linear-gradient(-1deg, transparent 0 2px, rgba(43, 36, 23, 0.01) 2px 3px);
}

html[lang="zh"] body {
  font-family: var(--font-cn);
  line-height: 1.75;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--ink);
  line-height: 1.25;
  margin: 0 0 0.5em;
  font-weight: 700;
}
html[lang="zh"] h1, html[lang="zh"] h2,
html[lang="zh"] h3, html[lang="zh"] h4 {
  font-family: var(--font-cn);
}

h1 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 2rem); }
h3 { font-size: 1.25rem; }

p { margin: 0 0 1em; }
a { color: var(--accent2); text-decoration: none; transition: color var(--tr); }
a:hover { color: var(--accent); }
img { max-width: 100%; display: block; }

.font-blackletter { font-family: var(--font-blackletter); }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}
@media (min-width: 1440px) { .container { max-width: 1280px; } }
@media (max-width: 480px) { .container { padding: 0 14px; } }

main { min-height: 55vh; padding-bottom: 48px; }

.section { padding: 40px 0; }
@media (max-width: 768px) { .section { padding: 28px 0; } }

.section-title {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  margin: 0 0 8px;
  position: relative;
  padding-bottom: 10px;
}
.section-title::after {
  content: "";
  display: block;
  width: 64px;
  height: 3px;
  margin-top: 8px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 2px;
}
.section-sub {
  color: var(--ink-soft);
  margin: 0 0 20px;
  font-style: italic;
}

/* ---------- Site header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(244, 236, 216, 0.96);
  backdrop-filter: blur(4px);
  border-bottom: 2px solid var(--ink);
  box-shadow: 0 2px 10px rgba(43, 36, 23, 0.12);
}
.site-header .header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-h);
  flex-wrap: wrap;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-blackletter);
  font-size: 1.18rem;
  color: var(--ink);
  white-space: nowrap;
  line-height: 1.1;
}
.logo:hover { color: var(--accent); }
.logo svg { width: 26px; height: 26px; flex: none; }

.site-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links > li { position: relative; }

.nav-links a,
.nav-links .nav-drop-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  font-size: 0.95rem;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-body);
  white-space: nowrap;
}
html[lang="zh"] .nav-links a,
html[lang="zh"] .nav-links .nav-drop-toggle { font-family: var(--font-cn); }
.nav-links a:hover, .nav-links .nav-drop-toggle:hover { color: var(--accent); }
.nav-links a.active { color: var(--accent); font-weight: bold; }

.nav-drop-toggle .caret { font-size: 0.65em; transition: transform var(--tr); }
.nav-dropdown.open .nav-drop-toggle .caret { transform: rotate(180deg); }

/* Desktop hover dropdown */
.nav-dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 560px;
  max-width: calc(100vw - 32px);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity var(--tr), transform var(--tr), visibility var(--tr);
  z-index: 120;
}
@media (min-width: 901px) {
  .nav-dropdown:hover > .dropdown-menu,
  .nav-dropdown:focus-within > .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: none;
  }
}
.dropdown-groups {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.dropdown-group h4 {
  margin: 0 0 6px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  border-bottom: 1px dashed var(--gold);
  padding-bottom: 4px;
  font-family: var(--font-heading);
}
.dropdown-group a {
  display: block;
  padding: 4px 2px;
  font-size: 0.88rem;
  white-space: normal;
  line-height: 1.35;
}
.dropdown-group a.all-link { color: var(--accent2); font-weight: bold; font-style: italic; }

/* Hamburger (≤900px) */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
}
.hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--ink);
  border-radius: 2px;
  transition: transform var(--tr), opacity var(--tr);
}
.site-header.nav-open .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.site-header.nav-open .hamburger span:nth-child(2) { opacity: 0; }
.site-header.nav-open .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

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

.fav-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  line-height: 18px;
  text-align: center;
  font-weight: bold;
}
.fav-count:empty, .fav-count[data-zero="1"] { display: none; }

/* Mobile nav panel */
@media (max-width: 900px) {
  .hamburger { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--paper);
    border-bottom: 2px solid var(--ink);
    box-shadow: var(--shadow-lg);
    padding: 10px 20px 18px;
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
    z-index: 110;
  }
  .site-header.nav-open .nav-links { display: flex; }
  .nav-links a, .nav-links .nav-drop-toggle { padding: 12px 6px; width: 100%; }
  .dropdown-menu {
    position: static;
    display: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: 1px dashed var(--gold);
    min-width: 0;
    max-width: none;
    padding: 10px;
    margin: 4px 0 8px;
  }
  .nav-dropdown.open > .dropdown-menu { display: block; }
  .dropdown-groups { grid-template-columns: 1fr; }
}

/* Language switch */
.lang-switch {
  display: inline-flex;
  border: 1px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper-dark);
}
.lang-switch button {
  border: 0;
  background: transparent;
  padding: 5px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: var(--font-body);
}
.lang-switch button.active {
  background: var(--ink);
  color: var(--paper);
  font-weight: bold;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background: var(--paper-dark);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  transition: transform var(--tr), box-shadow var(--tr), background var(--tr), color var(--tr);
  box-shadow: 2px 2px 0 var(--ink);
  user-select: none;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

html[lang="zh"] .btn { font-family: var(--font-cn); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 2px 2px 0 rgba(43, 36, 23, 0.8); }
.btn-primary:hover { background: #9c3d25; }

.btn-secondary { background: var(--accent2); border-color: var(--accent2); color: #fff; box-shadow: 2px 2px 0 rgba(43, 36, 23, 0.8); }
.btn-secondary:hover { background: #17402f; }

.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--accent2); }
.btn-ghost:hover { color: var(--accent); box-shadow: none; transform: none; background: rgba(168, 130, 60, 0.12); }

.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }

/* ---------- Cards ---------- */
.card {
  background: #fbf6e9;
  border: 1px solid rgba(90, 79, 58, 0.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
@media (max-width: 480px) { .tool-grid { grid-template-columns: 1fr; gap: 14px; } }

/* Photo-background tool card */
.tool-card {
  position: relative;
  display: block;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-md);
  background: var(--paper-dark);
  color: #fff;
  transition: transform var(--tr), box-shadow var(--tr);
  isolation: isolate;
}
.tool-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  color: #fff;
}
.tool-card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
  transition: transform 0.5s ease;
}
.tool-card:hover .tool-card-img { transform: scale(1.05); }
.tool-card-overlay {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to top,
      rgba(24, 18, 10, 0.92) 0%,
      rgba(24, 18, 10, 0.55) 38%,
      rgba(24, 18, 10, 0.08) 70%,
      rgba(24, 18, 10, 0.05) 100%);
}
.tool-card-body {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 46px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tool-card-name {
  font-family: var(--font-heading);
  font-size: 1.08rem;
  font-weight: bold;
  margin: 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
html[lang="zh"] .tool-card-name { font-family: var(--font-cn); }
.tool-card-desc {
  font-size: 0.82rem;
  margin: 0;
  color: rgba(255, 255, 255, 0.88);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tool-card .badge { align-self: flex-start; }

/* Favorite heart button */
.fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(24, 18, 10, 0.45);
  cursor: pointer;
  padding: 0;
  transition: background var(--tr), transform var(--tr);
}
.fav-btn:hover { background: rgba(24, 18, 10, 0.7); transform: scale(1.1); }
.fav-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  transition: fill var(--tr), stroke var(--tr);
}
.fav-btn.active { border-color: var(--accent); background: #fff; }
.fav-btn.active svg { fill: var(--accent); stroke: var(--accent); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: bold;
  letter-spacing: 0.03em;
  background: var(--paper-dark);
  color: var(--ink-soft);
  border: 1px solid rgba(90, 79, 58, 0.4);
}
.badge-pro {
  background: linear-gradient(135deg, var(--gold), #c9a04e);
  color: #fff;
  border: 1px solid #8a6a2e;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}
.badge-new { background: var(--accent2); color: #fff; border-color: var(--accent2); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 18, 10, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--tr), visibility var(--tr);
  z-index: 500;
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%) scale(0.96);
  width: min(480px, calc(100vw - 32px));
  max-height: 84vh;
  overflow-y: auto;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 26px;
  z-index: 510;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--tr), transform var(--tr), visibility var(--tr);
}
.modal.open { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
.modal h3 { margin-top: 0; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--ink-soft);
  background: var(--paper-dark);
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding: 14px 0 4px;
  list-style: none;
  margin: 0;
}
.breadcrumb li { display: inline-flex; align-items: center; gap: 6px; }
.breadcrumb li + li::before { content: "›"; color: var(--gold); }
.breadcrumb a { color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--accent); }

/* ---------- Tips box ---------- */
.tips-box {
  background: #efe4c7;
  border: 1px dashed var(--gold);
  border-left: 5px solid var(--gold);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 20px 0;
}
.tips-box h3, .tips-box h4 {
  margin: 0 0 8px;
  font-size: 1.02rem;
  color: var(--accent2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tips-box ul { margin: 0; padding-left: 20px; }
.tips-box li { margin-bottom: 6px; }

/* ---------- FAQ ---------- */
.faq-item {
  border: 1px solid rgba(90, 79, 58, 0.35);
  border-radius: var(--radius);
  background: #fbf6e9;
  margin-bottom: 12px;
  overflow: hidden;
}
.faq-item summary {
  padding: 14px 18px;
  cursor: pointer;
  font-weight: bold;
  font-family: var(--font-heading);
  list-style: none;
  position: relative;
  padding-right: 40px;
}
html[lang="zh"] .faq-item summary { font-family: var(--font-cn); }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: var(--accent);
  transition: transform var(--tr);
}
.faq-item[open] summary::after { content: "−"; }
.faq-item .faq-a { padding: 0 18px 14px; color: var(--ink-soft); }

/* ---------- Article body ---------- */
.article-body { font-size: 1.02rem; }
.article-body h2 {
  margin-top: 1.8em;
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.article-body h2::before {
  content: "§ ";
  color: var(--gold);
}
.article-body p { line-height: 1.8; }
html[lang="zh"] .article-body p { line-height: 1.9; }
.article-body img { border-radius: var(--radius-lg); margin: 18px 0; box-shadow: var(--shadow-md); }
.article-body ul, .article-body ol { padding-left: 24px; line-height: 1.8; }
.article-body blockquote {
  margin: 20px 0;
  padding: 12px 20px;
  border-left: 4px solid var(--gold);
  background: #efe4c7;
  font-style: italic;
  color: var(--ink-soft);
}
.article-body table { border-collapse: collapse; width: 100%; margin: 16px 0; }
.article-body th, .article-body td { border: 1px solid rgba(90, 79, 58, 0.4); padding: 8px 12px; text-align: left; }
.article-body th { background: var(--paper-dark); }

/* ---------- Page hero (photo background header) ---------- */
.page-hero {
  position: relative;
  color: #fff;
  padding: 64px 0 56px;
  background-color: var(--ink);
  background-size: cover;
  background-position: center;
  isolation: isolate;
  overflow: hidden;
}
.page-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to bottom, rgba(24, 18, 10, 0.55), rgba(24, 18, 10, 0.78)),
    var(--hero-img, none) center / cover no-repeat;
}
.page-hero .container { position: relative; }
.page-hero h1 {
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  margin-bottom: 10px;
}
.page-hero p {
  color: rgba(255, 255, 255, 0.92);
  max-width: 720px;
  margin: 0;
  font-size: 1.05rem;
}

/* ---------- Tool page layout ---------- */
.tool-layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
  padding: 24px 0 48px;
}
@media (max-width: 900px) {
  .tool-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .tool-preview { order: -1; }
}

.tool-form {
  background: #fbf6e9;
  border: 1px solid rgba(90, 79, 58, 0.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: calc(var(--header-h) + 14px);
}
@media (max-width: 900px) { .tool-form { position: static; } }

.tool-form label {
  display: block;
  font-weight: bold;
  font-size: 0.9rem;
  margin-bottom: 5px;
  color: var(--ink);
}
.tool-form .form-row { display: flex; flex-direction: column; }
.tool-form .form-row-inline { display: flex; gap: 10px; }
.tool-form .form-row-inline > div { flex: 1; }

.tool-form input[type="text"],
.tool-form input[type="date"],
.tool-form input[type="number"],
.tool-form input[type="url"],
.tool-form select,
.tool-form textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(90, 79, 58, 0.55);
  border-radius: 8px;
  background: #fffdf5;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color var(--tr), box-shadow var(--tr);
}
html[lang="zh"] .tool-form input,
html[lang="zh"] .tool-form select,
html[lang="zh"] .tool-form textarea { font-family: var(--font-cn); }
.tool-form input:focus, .tool-form select:focus, .tool-form textarea:focus {
  outline: none;
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(31, 77, 63, 0.18);
}
.tool-form textarea { resize: vertical; min-height: 84px; }
.tool-form input[type="file"] {
  width: 100%;
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding: 8px 0;
}
.tool-form input[type="file"]::file-selector-button {
  padding: 7px 14px;
  margin-right: 10px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--paper-dark);
  color: var(--ink);
  font-family: var(--font-body);
  cursor: pointer;
  font-weight: bold;
}
.tool-form input[type="file"]::file-selector-button:hover { background: var(--accent); color: #fff; }
.tool-form input[type="color"] {
  width: 46px;
  height: 34px;
  padding: 2px;
  border: 1px solid rgba(90, 79, 58, 0.55);
  border-radius: 6px;
  background: #fffdf5;
  cursor: pointer;
}

.tool-preview {
  background: #efe6cd;
  border: 1px solid rgba(90, 79, 58, 0.35);
  border-radius: var(--radius);
  padding: 18px;
}
.preview-hint {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0 0 10px;
}

.print-area {
  background: #fff;
  border: 1px solid rgba(90, 79, 58, 0.35);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  justify-content: center;
  box-shadow: inset 0 0 12px rgba(43, 36, 23, 0.08);
}
.print-area canvas {
  max-width: 100%;
  height: auto !important;
  box-shadow: var(--shadow-md);
  border-radius: 4px;
}

.export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
@media (max-width: 480px) { .export-bar .btn { flex: 1 1 100%; } }

/* ---------- Article cards ---------- */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
@media (max-width: 480px) { .article-grid { grid-template-columns: 1fr; gap: 14px; } }

.article-card {
  display: flex;
  flex-direction: column;
  background: #fbf6e9;
  border: 1px solid rgba(90, 79, 58, 0.35);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--tr), box-shadow var(--tr);
  color: var(--ink);
}
.article-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); color: var(--ink); }
.article-card-img { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; }
.article-card-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.article-card-title { margin: 0; font-size: 1.08rem; }
.article-card-date { font-size: 0.78rem; color: var(--gold); text-transform: uppercase; letter-spacing: 0.06em; }
.article-card-excerpt {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card .read-more { margin-top: auto; font-weight: bold; font-size: 0.9rem; }

/* ---------- Favorites page ---------- */
.fav-empty {
  text-align: center;
  padding: 44px 20px;
  border: 2px dashed var(--gold);
  border-radius: var(--radius-lg);
  background: rgba(168, 130, 60, 0.07);
}
.fav-empty .fav-empty-heart { font-size: 2.4rem; color: var(--accent); line-height: 1; }
.fav-empty h2 { margin: 10px 0 6px; }
.fav-empty p { color: var(--ink-soft); max-width: 520px; margin: 0 auto 18px; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--ink);
  color: #d8cdb2;
  margin-top: 40px;
  border-top: 4px solid var(--gold);
  padding: 44px 0 20px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
}
@media (max-width: 768px) { .footer-grid { grid-template-columns: 1fr; gap: 24px; } }
.footer-brand .logo { color: var(--paper); font-size: 1.3rem; margin-bottom: 10px; }
.footer-brand .logo:hover { color: var(--gold); }
.footer-brand p { color: #b3a685; font-size: 0.92rem; max-width: 380px; }
.site-footer h4 {
  color: var(--paper);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 12px;
  border-bottom: 1px dashed #5a4f3a;
  padding-bottom: 6px;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 8px; }
.site-footer a { color: #d8cdb2; font-size: 0.92rem; }
.site-footer a:hover { color: var(--gold); }
.footer-bottom {
  border-top: 1px solid #4a4030;
  margin-top: 30px;
  padding-top: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  color: #b3a685;
}

/* ---------- Back to top ---------- */
#back-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity var(--tr), transform var(--tr), visibility var(--tr);
  z-index: 90;
}
#back-top.show { opacity: 1; visibility: visible; transform: none; }
#back-top:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Misc helpers ---------- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.muted { color: var(--ink-soft); }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* i18n language blocks: default shows EN, hides ZH */
.lang-zh { display: none; }
html[lang="zh"] .lang-en { display: none; }
html[lang="zh"] .lang-zh { display: revert; }

/* ---------- Breakpoint guardrails (375px no horizontal scroll) ---------- */
@media (max-width: 360px) {
  body { font-size: 15px; }
  .logo { font-size: 1rem; }
  .btn { padding: 9px 14px; }
}
@media (max-width: 1440px) and (min-width: 1025px) {
  .tool-layout { grid-template-columns: 360px minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .page-hero { padding: 44px 0 40px; }
  .modal { padding: 20px; }
}

/* ==========================================================================
   Print styles — only .print-area reaches the paper
   ========================================================================== */
@media print {
  @page { margin: 8mm; }

  body {
    background: #fff !important;
    background-image: none !important;
    overflow: visible !important;
  }

  /* hide everything, then reveal the print area */
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }

  .site-header, .site-footer, .site-nav, .hamburger,
  .tool-form, .export-bar, .page-hero, .breadcrumb,
  .tips-box, .faq-item, .fav-btn, #back-top,
  .modal, .modal-overlay, .section-title, .section-sub,
  .preview-hint, .no-print, .related-tools {
    display: none !important;
  }

  .tool-layout { display: block !important; padding: 0 !important; }
  .tool-preview { border: 0 !important; background: none !important; padding: 0 !important; margin: 0 !important; }
  .print-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100% !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: none !important;
  }
  .print-area canvas {
    width: 100% !important;
    height: auto !important;
    box-shadow: none !important;
  }
}
