/* =====================================================================
   Free Daily Web Tools — Global Stylesheet
   Single stylesheet powering every page. Uses CSS custom properties so
   the dark/light theme toggle works instantly across the whole site.
   ===================================================================== */

/* ---------- Design tokens (Light theme is the default) ---------- */
:root {
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: #eef2ff;
  --accent: #06b6d4;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --text: #1e2233;
  --text-soft: #5b6178;
  --border: #e3e6ef;
  --shadow: 0 4px 14px rgba(20, 24, 55, 0.06);
  --shadow-lg: 0 12px 34px rgba(20, 24, 55, 0.12);
  --radius: 14px;
  --radius-sm: 9px;
  --header-h: 66px;
  --maxw: 1180px;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --transition: 0.22s ease;
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  --brand: #818cf8;
  --brand-hover: #a5b4fc;
  --brand-soft: #1e2140;
  --accent: #22d3ee;
  --bg: #0f1120;
  --surface: #181a2e;
  --surface-2: #21243d;
  --text: #eceef8;
  --text-soft: #a2a8c4;
  --border: #2b2f4c;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.5);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; color: var(--text); }
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 20px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font: inherit; font-weight: 600; border: 1px solid transparent;
  padding: 10px 18px; border-radius: var(--radius-sm);
  background: var(--brand); color: #fff; transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn:hover { background: var(--brand-hover); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-outline { background: transparent; color: var(--brand); border-color: var(--border); }
.btn-outline:hover { background: var(--brand-soft); color: var(--brand); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 7px 13px; font-size: .9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ---------- Form controls ---------- */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px; width: 100%; transition: border var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
textarea { resize: vertical; min-height: 130px; font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace; }
label { font-weight: 600; font-size: .92rem; display: block; margin-bottom: 6px; color: var(--text-soft); }
.field { margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 620px){ .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100; background: var(--surface);
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
}
.nav {
  height: var(--header-h); display: flex; align-items: center;
  justify-content: space-between; gap: 16px;
}
.brand { font-weight: 800; font-size: 1.25rem; color: var(--text); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .logo { color: var(--brand); }
.nav-links { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav-links > li > a, .nav-toggle-tools {
  display: inline-flex; align-items: center; gap: 5px; padding: 10px 14px;
  border-radius: var(--radius-sm); font-weight: 600; color: var(--text);
  background: transparent; border: none; font: inherit; cursor: pointer;
}
.nav-links > li > a:hover, .nav-toggle-tools:hover { background: var(--surface-2); text-decoration: none; }
.nav-actions { display: flex; align-items: center; gap: 8px; }

/* Theme toggle */
.theme-toggle {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem;
  transition: background var(--transition), transform var(--transition);
}
.theme-toggle:hover { background: var(--brand-soft); transform: rotate(-12deg); }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: inline; }

/* Hamburger */
.hamburger {
  display: none; width: 42px; height: 42px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.hamburger span { width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: var(--transition); }
.hamburger.open span:nth-child(1){ transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2){ opacity: 0; }
.hamburger.open span:nth-child(3){ transform: translateY(-6px) rotate(-45deg); }

/* ---------- Mega menu ---------- */
.mega-wrap { position: relative; }
.mega {
  position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(8px);
  width: min(92vw, 940px); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 22px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 26px;
  opacity: 0; visibility: hidden; transition: opacity var(--transition), transform var(--transition);
}
.mega-wrap:hover .mega, .mega.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.mega-col h4 {
  margin: 0 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--brand); display: flex; align-items: center; gap: 6px;
}
.mega-col ul { list-style: none; margin: 0 0 14px; padding: 0; }
.mega-col li a { display: block; padding: 5px 8px; border-radius: 7px; font-size: .9rem; color: var(--text-soft); }
.mega-col li a:hover { background: var(--surface-2); color: var(--brand); text-decoration: none; }

/* ---------- Hero ---------- */
.hero { padding: 58px 0 40px; text-align: center; }
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); margin: 0 0 14px; letter-spacing: -.02em; }
.hero .sub { font-size: 1.12rem; color: var(--text-soft); max-width: 680px; margin: 0 auto 26px; }
.hero .accent { color: var(--brand); }
.search-wrap { max-width: 560px; margin: 0 auto; position: relative; }
.search-wrap input { padding-left: 44px; height: 54px; border-radius: 30px; box-shadow: var(--shadow); font-size: 1.02rem; }
.search-wrap .search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-soft); }
.no-results { text-align: center; color: var(--text-soft); padding: 30px; display: none; }

/* ---------- Category filter bar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 30px 0 8px; }
.filter-bar button {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  padding: 8px 16px; border-radius: 30px; cursor: pointer; font: inherit; font-weight: 600; transition: var(--transition);
}
.filter-bar button:hover { border-color: var(--brand); color: var(--brand); }
.filter-bar button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Tool cards ---------- */
.cat-block { margin: 34px 0; }
.cat-block > h2 { display: flex; align-items: center; gap: 10px; font-size: 1.4rem; margin: 0 0 4px; }
.cat-block > p.cat-desc { color: var(--text-soft); margin: 0 0 18px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; gap: 14px; align-items: flex-start;
  box-shadow: var(--shadow); transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.tool-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--brand); text-decoration: none; }
.tool-card .ico {
  flex: 0 0 46px; width: 46px; height: 46px; border-radius: 12px; background: var(--brand-soft);
  display: grid; place-items: center; font-size: 1.4rem;
}
.tool-card h3 { margin: 0 0 3px; font-size: 1.02rem; color: var(--text); }
.tool-card p { margin: 0; font-size: .87rem; color: var(--text-soft); }

/* ---------- Sections / prose ---------- */
.section { padding: 30px 0; }
.prose { max-width: 820px; margin-inline: auto; }
.prose h2 { font-size: 1.5rem; margin: 30px 0 12px; }
.prose h3 { font-size: 1.15rem; margin: 22px 0 8px; }
.prose p, .prose li { color: var(--text); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.card-surface { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }

/* ---------- FAQ (accordion) ---------- */
.faq details {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 4px 18px; margin-bottom: 10px;
}
.faq summary { cursor: pointer; font-weight: 600; padding: 12px 0; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--brand); font-size: 1.3rem; line-height: 1; }
.faq details[open] summary::after { content: "\2212"; }
.faq details p { margin: 0 0 14px; color: var(--text-soft); }

/* ---------- Breadcrumb ---------- */
.breadcrumb { font-size: .85rem; color: var(--text-soft); padding: 16px 0 0; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.breadcrumb li::after { content: "\203A"; margin-left: 6px; color: var(--text-soft); }
.breadcrumb li:last-child::after { content: ""; }

/* ---------- Tool page layout ---------- */
.tool-hero { padding: 6px 0 8px; }
.tool-hero h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); margin: 6px 0 6px; }
.tool-hero .lead { color: var(--text-soft); margin: 0 0 6px; max-width: 760px; }
.tool-app { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin: 12px 0 8px; }
.tool-output {
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 14px; min-height: 46px; white-space: pre-wrap; word-break: break-word;
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace; font-size: .92rem;
}
.stat-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.stat {
  flex: 1 1 120px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; text-align: center;
}
.stat .num { font-size: 1.5rem; font-weight: 800; color: var(--brand); }
.stat .lbl { font-size: .78rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; }
.result-big { font-size: 1.5rem; font-weight: 800; color: var(--brand); }
.hint { font-size: .82rem; color: var(--text-soft); }
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: 30px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: var(--transition); z-index: 300; font-weight: 600;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
canvas { max-width: 100%; }

/* Related tools */
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 14px; }

/* ---------- Contact form ---------- */
.form-error { color: var(--err); font-size: .82rem; margin-top: 4px; display: none; }
.form-error.show { display: block; }
.form-note { padding: 12px 16px; background: var(--brand-soft); border-radius: var(--radius-sm); color: var(--text); margin-top: 14px; display: none; }
.form-note.show { display: block; }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 50px; padding: 42px 0 20px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 26px; }
.footer-grid h4 { font-size: .95rem; margin: 0 0 12px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin-bottom: 8px; }
.footer-grid a { color: var(--text-soft); font-size: .9rem; }
.footer-grid a:hover { color: var(--brand); }
.footer-about p { color: var(--text-soft); font-size: .9rem; }
.footer-bottom { text-align: center; color: var(--text-soft); font-size: .86rem; border-top: 1px solid var(--border); margin-top: 28px; padding-top: 18px; }
@media (max-width: 780px){ .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 460px){ .footer-grid { grid-template-columns: 1fr; } }

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed; right: 22px; bottom: 22px; width: 46px; height: 46px; border-radius: 50%;
  border: none; background: var(--brand); color: #fff; font-size: 1.2rem; cursor: pointer;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: var(--transition); z-index: 90;
}
.back-to-top.show { opacity: 1; pointer-events: auto; }
.back-to-top:hover { background: var(--brand-hover); }

/* ---------- Mobile nav ---------- */
@media (max-width: 900px){
  .hamburger { display: flex; }
  .nav-links {
    position: fixed; inset: var(--header-h) 0 auto 0; flex-direction: column; align-items: stretch;
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg);
    padding: 12px; gap: 2px; max-height: calc(100vh - var(--header-h)); overflow-y: auto;
    transform: translateY(-140%); transition: transform var(--transition); z-index: 99;
  }
  .nav-links.open { transform: translateY(0); }
  .nav-links > li > a, .nav-toggle-tools { width: 100%; justify-content: space-between; }
  .mega {
    position: static; transform: none; width: 100%; grid-template-columns: 1fr; box-shadow: none;
    border: none; padding: 4px 8px 8px; opacity: 1; visibility: visible; display: none; background: var(--surface-2); border-radius: var(--radius-sm);
  }
  .mega.show { display: grid; transform: none; }
  .mega-wrap:hover .mega { opacity: 1; }
  .mega-col ul { margin-bottom: 6px; }
}
