:root {
  --bg: #ebe6dc;
  --panel: #f0ebe2;
  --panel-alt: #ece6dc;
  --panel-border: #cfc6b8;

  --text: #2b2925;
  --muted: #746d63;

  --accent-soft: #e3dccf;

  --upload-accent: #f54927;

  --correct: #2b2925;
  --incorrect-bg: #e9cfcf;
  --incorrect-text: #9a3a3a;
  --current-bg: #3a362f;
  --current-text: #ece6dc;
  --pending: #a89f92;
  --extra-bg: #e5c7c7;
  --extra-text: #973737;

  --shadow: rgba(48, 42, 34, 0.045);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
kbd {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.page-shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.app-layout {
  min-height: calc(100vh - 52px);
  display: grid;
}

.trainer-layout {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 18px;
  min-height: 100%;
}

.field-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* hidden SEO heading (for search engines only) */

.seo-heading {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* header */

.site-header {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.site-title {
  font-family: "Zilla Slab Highlight", serif;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0em;
  text-transform: lowercase;
  color: var(--text);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.site-title:hover {
  opacity: 0.75;
}

/* source cloud */

.source-cloud-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 12px;
}

.genre-cloud {
  display: contents;
}

.upload-button,
.genre-chip {
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
  text-decoration: none;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease,
    opacity 0.18s ease,
    color 0.18s ease;
}

.upload-button:hover,
.genre-chip:hover {
  background: var(--accent-soft);
  border-color: #c4b9a7;
  transform: translateY(-1px);
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  white-space: nowrap;
}

.upload-button input {
  display: none;
}

.upload-accent {
  color: var(--upload-accent);
  border-color: rgba(245, 73, 39, 0.35);
}

.upload-accent:hover {
  background: rgba(245, 73, 39, 0.08);
  border-color: var(--upload-accent);
}

.genre-chip {
  flex: 0 0 auto;
  width: auto;
  max-width: 100%;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}

.genre-chip-active {
  background: #e2dacd;
  border-color: #c2b6a5;
}

/* status */

.status-text {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.status-text[hidden] {
  display: none;
}

/* stage */

.stage {
  display: grid;
  align-content: center;
  min-height: 56vh;
  padding: 4px 0 0;
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: #ddd4c8;
  margin: 0 auto 20px;
  width: min(100%, 820px);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: #504a42;
  border-radius: 999px;
  transition: width 0.15s ease;
}

/* typing area */

.paragraph-display {
  width: min(100%, 820px);
  min-height: 320px;
  margin: 0 auto;
  padding: 34px 36px;
  border-radius: 24px;
  background: #eee8de;
  border: 1px solid var(--panel-border);
  font-family: "JetBrains Mono", monospace;
  font-size: clamp(1.18rem, 1.8vw, 1.45rem);
  line-height: 2;
  letter-spacing: 0.01em;
  color: var(--muted);
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 10px 24px var(--shadow);
}

/* footer controls */

.stage-footer {
  width: min(100%, 820px);
  margin: 18px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.progress-meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.progress-meta strong {
  font-size: 1rem;
  font-weight: 650;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.toolbar button {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.2;
  transition:
    color 0.15s ease,
    opacity 0.15s ease,
    transform 0.12s ease;
}

.toolbar button:hover {
  color: var(--text);
  transform: translateY(-1px);
}

.toolbar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.toolbar kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid rgba(43, 41, 37, 0.12);
  border-radius: 999px;
  background: rgba(43, 41, 37, 0.03);
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  line-height: 1;
  letter-spacing: 0.01em;
}

.toolbar button:hover kbd {
  color: var(--text);
  border-color: rgba(43, 41, 37, 0.18);
  background: rgba(43, 41, 37, 0.05);
}

/* typing states */

.char-correct {
  color: var(--correct);
}

.char-incorrect {
  color: var(--incorrect-text);
  background: var(--incorrect-bg);
  border-radius: 4px;
}

.char-current {
  background: var(--current-bg);
  color: var(--current-text);
  border-radius: 4px;
}

.char-pending {
  color: var(--pending);
}

.char-extra {
  color: var(--extra-text);
  background: var(--extra-bg);
  border-radius: 4px;
}

/* hidden typing input */

.typing-panel {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

#typing-input {
  position: absolute;
  left: -9999px;
}

#typing-input:focus,
.paragraph-display:focus {
  outline: none;
  border-color: #b8ab98;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 0 0 4px rgba(185, 173, 156, 0.2),
    0 10px 24px var(--shadow);
}

/* site footer */

.site-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid rgba(43, 41, 37, 0.08);
}

.footer-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px 24px;
  flex-wrap: wrap;
}

.footer-nav a {
  color: var(--muted);
  font-size: 0.92rem;
  text-decoration: none;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.footer-nav a:hover {
  color: var(--text);
}

/* legal pages */

.legal-layout {
  width: min(100%, 820px);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.legal-backlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.15s ease, transform 0.12s ease;
}

.legal-backlink:hover {
  color: var(--text);
  transform: translateX(-1px);
}

.legal-card {
  padding: 32px 36px;
  border-radius: 24px;
  background: #eee8de;
  border: 1px solid var(--panel-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 10px 24px var(--shadow);
}

.legal-header {
  margin-bottom: 24px;
}

.legal-eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.legal-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 1.05;
  font-weight: 700;
  color: var(--text);
}

.legal-updated {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.legal-section + .legal-section {
  margin-top: 24px;
}

.legal-section h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  line-height: 1.2;
  color: var(--text);
}

.legal-section p,
.legal-section li {
  color: var(--muted);
  line-height: 1.8;
}

.legal-section p {
  margin: 0 0 12px;
}

.legal-section ul {
  margin: 0;
  padding-left: 20px;
}

.legal-section li + li {
  margin-top: 6px;
}

/* responsive */

@media (max-width: 900px) {
  .paragraph-display,
  .progress-track,
  .stage-footer {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100%, calc(100% - 1rem));
    padding: 12px 0 20px;
  }

  .site-header {
    margin-bottom: 14px;
  }

  .genre-chip {
    font-size: 13px;
    padding: 10px 12px;
  }

  .source-cloud-wrap {
    gap: 8px 10px;
  }

  .stage {
    min-height: auto;
  }

  .stage-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .progress-meta {
    justify-content: space-between;
  }

  .toolbar {
    justify-content: flex-start;
    gap: 16px;
  }

  .toolbar button {
    gap: 6px;
  }

  .toolbar kbd {
    font-size: 0.74rem;
  }

  .paragraph-display {
    min-height: 240px;
    padding: 24px 20px;
    font-size: 1.05rem;
    line-height: 1.9;
  }

  .footer-nav {
    justify-content: flex-start;
    gap: 12px 18px;
  }

  .legal-card {
    padding: 24px 20px;
  }

  .legal-layout {
    width: 100%;
  }

  .legal-header h1 {
    font-size: 1.8rem;
  }
}