:root {
  --bg: #0b0b14;
  --bg-alt: #12121f;
  --panel: #16162a;
  --panel-2: #1c1c34;
  --border: rgba(255,255,255,.08);
  --text: #f2f2fa;
  --text-dim: #9797b8;
  --text-faint: #6b6b8a;
  --blue: #4f8ef7;
  --cyan: #38bdf8;
  --purple: #a855f7;
  --pink: #ec4899;
  --orange: #f59e0b;
  --green: #00e676;
  --red: #ff5252;
  --radius: 16px;
  --radius-sm: 10px;
  --max: 1080px;
  --rail-w: 150px;
  --rail-gap: 24px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

img.chip-ico { width: 1em; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 100%);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.brand-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.5px;
}
.logo span { color: var(--blue); }

.chip-clima {
  font-size: 11px;
  padding: 3px 8px;
}

.main-nav { display: flex; gap: 22px; flex-wrap: wrap; }
.main-nav a {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 600;
  transition: color .15s;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
.main-nav a:hover { color: var(--text); }
.main-nav a.active { color: var(--text); border-bottom-color: var(--blue); }

.ad-banner-mount {
  display: none;
  max-width: 728px;
  margin: 0 auto;
  padding: 0 20px;
}
.ad-banner-mount.has-ad { display: block; padding: 8px 20px; }

.ticker-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 20px;
  border-top: 1px solid var(--border);
  overflow: hidden;
  font-size: 13px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 600;
}
.chip-val { color: var(--text); }
.chip .up { color: var(--green); }
.chip .down { color: var(--red); }

.ticker-wrap { flex: 1; min-width: 0; overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent); }
.ticker-track {
  display: flex;
  gap: 10px;
  width: max-content;
  animation: scroll-left 32s linear infinite;
}
.ticker-track:hover { animation-play-state: paused; }
@keyframes scroll-left {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Page shell + ad rails */
.page-shell { position: relative; max-width: var(--max); margin: 0 auto; padding: 0 20px; }

.ad-rail {
  display: none;
  position: fixed;
  top: 160px;
  width: var(--rail-w);
  max-height: 70vh;
  overflow: hidden;
  border-radius: var(--radius-sm);
}
.ad-rail-left { left: calc(50% - var(--max) / 2 - var(--rail-gap) - var(--rail-w)); }
.ad-rail-right { right: calc(50% - var(--max) / 2 - var(--rail-gap) - var(--rail-w)); }
.ad-rail.has-ad { display: block; }
@media (max-width: 1440px) {
  .ad-rail { display: none !important; }
}

.ad-link img { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); }
.ad-iframe { width: 100%; border: none; display: block; }
#ad-header_banner .ad-iframe { height: 90px; }
.ad-rail .ad-iframe { height: 600px; }

/* Hero */
.hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: 56px 20px 24px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(28px, 4vw, 42px);
  margin: 0 0 12px;
  letter-spacing: -.5px;
}
.hero p {
  color: var(--text-dim);
  max-width: 560px;
  margin: 0 auto;
  font-size: 16px;
}

/* Search */
.search-wrap { max-width: 480px; margin: 24px auto 0; }
.search-wrap input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 13px 18px;
  border-radius: 999px;
  font-size: 15px;
  font-family: inherit;
}
.search-wrap input:focus { outline: none; border-color: var(--blue); }
.search-wrap input::placeholder { color: var(--text-faint); }

/* Recently used */
.recent-section { max-width: var(--max); margin: 28px auto 0; padding: 0 20px; }
.section-title-sm { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-faint); margin: 0 0 10px; }
.recent-row { display: flex; gap: 10px; flex-wrap: wrap; }
.recent-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--text);
  transition: background .15s;
}
.recent-pill:hover { background: rgba(255,255,255,.1); }
.recent-icon { font-size: 15px; }

/* Category tabs */
.category-tabs {
  display: flex; gap: 8px; flex-wrap: wrap;
  max-width: var(--max); margin: 28px auto 0; padding: 0 20px;
}
.cat-tab {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.cat-tab:hover { background: rgba(255,255,255,.1); color: var(--text); }
.cat-tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Tool grid */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  max-width: var(--max);
  margin: 20px auto 0;
  padding: 0 20px 20px;
}
.grid-empty { color: var(--text-faint); text-align: center; padding: 40px 0; grid-column: 1 / -1; }

.tool-card {
  position: relative;
  background: linear-gradient(160deg, var(--panel), var(--bg-alt));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform .2s, border-color .2s;
}
.tool-card:hover { transform: translateY(-4px); border-color: rgba(255,255,255,.2); }
.tool-card-body { display: block; padding: 26px 20px; text-align: center; }
.tool-card .tc-icon { font-size: 32px; margin-bottom: 10px; }
.tool-card h3 { margin: 0 0 6px; font-size: 16px; }
.tool-card p { margin: 0; color: var(--text-dim); font-size: 13px; }

.fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  color: var(--text-faint);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
}
.fav-btn:hover { background: rgba(255,255,255,.14); color: var(--text); }
.fav-btn.active { color: #f5b400; border-color: #f5b400; }

/* Sections */
.tool-section {
  max-width: var(--max);
  margin: 0 auto;
  padding: 40px 0;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .5s ease, transform .5s ease;
}
.tool-section.visible { opacity: 1; transform: translateY(0); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.section-head h2 { font-size: 22px; margin: 0; }
.section-head h3 { font-size: 16px; margin: 0; color: var(--text-dim); }
.section-note { color: var(--text-faint); font-size: 12px; margin: 0 0 18px; }

.btn-ghost {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-ghost:hover { background: rgba(255,255,255,.12); color: var(--text); }

.card {
  background: linear-gradient(160deg, var(--panel), var(--bg-alt));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}

/* Converter */
.converter-card h3 { margin: 0 0 16px; font-size: 15px; color: var(--text-dim); font-weight: 600; }
.converter-row {
  display: grid;
  grid-template-columns: 1fr 1.3fr auto 1.3fr;
  gap: 10px;
  align-items: end;
}
.conv-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.conv-field label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-faint); }
.conv-field input, .conv-field select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  width: 100%;
}
.conv-field select { cursor: pointer; }
.btn-swap {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .2s;
}
.btn-swap:hover { transform: rotate(180deg); }
.conv-result {
  font-size: 28px;
  font-weight: 800;
  margin-top: 18px;
  color: var(--cyan);
}
.conv-rate { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* Grids */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.metals-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 10px; }

.crypto-card, .metal-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.crypto-card .cc-top { display: flex; justify-content: space-between; align-items: center; }
.crypto-card .cc-sym { font-weight: 800; font-size: 13px; letter-spacing: .3px; }
.crypto-card .cc-price { font-size: 18px; font-weight: 700; margin-top: 6px; }
.crypto-card .cc-pct { font-size: 12px; font-weight: 700; }
.up { color: var(--green); }
.down { color: var(--red); }

.skeleton {
  color: var(--text-faint);
  text-align: center;
  padding: 24px;
  font-size: 13px;
}

/* Speed test */
.speedtest-card { text-align: center; max-width: 480px; margin: 0 auto 18px; }
.spt-gauge { margin-bottom: 6px; }
.spt-number { font-size: 3rem; font-weight: 800; color: var(--blue); line-height: 1; }
.spt-unit { color: var(--text-faint); font-size: .85rem; margin-bottom: 10px; }
.spt-bar-bg { background: var(--panel-2); border-radius: 8px; height: 8px; overflow: hidden; margin-bottom: 20px; }
.spt-bar { height: 8px; width: 0%; border-radius: 8px; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width .3s; }
.spt-stats { display: flex; gap: 10px; margin-bottom: 18px; }
.spt-stat { background: var(--panel-2); border-radius: 10px; padding: 12px; flex: 1; }
.spt-stat-label { font-size: .65rem; color: var(--text-faint); text-transform: uppercase; margin-bottom: 4px; letter-spacing: .3px; }
.spt-stat-val { font-size: 1.1rem; font-weight: 700; }
.c-blue { color: var(--blue); }
.c-purple { color: var(--purple); }
.c-orange { color: var(--orange); }

.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff;
  border: none;
  padding: 13px 44px;
  border-radius: 50px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(79,142,247,.3);
  transition: transform .15s;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.spt-status { margin-top: 12px; font-size: .8rem; color: var(--text-faint); min-height: 18px; }

.history-card { max-width: 480px; margin: 0 auto; }
.table-wrap { overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table th, .history-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.history-table th { color: var(--text-faint); font-weight: 600; font-size: 11px; text-transform: uppercase; }

/* IP card */
.ip-card { max-width: 620px; margin: 0 auto; }
.ip-main { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.ip-flag { font-size: 26px; }
.ip-address { font-size: 22px; font-weight: 800; color: var(--blue); text-shadow: 0 0 16px rgba(79,142,247,.35); }
.btn-copy {
  margin-left: auto;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}
.btn-copy:hover { background: rgba(255,255,255,.12); color: var(--text); }
.ip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.ip-item { background: var(--panel-2); border-radius: var(--radius-sm); padding: 12px; }
.ip-label { font-size: 11px; text-transform: uppercase; color: var(--text-faint); margin-bottom: 4px; letter-spacing: .3px; }
.ip-value { font-weight: 700; font-size: 14px; }
.ip-status { margin-top: 14px; font-size: 12px; color: var(--text-faint); text-align: center; }

/* Breadcrumb */
.breadcrumb {
  font-size: 12px;
  color: var(--text-faint);
  max-width: var(--max);
  margin: 14px auto 0;
  padding: 0 20px;
}
.breadcrumb a { color: var(--text-dim); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { margin: 0 6px; }

/* Tool intro copy */
.tool-intro { color: var(--text-dim); font-size: 15px; max-width: 720px; margin: 6px 0 22px; }

/* FAQ */
.faq-section { margin-top: 12px; }
.faq-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
.faq-item:last-child { border-bottom: none; }
.faq-item h4 { margin: 0 0 6px; font-size: 15px; }
.faq-item p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.6; }

/* Related tools */
.related-tools-links { display: flex; flex-wrap: wrap; gap: 10px; }

/* Footer */
.site-footer {
  text-align: center;
  padding: 32px 20px 48px;
  color: var(--text-faint);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}
.footer-note { max-width: 520px; margin: 8px auto 0; }

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  max-width: 640px;
  margin: 20px auto 0;
}
.footer-legal a { color: var(--text-faint); font-size: 12px; }
.footer-legal a:hover { color: var(--text-dim); }
.footer-copy { margin-top: 14px; }

@media (max-width: 640px) {
  .main-nav { font-size: 12px; gap: 14px; }
  .converter-row { grid-template-columns: 1fr; }
  .btn-swap { justify-self: center; transform: rotate(90deg); }
  .btn-swap:hover { transform: rotate(270deg); }
  .spt-stats { flex-direction: column; }
  .ip-main { justify-content: center; text-align: center; }
  .btn-copy { margin-left: 0; }
}
