/* MaltiCalculator - main stylesheet (navy + cyan theme, dark by default) */
:root {
  --bg: #f4f7fc;
  --surface: #ffffff;
  --surface-2: #eef2fa;
  --text: #0b1530;
  --muted: #56617d;
  --border: #dbe2f0;
  --primary: #0891b2;
  --primary-hover: #0e7490;
  --primary-soft: #e0f6fb;
  --accent: #3b82f6;
  --accent-soft: #e6efff;
  --good: #0f8a5f;
  --warn: #b45309;
  --bad: #c2410c;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(11, 21, 48, .04), 0 6px 20px rgba(11, 21, 48, .07);
  --shadow-lg: 0 18px 50px -12px rgba(8, 145, 178, .28);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #050a1c; --surface: #0b1430; --surface-2: #101b3d; --text: #e7edfb; --muted: #97a3c2;
  --border: #1c2a55; --primary: #22d3ee; --primary-hover: #67e8f9; --primary-soft: #0c2a45;
  --accent: #60a5fa; --accent-soft: #10224a; --good: #34d399; --warn: #fbbf24; --bad: #fb923c;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25); --shadow-lg: 0 24px 60px -16px rgba(34,211,238,.18);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--font); }
a { color: var(--primary); }
img, canvas { max-width: 100%; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
h1, h2, h3 { letter-spacing: -0.015em; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border); }
.nav { display: flex; align-items: center; justify-content: space-between; min-height: 68px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.22rem; font-weight: 700; color: var(--text); text-decoration: none; }
.brand b { color: var(--primary); font-weight: 800; }
.brand-logo { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 4px 14px rgba(34,211,238,.35); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { font-size: .7rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a { color: var(--text); text-decoration: none; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: .95rem; }
.nav-links a:hover { background: var(--primary-soft); color: var(--primary); }
.theme-toggle, .nav-toggle { border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 40px; height: 40px; border-radius: 12px; cursor: pointer; }
.nav-toggle { display: none; }
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-links { display: none; position: absolute; top: 68px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
  .nav-links.open { display: flex; }
  .theme-toggle { width: 100%; }
}

/* Hero */
.hero { position: relative; overflow: hidden; color: #e7edfb; padding: 72px 0 80px;
  background: radial-gradient(700px 500px at 18% 45%, rgba(30,58,138,.55), transparent 70%),
              radial-gradient(500px 400px at 72% 50%, rgba(8,145,178,.22), transparent 70%),
              linear-gradient(120deg, #0a1238 0%, #070d28 55%, #02040f 100%); }
.hero::after { content: ""; position: absolute; inset: 0; opacity: .06; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.7) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.7) 1px, transparent 1px);
  background-size: 40px 40px; mask-image: radial-gradient(ellipse at 30% 50%, #000 20%, transparent 70%); }
.hero .wrap { position: relative; z-index: 1; }
.hero-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: center; }
.hero-badge { display: inline-flex; gap: 8px; align-items: center; background: rgba(34,211,238,.1); border: 1px solid rgba(34,211,238,.35); color: #a5f3fc; padding: 6px 14px; border-radius: 999px; font-size: .88rem; font-weight: 600; }
.hero-badge i { color: #22d3ee; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.5rem); line-height: 1.1; margin: 18px 0 14px; font-weight: 800; color: #fff; }
.hero h1 span { background: linear-gradient(90deg, #22d3ee, #60a5fa); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { max-width: 560px; margin: 0 0 28px; color: #aab6d3; font-size: 1.1rem; }
.search { position: relative; max-width: 560px; }
.search i { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); color: #0891b2; }
.search input { width: 100%; padding: 18px 20px 18px 52px; border-radius: 999px; border: 1px solid rgba(34,211,238,.4); font: inherit; font-size: 1.05rem; color: #0b1530; background: #fff; box-shadow: 0 0 0 6px rgba(34,211,238,.08), 0 16px 40px rgba(0,0,0,.4); }
.search input:focus { outline: 3px solid #22d3ee; }
.hero-points { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 22px; font-size: .92rem; color: #aab6d3; }
.hero-points i { color: #22d3ee; margin-right: 6px; }

/* Floating tool cards */
.hero-stage { position: relative; height: 380px; perspective: 900px; }
.hero-stage .glow { position: absolute; left: 50%; top: 50%; width: 260px; height: 260px; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle, rgba(34,211,238,.28), transparent 70%); filter: blur(10px); animation: glow 6s ease-in-out infinite; }
.fcard { position: absolute; width: 132px; height: 140px; border-radius: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: linear-gradient(160deg, rgba(23,35,78,.95), rgba(9,15,40,.95)); border: 1px solid rgba(148,163,255,.18);
  box-shadow: 0 24px 50px -12px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.06); transform-style: preserve-3d; animation: floaty 7s ease-in-out infinite; }
.fcard i { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; color: #fff; background: var(--c); box-shadow: 0 10px 24px -6px var(--c); }
.fcard b { font-size: .95rem; letter-spacing: .08em; color: var(--c); }
.fcard.f1 { left: 6%;  top: 8%;  --r: -8deg;  animation-delay: 0s; }
.fcard.f2 { left: 40%; top: 0%;  --r: 6deg;   animation-delay: -1.2s; }
.fcard.f3 { left: 72%; top: 14%; --r: -5deg;  animation-delay: -2.4s; width: 116px; height: 124px; }
.fcard.f4 { left: 14%; top: 56%; --r: 7deg;   animation-delay: -3.6s; width: 116px; height: 124px; }
.fcard.f5 { left: 48%; top: 52%; --r: -6deg;  animation-delay: -4.8s; }
.fcard.f6 { left: 78%; top: 62%; --r: 10deg;  animation-delay: -6s; width: 100px; height: 108px; }
@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(var(--r)) rotateY(-14deg); }
  50% { transform: translateY(-16px) rotate(calc(var(--r) * -0.6)) rotateY(14deg); }
}
@keyframes glow { 0%, 100% { opacity: .7; transform: translate(-50%, -50%) scale(1); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .fcard, .hero-stage .glow { animation: none; } }
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-stage { height: 150px; margin-top: 10px; }
  .fcard { width: 84px !important; height: 92px !important; border-radius: 18px; gap: 8px; }
  .fcard i { width: 40px; height: 40px; font-size: 1.1rem; border-radius: 11px; }
  .fcard b { font-size: .72rem; }
  .fcard.f1 { left: 0%; top: 18%; } .fcard.f2 { left: 18%; top: 4%; } .fcard.f3 { left: 36%; top: 22%; }
  .fcard.f4 { left: 54%; top: 4%; } .fcard.f5 { left: 72%; top: 20%; } .fcard.f6 { display: none; }
}

/* Home blocks */
.home-block { margin: 40px 0 8px; }
.all-title { font-size: 1.6rem; text-align: center; margin: 48px 0 0; }
.cat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.cat-tile { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); font-weight: 700; position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.cat-tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c); }
.cat-tile i { color: var(--c); font-size: 1.3rem; margin-bottom: 4px; }
.cat-tile small { color: var(--muted); font-weight: 500; }
.cat-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 18px 0 8px; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 15px; border-radius: 999px; cursor: pointer; font: inherit; font-size: .9rem; font-weight: 600; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.cat-section { margin: 36px 0; }
.cat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cat-head h2 { font-size: 1.35rem; margin: 0 0 14px; }
.cat-head h2 i { color: var(--c, var(--primary)); margin-right: 6px; }
.cat-head a { text-decoration: none; font-weight: 700; }
.no-results { text-align: center; color: var(--muted); margin: 32px 0; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card { display: block; position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s, box-shadow .15s; }
.card:hover { border-color: var(--c, var(--primary)); transform: translateY(-3px); box-shadow: var(--shadow); }
.card i { font-size: 1.25rem; color: var(--c, var(--primary)); background: color-mix(in srgb, var(--c, var(--primary)) 13%, transparent); width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 12px; }
.card h3 { margin: 0 0 4px; font-size: 1.02rem; }
.card p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.card-sm { padding: 14px; display: flex; align-items: center; gap: 12px; }
.card-sm i { width: 36px; height: 36px; font-size: 1rem; margin: 0; flex: none; }
.card-sm h3 { margin: 0; font-size: .95rem; }
.card-sm p { display: none; }

/* Pages */
.page, .tool-page { padding-top: 22px; padding-bottom: 48px; }
.crumbs { font-size: .88rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--primary); }
h1 { font-size: clamp(1.7rem, 4vw, 2.35rem); line-height: 1.2; margin: 8px 0 8px; }
h1 i { color: var(--c, var(--primary)); }
.lead { color: var(--muted); font-size: 1.06rem; margin: 0 0 22px; max-width: 760px; }
.tool-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 4px; }
.tool-head h1 { margin: 2px 0 6px; }
.tool-head .lead { margin-bottom: 18px; }
.tool-icon { flex: none; width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; font-size: 1.6rem; color: #fff; background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 60%, #000)); box-shadow: 0 10px 24px -8px var(--c); margin-top: 6px; }
.tag { display: inline-block; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--c); text-decoration: none; }
@media (max-width: 520px) { .tool-icon { width: 46px; height: 46px; font-size: 1.2rem; border-radius: 14px; } }

/* Tool box & form controls */
.tool-box { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 26px; box-shadow: var(--shadow-lg); overflow: hidden; }
.tool-box::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: linear-gradient(90deg, var(--c, var(--primary)), var(--accent)); }
@media (max-width: 520px) { .tool-box { padding: 18px 14px; } }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.row .field { margin-bottom: 0; }
label, .label { font-weight: 600; font-size: .92rem; }
input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="email"],
input[type="url"], input[type="password"], input[type="search"]:not(#tool-search), select, textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--bg);
  color: var(--text); font: inherit; font-size: 1rem; transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px var(--primary-soft); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
textarea { min-height: 150px; resize: vertical; line-height: 1.5; }
.mono, textarea.mono { font-family: var(--mono); font-size: .92rem; }
input[type="range"] { width: 100%; accent-color: var(--primary); }
input[type="color"] { width: 100%; height: 48px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--bg); padding: 4px; cursor: pointer; }
input[type="file"] { width: 100%; padding: 18px; border: 2px dashed color-mix(in srgb, var(--primary) 40%, var(--border)); border-radius: 14px; background: var(--primary-soft); color: var(--text); cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; margin: 0 16px 8px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; text-decoration: none; transition: border-color .15s, background .15s, transform .1s; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px -6px var(--primary); }
.btn-primary:hover { color: #fff; filter: brightness(1.06); border-color: transparent; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.result { position: relative; background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft)); border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent); border-radius: 16px; padding: 18px 20px; margin-top: 8px; }
.result-main { font-size: clamp(1.6rem, 5vw, 2.3rem); font-weight: 800; color: var(--primary-hover); line-height: 1.2; word-break: break-word; }
:root[data-theme="dark"] .result-main, :root[data-theme="dark"] .big-display { color: var(--primary); }
.result-sub { color: var(--muted); margin-top: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c, var(--primary)); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 1.3rem; color: var(--text); word-break: break-word; }
.stat span { font-size: .84rem; color: var(--muted); }
.note { font-size: .88rem; color: var(--muted); margin: 8px 0 0; }
.msg-good { color: var(--good); font-weight: 600; }
.msg-bad { color: var(--bad); font-weight: 600; }
.msg-warn { color: var(--warn); font-weight: 600; }
.preview { border: 1px solid var(--border); border-radius: 14px; background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 20px 20px; display: grid; place-items: center; min-height: 160px; padding: 12px; overflow: auto; }
.preview img, .preview canvas { max-height: 420px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.swatch { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); cursor: pointer; text-align: center; font-family: var(--mono); font-size: .85rem; }
.swatch div { height: 70px; }
.swatch span { display: block; padding: 6px; }
.out-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; font-family: var(--mono); font-size: .9rem; white-space: pre-wrap; word-break: break-word; min-height: 52px; }
.big-display { font-family: var(--mono); font-size: clamp(2.4rem, 11vw, 4.5rem); font-weight: 700; text-align: center; letter-spacing: 1px; margin: 10px 0; color: var(--primary-hover); }
.meter { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.meter div { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .2s, background .2s; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { border-bottom: 1px solid var(--border); padding: 9px 10px; text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; }
.diff-add { background: rgba(16, 185, 129, .18); }
.diff-del { background: rgba(239, 68, 68, .18); text-decoration: line-through; }
mark { background: #fde68a; color: #0f1f24; border-radius: 3px; }

/* Article content */
.content { max-width: 840px; margin-top: 40px; }
.content h2 { font-size: 1.45rem; margin: 34px 0 10px; padding-left: 12px; border-left: 4px solid var(--accent); }
.content h3 { font-size: 1.08rem; margin: 22px 0 6px; }
.content code { font-family: var(--mono); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.content .formula { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 12px; padding: 12px 16px; font-family: var(--mono); overflow-x: auto; }
.content table { margin: 12px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.content .note { border-top: 1px dashed var(--border); padding-top: 10px; margin-top: 24px; }
.home-content { margin: 56px auto 24px; }
.page.content { margin-top: 0; }

.related { margin-top: 44px; }
.related h2 { font-size: 1.3rem; }

.sitemap-cols { columns: 3 260px; column-gap: 32px; }
.sitemap-cols section { break-inside: avoid; margin-bottom: 24px; }
.sitemap-cols h2 { font-size: 1.1rem; margin: 0 0 8px; }
.sitemap-cols h2 a { color: var(--text); }
.sitemap-cols ul { margin: 0; padding-left: 18px; }
.inline-list { display: flex; flex-wrap: wrap; gap: 8px 20px; padding-left: 18px; }

/* Contact page */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 14px; margin: 10px 0 24px; }
.contact-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.contact-card i { font-size: 1.3rem; color: var(--primary); background: var(--primary-soft); width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 10px; }
.contact-card h3 { margin: 0 0 4px; }
.contact-card p { margin: 0; color: var(--muted); font-size: .95rem; overflow-wrap: break-word; }
.contact-card a { font-size: .9rem; }

/* Footer */
.site-footer { background: #030716; color: #a3aecb; margin-top: 48px; padding: 48px 0 20px; border-top: 4px solid var(--accent); }
.site-footer a { color: #d6ebe8; text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1.6fr 1fr; gap: 32px; }
.footer-grid h2 { color: #fff; font-size: 1rem; margin: 0 0 12px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin-bottom: 7px; }
.footer-grid div:nth-child(2) ul { columns: 2 150px; }
.brand-footer { color: #fff !important; text-decoration: none !important; margin-bottom: 10px; }
.brand-footer b { color: #22d3ee; }
.footer-bottom { border-top: 1px solid #1d3533; margin-top: 28px; padding-top: 16px; font-size: .9rem; text-align: center; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr; } }
