/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07);
  --radius: 8px;
  --max-w: 1100px;
  --transition: .2s ease;
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,.25);
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-underline-position: under;
}

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

/* ===== Header ===== */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.logo span { color: var(--primary); }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: .25rem;
}

.main-nav ul {
  list-style: none;
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
}

.main-nav a {
  display: block;
  padding: .4rem .75rem;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: .875rem;
  transition: background var(--transition), color var(--transition);
}
.main-nav a:hover,
.main-nav a.active {
  background: var(--bg-secondary);
  color: var(--primary);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .6rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  transition: background var(--transition);
}
.theme-toggle:hover { background: var(--bg-secondary); }

/* ===== Main Content ===== */
.page-wrapper {
  flex: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
}

/* ===== Ad Placeholders ===== */
.ad-slot {
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: .8rem;
  margin: 1.5rem 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Tool Card Grid (Landing) ===== */
.hero { text-align: center; margin-bottom: 2.5rem; }
.hero h1 { font-size: 2rem; margin-bottom: .5rem; }
.hero p { color: var(--text-secondary); font-size: 1.1rem; max-width: 600px; margin: 0 auto; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.tool-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tool-card .icon {
  font-size: 2rem;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.tool-card h2 { font-size: 1.15rem; }
.tool-card p { color: var(--text-secondary); font-size: .9rem; flex: 1; }
.tool-card .card-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-weight: 600;
  font-size: .9rem;
}

/* ===== Tool Page Layout ===== */
.tool-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

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

.tool-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ===== Tool Sections ===== */
.tool-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.tool-section h1 {
  font-size: 1.6rem;
  margin-bottom: .25rem;
}

.tool-subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

/* ===== Form Controls ===== */
textarea, input[type="text"], input[type="url"], input[type="number"], select {
  width: 100%;
  padding: .65rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: .95rem;
  transition: border-color var(--transition);
  resize: vertical;
}
textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

textarea { min-height: 160px; }

label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  cursor: pointer;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-group { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ===== Stats Row ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .75rem;
  margin-top: 1rem;
}

.stat-box {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: .75rem;
  text-align: center;
}
.stat-box .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}
.stat-box .stat-label {
  font-size: .75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ===== Range Slider ===== */
.range-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.range-group input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
}
.range-value {
  font-weight: 700;
  font-size: 1.1rem;
  min-width: 2.5rem;
  text-align: center;
}

/* ===== Password Strength Bar ===== */
.strength-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  margin-top: .5rem;
  overflow: hidden;
}
.strength-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s, background .3s;
}
.strength-text { font-size: .8rem; margin-top: .25rem; font-weight: 600; }

/* ===== Password Display ===== */
.password-display {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem .85rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .95rem;
  word-break: break-all;
}
.password-display .pw-text { flex: 1; }

/* ===== Toggle Switch ===== */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--transition);
}
.switch .slider::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ===== QR Output ===== */
.qr-output {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
}
.qr-output canvas, .qr-output img {
  max-width: 100%;
  border-radius: var(--radius);
}

/* ===== Output Box ===== */
.output-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: .95rem;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 100px;
  max-height: 400px;
  overflow-y: auto;
}

/* ===== Reference Table ===== */
.ref-table { width: 100%; border-collapse: collapse; margin-top: .75rem; font-size: .9rem; }
.ref-table th, .ref-table td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.ref-table th { font-weight: 600; color: var(--text-secondary); font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; }
.ref-table tr:last-child td { border-bottom: none; }

/* ===== Content Sections ===== */
.content-section { margin-top: 2rem; }
.content-section h2 { font-size: 1.3rem; margin-bottom: .75rem; }
.content-section h3 { font-size: 1.05rem; margin: 1rem 0 .5rem; }
.content-section p { color: var(--text-secondary); margin-bottom: .75rem; }
.content-section ul { margin: .5rem 0 1rem 1.25rem; color: var(--text-secondary); }
.content-section li { margin-bottom: .35rem; }

/* ===== FAQ ===== */
.faq-list { margin-top: .75rem; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item:last-child { border-bottom: none; }
.faq-question {
  width: 100%;
  background: none;
  border: none;
  padding: .85rem 0;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
}
.faq-question::after { content: '+'; font-size: 1.25rem; flex-shrink: 0; color: var(--text-secondary); transition: transform var(--transition); }
.faq-item.open .faq-question::after { content: '\2212'; }
.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}
.faq-answer-inner { padding: 0 0 .85rem; color: var(--text-secondary); font-size: .9rem; line-height: 1.7; }

/* ===== Breadcrumb ===== */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  font-size: .85rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { margin: 0 .15rem; }

/* ===== Footer ===== */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 2rem 1rem;
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.footer-col h3 {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-secondary);
  margin-bottom: .75rem;
}

.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: .4rem; }
.footer-col a { color: var(--text-secondary); font-size: .9rem; }
.footer-col a:hover { color: var(--primary); }

.footer-bottom {
  max-width: var(--max-w);
  margin: 1.5rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .8rem;
  color: var(--text-secondary);
}

/* ===== Copy Feedback ===== */
.copy-feedback {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--text);
  color: var(--bg);
  padding: .5rem 1.25rem;
  border-radius: var(--radius);
  font-size: .85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 200;
}
.copy-feedback.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Responsive ===== */
@media (min-width: 768px) {
  .tool-layout {
    grid-template-columns: 1fr 280px;
  }
  .hero h1 { font-size: 2.5rem; }
}

@media (max-width: 767px) {
  .nav-toggle { display: block; }
  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: .5rem 1rem 1rem;
    box-shadow: var(--shadow-md);
  }
  .main-nav.open { display: block; }
  .main-nav ul { flex-direction: column; }
  .main-nav a { padding: .6rem .75rem; }
  .header-inner { flex-wrap: wrap; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Utility ===== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.gap-1 { gap: .5rem; }
