/* ===========================
   YTUBE IQ - Main Stylesheet
   =========================== */

/* CSS Variables */
:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #718096;
  --accent: #e53e3e;
  --accent-dark: #c53030;
  --accent-light: #fff5f5;
  --success: #38a169;
  --warning: #d69e2e;
  --info: #3182ce;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --transition: 0.2s ease;
  --header-h: 64px;
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --surface: #1e1e1e;
  --border: #333333;
  --text: #f0f0f0;
  --text-muted: #a0a0a0;
  --accent-light: #2d1515;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.3);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  transition: background var(--transition), color var(--transition);
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  transition: background var(--transition);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: 100%; }
.logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 1.25rem;
  color: var(--text); text-decoration: none; flex-shrink: 0;
}
.logo .logo-yt { color: var(--accent); }
.main-nav { display: flex; align-items: center; gap: 24px; margin-left: auto; }
.main-nav a {
  color: var(--text-muted); font-size: 0.9375rem; font-weight: 500;
  text-decoration: none; transition: color var(--transition);
}
.main-nav a:hover, .main-nav a.active { color: var(--accent); text-decoration: none; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle, .mobile-menu-btn {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius); width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all var(--transition);
}
.theme-toggle:hover, .mobile-menu-btn:hover { border-color: var(--accent); color: var(--accent); }
.mobile-menu-btn { display: none; }

@media (max-width: 768px) {
  .main-nav {
    display: none; position: fixed;
    top: var(--header-h); left: 0; right: 0; bottom: 0;
    background: var(--surface); flex-direction: column;
    align-items: flex-start; padding: 24px 16px; gap: 0;
    overflow-y: auto; border-top: 1px solid var(--border); margin-left: 0;
    z-index: 99;
  }
  .main-nav.open { display: flex; }
  .main-nav a { font-size: 1.125rem; padding: 14px 0; width: 100%; border-bottom: 1px solid var(--border); }
  .mobile-menu-btn { display: flex; }
}

/* Hero */
.hero {
  text-align: center; padding: 80px 16px 60px;
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800; line-height: 1.2; margin-bottom: 16px;
}
.hero h1 .accent { color: var(--accent); }
.hero .tagline {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: var(--text-muted); margin-bottom: 32px;
  max-width: 600px; margin-left: auto; margin-right: auto;
}
.hero-search { max-width: 520px; margin: 0 auto 12px; position: relative; }
.hero-search input {
  width: 100%; padding: 14px 52px 14px 20px;
  border: 2px solid var(--border); border-radius: 40px;
  background: var(--surface); color: var(--text); font-size: 1rem;
  transition: border-color var(--transition);
}
.hero-search input:focus { outline: none; border-color: var(--accent); }
.hero-search button {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: var(--accent); color: white; border: none;
  border-radius: 50%; width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
}
.search-results-wrapper { max-width: 520px; margin: 0 auto; position: relative; }
.search-results {
  display: none; position: absolute; top: 4px; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  z-index: 50; overflow: hidden;
}
.search-results.active { display: block; }
.search-result-item {
  display: block; padding: 12px 16px;
  color: var(--text); text-decoration: none;
  font-size: 0.9375rem; transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-secondary); color: var(--accent); text-decoration: none; }
.search-no-results { padding: 12px 16px; color: var(--text-muted); font-size: 0.875rem; }

/* Sections */
.section { padding: 64px 0; }
.section-alt { background: var(--bg-secondary); }
.section-header { text-align: center; margin-bottom: 40px; }
.section-header h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); font-weight: 700; margin-bottom: 12px; }
.section-header p { color: var(--text-muted); font-size: 1.0625rem; max-width: 520px; margin: 0 auto; }

/* Grid */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
  box-shadow: var(--shadow); transition: box-shadow var(--transition), transform var(--transition);
}
a.card { color: var(--text); text-decoration: none; display: block; }
a.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); text-decoration: none; }

/* Tool Card Links (homepage) */
.tool-card-link {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  text-decoration: none; color: var(--text);
  transition: all var(--transition);
}
.tool-card-link:hover {
  border-color: var(--accent); box-shadow: var(--shadow-lg);
  transform: translateY(-2px); text-decoration: none;
}
.tool-icon {
  width: 42px; height: 42px; background: var(--accent-light);
  border-radius: var(--radius); display: flex; align-items: center;
  justify-content: center; margin-bottom: 12px;
  color: var(--accent); font-size: 1.25rem;
}
.tool-card-link h3 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.tool-card-link p { font-size: 0.8125rem; color: var(--text-muted); line-height: 1.4; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius);
  font-size: 0.9375rem; font-weight: 600; border: none;
  cursor: pointer; transition: all var(--transition);
  text-decoration: none; line-height: 1;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; color: white; }
.btn-secondary { background: var(--bg-secondary); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }
.btn-sm { padding: 6px 14px; font-size: 0.8125rem; }
.btn-outline { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.btn-outline:hover { background: var(--accent-light); text-decoration: none; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.9375rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  font-size: 0.9375rem; font-family: inherit;
  transition: border-color var(--transition);
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229,62,62,0.1);
}
.form-textarea { resize: vertical; min-height: 120px; }
.char-hint { font-size: 0.8125rem; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* Tool actions */
.tool-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

/* Tool Output */
.tool-output {
  margin-top: 20px; padding: 20px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); display: none;
}
.tool-output.visible { display: block; }
.output-text {
  font-size: 0.9375rem; line-height: 1.7; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.output-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.stat-value { font-size: 1.875rem; font-weight: 700; color: var(--accent); display: block; line-height: 1.2; }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); margin-top: 4px; display: block; }

/* Progress */
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.4s ease; }
.progress-fill.good { background: #38a169; }
.progress-fill.warn { background: #d69e2e; }
.progress-fill.bad { background: #e53e3e; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 0.8125rem; font-weight: 600; }
.badge-success { background: #c6f6d5; color: #276749; }
.badge-warning { background: #fefcbf; color: #744210; }
.badge-error { background: #fed7d7; color: #822727; }
.badge-info { background: #bee3f8; color: #2c5282; }
[data-theme="dark"] .badge-success { background: #1c4532; color: #68d391; }
[data-theme="dark"] .badge-warning { background: #2d2416; color: #f6e05e; }
[data-theme="dark"] .badge-error { background: #2d1515; color: #fc8181; }
[data-theme="dark"] .badge-info { background: #1a3a5c; color: #63b3ed; }

/* Tags */
.tags-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; background: var(--accent-light); color: var(--accent);
  border-radius: 20px; font-size: 0.8125rem; font-weight: 500;
  border: 1px solid rgba(229,62,62,0.2);
}

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.875rem; color: var(--text-muted); padding: 16px 0; flex-wrap: wrap; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--border); }
.breadcrumb .current { color: var(--text); }

/* Page Hero */
.page-hero { padding: 40px 0 32px; border-bottom: 1px solid var(--border); margin-bottom: 40px; }
.page-hero h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 800; color: var(--text); margin-bottom: 12px; }
.page-hero .lead { font-size: 1.0625rem; color: var(--text-muted); max-width: 680px; }

/* Content Sections */
.content-section { margin-top: 48px; padding-top: 48px; border-top: 1px solid var(--border); }
.content-section h2 { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-bottom: 20px; }
.content-section h3 { font-size: 1.125rem; font-weight: 600; color: var(--text); margin: 20px 0 10px; }
.content-section p { color: var(--text-muted); margin-bottom: 14px; line-height: 1.7; }
.content-section ul, .content-section ol { padding-left: 24px; color: var(--text-muted); margin-bottom: 14px; }
.content-section li { margin-bottom: 8px; line-height: 1.6; list-style: disc; }
.content-section ol li { list-style: decimal; }

/* FAQ */
.faq-item { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.faq-item summary {
  padding: 16px 20px; font-weight: 600; font-size: 0.9375rem;
  color: var(--text); cursor: pointer; list-style: none;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); user-select: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; font-size: 1.25rem; color: var(--accent); flex-shrink: 0; }
.faq-item[open] summary::after { content: '\2212'; }
.faq-item p { padding: 0 20px 16px; color: var(--text-muted); background: var(--surface); line-height: 1.7; margin: 0; }

/* Related tool cards */
.related-tool-card { text-decoration: none; color: var(--text); }
.related-tool-card:hover { transform: translateY(-2px); text-decoration: none; }
.related-tool-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--accent); }
.related-tool-card p { font-size: 0.875rem; color: var(--text-muted); margin: 0; }

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

/* Footer */
.site-footer { background: var(--bg-secondary); border-top: 1px solid var(--border); padding: 48px 0 24px; margin-top: 64px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; margin-bottom: 40px; }
@media (max-width: 768px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-tagline { font-size: 0.875rem; color: var(--text-muted); margin-top: 8px; line-height: 1.5; }
.footer-links h4 { font-size: 0.8125rem; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 14px; }
.footer-links li { margin-bottom: 8px; }
.footer-links a { font-size: 0.875rem; color: var(--text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.footer-bottom p { font-size: 0.875rem; color: var(--text-muted); }

/* Feature icons */
.feature-icon { width: 48px; height: 48px; background: var(--accent-light); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; margin-bottom: 16px; }

/* Info box */
.info-box { background: var(--accent-light); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 16px 20px; margin: 20px 0; }
.info-box p { color: var(--text); margin: 0; line-height: 1.6; }

/* Upload Zone */
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius-lg); padding: 48px 24px; text-align: center; cursor: pointer; transition: all var(--transition); }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: var(--accent-light); }
.upload-zone p { color: var(--text-muted); margin-top: 8px; font-size: 0.9375rem; }
.upload-zone input[type="file"] { display: none; }

/* Timestamp rows */
.timestamp-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.timestamp-row input { flex: 1; }
.timestamp-row .ts-time { flex: 0 0 130px; }
.btn-remove { background: none; border: 1px solid var(--border); border-radius: var(--radius); width: 34px; height: 40px; color: var(--text-muted); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.btn-remove:hover { border-color: var(--accent); color: var(--accent); }

/* Canvas */
canvas { max-width: 100%; border-radius: var(--radius); display: block; }

/* Score ring / meter */
.score-display { text-align: center; margin-bottom: 24px; }
.score-number { font-size: 4rem; font-weight: 800; color: var(--accent); line-height: 1; }
.score-label { font-size: 0.9375rem; color: var(--text-muted); }
.score-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.score-row-label { flex: 0 0 180px; font-size: 0.875rem; color: var(--text); }
.score-row-bar { flex: 1; }
.score-row-val { flex: 0 0 50px; text-align: right; font-weight: 600; font-size: 0.875rem; }

/* Result list items */
.result-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 8px; position: relative; }
.result-item p { margin: 0; color: var(--text); font-size: 0.9375rem; line-height: 1.5; }
.result-item .copy-single { position: absolute; top: 10px; right: 10px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 10px; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.result-item .copy-single:hover { border-color: var(--accent); color: var(--accent); }

/* Utility */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-4 { margin-top: 16px; } .mt-8 { margin-top: 32px; }
.mb-4 { margin-bottom: 16px; } .mb-8 { margin-bottom: 32px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* Skip link */
.skip-link { position: absolute; top: -40px; left: 0; background: var(--accent); color: white; padding: 8px 16px; z-index: 999; border-radius: 0 0 var(--radius) 0; }
.skip-link:focus { top: 0; }

/* Guide content */
.guide-content h2 { font-size: 1.5rem; font-weight: 700; margin: 32px 0 16px; color: var(--text); }
.guide-content h3 { font-size: 1.125rem; font-weight: 600; margin: 20px 0 10px; color: var(--text); }
.guide-content p { color: var(--text-muted); line-height: 1.8; margin-bottom: 16px; }
.guide-content ul, .guide-content ol { padding-left: 24px; color: var(--text-muted); margin-bottom: 16px; }
.guide-content li { margin-bottom: 8px; line-height: 1.7; }
.guide-content ul li { list-style: disc; }
.guide-content ol li { list-style: decimal; }
.guide-content blockquote { border-left: 4px solid var(--accent); padding: 12px 20px; margin: 20px 0; background: var(--accent-light); border-radius: var(--radius); }
.guide-content blockquote p { color: var(--text); margin: 0; }
.guide-sidebar { position: sticky; top: calc(var(--header-h) + 20px); }
.guide-layout { display: grid; grid-template-columns: 1fr 280px; gap: 40px; align-items: start; }
@media (max-width: 900px) { .guide-layout { grid-template-columns: 1fr; } .guide-sidebar { position: static; } }

/* Print */
@media print { .site-header, .site-footer, .ad-slot { display: none; } }
