/* ===============================
   🎨 THEME VARIABLES
================================ */

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;

  --accent: #2563eb;
  --accent-soft: rgba(37,99,235,0.15);

  --success: #16a34a;
  --danger: #dc2626;

  --radius: 18px;
}

body.dark {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #334155;
  --accent-soft: rgba(37,99,235,0.25);
}

/* ===============================
   🌍 GLOBAL
================================ */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background .3s ease, color .3s ease;
}

.container {
  max-width: 1250px;
  margin: auto;
  padding: 40px 20px;
}

/* ===============================
   📦 MAIN CARD
================================ */

.app {
  background: var(--card);
  padding: 35px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 15px 45px rgba(0,0,0,0.06);
  transition: .3s ease;
}

/* ===============================
   🧠 PREMIUM HEADER
================================ */

header {
  padding: 25px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 25px;
  margin-bottom: 30px;
  background: linear-gradient(145deg, var(--card), var(--bg));
  box-shadow: 0 8px 30px rgba(0,0,0,0.05);
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand .muted {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ===============================
   🎛 INPUTS
================================ */

input, select, textarea {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ===============================
   🔘 BUTTONS
================================ */

.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all .25s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37,99,235,0.3);
}

.btn.secondary {
  background: var(--border);
  color: var(--text);
}

.btn.secondary:hover {
  box-shadow: none;
}

.btn.danger {
  background: var(--danger);
}

.btn.danger:hover {
  box-shadow: 0 8px 20px rgba(220,38,38,0.3);
}

/* ===============================
   🌓 MODERN TOGGLE
================================ */

.theme-switch {
  position: relative;
  width: 55px;
  height: 28px;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 30px;
  transition: .3s;
  cursor: pointer;
}

.slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: .3s;
  box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

.theme-switch input:checked + .slider {
  background: var(--accent);
}

.theme-switch input:checked + .slider::before {
  transform: translateX(27px);
}

/* ===============================
   📊 GRID
================================ */

.grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 30px;
}

@media(max-width: 950px){
  .grid {
    grid-template-columns: 1fr;
  }
}

/* ===============================
   🪪 CARDS
================================ */

.card {
  background: var(--card);
  padding: 25px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 10px 35px rgba(0,0,0,0.04);
}

/* ===============================
   📈 METRICS
================================ */

.title-row { 
    display:flex; 
    align-items:center; 
    justify-content:space-between; 
    gap:12px; 
    margin-bottom: 10px; 
}

.title-row h2 { 
    margin:0; 
    font-size: 18px; 
    letter-spacing: 0.2px; 
}

.metrics {
  display: grid; 
  grid-template-columns: repeat(4, 1fr); 
  gap: 10px; 
  margin: 12px 0 16px;
}

@media (max-width: 640px) {
  .metrics { 
     grid-template-columns: repeat(2, 1fr); 
    }
}

.metric {
  border: 1px dashed var(--outline); 
  border-radius: 14px; 
  padding: 12px; 
  text-align:center;
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.03));
}
.metric .label { 
    font-size: 12px; 
    color: var(--muted); 
}

.metric .value { 
    font-size: 20px; 
    font-weight: 800; 
    margin-top: 4px; 
}

.actions { 
    display:flex; 
    flex-wrap:wrap; 
    gap: 10px; 
    margin-top: 12px; 
}
/* ===============================
   ⌨ PREVIEW
================================ */

.preview {
  border: 1px solid var(--border);
  padding: 22px;
  min-height: 180px;
  margin: 20px 0;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.8;
  border-radius: 14px;
  background: var(--bg);
  font-size: 15px;
}

.char.correct { color: var(--success); }
.char.incorrect { color: var(--danger); text-decoration: underline; }
.char.current { background: var(--accent-soft); border-radius: 4px; }

/* ===============================
   📊 PROGRESS
================================ */

.progress {
  height: 10px;
  background: var(--border);
  border-radius: 20px;
  overflow: hidden;
}

.bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), #3b82f6);
  transition: width 1s linear;
}

/* ===============================
   📝 TEXTAREA
================================ */

textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  margin-top: 12px;
}

/* ===============================
   🏆 TABLE
================================ */

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  text-align: left;
}

th {
  font-weight: 600;
  color: var(--muted);
}

/* ===============================
   🎉 CENTER MODAL OVERLAY
================================ */

.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  z-index: 999;
}

.result-box {
  background: var(--card);
  padding: 35px;
  border-radius: 20px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  animation: pop .3s ease;
}

.result-box h2 {
  margin-top: 0;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 20px;
}

@keyframes pop {
  from { transform: scale(.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ===============================
   👣 FOOTER
================================ */

footer {
  text-align: center;
  margin-top: 35px;
  font-size: 13px;
  color: var(--muted);
}