:root {
  --bg: #f5efe3;
  --bg-accent: #e9dcc8;
  --panel: rgba(255, 251, 244, 0.92);
  --ink: #2d2117;
  --muted: #715840;
  --line: rgba(77, 51, 24, 0.18);
  --button: #b85c38;
  --button-hover: #9e4827;
  --button-alt: #2f6f62;
  --button-alt-hover: #24584f;
  --focus: #c7742f;
  --focus-ring: rgba(199, 116, 47, 0.22);
  --revealed: #8b5d43;
  --chip-bg: rgba(255, 255, 255, 0.75);
  --shadow: 0 24px 60px rgba(64, 40, 19, 0.15);
  font-family: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.65), transparent 32%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-accent) 100%);
  color: var(--ink);
}

textarea,
input[type="text"],
button,
[role="radio"] {
  outline: none;
}

.shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px 18px;
}

.panel {
  width: min(860px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

body.receive-mode .panel {
  width: min(920px, 100%);
}

body.receive-mode h1 {
  font-size: clamp(2.2rem, 5.2vw, 4rem);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 4.8rem);
  line-height: 0.95;
}

.intro {
  max-width: 54ch;
  margin: 14px 0 24px;
  color: var(--muted);
  font-size: 1.05rem;
}

.hidden {
  display: none !important;
}

.error-banner {
  margin: 0 0 20px;
  padding: 14px 16px;
  border: 1px solid rgba(184, 92, 56, 0.28);
  border-radius: 16px;
  background: rgba(184, 92, 56, 0.08);
  color: #8b3f26;
}

.field,
.output-panel {
  display: block;
  margin-top: 20px;
}

.field > span,
.output-label,
.mode-label {
  font-weight: 700;
}

textarea,
input[type="text"] {
  width: 100%;
  margin-top: 8px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

textarea {
  resize: vertical;
  min-height: 170px;
}

textarea:focus,
input[type="text"]:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px var(--focus);
}

.chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.chip {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--ink);
}

.chip:hover {
  background: #fffaf2;
}

.mode-selector {
  margin-top: 20px;
}

.mode-pills {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.mode-option {
  position: relative;
}

.mode-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.mode-option input[type="radio"]:checked + .mode-pill {
  background: var(--button-alt);
  color: #fff8f2;
  border-color: var(--button-alt);
}

.mode-option input[type="radio"]:focus-visible + .mode-pill {
  box-shadow: 0 0 0 2px var(--focus);
}

.actions,
.output-actions,
.receive-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  color: #fff8f2;
  background: var(--button);
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

button:hover {
  background: var(--button-hover);
  transform: translateY(-1px);
}

button:focus-visible {
  box-shadow: 0 0 0 2px var(--focus);
}

#copyButton,
#shareButton,
#revealAllButton {
  background: var(--button-alt);
}

#shareButton {
  min-width: 112px;
}

#copyButton:hover,
#shareButton:hover,
#revealAllButton:hover {
  background: var(--button-alt-hover);
}

.reply-button {
  background: #6d4b33;
}

.reply-button:hover {
  background: #583d2a;
}

.output-panel {
  margin-top: 28px;
}

.output-label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.output {
  min-height: 160px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.75);
  line-height: 1.9;
  white-space: pre-wrap;
  word-break: break-word;
}

body.receive-mode .output-panel {
  margin-top: 8px;
  text-align: center;
}

body.receive-mode .output {
  min-height: 0;
  font-size: 1.55rem;
  line-height: 2.05;
  padding: 20px 24px;
}

.share-warning,
.share-error,
.reveal-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.share-error {
  color: #8b3f26;
}

.upgrade-prompt {
  display: none;
  position: relative;
  border-left: 3px solid var(--button-alt);
  padding: 10px 36px 10px 14px;
  margin-top: 12px;
  border-radius: 0 6px 6px 0;
  background: rgba(47, 111, 98, 0.08);
  opacity: 0;
  transition: opacity 150ms ease;
}

.upgrade-prompt.visible {
  display: block;
  opacity: 1;
}

.prompt-dismiss {
  position: absolute;
  top: 8px;
  right: 10px;
  padding: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  width: auto;
}

.prompt-dismiss:hover {
  background: none;
  color: var(--ink);
  transform: none;
}

.prompt-label {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--ink);
}

.prompt-cta {
  font-size: 13px;
  font-weight: 500;
  color: var(--button-alt);
  text-decoration: none;
}

.prompt-cta:hover {
  text-decoration: underline;
}

.reveal-hint {
  transition: opacity 160ms ease;
}

.reveal-hint.is-dismissed {
  opacity: 0;
  visibility: hidden;
}

.token {
  position: relative;
}

.token.word {
  border-bottom: 1px dotted rgba(45, 33, 23, 0.45);
  cursor: help;
  transition: color 120ms ease, opacity 120ms ease, border-color 120ms ease;
}

.token.word.revealed {
  color: var(--revealed);
  border-bottom: 1px solid rgba(139, 93, 67, 0.45);
}

.hover-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20;
  padding: 6px 8px;
  border-radius: 10px;
  background: #2d2117;
  color: #fff8f2;
  font-size: 0.8rem;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  max-width: min(220px, 80vw);
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 10px 28px rgba(45, 33, 23, 0.28);
}

.hover-tooltip::after {
  content: "";
  position: absolute;
  left: var(--arrow-left, 50%);
  transform: translateX(-50%);
  border: 6px solid transparent;
}

.hover-tooltip[data-placement="top"]::after {
  top: 100%;
  border-top-color: #2d2117;
}

.hover-tooltip[data-placement="bottom"]::after {
  bottom: 100%;
  border-bottom-color: #2d2117;
}

.output-actions {
  margin-top: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.receive-controls {
  justify-content: center;
}

.receive-controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  width: 100%;
}

@keyframes wordFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.token.word.word-span {
  opacity: 0;
  animation: wordFadeIn 200ms ease forwards;
  animation-delay: calc(var(--word-index) * 40ms);
}

@media (prefers-reduced-motion: reduce) {
  .token.word.word-span {
    opacity: 1;
    animation: none;
  }

  .reveal-hint {
    transition: none;
  }
}

@media (max-width: 640px) {
  .panel {
    padding: 22px;
  }

  .actions,
  .output-actions,
  .receive-controls {
    flex-direction: column;
    align-items: stretch;
  }

  button {
    width: 100%;
  }

  .chips {
    flex-direction: column;
  }

  .chip {
    width: 100%;
  }

  body.receive-mode h1 {
    font-size: clamp(1.8rem, 9vw, 3.1rem);
  }

  body.receive-mode .output {
    font-size: 1.35rem;
  }

  .receive-controls-row {
    flex-direction: column;
    align-items: stretch;
  }
}
