:root {
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-highlight: rgba(255, 255, 255, 0.9);
  --text-primary: rgba(28, 28, 32, 0.92);
  --text-secondary: rgba(28, 28, 32, 0.45);
  --text-tertiary: rgba(28, 28, 32, 0.32);
  --accent-orange: #ff9f0a;
  --accent-orange-dark: #d97e00;
  --shadow-color: rgba(60, 60, 90, 0.14);
  --divider: rgba(28, 28, 32, 0.08);
  --danger: #ff453a;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: var(--text-primary);
  background: radial-gradient(ellipse at 20% 15%, #e6dcff 0%, transparent 55%),
              radial-gradient(ellipse at 85% 80%, #dceefc 0%, transparent 55%),
              radial-gradient(ellipse at 50% 100%, #ffe3ee 0%, transparent 60%),
              linear-gradient(160deg, #f7f8fb 0%, #eef0f5 100%);
  background-color: #f2f3f7;
  min-height: 100vh;
  position: relative;
}

body[data-theme="dark"] {
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-bg-strong: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-highlight: rgba(255, 255, 255, 0.25);
  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.5);
  --text-tertiary: rgba(255, 255, 255, 0.34);
  --shadow-color: rgba(0, 0, 0, 0.6);
  --divider: rgba(255, 255, 255, 0.1);
  background: radial-gradient(ellipse at 20% 15%, #3a2a55 0%, transparent 55%),
              radial-gradient(ellipse at 85% 80%, #1a3a5c 0%, transparent 55%),
              radial-gradient(ellipse at 50% 100%, #4a1f3d 0%, transparent 60%),
              linear-gradient(160deg, #0a0a12 0%, #14141f 100%);
  background-color: #0a0a12;
}

a { color: inherit; text-decoration: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---- ambient orbs ---- */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.4;
  pointer-events: none;
  animation: float 18s ease-in-out infinite;
  z-index: 0;
}
.orb-1 { width: 380px; height: 380px; background: radial-gradient(circle, #c9b6ff, transparent 70%); top: -120px; left: -100px; }
.orb-2 { width: 320px; height: 320px; background: radial-gradient(circle, #ffc2d9, transparent 70%); bottom: -100px; right: -80px; animation-delay: 6s; }
.orb-3 { width: 260px; height: 260px; background: radial-gradient(circle, #aee0ff, transparent 70%); bottom: 20%; left: -60px; animation-delay: 12s; }

body[data-theme="dark"] .orb-1 { background: radial-gradient(circle, #7c4dff, transparent 70%); }
body[data-theme="dark"] .orb-2 { background: radial-gradient(circle, #ff6b9d, transparent 70%); }
body[data-theme="dark"] .orb-3 { background: radial-gradient(circle, #0abfff, transparent 70%); }
body[data-theme="dark"] .orb { opacity: 0.5; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.08); }
  66% { transform: translate(-20px, 25px) scale(0.95); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- glass helpers ---- */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 20px 50px -24px var(--shadow-color);
}

/* ---- navbar ---- */
.navbar {
  position: sticky;
  top: 16px;
  z-index: 30;
  margin: 16px auto 0;
  max-width: 1180px;
  width: calc(100% - 32px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-radius: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.2px;
}

.brand .brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(160deg, var(--accent-orange) 0%, var(--accent-orange-dark) 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
}
.brand .brand-mark svg { width: 15px; height: 15px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: 12px;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-links a:hover { color: var(--text-primary); background: rgba(127,127,127,0.1); }
.nav-links a.active { color: var(--text-primary); background: rgba(127,127,127,0.14); }

.nav-right { display: flex; align-items: center; gap: 10px; }

.nav-toggle {
  display: none;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  align-items: center; justify-content: center;
  cursor: pointer;
}
.nav-toggle svg { width: 18px; height: 18px; color: var(--text-primary); }

/* ---- theme toggle (reused, inline in nav) ---- */
.theme-toggle {
  width: 52px; height: 30px;
  border-radius: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 8px 20px -10px var(--shadow-color);
  cursor: pointer;
  padding: 3px;
  flex-shrink: 0;
  transition: background 0.3s ease;
}
.theme-toggle .knob {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(160deg, #ffffff 0%, #e4e6ec 100%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
  transform: translateX(0);
  transition: transform 0.32s cubic-bezier(0.34,1.3,0.64,1), background 0.3s ease;
}
body[data-theme="dark"] .theme-toggle .knob {
  transform: translateX(22px);
  background: linear-gradient(160deg, #3a3a44 0%, #1e1e26 100%);
}
.theme-toggle .knob svg { width: 13px; height: 13px; }
.theme-toggle .icon-sun { color: #ff9f0a; }
.theme-toggle .icon-moon { color: #cbd0ff; display: none; }
body[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
body[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---- page shell ---- */
.page {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 16px 0;
}

/* ---- tools layout ---- */
.tools-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-top: 22px;
}

.tool-sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 96px;
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  cursor: pointer;
  animation: rise 0.5s cubic-bezier(0.16,1,0.3,1) both;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tool-card:hover { transform: translateY(-1px); }
.tool-card.active {
  border-color: rgba(255, 159, 10, 0.55);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 12px 30px -16px rgba(255,159,10,0.35), 0 0 0 1.5px rgba(255,159,10,0.4);
}

.tool-card .icon {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--accent-orange) 0%, var(--accent-orange-dark) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}
.tool-card .icon svg { width: 20px; height: 20px; color: #fff; }

.tool-card .label { display: flex; flex-direction: column; gap: 2px; }
.tool-card .label .title { font-size: 14.5px; font-weight: 600; }
.tool-card .label .desc { font-size: 12px; color: var(--text-secondary); }

.tool-main { flex: 1; min-width: 0; }

.tool-panel {
  display: none;
  border-radius: 28px;
  padding: 28px;
  animation: rise 0.4s cubic-bezier(0.16,1,0.3,1) both;
}
.tool-panel.active { display: block; }

.tool-panel h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}
.tool-panel .tool-sub {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 22px;
}

/* ---- form elements (shared across tools) ---- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.input, select.input {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(127,127,127,0.06);
  outline: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus {
  border-color: rgba(255, 159, 10, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 159, 10, 0.15);
}
select.input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23999' stroke-width='2'><path d='M6 8l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  padding: 13px 22px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  background: linear-gradient(160deg, var(--accent-orange) 0%, var(--accent-orange-dark) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 10px 24px -10px rgba(255,159,10,0.5);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn-primary:active { transform: scale(0.97); filter: brightness(1.1); }

.swap-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-end;
  margin-bottom: 14px;
  transition: transform 0.2s ease;
}
.swap-btn svg { width: 17px; height: 17px; color: var(--text-primary); }
.swap-btn:active { transform: rotate(180deg); }

.result-box {
  margin-top: 18px;
  padding: 20px;
  border-radius: 18px;
  background: rgba(255, 159, 10, 0.08);
  border: 1px solid rgba(255, 159, 10, 0.25);
}
.result-box .result-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.result-box .result-value {
  font-size: 32px;
  font-weight: 300;
  letter-spacing: -0.5px;
}
.result-box .result-note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--divider);
}

.hint { font-size: 12.5px; color: var(--text-tertiary); margin-top: 10px; }
.error-text { font-size: 13px; color: var(--danger); margin-top: 8px; display: none; }
.error-text.show { display: block; }

/* ---- basic calculator (reused visual) ---- */
.calculator { width: 100%; max-width: 340px; margin: 0 auto; }
.display { padding: 14px 8px 14px; text-align: right; min-height: 92px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; }
.display .expression { font-size: 15px; color: var(--text-secondary); min-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.display .result { font-size: 52px; font-weight: 300; letter-spacing: -1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: font-size 0.15s ease; }
.display .result.is-error { color: var(--danger); animation: shake 0.35s ease; }
@keyframes shake { 0%,100% { transform: translateX(0);} 25% { transform: translateX(-6px);} 75% { transform: translateX(6px);} }

.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 8px; }
.calc-keys button {
  border: none; outline: none; font-family: inherit;
  aspect-ratio: 1; border-radius: 50%;
  font-size: 22px; font-weight: 400; color: var(--text-primary);
  cursor: pointer; background: var(--glass-bg); border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 2px 8px -4px rgba(60,60,90,0.1);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.calc-keys button:active { transform: scale(0.92); filter: brightness(1.3); }
.calc-keys .btn-fn { background: rgba(0,0,0,0.055); font-weight: 500; font-size: 19px; }
body[data-theme="dark"] .calc-keys .btn-fn { background: rgba(255,255,255,0.14); }
.calc-keys .btn-op {
  background: linear-gradient(160deg, var(--accent-orange) 0%, var(--accent-orange-dark) 100%);
  color: #fff; font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 4px 14px -4px rgba(255,159,10,0.5);
}
.calc-keys .btn-op.active { background: #fff; color: var(--accent-orange-dark); }
.calc-keys .btn-zero { grid-column: span 2; aspect-ratio: auto; border-radius: 40px; justify-self: stretch; text-align: left; padding-left: 26px; }

/* ---- footer ---- */
.site-footer {
  position: relative;
  z-index: 1;
  margin-top: 60px;
  padding: 40px 16px 28px;
  border-top: 1px solid var(--divider);
}
.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 36px;
  justify-content: space-between;
}
.footer-col { min-width: 160px; }
.footer-col h4 {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.footer-col a, .footer-col p {
  display: block;
  font-size: 14px;
  color: var(--text-primary);
  opacity: 0.85;
  margin-bottom: 9px;
}
.footer-col a:hover { opacity: 1; text-decoration: underline; }
.footer-bottom {
  max-width: 1180px;
  margin: 28px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--divider);
  font-size: 12.5px;
  color: var(--text-tertiary);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---- simple content page (about/contacts/legal) ---- */
.content-card {
  border-radius: 28px;
  padding: 36px;
  margin-top: 22px;
  max-width: 780px;
}
.content-card h1 { font-size: 28px; font-weight: 650; letter-spacing: -0.4px; margin-bottom: 14px; }
.content-card h2 { font-size: 18px; font-weight: 650; margin: 24px 0 10px; }
.content-card p { font-size: 15px; line-height: 1.65; color: var(--text-primary); opacity: 0.9; margin-bottom: 12px; }
.content-card ul { margin: 0 0 14px 20px; }
.content-card li { font-size: 15px; line-height: 1.65; opacity: 0.9; margin-bottom: 6px; }

.contact-list { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.contact-item { display: flex; align-items: center; gap: 12px; }
.contact-item .icon {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(160deg, var(--accent-orange) 0%, var(--accent-orange-dark) 100%);
  display: flex; align-items: center; justify-content: center;
}
.contact-item .icon svg { width: 18px; height: 18px; color: #fff; }
.contact-item a, .contact-item span { font-size: 15px; }

/* ---- responsive ---- */
@media (max-width: 860px) {
  .tools-layout { flex-direction: column; }
  .tool-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    position: static;
    padding-bottom: 4px;
  }
  .tool-card { flex-shrink: 0; min-width: 220px; }
  .nav-links {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    border-radius: 18px;
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 20px 50px -24px var(--shadow-color);
  }
  .nav-links.mobile-open { display: flex; }
  .nav-links a { width: 100%; }
  .nav-toggle { display: flex; }
  .navbar { position: relative; }
}

@media (max-width: 480px) {
  .field-row { flex-direction: column; gap: 0; }
  .content-card { padding: 24px; }
}
