*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --accent: #3b82f6;
  --bg: #0f172a;
  --bg2: #1a1a2e;
  --bg3: #16213e;
  --card: #1e1e35;
  --border: rgba(59, 130, 246, 0.15);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --green: #22c55e;
  --yellow: #eab308;
  --orange: #f97316;
  --red: #ef4444;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Sarabun', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  background: rgba(15,15,26,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 14px 0;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 1.3rem; font-weight: 700; }
.logo-icon { font-size: 1.5rem; }
.logo-accent { color: var(--primary); }
.nav-links { display: flex; gap: 24px; }
.nav-links a { color: var(--text-muted); text-decoration: none; font-size: 0.95rem; transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }

/* Hero */
.hero {
  padding: 80px 0 60px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.15) 0%, transparent 70%);
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 700; line-height: 1.2; margin-bottom: 16px; }
.gradient-text { background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero-sub { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 28px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.badge { background: var(--card); border: 1px solid var(--border); padding: 6px 14px; border-radius: 999px; font-size: 0.85rem; color: var(--text-muted); }

/* Analyzer */
.analyzer-section { padding: 40px 0; }
.analyzer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
@media (max-width: 768px) { .analyzer-grid { grid-template-columns: 1fr; } }

.input-panel, .score-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.panel-header h2, .panel-header h3 { font-size: 1.1rem; font-weight: 600; }
.char-count { font-size: 0.82rem; color: var(--text-muted); }

.platform-selector { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; align-items: center; }
.platform-label { font-size: 0.82rem; color: var(--text-muted); margin-right: 4px; }
.platform-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: 'Sarabun', sans-serif;
  transition: all 0.2s;
}
.platform-btn:hover { border-color: var(--primary); color: var(--text); }
.platform-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Sarabun', sans-serif;
  font-size: 0.95rem;
  padding: 14px;
  resize: vertical;
  line-height: 1.7;
  transition: border-color 0.2s;
}
textarea:focus { outline: none; border-color: var(--primary); }
textarea::placeholder { color: var(--text-muted); }

.input-actions { display: flex; gap: 10px; margin-top: 14px; justify-content: flex-end; flex-wrap: wrap; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: 'Sarabun', sans-serif;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, transform 0.1s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--bg2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { color: var(--text); border-color: var(--text-muted); }

/* Score Panel */
.score-empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.hidden { display: none !important; }

.main-score-card { display: flex; align-items: center; gap: 24px; margin-bottom: 20px; }

.score-circle { position: relative; width: 110px; height: 110px; flex-shrink: 0; }
.score-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-bg { fill: none; stroke: var(--border); stroke-width: 8; }
.score-fill {
  fill: none;
  stroke: var(--green);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  transition: stroke-dashoffset 1s ease, stroke 0.5s;
}
.score-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
  font-weight: 700;
}

.score-label { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.reader-level { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 6px; }
.platform-score { font-size: 0.85rem; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.stat-icon { font-size: 1.2rem; margin-bottom: 4px; }
.stat-value { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); }

.action-items { margin-bottom: 16px; }
.action-items h3 { font-size: 0.95rem; margin-bottom: 10px; }
.action-items ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.action-items li {
  background: var(--bg2);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.export-bar { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-export {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-family: 'Sarabun', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.btn-export:hover { border-color: var(--primary); color: var(--primary); }

/* Highlight Section */
.highlight-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.legend { display: flex; gap: 12px; flex-wrap: wrap; }
.legend-item {
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 4px;
}
.hard-sentence-legend { background: rgba(239,68,68,0.2); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.hard-word-legend { background: rgba(245,158,11,0.2); color: #fcd34d; border: 1px solid rgba(245,158,11,0.3); }
.passive-legend { background: rgba(99,102,241,0.2); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.3); }

.highlighted-text {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  font-size: 0.95rem;
  line-height: 2;
  margin-top: 14px;
}
.highlight-hard-sentence { background: rgba(239,68,68,0.2); border-radius: 3px; padding: 1px 0; }
.highlight-hard-word { background: rgba(245,158,11,0.25); border-radius: 3px; padding: 1px 2px; cursor: help; border-bottom: 2px solid #f59e0b; }
.highlight-passive { background: rgba(99,102,241,0.2); border-radius: 3px; padding: 1px 2px; }

/* Vocab */
.vocab-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.vocab-section h3 { margin-bottom: 16px; }
.vocab-table-wrapper { overflow-x: auto; }
.vocab-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.vocab-table th { background: var(--bg2); padding: 10px 14px; text-align: left; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.vocab-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.vocab-table tr:last-child td { border-bottom: none; }
.vocab-table tr:hover td { background: var(--bg2); }
.suggest-word { color: var(--green); font-weight: 500; }
.word-count-badge { background: var(--primary); color: #fff; padding: 2px 8px; border-radius: 999px; font-size: 0.78rem; }

/* Compare */
.compare-section {
  padding: 60px 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.compare-section h2 { text-align: center; margin-bottom: 8px; }
.section-sub { text-align: center; color: var(--text-muted); margin-bottom: 32px; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 600px) { .compare-grid { grid-template-columns: 1fr; } }
.compare-input label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 8px; color: var(--text-muted); }
.compare-section .btn-primary { margin: 0 auto; display: flex; }

.compare-results {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
}
.compare-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.compare-card.winner { border-color: var(--green); }
.compare-card .big-score { font-size: 2.5rem; font-weight: 700; }
.compare-card .compare-label { color: var(--text-muted); font-size: 0.88rem; margin-top: 4px; }
.compare-vs { text-align: center; font-size: 1.4rem; font-weight: 700; color: var(--text-muted); }
.winner-badge { display: inline-block; background: var(--green); color: #000; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; margin-top: 8px; }

/* How it works */
.how-section { padding: 60px 0; }
.how-section h2 { text-align: center; margin-bottom: 8px; }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin: 32px 0; }
@media (max-width: 768px) { .how-grid { grid-template-columns: 1fr; } }
.how-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.how-icon { font-size: 2rem; margin-bottom: 12px; }
.how-card h3 { font-size: 1rem; margin-bottom: 8px; }
.how-card p { color: var(--text-muted); font-size: 0.88rem; }

.score-table { text-align: center; }
.score-table h3 { margin-bottom: 16px; }
.score-range-grid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.score-range {
  background: var(--card);
  border: 1px solid var(--clr, var(--border));
  border-radius: 10px;
  padding: 14px 20px;
  text-align: center;
  min-width: 110px;
}
.range-score { display: block; font-size: 1.1rem; font-weight: 700; color: var(--clr); }
.range-label { display: block; font-size: 0.88rem; font-weight: 600; margin: 4px 0 2px; }
.range-desc { display: block; font-size: 0.78rem; color: var(--text-muted); }

/* Footer */
.site-footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.footer-sub { margin-top: 6px; font-size: 0.8rem; }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Score color states */
.score-great .score-fill { stroke: #22c55e; }
.score-good .score-fill { stroke: #84cc16; }
.score-ok .score-fill { stroke: #eab308; }
.score-hard .score-fill { stroke: #f97316; }
.score-vhard .score-fill { stroke: #ef4444; }
.score-great .score-number { color: #22c55e; }
.score-good .score-number { color: #84cc16; }
.score-ok .score-number { color: #eab308; }
.score-hard .score-number { color: #f97316; }
.score-vhard .score-number { color: #ef4444; }

@media print {
  .site-header, .input-panel, .compare-section, .how-section, .site-footer, .export-bar, .input-actions, .platform-selector { display: none !important; }
  .analyzer-section { padding: 0; }
  body { background: #fff; color: #000; }
  .score-panel, .highlight-section, .vocab-section { background: #fff; border: 1px solid #ddd; }
}
