/* ── RESET & VARIABLES ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #191a1e;
  --bg-secondary: #191a1e;
  --bg-card: #2c2f33;
  --bg-input: #23252a;
  --border: #545861;
  --border-focus: #ca4b44;
  --text-primary: #e5e7eb;
  --text-secondary: #a6a9ad;
  --text-muted: #a6a9ad;
  --accent: #ca4b44;
  --accent-hover: #d45b55;
  --accent-glow: rgba(202, 75, 68, 0.15);
  --danger: #ff4a6e;
  --success: #2ecc71;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { scroll-behavior: smooth; }

html, body {
  min-height: 100vh;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── NAV ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #2c2f33;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.nav-inner {
  max-width: 1050px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 17px;
}
.nav-brand img { height: 32px; width: 32px; border-radius: 6px; }
.nav-tag {
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}
.nav-tag:hover { color: var(--accent-hover); }

/* ── HERO ── */
.hero {
  padding: 60px 24px 40px;
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}
.hero h1 {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  color: var(--text-primary);
}
.hero p {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 520px;
  margin: 0 auto 10px;
}

/* ── TOOL WRAPPER ── */
.tool-wrap { max-width: 1050px; margin: 0 auto; padding: 0 24px 80px; }

/* ── FORM ELEMENTS ── */
.input {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input::placeholder { color: var(--text-muted); }

/* ── BUTTONS ── */
.btn {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.1s, border-color 0.2s, color 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-secondary {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text-primary); border-color: var(--accent); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  font-size: 14px;
  padding: 10px 18px;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ── TOOLBAR ── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.toolbar .input { flex: 1; min-width: 220px; }
.count {
  padding: 9px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
}
.count strong { color: var(--text-primary); font-size: 15px; font-variant-numeric: tabular-nums; }

/* ── CARDS ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.category { margin-bottom: 16px; overflow: hidden; }
.cathead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.card h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.cat-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── WORD GRID ── */
.words {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 10px;
  padding: 18px 24px 22px;
}
.word {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  color: var(--text-primary);
  transition: background 0.15s, border-color 0.15s;
}
.word:hover { background: rgba(255, 255, 255, 0.06); }
.word:has(input:checked) { background: var(--accent-glow); border-color: rgba(202, 75, 68, 0.4); }
.word input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}
.empty { padding: 24px; color: var(--text-muted); font-size: 14px; text-align: center; }

/* ── CUSTOM TERMS ── */
.custom-body { padding: 20px 24px; }
.custom { display: flex; gap: 10px; align-items: flex-start; }
.custom .input { flex: 1; min-width: 0; }
.custom .btn { min-height: 47px; }
.custom-input {
  min-height: 47px;
  max-height: 200px;
  resize: vertical;
  line-height: 1.5;
}
.custom-status {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 10px;
}
.custom-status:empty { display: none; }
.words-custom { padding: 0; }
.words-custom:not(:empty) { margin-top: 14px; }
.word.covered { opacity: 0.5; }
.word.covered:has(input:checked) { background: transparent; border-color: var(--border); }
.word-note { color: var(--text-muted); font-size: 12px; margin-left: auto; white-space: nowrap; }

/* ── OUTPUT ── */
.output { padding: 24px; margin-top: 24px; }
.outhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.copy-status {
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
  min-height: 20px;
  margin-bottom: 8px;
}
textarea {
  width: 100%;
  resize: vertical;
  min-height: 120px;
  max-height: 300px;
  padding: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── HINT ── */
.hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 16px;
  text-align: center;
}

/* ── FOOTER ── */
.footer {
  text-align: center;
  padding: 28px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1050px;
  margin: 0 auto;
  flex-wrap: wrap;
  gap: 8px;
}
.footer a { color: var(--text-secondary); text-decoration: none; transition: color 0.2s; }
.footer a:hover { color: var(--text-primary); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .words { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .nav { padding: 0 16px; }
  .footer { padding: 22px 16px; }
  .hero, .tool-wrap { padding-left: 16px; padding-right: 16px; }
  .toolbar .input { flex-basis: 100%; }
  .cathead { flex-direction: column; align-items: flex-start; padding: 16px; }
  .cat-actions { justify-content: flex-start; }
  .words { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; gap: 4px; }
  .custom-body, .output { padding: 16px; }
  .outhead { align-items: flex-start; }
}

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