:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

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

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.logo span {
  color: var(--text);
}

nav a {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 24px;
  font-weight: 500;
  transition: color 0.2s;
}

nav a:hover {
  color: var(--primary);
}

/* Hero */
.hero {
  text-align: center;
  padding: 60px 20px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: white;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.hero p {
  font-size: 1.2rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto;
}

/* Categories */
.categories {
  padding: 60px 0;
}

.categories h2 {
  text-align: center;
  font-size: 1.8rem;
  margin-bottom: 40px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.category-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.category-card h3 {
  font-size: 1.3rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-card p {
  color: var(--text-muted);
  margin-bottom: 16px;
}

.category-card ul {
  list-style: none;
}

.category-card li {
  margin-bottom: 8px;
}

.category-card a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.category-card a:hover {
  text-decoration: underline;
}

/* Tool Page */
.tool-page {
  padding: 40px 0;
}

.tool-header {
  text-align: center;
  margin-bottom: 40px;
}

.tool-header h1 {
  font-size: 2rem;
  margin-bottom: 12px;
}

.tool-header p {
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

.breadcrumb {
  margin-bottom: 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.tool-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  max-width: 800px;
  margin: 0 auto;
}

/* Form Elements */
textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

textarea {
  min-height: 150px;
  resize: vertical;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.input-group {
  margin-bottom: 20px;
}

.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--text-muted);
}

.btn-secondary:hover {
  background: var(--text);
}

.btn-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.result-box {
  background: #f1f5f9;
  border-radius: 8px;
  padding: 20px;
  margin-top: 20px;
  font-family: 'Monaco', 'Consolas', monospace;
  word-break: break-all;
}

.result-label {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.stat-item {
  background: #f1f5f9;
  padding: 16px;
  border-radius: 8px;
  text-align: center;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Ad Placeholder */
.ad-container {
  background: #f1f5f9;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin: 30px 0;
  color: var(--text-muted);
}

.ad-container.horizontal {
  min-height: 90px;
}

.ad-container.square {
  min-height: 250px;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

/* Footer */
footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 40px 0;
  margin-top: 60px;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: 20px;
}

.footer-links a:hover {
  color: var(--primary);
}

/* Responsive */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 1.8rem;
  }

  .tool-container {
    padding: 20px;
  }

  .footer-content {
    flex-direction: column;
    text-align: center;
  }

  .footer-links a {
    margin: 0 10px;
  }
}

/* Copy button */
.copy-btn {
  background: var(--success);
  padding: 8px 16px;
  font-size: 0.9rem;
}

.copy-btn.copied {
  background: var(--text-muted);
}

/* Color picker specific */
.color-preview {
  width: 100%;
  height: 100px;
  border-radius: 8px;
  margin-bottom: 20px;
  border: 2px solid var(--border);
}

.color-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* QR Code */
#qr-output {
  display: flex;
  justify-content: center;
  padding: 20px;
  background: white;
  border-radius: 8px;
}

/* Range slider */
input[type="range"] {
  width: 100%;
  margin: 10px 0;
}

/* Checkbox and radio */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
  cursor: pointer;
}

.checkbox-group input {
  width: auto;
}

/* Unit converter specific */
.converter-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: end;
}

.swap-btn {
  background: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-bottom: 8px;
}
