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

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1a1a1a;
  --border: #222;
  --border-focus: #444;
  --text: #e8e8e8;
  --text-2: #888;
  --text-3: #555;
  --accent: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- Loading overlay ---------- */
#loading-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 1000;
  transition: opacity .4s;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; visibility: hidden; }

.loading-title { font-size: 1.4rem; font-weight: 600; letter-spacing: -.02em; margin-bottom: 8px; }
.loading-sub { font-size: .82rem; color: var(--text-2); margin-bottom: 24px; }
.progress-wrap {
  width: 320px; max-width: 80vw;
  background: var(--surface2);
  border-radius: 4px; height: 4px;
  overflow: hidden; margin-bottom: 12px;
}
.progress-bar {
  height: 100%; width: 0%;
  background: var(--accent);
  transition: width .3s ease;
  border-radius: 4px;
}
.progress-text { font-size: .75rem; color: var(--text-3); font-family: var(--font-mono); }

/* ---------- App layout ---------- */
#app {
  display: none;
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 48px;
}
#app.visible { display: block; }

/* ---------- Header ---------- */
header { margin-bottom: 28px; }
.pill {
  display: inline-block; font-size: .65rem; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 9px; border-radius: 20px;
  background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.15);
  color: var(--accent); margin-bottom: 8px;
}
h1 { font-size: 1.4rem; font-weight: 600; letter-spacing: -.02em; }
.subtitle { font-size: .82rem; color: var(--text-2); margin-top: 4px; }

/* ---------- How it works (collapsible) ---------- */
.info-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 28px;
}
.info-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 14px 18px; cursor: pointer;
  font-size: .68rem; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-2);
  background: none; border: none; width: 100%;
  text-align: left;
}
.info-toggle .chevron {
  transition: transform .15s; font-size: .6rem;
}
.info-toggle[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.info-body {
  padding: 0 18px 18px; font-size: .82rem;
  color: var(--text-2); line-height: 1.7;
  display: none;
}
.info-body.open { display: block; }
.info-body p { margin-bottom: 10px; }
.info-body strong { color: var(--text); }

/* ---------- Input section (full width) ---------- */
.input-section { margin-bottom: 28px; }

.section-label {
  font-size: .68rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 4px;
}
.section-hint {
  font-size: .75rem; color: var(--text-3); margin-bottom: 12px;
}

textarea {
  width: 100%; min-height: 100px; max-height: 300px;
  resize: vertical; padding: 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-family: var(--font-sans); font-size: .95rem;
  line-height: 1.6; outline: none;
  transition: border-color .15s;
}
textarea:focus { border-color: var(--border-focus); }
textarea::placeholder { color: var(--text-3); }

.input-meta {
  font-size: .75rem; color: var(--text-3);
  margin-top: 6px; font-family: var(--font-mono);
}

.lang-detect {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 12px;
}
.lang-badge {
  font-size: .85rem; font-weight: 700;
  padding: 4px 14px; border-radius: 6px;
  background: var(--accent); color: #fff;
  border: 2px solid #60a5fa;
  letter-spacing: .06em;
  box-shadow: 0 0 8px rgba(59,130,246,.4);
}

/* ---------- Example buttons ---------- */
.examples {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-top: 10px;
}
.examples button {
  background: transparent; border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 10px;
  font-size: .7rem; font-weight: 600;
  letter-spacing: .05em; color: var(--text-2);
  cursor: pointer; transition: all .15s;
  font-family: var(--font-sans);
}
.examples button:hover {
  border-color: var(--border-focus); color: var(--text);
}

/* ---------- Stats grid (3 columns) ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}
.stat-card-header {
  font-size: .68rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.stat-card-header .tag {
  font-size: .6rem; font-weight: 500;
  padding: 1px 6px; border-radius: 4px;
  letter-spacing: .04em; text-transform: none;
}
#u3d-lang-label {
  color: #60a5fa;
  font-weight: 700;
  padding: 2px 8px;
  border: 1.5px solid rgba(59,130,246,.5);
  border-radius: 4px;
  background: rgba(59,130,246,.12);
}

.tag-u2 { background: rgba(34,197,94,.12); color: var(--green); }
.tag-u3s { background: rgba(59,130,246,.12); color: var(--accent); }
.tag-u3d {
  background: var(--accent);
  color: #fff;
  border: 2px solid #60a5fa;
  box-shadow: 0 0 8px rgba(59,130,246,.4);
  font-weight: 700;
}

.stat-row {
  display: flex; justify-content: space-between;
  align-items: center; padding: 4px 0;
  font-size: .78rem;
}
.stat-row .label { color: var(--text-2); }
.stat-row .value { font-family: var(--font-mono); font-weight: 500; }

/* ---------- Gauge bar ---------- */
.gauge-track {
  height: 4px; background: var(--surface2);
  border-radius: 2px; margin-top: 2px; margin-bottom: 2px;
  overflow: hidden;
}
.gauge-fill {
  height: 100%; border-radius: 2px;
  transition: width .4s ease;
}
.gauge-green { background: var(--green); }
.gauge-blue { background: var(--accent); }
.gauge-orange { background: var(--orange); }

/* ---------- Verification badge ---------- */
.verify { font-size: .72rem; }
.verify-ok { color: var(--green); }
.verify-fail { color: var(--red); }

/* ---------- Winner badge ---------- */
.stat-card.winner {
  border-color: var(--green);
  position: relative;
}
.stat-card.winner::before {
  content: 'Winner';
  position: absolute;
  top: -10px; left: 16px;
  font-size: .6rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 1px 8px; border-radius: 4px;
  background: var(--green); color: #0a0a0a;
}

/* ---------- Placeholder state ---------- */
.stat-placeholder {
  color: var(--text-3); font-size: .78rem;
  text-align: center; padding: 20px 0;
}

/* ---------- Footer ---------- */
footer {
  text-align: center; padding: 40px 0 24px;
  font-size: .75rem; color: var(--text-3);
}
footer a {
  color: var(--text-2); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
footer a:hover { color: var(--text); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  #app { padding: 32px 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  #app { padding: 24px 16px; }
  h1 { font-size: 1.1rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .progress-wrap { width: 260px; }
}
