:root {
  --bg: #fafaf7;
  --text: #111;
  --muted: #999;
  --red: #e8333f;
  --border: #e0e0da;
  --serif: 'Instrument Serif', Georgia, serif;
  --display: 'Playfair Display', Georgia, serif;
  --body-serif: 'Noto Serif', Georgia, serif;
  --mono: 'DM Mono', monospace;
}

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

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.deco {
  position: fixed; pointer-events: none; user-select: none; z-index: 0;
  font-size: 120px; opacity: 0.05;
}
.deco--1 { top: -20px; right: 40px; transform: rotate(12deg); }
.deco--2 { bottom: 30px; left: -10px; transform: rotate(-8deg); font-size: 140px; }
.deco--3 { top: 45%; right: -20px; transform: rotate(20deg); font-size: 100px; opacity: 0.035; }

.stamp {
  position: fixed; bottom: 20px; right: 20px; z-index: 0;
  width: 100px; height: 100px; border: 3px solid var(--red);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  transform: rotate(-15deg); opacity: 0.07;
  font-family: var(--mono); font-size: 10px; text-align: center;
  color: var(--red); line-height: 1.3; letter-spacing: 1px; text-transform: uppercase;
}

.marquee {
  overflow: hidden; white-space: nowrap;
  border-bottom: 1px solid var(--border);
  padding: 8px 0; font-size: 10px; letter-spacing: 3px;
  color: var(--muted); text-transform: uppercase;
}
.marquee__inner { display: inline-block; animation: scroll 40s linear infinite; }
@keyframes scroll { from { transform: translateX(0) } to { transform: translateX(-50%) } }

/* nav */
.nav {
  display: flex; justify-content: center; gap: 16px;
  padding: 16px 20px; position: relative; z-index: 2;
}
.nav__link {
  font-family: var(--mono); font-size: 13px; letter-spacing: 1px;
  text-decoration: none; color: var(--muted);
  padding: 4px 0; border-bottom: 1.5px solid transparent;
  transition: all 0.2s;
}
.nav__link:hover { color: var(--text); }
.nav__link--active { color: var(--text); border-bottom-color: var(--red); }
.nav__dot { color: var(--border); }
.nav__count {
  display: inline-block; padding: 1px 6px; border-radius: 8px;
  background: var(--red); color: #fff; font-size: 10px;
}

/* pages */
.page { display: none; position: relative; z-index: 1; }
.page--active { display: block; animation: fadeUp 0.35s ease; }

/* center mogify page vertically on desktop */
@media (min-height: 700px) and (min-width: 601px) {
  #page-mogify.page--active {
    min-height: calc(100vh - 120px);
    display: flex; flex-direction: column; justify-content: center;
  }
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: translateY(0) } }

/* header */
.header { text-align: center; padding: 48px 20px 12px; }
.title {
  font-family: var(--serif); font-size: clamp(56px, 14vw, 130px);
  font-weight: 400; letter-spacing: -3px; line-height: 0.85;
}
.title em { font-family: var(--serif); }
.title span { color: var(--red); font-size: 0.4em; vertical-align: super; letter-spacing: 0; }
.vocab-title { font-size: clamp(40px, 10vw, 90px); }
.subtitle {
  margin-top: 10px; font-size: 11px; letter-spacing: 3px;
  text-transform: uppercase; color: var(--muted);
}

/* main */
.main { max-width: 660px; margin: 0 auto; padding: 24px 20px 0; width: 100%; }

.input-wrap { margin-bottom: 14px; position: relative; }
textarea {
  width: 100%; padding: 18px 20px;
  font-family: var(--mono); font-size: 14px; line-height: 1.6;
  background: #fff; border: 2px solid var(--text); border-radius: 0;
  color: var(--text); resize: vertical; min-height: 100px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea:focus { outline: none; border-color: var(--red); box-shadow: 4px 4px 0 0 var(--red); }
textarea::placeholder { color: #c5c5c0; }
.input-meta {
  position: absolute; bottom: 8px; right: 10px;
  font-size: 10px; color: var(--muted);
}

/* actions — mogify button centered */
.actions { display: flex; gap: 8px; align-items: center; margin-bottom: 20px; }
.btn {
  padding: 12px 28px; font-family: var(--mono); font-size: 13px;
  letter-spacing: 1px; text-transform: lowercase;
  border: 2px solid var(--text); background: var(--text); color: var(--bg);
  cursor: pointer; transition: all 0.15s; position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: var(--red); opacity: 0; transition: opacity 0.15s; z-index: 0;
}
.btn:hover::after { opacity: 1; }
.btn:hover { border-color: var(--red); color: #fff; }
.btn > * { position: relative; z-index: 1; }
.btn:active { transform: translate(2px, 2px); }
.btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
.btn:disabled::after { display: none; }
.btn--sm { padding: 8px 18px; font-size: 11px; }
.btn--ghost { background: transparent; color: var(--text); }
.btn--ghost::after { display: none; }
.btn--ghost:hover { background: var(--text); color: var(--bg); }

.status { font-size: 11px; color: var(--muted); margin-left: auto; font-style: italic; }

/* output */
.output-wrap { animation: fadeUp 0.3s ease; }
.output {
  padding: 24px; background: #fff; border: 2px solid var(--text);
  font-family: var(--mono); font-size: 14px; line-height: 1.8;
  white-space: pre-wrap; word-wrap: break-word;
  box-shadow: 6px 6px 0 0 var(--text);
}

.output-actions {
  display: flex; gap: 8px; align-items: center; margin-top: 12px;
}
.copied-msg { font-size: 11px; color: var(--red); font-style: italic; }

/* highlighted terms in output */
.term-hl {
  background: var(--text); color: var(--bg);
  padding: 1px 5px; cursor: help;
  transition: background 0.15s;
  white-space: nowrap;
}
.term-hl:hover { background: var(--red); color: #fff; }
.term-hl--new { background: var(--red); color: #fff; }
.term-hl--new:hover { background: var(--text); }

.tooltip {
  display: none; position: fixed; z-index: 100;
  padding: 10px 14px; max-width: 300px;
  background: var(--text); color: var(--bg);
  font-family: var(--mono); font-size: 12px; line-height: 1.4;
  pointer-events: none;
  box-shadow: 3px 3px 0 0 var(--red);
}
.tooltip--visible { display: block; animation: fadeUp 0.12s ease; }

.tape {
  max-width: 660px; margin: 32px auto 0; padding: 0 20px; width: 100%;
}
.tape__inner {
  padding: 10px 16px;
  background: repeating-linear-gradient(45deg, #f5e642, #f5e642 10px, #111 10px, #111 20px);
  text-align: center;
}
.tape span {
  background: #111; color: #f5e642; padding: 4px 14px;
  font-size: 10px; letter-spacing: 3px; text-transform: uppercase;
}

/* ── VOCAB PAGE — Wikipedia-style cards ── */
.vocab-controls {
  max-width: 800px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px 20px; flex-wrap: wrap;
}
.vocab-search {
  flex: 1; min-width: 160px; padding: 10px 16px;
  font-family: var(--mono); font-size: 13px;
  background: #fff; border: 1.5px solid var(--border); color: var(--text);
  transition: border-color 0.2s;
}
.vocab-search:focus { outline: none; border-color: var(--text); }
.vocab-search::placeholder { color: var(--muted); }
.vocab-filters {
  display: flex; gap: 6px;
}
.filter {
  padding: 6px 16px; font-family: var(--mono); font-size: 11px;
  letter-spacing: 1px; text-transform: lowercase;
  border: 1.5px solid var(--border); background: transparent;
  color: var(--muted); cursor: pointer; transition: all 0.15s;
}
.filter:hover { border-color: var(--text); color: var(--text); }
.filter--active { border-color: var(--text); background: var(--text); color: var(--bg); }

.vocab-grid {
  max-width: 800px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px; padding: 0 20px 40px;
}

/* wiki card */
.wiki-card {
  padding: 20px 24px; background: #fff;
  border: 1px solid var(--border);
  transition: all 0.2s; position: relative;
}
.wiki-card:hover { border-color: var(--text); box-shadow: 0 2px 12px rgba(0,0,0,0.06); }

.wiki-card__term {
  font-family: var(--display); font-size: 22px; font-weight: 700;
  margin-bottom: 2px; line-height: 1.2;
}
.wiki-card__coined {
  display: inline-block; font-size: 12px;
  color: var(--red); margin-left: 6px; vertical-align: middle;
  cursor: help; opacity: 0.6;
  transition: opacity 0.15s;
}
.wiki-card__coined:hover { opacity: 1; }
.wiki-card__pronunciation {
  font-family: var(--body-serif); font-size: 14px;
  color: var(--muted); font-style: italic; margin-bottom: 8px;
}
.wiki-card__type {
  display: inline-block; font-family: var(--body-serif); font-size: 12px;
  font-style: italic; color: var(--muted); margin-bottom: 8px;
}
.wiki-card__def {
  font-family: var(--body-serif); font-size: 14px; color: #333;
  line-height: 1.5;
}
.wiki-card__def b { font-weight: 700; }
.wiki-card__divider {
  width: 40px; height: 1px; background: var(--border); margin: 10px 0;
}

.wiki-card--coined { border-left: 3px solid var(--red); }

/* footer */
.footer {
  text-align: center; padding: 32px 20px; font-size: 10px;
  color: var(--muted); letter-spacing: 2px; text-transform: uppercase;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); }
::-webkit-scrollbar-thumb:hover { background: var(--text); }

@media (max-width: 600px) {
  .header { padding: 24px 16px 8px; }
  .title { font-size: 48px; letter-spacing: -2px; }
  .main { padding: 16px; }
  .deco, .stamp { display: none; }
  #page-mogify { min-height: auto; justify-content: flex-start; }
  .vocab-grid { grid-template-columns: 1fr; padding: 0 16px 32px; }
  .vocab-controls { padding: 0 16px 16px; }
  .tape { padding: 0 16px; }
  .actions { flex-wrap: wrap; }
  .status { width: 100%; margin: 4px 0 0; }
  .output { padding: 16px; font-size: 13px; box-shadow: 4px 4px 0 0 var(--text); }
  textarea { min-height: 80px; padding: 14px 16px; }
}
