/* Funkcia v6.1 - Ported from working standalone examples */
/* Fonts loaded via <link> in HTML, NOT @import */

:root {
  --bg:        #0C0B09;
  --bg2:       #131210;
  --surface:   #1A1816;
  --surface2:  #22201D;
  --surface3:  #2B2925;
  --border:    #2E2C27;
  --border2:   #3A3732;
  --border3:   #47443E;
  --text:      #EDE9E2;
  --text2:     #BFB9AE;
  --text3:     #8A8479;
  --text4:     #5E5950;
  --accent:    #E2A336;
  --accent2:   #F0C06A;
  --accent-dim:#C48A1F;
  --accent-bg: rgba(226,163,54,0.06);
  --accent-bg2:rgba(226,163,54,0.12);
  --accent-border:rgba(226,163,54,0.22);
  --green:     #6CD4A0;
  --green-bg:  rgba(108,212,160,0.06);
  --green-border:rgba(108,212,160,0.16);
  --blue:      #7EB0E2;
  --blue-bg:   rgba(126,176,226,0.06);
  --blue-border:rgba(126,176,226,0.16);
  --rose:      #E88B8B;
  --rose-bg:   rgba(232,139,139,0.06);
  --rose-border:rgba(232,139,139,0.18);
  --red:       #E87070;
  --red-bg:    rgba(232,112,112,0.06);
  --red-border:rgba(232,112,112,0.18);
  --lav:       #B09BE0;
  --lav-bg:    rgba(176,155,224,0.06);
  --lav-border:rgba(176,155,224,0.15);
  --r:    12px;
  --r-lg: 16px;
  --r-sm: 8px;
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-d: 'Bricolage Grotesque', Georgia, serif;
  --font-m: 'JetBrains Mono', monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior:smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--accent-bg2); color: var(--accent2); }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== NAV ===== */
nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(12,11,9,0.85);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid rgba(46,44,39,0.5);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1200px; margin: 0 auto;
  padding: 0 32px; height: 56px;
}
.logo {
  font-family: var(--font-d);
  font-size: 20px; font-weight: 700;
  text-decoration: none; color: var(--text);
  letter-spacing: -0.3px; flex-shrink: 0;
}
.logo:hover { opacity: 0.8; }
.logo span, .logo em { font-style: normal; color: var(--accent); }
.nav-links { display: flex; gap: 2px; list-style: none; }
.nav-links a {
  color: var(--text4); text-decoration: none;
  font-size: 12px; font-weight: 500;
  padding: 5px 10px; border-radius: 6px;
  transition: all 0.15s var(--ease);
}
.nav-links a:hover { color: var(--text2); background: var(--surface2); }
.nav-right { display: flex; align-items: center; gap: 6px; }
.theme-toggle {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 8px;
  cursor: pointer; color: var(--text3);
  font-size: 13px; line-height: 1;
  transition: all 0.15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border2); background: var(--surface2); }

/* Hamburger */
.hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 4px; color: var(--text2);
}
.hamburger svg {
  width: 20px; height: 20px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round;
}
.mobile-menu {
  display: none;
  position: fixed; top: 56px; left: 0; right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px; z-index: 99;
  flex-direction: column; gap: 2px;
}
.mobile-menu.open { display: flex; }
.mobile-menu a {
  display: block; padding: 10px 12px;
  color: var(--text2); text-decoration: none;
  font-size: 14px; font-weight: 500;
  border-radius: var(--r-sm);
  transition: all 0.15s;
}
.mobile-menu a:hover { color: var(--text); background: var(--surface2); }
@media(max-width:800px) {
  .nav-inner { padding: 0 16px; height: 50px; }
  .nav-links { display: none; }
  .hamburger { display: block; }
}

/* ===== HOMEPAGE ===== */
.home-header {
  max-width: 1200px; margin: 0 auto;
  padding: 28px 32px 0;
  display: flex; align-items: flex-end;
  justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
}
.home-header h1 {
  font-family: var(--font-d);
  font-size: 28px; font-weight: 800;
  letter-spacing: -0.8px; line-height: 1.1;
  margin-bottom: 4px;
}
.home-header h1 .hl {
  background: linear-gradient(135deg, var(--accent) 20%, var(--accent2) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.home-header p { color: var(--text4); font-size: 13px; }
.search-box { position: relative; width: 340px; flex-shrink: 0; }
.search-box input {
  width: 100%;
  padding: 11px 16px 11px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: all 0.25s var(--ease);
}
.search-box input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-bg), 0 4px 24px rgba(0,0,0,0.3);
  background: var(--surface2);
}
.search-box input::placeholder { color: var(--text4); }
.search-icon {
  position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text4); pointer-events: none;
}
.search-meta {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  display: flex; align-items: center; gap: 6px;
}
.search-count {
  font-family: var(--font-m);
  font-size: 10px; color: var(--text4);
  opacity: 0; transition: opacity 0.2s;
}
.search-count.on { opacity: 1; }
.search-kbd {
  font-family: var(--font-m);
  font-size: 10px; color: var(--text4);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 4px;
}
@media(max-width:640px) {
  .home-header { padding: 20px 16px 0; flex-direction: column; align-items: stretch; }
  .home-header h1 { font-size: 22px; }
  .search-box { width: 100%; }
}

/* Chips */
.chips {
  max-width: 1200px; margin: 0 auto;
  padding: 20px 32px 4px;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.chip {
  padding: 5px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--text3);
  font-family: var(--font);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
}
.chip:hover { color: var(--text2); border-color: var(--border2); background: var(--surface); }
.chip.active { color: var(--accent2); border-color: var(--accent-border); background: var(--accent-bg); font-weight: 600; }
.chip .cc { font-family: var(--font-m); font-size: 10px; margin-left: 4px; opacity: 0.5; }
@media(max-width:640px) { .chips { padding: 16px 16px 4px; } }

/* Category sections */
.category-section {
  max-width: 1200px; margin: 0 auto;
  padding: 0 32px 28px;
}
@media(max-width:640px) { .category-section { padding: 0 16px 20px; } }
.cat-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; padding-top: 8px;
}
.cat-head h2 {
  font-family: var(--font-d);
  font-size: 16px; font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text2);
}
.cat-head .cnt {
  font-family: var(--font-m);
  font-size: 10px; font-weight: 500;
  color: var(--text4);
  padding: 2px 8px;
  background: var(--surface);
  border-radius: 100px;
}
.cat-line {
  height: 1px;
  background: linear-gradient(90deg, var(--border2) 0%, transparent 80%);
  margin-bottom: 14px;
}

/* Homepage card grid */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
@media(max-width:1080px) { .calc-grid { grid-template-columns: repeat(3, 1fr); } }
@media(max-width:760px)  { .calc-grid { grid-template-columns: repeat(2, 1fr); } }
@media(max-width:480px)  { .calc-grid { grid-template-columns: 1fr; gap: 6px; } }

.calc-link {
  display: block;
  text-decoration: none;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--r);
  transition: all 0.2s var(--ease);
  position: relative;
  overflow: hidden;
}
.calc-link::before {
  content: '';
  position: absolute; left: 0; top: 0;
  width: 2px; height: 100%;
  background: var(--accent);
  opacity: 0; transition: opacity 0.15s;
  border-radius: 2px 0 0 2px;
}
.calc-link:hover {
  border-color: var(--border);
  background: var(--surface2);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.calc-link:hover::before { opacity: 1; }
.calc-link h3 {
  font-size: 13px; font-weight: 600;
  color: var(--text); line-height: 1.3;
  margin-bottom: 2px;
}
.calc-link p {
  font-size: 11px; color: var(--text4);
  line-height: 1.4; margin: 0;
}

/* Empty state */
.empty-state {
  display: none; text-align: center;
  padding: 48px 20px; color: var(--text4);
  font-size: 14px; max-width: 1200px; margin: 0 auto;
}
.empty-state.show { display: block; }
.empty-state span { display: block; font-size: 28px; margin-bottom: 8px; opacity: 0.3; }

/* ===== CALC PAGE LAYOUT ===== */
.page {
  max-width: 1200px; margin: 0 auto;
  padding: 24px 32px 80px;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 28px; align-items: start;
}
@media(max-width:960px) { .page { grid-template-columns: 1fr; padding: 16px 16px 60px; gap: 24px; } }

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text4);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--text3); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--text4); font-size: 10px; }
h1 {
  font-family: var(--font-d);
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.6px; line-height: 1.15;
  margin-bottom: 4px;
}
.subtitle { color: var(--text3); font-size: 13px; margin-bottom: 20px; }

/* ===== CALCULATOR CARD ===== */
.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
}
.calc-card h2 {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text4);
  padding: 20px 24px 0;
}

/* Mode selector - segmented bar */
.mode-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  margin: 12px 24px 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.mode-btn {
  padding: 12px 8px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text4);
  font-family: var(--font);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  text-align: center;
  position: relative;
}
.mode-btn:last-child { border-right: none; }
.mode-btn:hover { color: var(--text2); background: var(--surface2); }
.mode-btn.active,
.mode-btn[aria-pressed="true"] {
  color: var(--accent2);
  background: var(--accent-bg);
  font-weight: 600;
}
.mode-btn.active::after,
.mode-btn[aria-pressed="true"]::after {
  content: '';
  position: absolute; bottom: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

/* Formula bar */
.formula-bar {
  padding: 8px 24px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-m);
  font-size: 12px; color: var(--text3);
  display: flex; align-items: center;
  min-height: 34px; margin-top: 12px;
}
.formula-bar .fb-label {
  font-family: var(--font);
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  margin-right: 8px; opacity: 0.5;
}

/* Inputs */
.calc-body { padding: 20px 24px 24px; }
.input-group { margin-bottom: 12px; animation: fadeIn 0.15s var(--ease); }
.input-group label {
  display: block;
  font-size: 11px; font-weight: 600;
  color: var(--text3); margin-bottom: 5px;
  letter-spacing: 0.2px; text-transform: uppercase;
}
.input-row {
  display: flex;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-row:focus-within {
  border-color: rgba(226,163,54,0.3);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.input-row input {
  flex: 1;
  padding: 11px 14px;
  background: var(--bg2);
  border: none;
  color: var(--text);
  font-family: var(--font-m);
  font-size: 15px;
  outline: none;
  min-width: 0;
}
.input-row input:focus { background: var(--surface); }
.input-row input::placeholder { color: var(--text4); font-size: 13px; }
.input-row input.invalid { background: var(--red-bg); }
.unit {
  display: flex; align-items: center; justify-content: center;
  padding: 0 12px; min-width: 44px;
  background: var(--surface2);
  border-left: 1px solid var(--border);
  font-family: var(--font-m);
  font-size: 12px; font-weight: 500;
  color: var(--text4);
  white-space: nowrap; user-select: none;
}
.input-error {
  font-size: 10px; color: var(--red);
  margin-top: 3px; display: none;
}
.input-error.show { display: block; }

/* Result */
.result-box {
  margin-top: 20px;
  padding: 20px 24px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--r);
  position: relative; overflow: hidden;
  display: flex; justify-content: space-between;
  align-items: flex-end; gap: 12px;
}
.result-box::before {
  content: '';
  position: absolute; left: 0; top: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dim) 100%);
  border-radius: 2px 0 0 2px;
}
.result-main { flex: 1; }
.result-label {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text4); margin-bottom: 6px;
}
.result-value {
  font-family: var(--font-m);
  font-size: 32px; font-weight: 600;
  color: var(--accent2);
  line-height: 1.2; transition: all 0.15s;
}
.result-unit {
  font-size: 14px; font-weight: 500;
  color: var(--text3); margin-left: 6px;
}
.result-note { font-size: 11px; color: var(--text3); margin-top: 4px; }
.copy-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 12px;
  cursor: pointer; color: var(--text3);
  font-family: var(--font);
  font-size: 11px; font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap; flex-shrink: 0;
}
.copy-btn:hover { color: var(--text); border-color: var(--border2); background: var(--surface3); }
.copy-btn.copied { color: var(--green); border-color: var(--green-border); }
.reset-btn {
  margin-top: 14px;
  padding: 7px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text3);
  font-family: var(--font);
  font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.reset-btn:hover { border-color: var(--border2); color: var(--text2); background: var(--surface2); }

/* Calc actions row */
.calc-actions {
  display: flex; align-items: center; gap: 8px;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.calc-hints {
  margin-left: auto;
  font-size: 10px; color: var(--text4);
  display: flex; gap: 8px;
}
.calc-hints kbd {
  font-family: var(--font-m); font-size: 9px;
  padding: 1px 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px; color: var(--text3);
}
@media(max-width:600px) { .calc-hints { display: none; } }

/* Quick-ref sidebar card */
.quick-ref {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
}
.quick-ref h3 {
  font-family: var(--font-d);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text4); margin-bottom: 12px;
}
.quick-ref code {
  display: block; text-align: center;
  font-family: var(--font-m);
  font-size: 15px; font-weight: 500;
  color: var(--accent2);
  padding: 12px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-sm);
  letter-spacing: 0.3px;
  margin-bottom: 10px;
}
.quick-ref p {
  font-size: 12px; color: var(--text3);
  line-height: 1.6; margin-bottom: 4px;
}
.quick-ref .ref-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(46,44,39,0.3);
  font-size: 12px;
}
.quick-ref .ref-row:last-child { border-bottom: none; }
.quick-ref .ref-var {
  font-family: var(--font-m); font-weight: 600;
  color: var(--text);
}
.quick-ref .ref-unit {
  font-family: var(--font-m); color: var(--text4);
  font-size: 11px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity:0; transform:translateY(4px); }
  to   { opacity:1; transform:translateY(0); }
}
@keyframes flash {
  0%   { opacity:0.5; transform:scale(0.98); }
  100% { opacity:1; transform:scale(1); }
}
.result-value.flash { animation: flash 0.2s var(--ease); }
@keyframes rise {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:translateY(0); }
}
.home-header { animation: rise 0.4s 0.05s var(--ease) both; }
.chips       { animation: rise 0.4s 0.1s var(--ease) both; }

/* ===== FORMULAS ===== */
.formula-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px; margin-bottom: 10px;
}
.formula-card code {
  display: block; text-align: center;
  font-family: var(--font-m);
  font-size: 16px; font-weight: 500;
  color: var(--green);
  padding: 12px;
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  border-radius: var(--r-sm);
  letter-spacing: 0.3px;
}
.formula-card p { color: var(--text3); font-size: 12px; margin-top: 8px; line-height: 1.65; }

/* Content */
.content-section { margin-bottom: 20px; }
.content-section h2 { font-family: var(--font-d); font-size: 18px; font-weight: 700; letter-spacing: -0.2px; margin-bottom: 10px; }
.content-section h3 { font-size: 13px; font-weight: 700; margin-top: 16px; margin-bottom: 4px; }
.content-section p { color: var(--text2); font-size: 13px; margin-bottom: 8px; line-height: 1.75; }

/* Sidebar */
.sidebar { display: flex; flex-direction: column; gap: 14px; }
.related-tools {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.related-tools h3 {
  font-family: var(--font-d);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text4); margin-bottom: 8px;
}
.related-tools a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  color: var(--text3); text-decoration: none;
  font-size: 12px; font-weight: 500;
  border-radius: 6px; transition: all 0.15s;
}
.related-tools a:hover { background: var(--surface2); color: var(--text); }
.related-tools a span { font-size: 10px; color: var(--accent); opacity: 0.4; transition: opacity 0.15s; }
.related-tools a:hover span { opacity: 1; }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 24px 32px; text-align: center;
  color: var(--text4); font-size: 11px;
  max-width: 1200px; margin: 0 auto;
}
footer a { color: var(--text3); text-decoration: none; }
footer a:hover { color: var(--accent); }

/* Ambient glow */
body::before {
  content: '';
  position: fixed; top: -120px; left: 50%;
  transform: translateX(-50%);
  width: 600px; height: 400px;
  background: radial-gradient(ellipse, rgba(226,163,54,0.03) 0%, transparent 65%);
  pointer-events: none; z-index: -1;
}

/* Mobile calc adjustments */
@media(max-width:600px) {
  h1 { font-size: 22px; }
  .calc-card h2 { padding: 14px 16px 0; }
  .mode-selector { padding: 10px 16px 0; }
  .formula-bar { padding: 8px 16px; }
  .calc-body { padding: 16px; }
  .result-value { font-size: 24px; }
  .category-section { padding: 0 16px 16px; }
  footer { padding: 20px 16px; }
}
