/* ============================================================
   English Toolkit — shared design system
   ============================================================ */
:root {
  --bg: #f6f7fb;
  --bg-soft: #eef0f8;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --border: #e6e8f0;
  --text: #1a1d29;
  --muted: #6b7185;
  --faint: #9aa0b4;

  --brand: #5b5bf0;
  --brand-2: #8a5cf6;
  --brand-soft: #ececff;
  --accent: #14b8a6;
  --warn: #f59e0b;
  --danger: #ef4444;
  --ok: #16a34a;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 23, 41, .06), 0 1px 3px rgba(20, 23, 41, .04);
  --shadow: 0 8px 30px rgba(28, 30, 60, .08);
  --shadow-lg: 0 20px 50px rgba(28, 30, 60, .14);
  --grad: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(138, 92, 246, .10), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(91, 91, 240, .10), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

/* ---------- Top nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(12px);
  background: rgba(255, 255, 255, .72);
  border-bottom: 1px solid var(--border);
}
.nav__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -.02em;
  text-decoration: none;
  color: var(--text);
  font-size: 17px;
}
.brand__mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--grad);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 4px 12px rgba(91, 91, 240, .4);
}
.nav__links { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.nav__links a {
  font-size: 13.5px;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 9px;
  font-weight: 500;
  transition: .15s;
  white-space: nowrap;
}
.nav__links a:hover { background: var(--brand-soft); color: var(--brand); }
.nav__links a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* ---------- Layout ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 22px; }
.page { max-width: 860px; margin: 0 auto; padding: 38px 22px 80px; }
.page--wide { max-width: 1000px; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 70px 22px 30px; }
.hero h1 {
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1.05;
  letter-spacing: -.03em;
  margin: 14px 0 16px;
  font-weight: 800;
}
.hero h1 .grad {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p { font-size: 18px; color: var(--muted); max-width: 600px; margin: 0 auto; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--brand);
  background: var(--brand-soft);
  padding: 6px 13px; border-radius: 999px;
}

/* ---------- Tool grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 18px;
  margin-top: 38px;
}
.card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
  position: relative;
  overflow: hidden;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: transparent; }
.card__icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 22px;
  margin-bottom: 14px;
  background: var(--brand-soft);
}
.card h3 { margin: 0 0 6px; font-size: 16.5px; font-weight: 700; letter-spacing: -.01em; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card__go {
  margin-top: 14px; font-size: 13px; font-weight: 600; color: var(--brand);
  display: inline-flex; align-items: center; gap: 5px;
}

/* ---------- Tool page header ---------- */
.back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 500;
  margin-bottom: 22px;
}
.back:hover { color: var(--brand); }
.tool-head { margin-bottom: 26px; }
.tool-head .pill { margin-bottom: 14px; }
.tool-head h1 { font-size: clamp(26px, 4vw, 38px); margin: 0 0 8px; letter-spacing: -.025em; font-weight: 800; }
.tool-head p { color: var(--muted); font-size: 16px; margin: 0; max-width: 640px; }

/* ---------- Panels & forms ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.panel h2 { margin: 0 0 4px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.panel .sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 7px; }
.field .hint { color: var(--faint); font-weight: 400; font-size: 12.5px; }

.row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.row-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 620px){ .row, .row-3 { grid-template-columns: 1fr; } }

input[type=number], input[type=text], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(91, 91, 240, .12);
}
textarea { resize: vertical; min-height: 200px; line-height: 1.6; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7185' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-weight: 600; font-size: 15px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  background: var(--grad); color: #fff;
  box-shadow: 0 6px 16px rgba(91, 91, 240, .32);
  transition: .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(91, 91, 240, .4); }
.btn:active { transform: translateY(0); }
.btn--ghost {
  background: var(--surface-2); color: var(--text); box-shadow: none;
  border: 1.5px solid var(--border);
}
.btn--ghost:hover { background: var(--bg-soft); box-shadow: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Result blocks ---------- */
.result {
  background: linear-gradient(135deg, rgba(91,91,240,.06), rgba(138,92,246,.06));
  border: 1px solid var(--brand-soft);
  border-radius: var(--radius);
  padding: 24px;
}
.score-big {
  font-size: 60px; font-weight: 800; letter-spacing: -.04em;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  line-height: 1;
}
.score-label { color: var(--muted); font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
}
.stat__num { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.stat__lbl { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-top: 2px; }

.badge {
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
}
.badge--ok { background: #dcfce7; color: #15803d; }
.badge--warn { background: #fef3c7; color: #b45309; }
.badge--danger { background: #fee2e2; color: #b91c1c; }
.badge--info { background: var(--brand-soft); color: var(--brand); }

table.t { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.t th, table.t td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.t th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
table.t tr:last-child td { border-bottom: none; }

.muted { color: var(--muted); }
.hidden { display: none !important; }
.note { font-size: 13px; color: var(--faint); margin-top: 14px; }

/* worksheet / quiz output */
.sheet {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 30px; box-shadow: var(--shadow);
}
.sheet h3 { margin: 0 0 4px; }
.q-item { padding: 12px 0; border-bottom: 1px dashed var(--border); }
.q-item:last-child { border-bottom: none; }
.q-num { font-weight: 700; color: var(--brand); margin-right: 6px; }
.options { margin: 8px 0 0; padding-left: 22px; color: var(--text); }
.options li { margin: 3px 0; list-style: upper-alpha; }
.answer-key { background: var(--surface-2); border-radius: var(--radius-sm); padding: 16px 20px; margin-top: 18px; }
.answer-key h4 { margin: 0 0 8px; font-size: 14px; }
.answer-key .keys { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 14px; }

/* ---------- Validation ---------- */
.error-msg {
  display: none;
  align-items: center;
  gap: 5px;
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 6px;
  animation: errIn .14s ease;
}
.error-msg.warn-msg { color: var(--warn); }
@keyframes errIn { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
input.invalid, select.invalid, textarea.invalid {
  border-color: var(--danger) !important;
  background: #fff6f6 !important;
}
input.invalid:focus, select.invalid:focus, textarea.invalid:focus {
  box-shadow: 0 0 0 4px rgba(239, 68, 68, .12) !important;
}
.form-alert {
  display: none;
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  font-size: 13.5px;
  font-weight: 600;
  margin-top: 16px;
}

.footer { text-align: center; color: var(--faint); font-size: 13px; padding: 40px 0 30px; }

@media print {
  .nav, .back, .btn-row, .no-print { display: none !important; }
  body { background: #fff; }
  .sheet { box-shadow: none; border: none; }
}
