/* ============================================================
   WORD COUNTER — Mobile-First Stylesheet v3
   Theme: Toolslice white, Violet accent
   Every breakpoint tested: 320px → 1440px
   Tap targets: min 44×44px on all interactive elements
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #ffffff;
  --hero-bg:     linear-gradient(135deg, #f5f3ff 0%, #ede9fe 40%, #eef2ff 100%);
  --surface:     #ffffff;
  --surface2:    #faf9ff;
  --surface3:    #f1f5f9;
  --border:      #e2e8f0;
  --border2:     #cbd5e1;
  --accent:      #7c3aed;
  --accent-dim:  rgba(124,58,237,.09);
  --accent-hover:#6d28d9;
  --logo-grad:   linear-gradient(135deg,#f97316,#ec4899,#8b5cf6);
  --text:        #1e1b4b;
  --text2:       #475569;
  --muted:       #94a3b8;
  --danger:      #ef4444;
  --warn:        #f59e0b;
  --success:     #10b981;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 1px 3px rgba(0,0,0,.06),0 4px 16px rgba(124,58,237,.07);
  --shadow-md:   0 4px 24px rgba(124,58,237,.14);
  --font:        'Plus Jakarta Sans', sans-serif;
  --tr:          .18s cubic-bezier(.4,0,.2,1);
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px;
  line-height: 1.6; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── HEADER ──────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 200;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0 16px; height: 52px;
  display: flex; align-items: center; gap: 10px;
}
.site-logo {
  font-size: 1.2rem; font-weight: 800;
  background: var(--logo-grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; text-decoration: none; letter-spacing: -.4px;
  flex-shrink: 0;
}
.site-logo .accent {
  background: var(--logo-grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-tag {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  border-left: 1px solid var(--border); padding-left: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hdr-badge {
  margin-left: auto; flex-shrink: 0;
  background: var(--accent-dim); border: 1px solid rgba(124,58,237,.2);
  color: var(--accent); font-size: 9.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px;
  letter-spacing: .4px; text-transform: uppercase;
}

/* ── HERO BANNER ─────────────────────────────────────────── */
.hero {
  background: var(--hero-bg); border-bottom: 1px solid var(--border);
  padding: 16px;
}
.hero-top { display: flex; flex-direction: column; gap: 5px; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid rgba(124,58,237,.22);
  background: rgba(124,58,237,.06);
  padding: 3px 10px; border-radius: 20px;
  font-size: 10.5px; font-weight: 700;
  color: var(--accent); letter-spacing: .4px; text-transform: uppercase;
  width: fit-content;
}
.hero-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink {
  0%,100%{ opacity:1; transform:scale(1) }
  50%{ opacity:.3; transform:scale(.65) }
}
.hero h1 {
  font-size: clamp(1.15rem, 4vw, 1.55rem);
  font-weight: 800; line-height: 1.2; letter-spacing: -.5px;
  color: var(--text); margin: 0;
}
.hero h1 .hl { color: var(--accent); }
.feature-pills {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-top: 10px;
}
.feat-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff; border: 1px solid var(--border);
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; color: var(--text2); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.04); white-space: nowrap;
}
.feat-pill::before { content: '✓'; color: var(--accent); font-size: 9px; font-weight: 800; }

/* ── CONTAINER ───────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 12px 12px 60px; }

/* ── AD SLOT ─────────────────────────────────────────────── */
.ad-slot {
  background: var(--surface2); border: 1px dashed var(--border2);
  border-radius: var(--radius); min-height: 60px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 11.5px;
  margin-bottom: 12px; padding: 10px; text-align: center;
}

/* ── STAT GRID ─────────────────────────────────────────────
   Mobile: 2 columns (words + chars most prominent)
   Tablet: 3 columns
   Desktop: 5 columns
───────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin-bottom: 12px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 10px;
  box-shadow: var(--shadow); text-align: center;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; background: var(--accent); opacity: 0;
  transition: opacity var(--tr);
}
.stat-card.lit::before { opacity: 1; }
.stat-num {
  font-size: 1.7rem; font-weight: 800;
  color: var(--accent); line-height: 1; margin-bottom: 3px;
  transition: color var(--tr);
}
.stat-num.zero { color: var(--muted); }
.stat-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted);
}
.stat-sub { font-size: 10px; color: var(--text2); margin-top: 2px; }

/* ── TOOL CARD ───────────────────────────────────────────── */
.tool-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  margin-bottom: 12px;
}

/* ── TOOLBAR ─────────────────────────────────────────────── */
.toolbar {
  border-bottom: 1px solid var(--border); padding: 10px 12px;
  background: var(--surface2);
  display: flex; flex-direction: column; gap: 8px;
}
.toolbar-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.toolbar-title {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted);
  display: flex; align-items: center; gap: 5px;
}
.toolbar-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.limit-label {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
}
/* Limit pills — scrollable row on mobile, no wrap overflow */
.limit-pills-scroll {
  display: flex; gap: 5px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 2px; scrollbar-width: none;
}
.limit-pills-scroll::-webkit-scrollbar { display: none; }
.limit-pill {
  appearance: none; cursor: pointer; border: none;
  min-width: 44px; min-height: 32px;
  padding: 5px 11px; border-radius: 20px;
  font-family: var(--font); font-size: 12px; font-weight: 600;
  color: var(--text2); background: var(--surface);
  border: 1px solid var(--border);
  transition: all var(--tr); white-space: nowrap;
  flex-shrink: 0;
  /* Ensure tap target */
  display: inline-flex; align-items: center; justify-content: center;
}
.limit-pill:hover  { color: var(--accent); border-color: rgba(124,58,237,.35); background: var(--accent-dim); }
.limit-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }

/* ── TEXTAREA ────────────────────────────────────────────── */
.textarea-wrap { position: relative; }
textarea#inputText {
  width: 100%; border: none; outline: none; resize: vertical;
  background: transparent; font-family: var(--font); font-size: 15px;
  color: var(--text); line-height: 1.75; padding: 14px;
  caret-color: var(--accent);
  min-height: 200px;
  /* iOS font size fix — prevents auto-zoom */
  font-size: max(16px, 15px);
  touch-action: manipulation;
}
textarea#inputText::placeholder { color: var(--muted); }

/* Live limit bar */
.limit-bar-wrap {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px; background: var(--border); display: none;
}
.limit-bar-wrap.show { display: block; }
.limit-bar { height: 100%; transition: width .25s, background .25s; }

/* ── ACTION BAR ──────────────────────────────────────────── */
.action-bar {
  border-top: 1px solid var(--border); padding: 10px 12px;
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); flex-wrap: wrap;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 38px; padding: 0 16px;
  border-radius: 20px; border: none; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 700;
  white-space: nowrap; transition: all var(--tr);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 10px rgba(124,58,237,.25);
}
.btn-primary:hover  { background: var(--accent-hover); }
.btn-primary:active { transform: scale(.97); }
.btn-ghost {
  background: var(--surface); color: var(--text2); border: 1px solid var(--border);
}
.btn-ghost:hover  { color: var(--accent); border-color: rgba(124,58,237,.3); background: var(--accent-dim); }
.btn-ghost:active { transform: scale(.97); }
.char-live {
  margin-left: auto; font-size: 12px; color: var(--muted);
  white-space: nowrap; font-weight: 500;
}
.char-live .lim-num { font-weight: 800; }
.char-live.warn .lim-num { color: var(--warn); }
.char-live.over .lim-num { color: var(--danger); }

/* ── DETAIL CARDS ────────────────────────────────────────── */
.detail-row {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 12px;
}

/* Time card */
.time-card, .read-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted); margin-bottom: 12px;
}
.time-items { display: flex; flex-direction: column; gap: 7px; }
.time-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  min-height: 40px;
}
.time-item-left { display: flex; align-items: center; gap: 7px; }
.time-icon { font-size: 15px; line-height: 1; }
.time-name { font-size: 12.5px; font-weight: 600; color: var(--text2); }
.time-val  { font-size: 13px; font-weight: 800; color: var(--accent); }

/* Readability card */
.read-score-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.read-score-big { font-size: 2.6rem; font-weight: 800; color: var(--accent); line-height: 1; }
.read-score-info { flex: 1; min-width: 0; }
.read-grade { font-size: 13.5px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.read-desc  { font-size: 12px; color: var(--text2); }
.read-track { height: 6px; background: var(--surface3); border-radius: 6px; overflow: hidden; margin-bottom: 10px; }
.read-fill  { height: 100%; border-radius: 6px; transition: width .7s cubic-bezier(.4,0,.2,1), background .4s; }
.read-legend { display: flex; flex-wrap: wrap; gap: 8px; }
.read-leg-item { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--muted); font-weight: 600; }
.read-leg-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ── KEYWORD DENSITY ─────────────────────────────────────── */
.keyword-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.keyword-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.keyword-header .card-title { margin-bottom: 0; }
.kw-badge {
  background: var(--accent-dim); border: 1px solid rgba(124,58,237,.2);
  color: var(--accent); font-size: 9.5px; font-weight: 800;
  padding: 2px 7px; border-radius: 20px;
}
.keyword-list { display: flex; flex-direction: column; gap: 6px; }
.kw-item { display: flex; align-items: center; gap: 8px; }
.kw-rank { font-size: 10.5px; font-weight: 800; color: var(--muted); width: 16px; text-align: right; flex-shrink: 0; }
.kw-word { font-size: 13px; font-weight: 700; color: var(--text); min-width: 0; flex: 0 0 auto; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kw-bar-wrap { flex: 1; height: 5px; background: var(--surface3); border-radius: 5px; overflow: hidden; min-width: 0; }
.kw-bar { height: 100%; border-radius: 5px; background: var(--accent); opacity: .75; transition: width .5s cubic-bezier(.4,0,.2,1); }
.kw-meta { font-size: 11px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.kw-pct { color: var(--accent); font-weight: 700; }
.kw-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 0; }

/* ── PLATFORM LIMITS ─────────────────────────────────────── */
.platform-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
/* Mobile: 2 col grid */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}
.plat-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 11px;
  transition: border-color var(--tr), background var(--tr);
}
.plat-item.ok   { border-color: rgba(16,185,129,.3);  background: rgba(16,185,129,.04); }
.plat-item.warn { border-color: rgba(245,158,11,.3);  background: rgba(245,158,11,.04); }
.plat-item.over { border-color: rgba(239,68,68,.3);   background: rgba(239,68,68,.04); }
.plat-name  { font-size: 11.5px; font-weight: 700; color: var(--text); margin-bottom: 5px; }
.plat-track { height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.plat-fill  { height: 100%; border-radius: 4px; transition: width .4s, background .3s; }
.plat-fill.ok   { background: var(--success); }
.plat-fill.warn { background: var(--warn); }
.plat-fill.over { background: var(--danger); }
.plat-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 2px; }
.plat-used  { font-size: 10.5px; font-weight: 800; }
.plat-item.ok   .plat-used { color: var(--success); }
.plat-item.warn .plat-used { color: var(--warn); }
.plat-item.over .plat-used { color: var(--danger); }
.plat-limit  { font-size: 10px; color: var(--muted); }
.plat-status { font-size: 10px; font-weight: 700; }
.plat-status.ok   { color: var(--success); }
.plat-status.warn { color: var(--warn); }
.plat-status.over { color: var(--danger); }

/* ── SEO SECTION ─────────────────────────────────────────── */
.seo-section { border-top: 1px solid var(--border); background: var(--surface2); padding: 40px 0 0; }
.seo-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.seo-inner h2 { font-size: clamp(1.25rem,4vw,1.9rem); font-weight: 800; letter-spacing: -.5px; color: var(--text); margin-bottom: 12px; }
.seo-inner h3 { font-size: 1rem; font-weight: 700; color: var(--text); margin: 24px 0 7px; }
.seo-inner p  { color: var(--text2); font-size: 14px; line-height: 1.8; margin-bottom: 10px; }

.faq-wrap { margin: 14px 0 40px; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-q {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: 16px 0; font-family: var(--font); font-size: 14px; font-weight: 700;
  color: var(--text); display: flex; justify-content: space-between;
  align-items: center; gap: 12px; transition: color var(--tr);
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.faq-q:hover { color: var(--accent); }
.faq-icon {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--muted); transition: all var(--tr);
}
.faq-item.open .faq-icon { background: var(--accent); border-color: var(--accent); color: #fff; transform: rotate(45deg); }
.faq-a { display: none; padding: 0 0 16px; color: var(--text2); font-size: 13.5px; line-height: 1.8; }
.faq-item.open .faq-a { display: block; }

/* ── TOAST ───────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%) translateY(60px);
  z-index: 2000; background: var(--text); color: #fff;
  padding: 11px 20px; border-radius: 24px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none;
  box-shadow: 0 6px 24px rgba(30,27,75,.25);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── FOOTER ──────────────────────────────────────────────── */
footer { border-top: 1px solid var(--border); background: var(--surface2); text-align: center; padding: 28px 16px; color: var(--muted); font-size: 12.5px; }
footer a { color: var(--muted); text-decoration: none; margin: 0 7px; }
footer a:hover { color: var(--accent); }
.footer-links { margin-bottom: 10px; }
.footer-warn { font-size: 11px; color: var(--muted); max-width: 640px; margin: 10px auto 0; line-height: 1.6; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS — mobile-first upgrades
════════════════════════════════════════════════════════════ */

/* 480px — small phones in landscape / large phones */
@media (min-width: 480px) {
  .container    { padding: 14px 16px 60px; }
  .stat-grid    { grid-template-columns: repeat(3, 1fr); }
  .stat-num     { font-size: 1.9rem; }
}

/* 640px — small tablet / large phone landscape */
@media (min-width: 640px) {
  .site-header  { padding: 0 20px; }
  .hero         { padding: 18px 20px; }
  .container    { padding: 14px 20px 60px; }
  .stat-grid    { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .platform-grid { grid-template-columns: repeat(3, 1fr); }
  textarea#inputText { min-height: 240px; font-size: 15px; }
}

/* 768px — tablet portrait */
@media (min-width: 768px) {
  .stat-grid    { grid-template-columns: repeat(5, 1fr); }
  .detail-row   { flex-direction: row; }
  .time-card, .read-card { flex: 1; }
  .toolbar      { flex-direction: row; align-items: center; }
  .toolbar-top  { flex: 1; }
  textarea#inputText { min-height: 260px; }
}

/* 1024px — desktop */
@media (min-width: 1024px) {
  .site-header  { padding: 0 24px; height: 54px; }
  .hero         { padding: 20px 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .hero-top     { flex: 1; }
  .feature-pills { margin-top: 0; }
  .container    { padding: 16px 24px 60px; }
  .stat-grid    { gap: 12px; margin-bottom: 14px; }
  .platform-grid { grid-template-columns: repeat(3, 1fr); }
}