/* All in One Calculator */
:root {
  --primary: #2563eb; --primary-hover: #1d4ed8; --primary-light: #dbeafe;
  --secondary: #64748b; --success: #16a34a; --warning: #d97706; --danger: #dc2626;
  --bg: #f8fafc; --bg-card: #ffffff; --bg-input: #ffffff;
  --text: #0f172a; --text-muted: #64748b; --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08); --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
  --radius: 10px; --radius-sm: 6px; --nav-height: 64px;
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
[data-theme="dark"] {
  --primary: #3b82f6; --primary-hover: #60a5fa; --primary-light: #1e3a5f;
  --secondary: #94a3b8; --success: #22c55e; --warning: #f59e0b; --danger: #ef4444;
  --bg: #0f172a; --bg-card: #1e293b; --bg-input: #1e293b;
  --text: #f1f5f9; --text-muted: #94a3b8; --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,0.3); --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column;
  transition: background 0.2s, color 0.2s;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.navbar {
  position: sticky; top: 0; z-index: 1000; height: var(--nav-height);
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow); display: flex; align-items: center; padding: 0 1.25rem;
}
.nav-inner {
  max-width: 1200px; width: 100%; margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
}
.logo {
  font-size: 1.25rem; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; text-decoration: none;
}
.logo:hover { text-decoration: none; color: var(--primary); }
.logo-icon {
  width: 32px; height: 32px; background: var(--primary); color: white;
  border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.nav-search { flex: 1; max-width: 420px; position: relative; }
.nav-search input {
  width: 100%; padding: 0.55rem 1rem 0.55rem 2.5rem; border: 1px solid var(--border);
  border-radius: 999px; background: var(--bg); color: var(--text); font-size: 0.95rem; outline: none;
}
.nav-search input:focus { border-color: var(--primary); }
.nav-search .search-icon {
  position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.nav-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.btn-icon {
  width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.btn-icon:hover { background: var(--primary-light); border-color: var(--primary); }
.nav-toggle {
  display: none; width: 40px; height: 40px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--text); cursor: pointer; font-size: 1.25rem;
}
.main { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.hero { text-align: center; padding: 2rem 0 2.5rem; }
.hero h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 800; margin-bottom: 0.75rem; letter-spacing: -0.02em; }
.hero p { color: var(--text-muted); font-size: 1.1rem; max-width: 560px; margin: 0 auto 1.5rem; }
.category-tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-bottom: 2rem; }
.cat-tab {
  padding: 0.45rem 1rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-muted); font-size: 0.9rem;
  cursor: pointer; transition: all 0.15s; font-weight: 500;
}
.cat-tab:hover, .cat-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.tool-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0; box-shadow: var(--shadow); transition: box-shadow 0.2s, transform 0.15s, border-color 0.15s;
  display: flex; flex-direction: column; position: relative; cursor: pointer;
}
.tool-card:hover, .tool-card:focus-within {
  box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--primary);
}
.tool-card .card-link {
  display: flex; flex-direction: column; gap: 0.6rem; padding: 1.25rem; padding-right: 2.75rem;
  color: inherit; text-decoration: none; flex: 1; border-radius: inherit; min-height: 100%;
  -webkit-tap-highlight-color: transparent; cursor: pointer;
}
.tool-card .card-link:hover, .tool-card .card-link:focus { text-decoration: none; color: inherit; }
.tool-card .card-link:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.tool-card .icon {
  width: 44px; height: 44px; border-radius: 10px; background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
}
.tool-card h3 { font-size: 1.05rem; font-weight: 600; margin: 0; color: var(--text); }
.tool-card:hover h3 { color: var(--primary); }
.tool-card p { font-size: 0.875rem; color: var(--text-muted); flex: 1; margin: 0; }
.tool-card .fav-btn {
  position: absolute; top: 0.75rem; right: 0.75rem; z-index: 2; background: var(--bg-card);
  border: none; cursor: pointer; font-size: 1.2rem; color: var(--text-muted);
  padding: 0.35rem; line-height: 1; border-radius: 6px;
}
.tool-card .fav-btn.active, .tool-card .fav-btn:hover { color: #eab308; }

/* Recently Used: ~half footprint, name only */
#recent-grid.tools-grid {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.65rem;
}
#recent-grid .tool-card--compact .card-link {
  gap: 0.35rem;
  padding: 0.65rem 0.7rem;
  padding-right: 1.9rem;
}
#recent-grid .tool-card--compact .icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 0.95rem;
}
#recent-grid .tool-card--compact h3 {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#recent-grid .tool-card--compact .fav-btn {
  top: 0.35rem;
  right: 0.35rem;
  font-size: 0.95rem;
  padding: 0.2rem;
}
#recent-section .section-title {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.75rem;
}
@media (max-width: 480px) {
  #recent-grid.tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.5rem;
  }
}
.section-title { font-size: 1.35rem; font-weight: 700; margin: 2rem 0 1rem; display: flex; align-items: center; gap: 0.5rem; }
.section-title:first-child { margin-top: 0; }
.tool-page { max-width: 720px; margin: 0 auto; }
.tool-header { margin-bottom: 1.75rem; }
.tool-header .breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.tool-header h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; }
.tool-header .desc { color: var(--text-muted); font-size: 1rem; }
.tool-box {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.5rem;
}
.form-group { margin-bottom: 1.15rem; }
.form-group label { display: block; font-weight: 500; font-size: 0.9rem; margin-bottom: 0.35rem; color: var(--text); }
.form-group .hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
}
input[type="text"], input[type="number"], input[type="date"], input[type="time"],
input[type="datetime-local"], select, textarea {
  width: 100%; padding: 0.6rem 0.85rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-input); color: var(--text);
  font-size: 1rem; font-family: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
input.error, select.error, textarea.error { border-color: var(--danger); }
textarea { resize: vertical; min-height: 120px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.65rem 1.25rem; border: none; border-radius: var(--radius-sm);
  font-size: 0.95rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--primary-light); }
.btn-group { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.5rem; }
.result-box {
  background: var(--primary-light); border: 1px solid var(--primary); border-radius: var(--radius-sm);
  padding: 1.15rem; margin-top: 1.25rem; display: none;
}
.result-box.show { display: block; }
.result-box .label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.result-box .value { font-size: 1.5rem; font-weight: 700; color: var(--primary); word-break: break-all; }
.result-box .sub { font-size: 0.9rem; color: var(--text-muted); margin-top: 0.35rem; }
.result-rows { margin-top: 0.75rem; }
.result-row {
  display: flex; justify-content: space-between; padding: 0.4rem 0;
  border-bottom: 1px solid var(--border); font-size: 0.95rem;
}
.result-row:last-child { border-bottom: none; }
.result-row .r-label { color: var(--text-muted); }
.result-row .r-value { font-weight: 600; }
.error-msg { color: var(--danger); font-size: 0.875rem; margin-top: 0.35rem; display: none; }
.error-msg.show { display: block; }
.info-box {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; margin-top: 1.5rem;
}
.info-box h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.info-box p, .info-box ul { font-size: 0.9rem; color: var(--text-muted); }
.info-box ul { padding-left: 1.25rem; margin-top: 0.5rem; }
.ad-placeholder {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.5rem;
  text-align: center; color: var(--text-muted); font-size: 0.85rem; margin: 1.5rem 0; background: var(--bg);
}
.ad-placeholder::before { content: "Advertisement Space"; display: block; font-weight: 600; margin-bottom: 0.25rem; }
.calc-display {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 1rem 1.15rem; font-size: 1.75rem; font-weight: 600; text-align: right;
  min-height: 60px; word-break: break-all; margin-bottom: 1rem; font-variant-numeric: tabular-nums;
}
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.calc-btn {
  padding: 1rem 0.5rem; font-size: 1.15rem; font-weight: 600; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text); cursor: pointer;
}
.calc-btn:hover { background: var(--primary-light); }
.calc-btn.op { background: var(--primary); color: white; border-color: var(--primary); }
.calc-btn.eq { background: var(--success); color: white; border-color: var(--success); grid-column: span 2; }
.calc-btn.clear { background: var(--danger); color: white; border-color: var(--danger); }
.clock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.clock-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 1rem; text-align: center;
}
.clock-card .city { font-weight: 600; margin-bottom: 0.25rem; }
.clock-card .time { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); }
.clock-card .date { font-size: 0.8rem; color: var(--text-muted); }
.timer-display {
  font-size: 3rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em; margin: 1rem 0; color: var(--primary);
}
.footer {
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding: 2.5rem 1.25rem 1.5rem; margin-top: auto;
}
.footer-inner {
  max-width: 1200px; margin: 0 auto; display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2rem;
}
.footer h4 { font-size: 0.95rem; margin-bottom: 0.75rem; font-weight: 600; }
.footer p, .footer a { font-size: 0.875rem; color: var(--text-muted); }
.footer a:hover { color: var(--primary); }
.footer ul { list-style: none; }
.footer li { margin-bottom: 0.4rem; }
.footer-bottom {
  max-width: 1200px; margin: 1.5rem auto 0; padding-top: 1.25rem;
  border-top: 1px solid var(--border); text-align: center; font-size: 0.85rem; color: var(--text-muted);
}
@media (max-width: 768px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .nav-search { display: none; }
  .nav-search.mobile-open {
    display: block; position: absolute; top: var(--nav-height); left: 0; right: 0;
    padding: 0.75rem 1rem; background: var(--bg-card); border-bottom: 1px solid var(--border); max-width: none;
  }
  .nav-toggle { display: flex; align-items: center; justify-content: center; }
}
@media (max-width: 480px) { .footer-inner { grid-template-columns: 1fr; } }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h2 { color: var(--text); margin-bottom: 0.5rem; }
.check-group { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; margin-top: 0.35rem; }
.check-group label { display: flex; align-items: center; gap: 0.4rem; font-weight: 400; cursor: pointer; }
.check-group input { width: auto; accent-color: var(--primary); }
.related-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.related-tools a {
  padding: 0.35rem 0.75rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; font-size: 0.85rem; color: var(--text-muted); text-decoration: none;
}
.related-tools a:hover { border-color: var(--primary); color: var(--primary); }
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
input[type="range"] { width: 100%; accent-color: var(--primary); cursor: pointer; }


/* Navigation links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem 1rem;
  margin-left: 0.75rem;
}
.nav-links a {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--primary);
  text-decoration: none;
}
@media (max-width: 640px) {
  .nav-links { display: none; }
  .nav-links.mobile-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--nav-height);
    left: 0; right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
    gap: 0.65rem;
    z-index: 999;
  }
}

/* Guides */
.guides-hero { margin-bottom: 1.5rem; }
.guides-hero p { color: var(--text-muted); max-width: 640px; }
.guide-category { margin-bottom: 2rem; }
.guide-category h2 {
  font-size: 1.15rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.guide-list { display: grid; gap: 0.85rem; }
.guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.guide-card h3 { font-size: 1.05rem; margin: 0; }
.guide-card h3 a { color: var(--text); text-decoration: none; }
.guide-card h3 a:hover { color: var(--primary); }
.guide-card p { margin: 0; font-size: 0.9rem; color: var(--text-muted); }
.guide-card .read-link {
  align-self: flex-start;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}
.guide-card .read-link:hover { text-decoration: underline; }

.article-page { max-width: 760px; margin: 0 auto; }
.article-page .breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.article-page h1 { font-size: clamp(1.45rem, 3vw, 1.85rem); margin-bottom: 0.5rem; }
.article-meta { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1.25rem; }
.article-body {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.35rem;
  box-shadow: var(--shadow);
}
.article-body h2 { font-size: 1.15rem; margin: 1.5rem 0 0.6rem; }
.article-body h2:first-child { margin-top: 0; }
.article-body h3 { font-size: 1.02rem; margin: 1.15rem 0 0.45rem; }
.article-body p, .article-body li { font-size: 0.95rem; color: var(--text-muted); line-height: 1.7; }
.article-body p { margin-bottom: 0.85rem; }
.article-body ul, .article-body ol { padding-left: 1.25rem; margin: 0.4rem 0 0.9rem; }
.article-body li { margin-bottom: 0.35rem; }
.article-body .formula {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin: 0.75rem 0 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  color: var(--text);
  overflow-x: auto;
}
.article-body .example {
  border-left: 3px solid var(--primary);
  padding: 0.65rem 0 0.65rem 1rem;
  margin: 0.85rem 0 1.1rem;
  background: var(--primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.article-body .example p { margin-bottom: 0.35rem; color: var(--text); }
.article-cta {
  margin-top: 1.5rem;
  padding: 1rem 1.15rem;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
}
.article-cta p { margin: 0 0 0.5rem; color: var(--text); font-size: 0.95rem; }
.article-cta a.btn { text-decoration: none; }

.learn-more {
  margin-top: 1.5rem;
  padding: 1.15rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.learn-more h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.learn-more p, .learn-more li { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; }
.learn-more ul { padding-left: 1.2rem; margin: 0.4rem 0 0.75rem; }
.learn-more .formula {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  margin: 0.5rem 0 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
}
.learn-more a { font-weight: 600; }
