/* eTools247 – main stylesheet */

:root {
  --bg: #f6f7fb; --card: #ffffff; --text: #1f2333; --muted: #626a80; --line: #e3e6ef;
  --brand: #5b3df5; --brand2: #ff4f8b;
  --fin: #16a34a; --health: #e11d48; --math: #2563eb; --date: #d97706; --conv: #7c3aed; --other: #0891b2; --txt: #db2777;
  --input: #ffffff; --footer: #1f2333; --footer-text: #c8ccda;
  --c: var(--brand);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141c; --card: #1c1f2b; --text: #e8eaf2; --muted: #a0a7bb; --line: #2e3344;
    --input: #262a38; --footer: #0b0d13; --footer-text: #a0a7bb; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12141c; --card: #1c1f2b; --text: #e8eaf2; --muted: #a0a7bb; --line: #2e3344;
  --input: #262a38; --footer: #0b0d13; --footer-text: #a0a7bb; color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* Category colours: any element with one of these classes sets --c */
.fin { --c: var(--fin); } .health { --c: var(--health); } .math { --c: var(--math); }
.date { --c: var(--date); } .conv { --c: var(--conv); } .other { --c: var(--other); } .txt { --c: var(--txt); }

/* ---------- Header ---------- */
header { background: linear-gradient(120deg, var(--brand), var(--brand2)); color: #fff; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; flex-wrap: wrap; }
.logo { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.5px; }
.logo span { background: #fff; color: var(--brand); border-radius: 8px; padding: 0 6px; margin-left: 2px; }
.right { display: flex; align-items: center; }
.topbar nav a { margin-left: 18px; font-weight: 600; opacity: .9; }
.topbar nav a:hover { opacity: 1; text-decoration: underline; }
.theme-btn { border: 0; background: rgba(255,255,255,.2); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; margin-left: 18px; }
.theme-btn:hover { background: rgba(255,255,255,.35); }

.hero { text-align: center; padding: 28px 0 44px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(1.6rem, 4vw, 2.4rem); }
.hero p { margin: 0 0 20px; opacity: .92; }
.search { display: flex; max-width: 560px; margin: 0 auto; background: var(--input); border-radius: 999px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.search input { flex: 1; border: 0; padding: 14px 20px; font-size: 1rem; outline: none; min-width: 0; color: var(--text); background: transparent; }
.search button { border: 0; background: #1f2333; color: #fff; padding: 0 22px; font-weight: 700; cursor: pointer; }
.search.small { max-width: 420px; margin: 0; box-shadow: none; }
.search.small input { padding: 9px 16px; font-size: .95rem; }
.mini-search { padding: 0 0 16px; }
.search-results { max-width: 560px; margin: 10px auto 0; text-align: left; }
.mini-search .search-results { margin: 6px 0 0; }
.search-results:empty { display: none; }
.search-results a { display: inline-block; background: rgba(255,255,255,.2); border-radius: 999px; padding: 4px 12px; margin: 4px 4px 0 0; font-size: .9rem; }
.search-results a:hover { background: rgba(255,255,255,.35); }

/* ---------- Layout ---------- */
main.wrap { padding-top: 28px; padding-bottom: 40px; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
h2.section-title { font-size: 1.25rem; margin: 0 0 14px; }

/* Popular chips */
.popular { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.popular a { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: .95rem; }
.popular a:hover { border-color: var(--brand); color: var(--brand); }

/* Category cards */
.cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.cat { background: var(--card); border-radius: 14px; overflow: hidden; border: 1px solid var(--line); scroll-margin-top: 16px; }
.cat h3 { margin: 0; padding: 12px 16px; color: #fff; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; background: var(--c); }
.cat ul { list-style: none; margin: 0; padding: 8px 16px 14px; }
.cat li a, .cat li span { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.cat li:last-child a, .cat li:last-child span { border-bottom: 0; }
.cat li a { font-weight: 600; }
.cat li a:hover { color: var(--c); }
.cat li span { color: var(--muted); }
.soon { font-size: .75rem; background: var(--bg); border-radius: 999px; padding: 1px 8px; align-self: center; }

/* ---------- Calculator card (homepage + tool pages) ---------- */
.calc { background: var(--card); border-radius: 14px; border: 1px solid var(--line); overflow: hidden; }
aside.calc { position: sticky; top: 16px; }
.calc-head { background: var(--c); color: #fff; padding: 12px 16px; }
.calc-head h2 { margin: 0; font-size: 1.1rem; }
.calc-head p { margin: 2px 0 0; font-size: .85rem; opacity: .9; }
.calc form, .calc .body { padding: 16px; }
.calc + .calc { margin-top: 16px; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 1; padding: 8px; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--text); }
.tabs button.on { background: var(--c); color: #fff; border-color: var(--c); }

label { display: block; font-size: .9rem; font-weight: 600; margin: 10px 0 4px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
.row > .fixed { flex: 0 0 auto; }
input[type=number], input[type=date], select {
  width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem;
  background: var(--input); color: var(--text); font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--c); outline-offset: 0; border-color: var(--c); }
.btn { display: block; width: 100%; margin-top: 14px; padding: 12px; border: 0; border-radius: 8px; background: var(--c); color: #fff; font-weight: 700; font-size: 1rem; cursor: pointer; text-align: center; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--c); border: 1px solid var(--c); }
.icon-btn { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 8px; padding: 9px 12px; cursor: pointer; font-size: 1rem; }

.result { margin-top: 14px; padding: 14px; border-radius: 10px; background: var(--bg); text-align: center; }
.result[hidden] { display: none; }
.result .big { font-size: 2rem; font-weight: 800; color: var(--c); line-height: 1.2; word-break: break-word; }
.result .note { color: var(--muted); font-size: .9rem; }
.scale { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin-top: 10px; position: relative; }
.scale div { flex: 1; }
.marker { position: relative; height: 14px; }
.marker span { position: absolute; top: 0; transform: translateX(-50%); font-size: .8rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.stats b { display: block; font-size: 1.2rem; }
.stats small { color: var(--muted); }
.inline-calc { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-calc input { flex: 1 1 90px; width: auto; }
.inline-calc .word { flex: 0 0 auto; color: var(--muted); font-weight: 600; }
.answer { margin-top: 12px; font-size: 1.15rem; }
.answer b { color: var(--c); font-size: 1.4rem; }

table.data { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .95rem; }
table.data th, table.data td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
table.data th { color: var(--muted); font-weight: 600; }
table.data td:last-child { font-weight: 700; text-align: right; }

/* ---------- Tool pages ---------- */
.breadcrumb { font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
.breadcrumb a:hover { color: var(--c); text-decoration: underline; }
.tool-page h1 { margin: 0 0 6px; font-size: clamp(1.5rem, 3.5vw, 2rem); }
.lead { color: var(--muted); margin: 0 0 18px; font-size: 1.05rem; }
.content { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-top: 24px; }
.content h2 { margin: 0 0 10px; font-size: 1.2rem; }
.content h3 { margin: 18px 0 6px; font-size: 1.05rem; }
.content p, .content li { color: var(--muted); }
.content code, .formula { background: var(--bg); border-radius: 6px; padding: 2px 6px; font-family: ui-monospace, Consolas, monospace; color: var(--text); }
.formula { display: block; padding: 10px 14px; margin: 8px 0; }
.faq details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq details:last-child { border-bottom: 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; }

.sidebar { display: grid; gap: 16px; position: sticky; top: 16px; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.box h2 { margin: 0 0 8px; font-size: 1.05rem; }
.box ul { list-style: none; margin: 0; padding: 0; }
.box li a { display: block; padding: 6px 0; border-bottom: 1px dashed var(--line); font-weight: 600; }
.box li:last-child a { border-bottom: 0; }
.box li a:hover { color: var(--brand); }
.ad-slot { min-height: 250px; border: 2px dashed var(--line); border-radius: 14px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem; }

/* About / text pages */
.about, .page-text { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-top: 28px; }
.page-text { margin-top: 0; max-width: 780px; }
.about h2, .page-text h2 { margin-top: 0; font-size: 1.15rem; }
.about p, .page-text p, .page-text li { color: var(--muted); }
.page-text a { color: var(--brand); text-decoration: underline; }

/* ---------- Footer ---------- */
footer { background: var(--footer); color: var(--footer-text); padding: 24px 0; font-size: .9rem; }
footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
footer a { margin-right: 14px; }
footer a:hover { color: #fff; }

@media (max-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  aside.calc, .sidebar { position: static; }
}
@media (max-width: 560px) {
  .cats { grid-template-columns: 1fr; }
  .topbar nav { display: none; }
  .theme-btn { margin-left: 0; }
}

/* Ad placeholder between calculator and text on tool pages */
.tool-page .ad-slot { min-height: 100px; margin-top: 24px; }
.text-page h1 { margin: 0 0 16px; }

/* Morse code translator */
textarea { width: 100%; min-height: 110px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; background: var(--input); color: var(--text); font-family: inherit; resize: vertical; }
textarea:focus { outline: 2px solid var(--c); border-color: var(--c); }
textarea.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: 1px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-row .btn { width: auto; flex: 1 1 130px; margin-top: 0; }
.speed { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: .9rem; color: var(--muted); }
.speed input { flex: 1; accent-color: var(--c); }
.lamp { width: 22px; height: 22px; border-radius: 50%; background: var(--line); flex: 0 0 auto; transition: background .03s; }
.lamp.on { background: var(--c); box-shadow: 0 0 14px var(--c); }
.morse-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin-top: 10px; }
.morse-table div { background: var(--bg); border-radius: 8px; padding: 6px 8px; display: flex; justify-content: space-between; font-family: ui-monospace, Consolas, monospace; }
.morse-table b { color: var(--c); }
