/* Lipogram Composer — only what's unique to it. Tokens, body, top-bar,
   header, kicker and note live in /lib/composer-base.css. */
:root {
  /* The one "off" tone, thinned out for washes and hairlines. */
  --off-wash: color-mix(in srgb, var(--off) 16%, transparent);
  --off-line: color-mix(in srgb, var(--off) 45%, transparent);
  --off-rule: color-mix(in srgb, var(--off) 80%, transparent);
}

.lipo-root {
  min-height: calc(100vh - 48px);
  padding: 0 24px 120px;
}

.lipo-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 0 40px;
}

/* Mode switch — Lipogram / Univocalic */
.lipo-mode-switch {
  display: inline-flex;
  margin-top: 18px;
  background: rgba(26, 23, 20, 0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}
.lipo-mode-switch button {
  background: transparent;
  border: 0;
  padding: 6px 14px;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: #4a453e;
  cursor: pointer;
  border-radius: 2px;
}
.lipo-mode-switch button.is-on {
  background: var(--ink);
  color: var(--bg-page);
}

/* Alphabet strip — the control AND the readout. One row of 26 on a wide
   page, a–m over n–z on a narrow one, 9-wide on a phone. */
.lipo-alphabet {
  display: grid;
  grid-template-columns: repeat(26, minmax(0, 1fr));
  gap: 2px;
}

.lipo-letter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 8px 0 6px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--font-mono);
  line-height: 1;
  color: var(--ink-faint); /* unused letters sit back */
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.lipo-letter.is-used { color: var(--ink); }
.lipo-letter:hover:not(:disabled) {
  background: var(--bg-card-hit);
  border-color: rgba(26, 23, 20, 0.4);
}
/* Inert (consonants in univocalic mode): readout only, so no card. */
.lipo-letter:disabled {
  cursor: default;
  background: transparent;
  border-color: transparent;
}

.lipo-letter-glyph { font-size: 0.95rem; }
.lipo-letter-count {
  min-height: 1em;
  font-size: 0.56rem;
  color: var(--ink-mute);
}

/* Banned: struck through, sunk off the card. Red only if one got in. */
.lipo-letter.is-banned {
  background: transparent;
  border-style: dashed;
  color: var(--ink-faint);
}
.lipo-letter.is-banned .lipo-letter-glyph { text-decoration: line-through; }
.lipo-letter.is-stray {
  border-style: solid;
  border-color: var(--off-line);
  background: var(--off-wash);
  color: var(--off);
}
.lipo-letter.is-stray .lipo-letter-count { color: var(--off); font-weight: 700; }

/* Univocalic: the one vowel that stays. */
.lipo-letter.is-on,
.lipo-letter.is-on:hover:not(:disabled) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg-page);
}
.lipo-letter.is-on .lipo-letter-count { color: rgba(243, 242, 239, 0.7); }

.lipo-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 12px;
}

.lipo-link {
  background: transparent;
  border: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-mute);
  cursor: pointer;
}
.lipo-link:hover,
.lipo-link.is-on { color: var(--ink); }

/* Editor — title, then the body over its highlight backdrop */
.lipo-editor {
  margin-top: 24px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 160ms ease, background 160ms ease;
}
.lipo-editor:focus-within { background: var(--bg-card-hit); }
.lipo-editor--ok {
  border-color: var(--ok-line);
  background: var(--bg-card-hit);
}
.lipo-editor--off { border-color: var(--off-line); }

.lipo-title {
  display: block;
  width: 100%;
  padding: 14px 18px 10px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
  outline: none;
}
.lipo-title.is-off { border-bottom-color: var(--off-rule); }
.lipo-title::placeholder,
.lipo-body::placeholder {
  color: rgba(26, 23, 20, 0.3);
  font-style: italic;
}

.lipo-field { position: relative; }

/* The two layers must agree on EVERY metric or the marks drift off their
   glyphs. Kerning and ligatures are off on both: a <mark> boundary breaks
   them in the mirror (an "fi" ligature, a kerned pair) but not in the
   textarea, and the widths stop matching. */
.lipo-backdrop,
.lipo-body {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 16px 18px 20px;
  border: 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 400;
  font-style: normal;
  line-height: 1.55;
  letter-spacing: 0;
  word-spacing: 0;
  text-align: left;
  text-indent: 0;
  text-transform: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: normal;
  tab-size: 4;
  font-kerning: none;
  font-variant-ligatures: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.lipo-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: transparent;
  pointer-events: none;
  user-select: none;
}

/* Wash and underline only — nothing that takes up layout space. */
.lipo-backdrop mark {
  margin: 0;
  padding: 0;
  color: transparent;
  background: var(--off-wash);
  border-radius: 2px;
  box-shadow: inset 0 -2px 0 var(--off-rule);
}

.lipo-body {
  position: relative;
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  outline: none;
  resize: none;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
}

/* iOS Safari insets textarea text by 3px a side, whatever the padding. */
@supports (-webkit-touch-callout: none) {
  .lipo-backdrop {
    padding-left: 21px;
    padding-right: 21px;
  }
}

/* Status — the verdict, then the offending words */
.lipo-status {
  margin-top: 12px;
  font-family: var(--font-mono);
}

.lipo-status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  font-size: 0.74rem;
  letter-spacing: 0.5px;
}

.lipo-status-constraint { color: var(--ink-mute); }
.lipo-status-read { font-weight: 700; color: var(--ink-mute); }
.lipo-status-read--ok { color: var(--ok); }
.lipo-status-read--off { color: var(--off); }

.lipo-strays {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin: 10px 0 0;
  padding: 0;
}
.lipo-strays li { max-width: 100%; }

.lipo-stray {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: transparent;
  border: 1px solid var(--off-line);
  border-radius: 2px;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.lipo-stray:hover {
  background: var(--off-wash);
  color: var(--ink);
}
.lipo-stray-where { color: var(--ink-mute); }

/* Action row + archive — the haiku family, under this toy's prefix */
.lipo-actions {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 16px;
}
.lipo-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.lipo-btn {
  background: transparent;
  border: 1px solid rgba(26, 23, 20, 0.25);
  color: rgba(26, 23, 20, 0.75);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.lipo-btn:hover:not(:disabled) {
  background: rgba(26, 23, 20, 0.06);
  color: var(--ink);
  border-color: rgba(26, 23, 20, 0.5);
}
.lipo-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.lipo-btn--primary {
  border-color: rgba(26, 23, 20, 0.55);
  color: var(--ink);
}
.lipo-btn--primary:hover:not(:disabled) {
  background: var(--ink); color: var(--bg-page); border-color: var(--ink);
}
.lipo-btn--primary.is-glow {
  border-color: rgba(42, 77, 51, 0.7);
  color: var(--ok);
  background: var(--ok-wash);
}
.lipo-btn--primary.is-glow:hover:not(:disabled) {
  background: rgba(42, 77, 51, 0.9); color: var(--bg-page); border-color: rgba(42, 77, 51, 0.95);
}

.lipo-archive {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.lipo-archive-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.lipo-archive-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.lipo-archive-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 14px;
}
.lipo-archive-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.lipo-archive-item--fits {
  border-color: rgba(53, 94, 59, 0.4);
  background: var(--bg-card-hit);
}
.lipo-archive-text {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--ink);
}
.lipo-archive-title {
  font-size: 1.15rem;
  font-weight: 500;
  margin-bottom: 4px;
}
.lipo-archive-line {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.lipo-archive-more {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.5px;
  color: var(--ink-mute);
}
.lipo-archive-meta {
  display: flex; flex-direction: column;
  align-items: flex-end; justify-content: space-between;
  gap: 8px;
  font-family: var(--font-mono);
}
.lipo-archive-verdict {
  display: flex; flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}
.lipo-archive-constraint {
  max-width: 22ch;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  color: var(--ink-mute);
}
.lipo-archive-num { font-weight: 700; font-size: 0.85rem; }
.lipo-archive-num--ok { color: var(--ok); }
.lipo-archive-num--off { color: var(--off); }
.lipo-archive-buttons { display: flex; gap: 10px; }

/* Mobile */
@media (max-width: 760px) {
  .lipo-alphabet { grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 3px; }
}

@media (max-width: 640px) {
  .lipo-root { padding: 0 14px 80px; }
  .lipo-page { padding: 32px 0 24px; }
  .compose-head h1 { font-size: 1.7rem; }
  .section-note { font-size: 0.9rem; }
  .lipo-title { font-size: 1.3rem; padding: 12px 14px 8px; }
  .lipo-backdrop,
  .lipo-body { font-size: 1.1rem; padding: 12px 14px 16px; }
  .lipo-actions { flex-wrap: wrap; }
  .lipo-btn { padding: 6px 10px; font-size: 0.68rem; }
  .lipo-archive { margin-top: 40px; }
  .lipo-archive-item { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px; }
  .lipo-archive-text { font-size: 1rem; }
  .lipo-archive-meta { flex-direction: row; width: 100%; justify-content: space-between; align-items: flex-end; }
  .lipo-archive-verdict { align-items: flex-start; text-align: left; }

  @supports (-webkit-touch-callout: none) {
    .lipo-backdrop { padding-left: 17px; padding-right: 17px; }
  }
}

@media (max-width: 480px) {
  .lipo-alphabet { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
  .lipo-letter { padding: 10px 0 8px; }
  .lipo-letter-glyph { font-size: 1rem; }
  .lipo-letter-count { font-size: 0.6rem; }
}
