:root {
  --bg: #0d0f14;
  --surface: #161920;
  --surface-2: #1c2029;
  --border: #2a2f3a;
  --border-light: #1e222b;
  --border-nav: #262b35;
  --text: #eef0f3;
  --text-dim: #9aa3b2;
  --text-faint: #7c8494;
  --accent: #f59e0b;
  --accent-hover: #ffc835;
  --accent-soft: rgba(245, 158, 11, 0.12);
  --disabled-bg: #23262f;
  --disabled-text: #5c6270;
  --success: #22c55e;
  --error: #ef4444;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 10px;
}

* { box-sizing: border-box; }

html { overflow-x: hidden; }
body {
  margin: 0;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---------------------------------------------------------------- Header / nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 15, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-nav);
}
.header-inner {
  position: relative;
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}
.logo {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.logo span { color: var(--accent); }

.mega-nav { display: flex; gap: 8px; }
.nav-item { position: relative; }
.nav-trigger {
  display: inline-block;
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-trigger:hover { background: var(--surface); color: var(--text); }

/* No gap between the trigger and the panel below it -- a gap here is a dead
   zone the pointer passes through while moving from the trigger into the
   panel, which drops :hover on .nav-item and hides the panel before the
   pointer ever reaches it. Sitting the panel flush (top: 100%) means the
   hoverable area is continuous the whole way down. */
.mega-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border-nav);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  min-width: 220px;
  max-width: min(320px, calc(100vw - 32px));
}
.nav-item:hover .mega-panel { display: block; }
/* The rightmost nav item sits near the viewport's right edge -- anchoring
   its panel to the trigger's right side (instead of left) keeps it from
   running past the edge of the screen on narrower viewports. */
.nav-item:last-child .mega-panel { left: auto; right: 0; }
.mega-col h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; color: var(--text-faint); letter-spacing: 0.05em; }
.mega-col ul { list-style: none; margin: 0; padding: 0; }
.mega-col li { margin-bottom: 6px; }
.mega-col a { color: var(--text); font-size: 14px; }
.mega-col a:hover { color: var(--accent); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: none;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.15s, opacity 0.15s;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 860px) {
  .header-inner { padding: 18px 20px; }
  .nav-toggle { display: flex; }
  .mega-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border-nav);
    padding: 8px 20px 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  }
  .mega-nav.open { display: flex; }
  .nav-item { position: static; }
  .nav-trigger { padding: 12px 4px; }
  /* Submenus rely on :hover, which mobile browsers handle poorly (a tap can
     both navigate and toggle it) -- easier to hide them and let the trigger
     link straight to the hub page, which already lists everything inside. */
  .mega-panel { display: none !important; }
}

/* ---------------------------------------------------------------- Page / hero */
.page { max-width: 1280px; margin: 0 auto; padding: 80px 48px 112px; }
@media (max-width: 600px) {
  .page { padding: 48px 20px 72px; }
}
.hero { text-align: center; margin-bottom: 32px; }
.hero h1 {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  max-width: 760px;
  margin: 0 auto 24px;
}
.subtitle {
  font-size: 17px;
  color: var(--text-dim);
  text-align: center;
  max-width: 640px;
  margin: 0 auto 40px;
}

.converter-card {
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border-nav);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.dropzone {
  border: 1px dashed #333a47;
  border-radius: var(--radius-lg);
  padding: 56px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover { border-color: var(--accent); background: var(--surface-2); }
.dz-label { font-size: 17px; color: var(--text-dim); margin: 0 0 20px; }
.dz-label button { height: auto; background: none; border: none; color: var(--accent); font-size: 16px; cursor: pointer; text-decoration: underline; padding: 0; }
.dz-label button.primary-btn {
  background: var(--accent);
  color: #3d2500;
  text-decoration: none;
  padding: 0 16px;
  height: 36px;
  margin: 8px 0 0 6px;
}
.dz-label button.primary-btn:hover { background: var(--accent-hover); }
.dz-hint { color: var(--text-faint); font-size: 14px; margin: 8px 0 0; }

.hidden { display: none !important; }

.progress-track {
  background: var(--surface-2);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin: 16px 0;
}
.progress-fill {
  background: var(--accent);
  height: 100%;
  width: 0%;
  transition: width 0.2s;
}

.detected-line { margin: 0 0 16px; font-size: 15px; }
.detected-line strong { color: var(--accent); }

select, input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], textarea {
  height: 52px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 0 16px;
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s;
}
textarea { height: auto; padding: 12px 16px; }
select:focus, input[type="text"]:focus, input[type="number"]:focus, input[type="date"]:focus, input[type="time"]:focus, input[type="datetime-local"]:focus, textarea:focus {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
  border-color: var(--accent);
}
select:disabled { opacity: 0.6; cursor: not-allowed; }

/* date/time pickers render a native dark-on-dark calendar icon by default --
   invert it so it's visible against the dark input background. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  cursor: pointer;
}

input[type="range"] { width: 100%; height: auto; padding: 0; background: none; border: none; accent-color: var(--accent); }

input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
  vertical-align: middle;
}

input[type="color"] {
  height: 52px;
  width: 64px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  flex: none;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: var(--radius-sm); }

/* ---------------------------------------------------------------- Buttons / file inputs */
button {
  height: 40px;
  padding: 0 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

input[type="file"] {
  height: auto;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px dashed #333a47;
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
}
input[type="file"]::file-selector-button,
input[type="file"]::-webkit-file-upload-button {
  height: 36px;
  padding: 0 16px;
  margin-right: 12px;
  background: var(--accent);
  color: #3d2500;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
input[type="file"]::file-selector-button:hover,
input[type="file"]::-webkit-file-upload-button:hover { background: var(--accent-hover); }

.format-picker {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
}
.format-picker-col { flex: 1; min-width: 0; }
.format-picker-col label { display: block; margin-bottom: 10px; font-size: 14px; font-weight: 600; color: var(--text-dim); }
.format-picker-col select { width: 100%; }
.format-arrow { color: var(--text-faint); padding-bottom: 14px; font-size: 18px; }
@media (max-width: 520px) {
  .format-picker { flex-direction: column; align-items: stretch; }
  .format-arrow { display: none; }
}

#ready-panel { margin-top: 24px; }
#ready-panel .primary-btn { margin-left: 12px; }

.primary-btn {
  height: 52px;
  padding: 0 28px;
  background: var(--accent);
  color: #3d2500;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.primary-btn:hover { background: var(--accent-hover); }

.btn-secondary {
  height: 52px;
  padding: 0 28px;
  background: transparent;
  color: var(--text);
  border: 1px solid #333a47;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s;
}
.btn-secondary:hover { border-color: #4a5266; }

.link-btn {
  height: auto;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  margin-top: 16px;
  padding: 0;
  transition: color 0.15s;
}
.link-btn:hover { color: var(--text); }

.error-line { color: var(--error); margin-top: 12px; font-size: 15px; }

/* ---------------------------------------------------------------- Client tools / card grids */
.client-tools { margin-top: 96px; }
.client-tools h2 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0 0 12px;
}
.client-tools .subtitle { margin-bottom: 40px; }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 40px;
  margin-top: 16px;
}
@media (max-width: 900px) {
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .tools-grid { grid-template-columns: 1fr; }
}

.tool-link-card {
  display: block;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border-light);
}
.tool-link-card h3 { font-size: 15px; font-weight: 600; margin: 0; color: var(--text); transition: color 0.15s; }
.tool-link-card:hover h3 { color: var(--accent); }
.tool-link-card p { margin: 3px 0 0; color: var(--text-faint); font-size: 13px; line-height: 1.4; }

.tool-body { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.tool-body-standalone { margin-top: 0; }
.tool-body select, .tool-body input, .tool-body textarea { width: 100%; }
.unit-row { display: flex; align-items: center; gap: 8px; }
.unit-row input, .unit-row select { flex: 1; min-width: 0; }
.tool-output { color: var(--text-dim); font-size: 14px; margin: 0; word-break: break-word; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-actions button {
  height: 40px;
  padding: 0 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: border-color 0.15s;
}
.tool-actions button:hover { border-color: var(--accent); }

#qr-canvas { background: white; border-radius: var(--radius-md); }

.tool-standalone-card { max-width: 480px; margin: 0 auto; }
.back-to-tools { text-align: center; margin-top: 24px; }

/* ---------------------------------------------------------------- Breadcrumbs / SEO content */
.breadcrumbs { font-size: 14px; color: var(--text-faint); margin-bottom: 32px; }
.breadcrumbs a { color: var(--text-dim); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .crumb-sep { margin: 0 8px; color: var(--text-faint); }

.seo-content { max-width: 720px; margin: 64px auto 0; }
.seo-content h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 16px; }
.seo-content h3 { font-size: 16px; font-weight: 600; margin: 24px 0 6px; color: var(--text); }
.seo-content p { color: var(--text-dim); font-size: 15px; line-height: 1.7; margin: 0 0 12px; }
.howto-steps { color: var(--text-dim); font-size: 15px; line-height: 1.9; margin: 0; padding-left: 22px; }

.related-links { display: flex; flex-wrap: wrap; gap: 10px; }
.related-links a {
  display: inline-block;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border-nav);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 14px;
  transition: border-color 0.15s, color 0.15s;
}
.related-links a:hover { border-color: var(--accent); color: var(--text); }

/* ---------------------------------------------------------------- Footer / errors */
.site-footer { color: var(--text-faint); padding: 48px; font-size: 14px; border-top: 1px solid var(--border-light); }
.footer-cols {
  max-width: 1280px;
  margin: 0 auto 32px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}
@media (max-width: 800px) { .footer-cols { grid-template-columns: 1fr; } }
.footer-col h4 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); }
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: 8px; }
.footer-col a { color: var(--text-dim); font-size: 14px; }
.footer-col a:hover { color: var(--accent); }
.footer-line { text-align: center; margin: 0; }
.error-page { text-align: center; padding: 140px 24px; }
.error-page h1 { font-size: 56px; font-weight: 700; letter-spacing: -0.03em; }
