:root {
  --black: #000000;
  --panel: #0a0a0a;
  --line: rgba(255, 255, 255, 0.12);
  --line-soft: rgba(255, 255, 255, 0.07);
  --white: #f5f5f4;
  --muted: #8a8a86;
  --muted-dim: #5c5c58;
  --radius-lg: 18px;
  --radius-md: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--black);
  color: var(--white);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.confession-panel {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
}

.panel-copy[hidden] {
  display: none;
}

#page-title {
  margin: 0;
  font-family: "Concert One", sans-serif;
  font-weight: 600;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--white);
}

.intro {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.confession-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.confession-form[hidden] {
  display: none;
}

.field-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.field-stack {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
  transition: border-color 0.2s var(--ease);
}

.field-stack:focus-within {
  border-color: rgba(255, 255, 255, 0.35);
}

textarea {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--white);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.55;
  padding: 14px 16px 6px;
  resize: none;
  outline: none;
}

textarea::placeholder {
  color: var(--muted-dim);
}

.field-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0 14px 10px;
}

.char-count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted-dim);
  transition: color 0.2s var(--ease);
}

.char-count.is-low {
  color: #ff0000; 
}

.turnstile-wrap {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  border-top: 1px solid transparent;
  transition: max-height 0.45s var(--ease), opacity 0.3s var(--ease), border-color 0.45s var(--ease);
}

.turnstile-wrap.is-open {
  max-height: 100px;
  opacity: 1;
  border-top-color: var(--line-soft);
}

.turnstile-wrap-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
}

.submit-button {
  appearance: none;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  background: var(--white);
  color: var(--black);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s var(--ease), opacity 0.2s var(--ease), background 0.2s var(--ease);
}

.submit-button:hover {
  background: #e6e6e3;
}

.submit-button:active {
  transform: scale(0.97);
}

.submit-button:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.submit-button.is-pressed {
  animation: press 0.28s var(--ease);
}

@keyframes press {
  0% { transform: scale(1); }
  40% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

/* Success state replaces the form entirely */
.success-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 56px 16px;
  animation: rise-in 0.5s var(--ease);
}

.success-panel[hidden] {
  display: none;
}

.success-mark {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
}

.success-mark svg {
  width: 22px;
  height: 22px;
}

.success-mark svg path {
  stroke-dasharray: 28;
  stroke-dashoffset: 28;
  animation: draw-check 0.5s 0.15s var(--ease) forwards;
}

@keyframes draw-check {
  to { stroke-dashoffset: 0; }
}

.success-text {
  margin: 0;
  font-family: "Concert One", sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--white);
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Toasts */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
}

.toast {
  background: var(--white);
  color: var(--black);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 480px) {
  .confession-panel {
    padding: 28px 20px 22px;
  }

  #page-title {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}