/* ============================================================
   Glow UI - Word Counter
   Dark mode default, light mode via [data-theme="light"]
   ============================================================ */

:root {
  --bg: #121212;
  --bg-card: #181818;
  --bg-hover: #282828;
  --border: #404040;
  --text-muted: #535353;
  --text-secondary: #B3B3B3;
  --text-primary: #FFFFFF;
  --green: #1DB954;
  --green-hover: #1ed760;
  --red: #C0392B;
  --font: 'Inter', sans-serif;
}

[data-theme="light"] {
  --bg: #FFFFFF;
  --bg-card: #F5F5F5;
  --bg-hover: #E8E8E8;
  --border: #D0D0D0;
  --text-muted: #999999;
  --text-secondary: #666666;
  --text-primary: #121212;
  --green: #1DB954;
  --green-hover: #17a349;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

/* ---- Header ---- */
.header {
  background: rgba(18, 18, 18, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

[data-theme="light"] .header {
  background: rgba(255, 255, 255, 0.9);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  color: var(--green);
  font-weight: 800;
  font-size: 20px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.header-nav {
  display: flex;
  gap: 8px;
  flex: 1;
}

.header-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 4px;
  transition: color 0.15s;
}

.header-nav a:hover,
.header-nav a.active {
  color: var(--text-primary);
}

.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ---- 3-column layout ---- */
.layout-3col {
  display: grid;
  grid-template-columns: 180px 1fr 300px;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 24px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 88px;
}

/* ---- Main content ---- */
.main-content {
  min-width: 0;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
}

/* ---- Editor area ---- */
.editor-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
}

.text-input {
  width: 100%;
  min-height: 220px;
  padding: 16px;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  border: none;
  outline: none;
  resize: vertical;
}

.text-input::placeholder {
  color: var(--text-muted);
}

.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-hover);
}

.btn-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 16px;
  border-radius: 9999px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-clear:hover {
  border-color: var(--red);
  color: var(--red);
}

.char-limit-info {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- Stats grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: background 0.15s, border-color 0.15s;
}

.stat-card:hover {
  background: var(--bg-hover);
  border-color: var(--green);
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--green);
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
}

/* ---- Mobile ad ---- */
.ad-slot--mobile {
  display: none;
  margin-bottom: 24px;
}

/* ---- Keyword section ---- */
.keyword-section {
  margin-bottom: 40px;
}

.keyword-section h2,
.info-section h2,
.faq-section h2,
.cross-links h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.section-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.keyword-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.keyword-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.keyword-table thead th {
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.keyword-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.keyword-table tbody tr:last-child {
  border-bottom: none;
}

.keyword-table tbody tr:hover {
  background: var(--bg-hover);
}

.keyword-table tbody td {
  padding: 10px 16px;
  color: var(--text-primary);
}

.keyword-table tbody td:first-child {
  color: var(--text-muted);
  font-size: 12px;
}

.empty-row td {
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
  font-style: italic;
}

.density-bar-wrap {
  background: var(--bg-hover);
  border-radius: 9999px;
  height: 6px;
  width: 100px;
  overflow: hidden;
}

.density-bar {
  height: 100%;
  background: var(--green);
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* ---- Info & FAQ sections ---- */
.info-section {
  margin-bottom: 40px;
}

.info-section h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 20px 0 8px;
}

.info-section p,
.faq-item p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 12px;
}

.use-cases-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.use-cases-list li {
  font-size: 14px;
  color: var(--text-secondary);
  padding-left: 20px;
  position: relative;
  line-height: 1.6;
}

.use-cases-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
}

.faq-section {
  margin-bottom: 40px;
}

.faq-item {
  border-top: 1px solid var(--border);
  padding: 20px 0;
}

.faq-item h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

/* ---- Cross-links ---- */
.cross-links {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  margin-bottom: 24px;
}

.cross-links-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.service-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.service-card:hover {
  background: var(--bg-hover);
  border-color: var(--green);
  transform: scale(1.02);
}

.service-icon {
  font-size: 24px;
}

.service-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.service-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---- Ad slots ---- */
.ad-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
}

.ad-slot--bottom {
  margin-bottom: 24px;
}

.ad-slot--sticky {
  position: sticky;
  top: 88px;
}

/* ---- Footer ---- */
.footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-bottom: 12px;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 14px;
  text-decoration: none;
  transition: color 0.15s;
}

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

.footer-copyright {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- Responsive ---- */

/* 1100px: collapse right sidebar */
@media (max-width: 1100px) {
  .layout-3col {
    grid-template-columns: 180px 1fr;
  }
  .sidebar-right {
    display: none;
  }
  .ad-slot--mobile {
    display: flex;
  }
}

/* 768px: collapse left sidebar */
@media (max-width: 768px) {
  .layout-3col {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }
  .sidebar-left {
    display: none;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .page-header h1 {
    font-size: 28px;
  }
  .cross-links-grid {
    grid-template-columns: 1fr 1fr;
  }
  .header-nav {
    display: none;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .stat-value {
    font-size: 22px;
  }
  .cross-links-grid {
    grid-template-columns: 1fr;
  }
}
