:root {
  --paper: #fff4d2;
  --ink: #1b140c;
  --stamp: #d0122d;
  --peace: #1f4d8f;
  --polite: #c75b12;
  --popcorn: #7b2cbf;
  --twist: #0b7a5c;
  --tape: #f0c14a;
  --line: #ead7a4;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Rubik", "Arial Hebrew", "Avenir Next", "Segoe UI", sans-serif;
  background:
    repeating-linear-gradient(-18deg, transparent, transparent 22px, rgba(27, 20, 12, 0.025) 22px, rgba(27, 20, 12, 0.025) 23px),
    var(--paper);
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.wrap {
  width: min(720px, calc(100% - 2rem));
  margin: 0 auto;
  padding:
    calc(2rem + env(safe-area-inset-top))
    env(safe-area-inset-right)
    calc(3.5rem + env(safe-area-inset-bottom))
    env(safe-area-inset-left);
}

.mast {
  text-align: center;
  margin-bottom: 1.5rem;
}

.kicker {
  display: inline-block;
  margin: 0 0 0.6rem;
  padding: 0.2rem 0.6rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: rotate(-1.5deg);
  background: white;
}

h1 {
  margin: 0;
  font-size: clamp(3.6rem, 14vw, 7rem);
  line-height: 0.85;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.aka {
  margin: 0.35rem 0 0;
  font-size: 1.35rem;
  font-weight: 800;
}

.slip {
  position: relative;
  margin-top: 1.6rem;
  padding: 1.25rem 1.25rem 1.4rem;
  background: #fffdf6;
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
}

.slip::before {
  content: "FORM K-7";
  position: absolute;
  top: -0.7rem;
  left: auto;
  inset-inline-start: 1rem;
  padding: 0 0.4rem;
  background: var(--tape);
  border: 2px solid var(--ink);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  transform: rotate(-2deg);
}

.slip-head {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  margin: 0.4rem 0 0.8rem;
  font-size: 0.8rem;
  font-weight: 700;
}

.slip-head span:last-child {
  white-space: nowrap;
}

label {
  display: block;
  margin-bottom: 0.45rem;
  font-weight: 800;
}

.composer {
  display: block;
}

textarea {
  width: 100%;
  min-height: 5.5rem;
  resize: vertical;
  padding: 0.25rem 0.6rem;
  border: none;
  border-radius: 0;
  background-color: transparent;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 25px,
    var(--line) 25px,
    var(--line) 26px
  );
  color: var(--ink);
  font: 600 0.95rem/26px "Rubik", "Arial Hebrew", sans-serif;
  outline: none;
}

textarea:focus {
  background-color: #fff8e4;
}

.mic {
  width: 3.6rem;
  padding: 0.4rem 0.2rem;
  border: 3px solid var(--ink);
  background: white;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}

.mic svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  margin: 0 auto 0.2rem;
}

.mic span {
  display: block;
  font: 800 0.6rem/1 "Rubik", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mic.live {
  background: var(--stamp);
  color: white;
  animation: pulse 1s ease-in-out infinite;
}

.mic:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.hint {
  min-height: 1.2rem;
  margin: 0.55rem 0 0;
  font-size: 0.85rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 0.9rem;
}

button.judge,
.verdict button {
  border: 3px solid var(--ink);
  font: 800 1rem/1 "Rubik", sans-serif;
  cursor: pointer;
}

button.judge {
  padding: 0.95rem 1.3rem;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 5px 5px 0 var(--stamp);
}

button.judge:hover,
.mic:hover:not(:disabled),
.verdict button:hover {
  transform: translate(-1px, -1px);
}

button.judge:disabled {
  cursor: progress;
  opacity: 0.7;
}

.verdict {
  margin-top: 1.5rem;
  text-align: center;
  scroll-margin-top: 0.75rem;
}

.verdict[hidden] {
  display: none;
}

.eyebrow {
  margin: 0 0 0.8rem;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stamp {
  display: inline-block;
  max-width: 100%;
  margin: 0;
  padding: 0.15em 0.35em 0.05em;
  border: 8px solid currentColor;
  border-radius: 14px;
  font-size: clamp(3rem, 12vw, 5.6rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

html[lang="en"] .stamp {
  font-size: clamp(1.7rem, 6.4vw, 3.3rem);
}

.stamp.kfots,
.stamp.full_kfots {
  color: var(--stamp);
  transform: rotate(-8deg);
  animation: slam 0.45s cubic-bezier(0.15, 1.3, 0.35, 1);
}

.stamp.polite_kfots {
  color: var(--polite);
  transform: rotate(-4deg);
  animation: slam 0.45s cubic-bezier(0.15, 1.3, 0.35, 1);
}

.stamp.popcorn {
  color: var(--popcorn);
  transform: rotate(4deg);
  animation: settle 0.5s cubic-bezier(0.2, 1.1, 0.35, 1);
}

.stamp.peace,
.stamp.let_it_slide {
  color: var(--peace);
  transform: rotate(3deg);
  text-transform: none;
  animation: settle 0.55s cubic-bezier(0.2, 1.1, 0.35, 1);
}

.stamp.plot_twist {
  color: var(--twist);
  transform: rotate(-5deg);
  animation: slam 0.45s cubic-bezier(0.15, 1.3, 0.35, 1);
}

.mast-tools {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.lang-switch {
  display: inline-flex;
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  background: white;
}

.lang-switch button {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 800 0.8rem/1 "Rubik", sans-serif;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}

.lang-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.sound-toggle {
  margin-top: 0;
  padding: 0.35rem 0.8rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  font: 800 0.8rem/1 "Rubik", sans-serif;
  cursor: pointer;
}

.sound-toggle[aria-pressed="false"] {
  opacity: 0.6;
}

.word-count {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: start;
  opacity: 0.75;
}

.word-count.over {
  color: var(--stamp);
  opacity: 1;
}

.stamp.not_for_judging {
  color: var(--ink);
  transform: rotate(-2deg);
  text-transform: none;
  animation: settle 0.55s cubic-bezier(0.2, 1.1, 0.35, 1);
}

.filters {
  display: grid;
  gap: 1rem;
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 2px dashed var(--line);
}

.filter-group {
  display: grid;
  gap: 0.35rem;
}

.filter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.filter-title {
  font-size: 0.85rem;
  font-weight: 800;
}

.filter-val {
  padding: 0.15rem 0.55rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--tape);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--stamp);
  border: 3px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--stamp);
  border: 3px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
}

.slider-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.7;
}

.latin {
  margin: 0.8rem 0 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.aside {
  max-width: 28rem;
  margin: 0.45rem auto 0;
  font-size: 1.05rem;
  line-height: 1.4;
}

.verdict-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.verdict button {
  padding: 0.7rem 0.95rem;
  background: white;
  box-shadow: 3px 3px 0 var(--ink);
}

.fine {
  margin: 2rem 0 0;
  text-align: center;
  font-size: 0.8rem;
}

.fine + .fine {
  margin-top: 0.5rem;
  font-size: 0.72rem;
  opacity: 0.8;
}

.shake {
  animation: shake 0.35s linear;
}

@keyframes slam {
  0% { transform: rotate(-18deg) scale(1.45); opacity: 0; }
  100% { transform: rotate(-8deg) scale(1); opacity: 1; }
}

@keyframes settle {
  0% { transform: rotate(-6deg) scale(0.7); opacity: 0; }
  100% { transform: rotate(3deg) scale(1); opacity: 1; }
}

@keyframes shake {
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

@keyframes pulse {
  50% { box-shadow: 4px 4px 0 var(--ink), 0 0 0 8px rgba(208, 18, 45, 0.18); }
}

.demo-note {
  display: inline-block;
  margin: 0.9rem 0 0;
  padding: 0.35rem 0.8rem;
  border: 2px dashed var(--stamp);
  color: var(--stamp);
  font-size: 0.9rem;
  font-weight: 800;
  transform: rotate(-0.8deg);
}

button.secondary {
  padding: 0.95rem 1.3rem;
  border: 3px solid var(--ink);
  background: var(--tape);
  color: var(--ink);
  font: 800 1rem/1 "Rubik", sans-serif;
  cursor: pointer;
  box-shadow: 5px 5px 0 var(--ink);
}

button.secondary:hover {
  transform: translate(-1px, -1px);
}

button.secondary:disabled,
button.clear-btn:disabled {
  cursor: progress;
  opacity: 0.7;
}

button.clear-btn {
  padding: 0.95rem 1.05rem;
  border: 3px solid var(--ink);
  background: white;
  color: var(--ink);
  font: 800 1rem/1 "Rubik", sans-serif;
  cursor: pointer;
  box-shadow: 5px 5px 0 var(--ink);
}

button.clear-btn:hover {
  transform: translate(-1px, -1px);
}

button.clear-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.verdict button:disabled {
  cursor: progress;
  opacity: 0.7;
}

@media (max-width: 640px) {
  .wrap {
    width: calc(100% - 1rem);
    padding:
      calc(0.55rem + env(safe-area-inset-top))
      env(safe-area-inset-right)
      calc(0.6rem + env(safe-area-inset-bottom))
      env(safe-area-inset-left);
  }

  .mast {
    margin-bottom: 0.45rem;
  }

  .kicker {
    margin-bottom: 0.25rem;
    padding: 0.08rem 0.45rem;
    font-size: 0.64rem;
  }

  h1 {
    font-size: clamp(2.05rem, 11vw, 2.6rem);
  }

  .mast-tools {
    margin-top: 0.35rem;
    gap: 0.35rem;
  }

  .lang-switch button,
  .sound-toggle {
    padding: 0.24rem 0.5rem;
    font-size: 0.7rem;
  }

  .slip {
    margin-top: 0.7rem;
    padding: 0.65rem 0.65rem 0.7rem;
    box-shadow: 4px 4px 0 var(--ink);
  }

  .slip-head {
    margin: 0.1rem 0 0.35rem;
    font-size: 0.7rem;
  }

  label {
    margin-bottom: 0.2rem;
    font-size: 0.88rem;
  }

  textarea {
    min-height: 3.15rem;
  }

  .mic {
    width: 2.7rem;
    padding: 0.2rem 0.1rem;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .word-count {
    margin-top: 0.1rem;
  }

  .filters {
    gap: 0.4rem;
    margin-top: 0.45rem;
    padding-top: 0.4rem;
  }

  .filter-group {
    gap: 0.12rem;
  }

  .filter-title,
  .filter-val {
    font-size: 0.72rem;
  }

  .slider {
    height: 8px;
  }

  .slider::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
  }

  .slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }

  .hint {
    min-height: 0.85rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
  }

  .actions {
    gap: 0.4rem;
    margin-top: 0.4rem;
  }

  .actions button {
    flex: 1 1 0;
  }

  button.judge,
  button.secondary,
  button.clear-btn {
    padding: 0.65rem 0.55rem;
    font-size: 0.88rem;
    box-shadow: 3px 3px 0 var(--ink);
  }

  button.clear-btn {
    flex: 0 0 auto;
    padding-inline: 0.75rem;
  }

  button.judge {
    box-shadow: 3px 3px 0 var(--stamp);
  }

  .verdict {
    margin-top: 0.65rem;
    scroll-margin-top: 0.35rem;
  }

  .eyebrow {
    margin-bottom: 0.3rem;
    font-size: 0.68rem;
  }

  .stamp {
    border-width: 5px;
    border-radius: 10px;
    font-size: clamp(1.45rem, 7.5vw, 2rem);
  }

  html[lang="en"] .stamp {
    font-size: clamp(1.15rem, 5.4vw, 1.55rem);
  }

  .latin {
    margin-top: 0.3rem;
    font-size: 0.92rem;
  }

  .aside {
    margin-top: 0.2rem;
    font-size: 0.84rem;
    line-height: 1.28;
  }

  .verdict-actions {
    margin-top: 0.45rem;
    gap: 0.4rem;
  }

  .verdict button {
    padding: 0.48rem 0.65rem;
    font-size: 0.82rem;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .fine {
    margin-top: 0.55rem;
    font-size: 0.64rem;
  }

  .fine + .fine {
    font-size: 0.58rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stamp.kfots, .stamp.peace, .mic.live, .shake {
    animation: none;
  }
}
