:root {
  --ink: #f5f3ff;
  --muted: #c9bfe8;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.18);
  --pink: #ff5fc4;
  --cyan: #4deaff;
  --violet: #a259ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 15% 20%, #3a1c71 0%, transparent 45%),
              radial-gradient(circle at 85% 15%, #ff5fc4 0%, transparent 40%),
              radial-gradient(circle at 75% 85%, #4deaff 0%, transparent 45%),
              linear-gradient(135deg, #150a2e 0%, #1c0f3d 40%, #2a0f4d 100%);
  background-size: 180% 180%, 180% 180%, 180% 180%, 100% 100%;
  animation: drift 18s ease-in-out infinite;
  overflow-x: hidden;
  position: relative;
}

@keyframes drift {
  0%, 100% { background-position: 0% 0%, 100% 0%, 100% 100%, 0 0; }
  50% { background-position: 20% 30%, 80% 20%, 70% 70%, 0 0; }
}

.float {
  position: fixed;
  font-size: 2rem;
  opacity: 0.35;
  filter: drop-shadow(0 0 12px rgba(255,255,255,0.25));
  animation: bob 6s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
}
.float.f1 { top: 12%; left: 8%; animation-delay: 0s; }
.float.f2 { top: 70%; left: 85%; animation-delay: 1.5s; font-size: 2.6rem; }
.float.f3 { top: 20%; left: 88%; animation-delay: 3s; font-size: 1.6rem; }
.float.f4 { top: 80%; left: 12%; animation-delay: 2.2s; font-size: 1.8rem; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-18px) rotate(4deg); }
}

.card {
  width: 100%;
  max-width: 560px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 32px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
  position: relative;
  z-index: 1;
}

h1 {
  font-family: 'Unbounded', 'Inter', sans-serif;
  font-weight: 900;
  font-size: 1.9rem;
  margin: 0 0 6px;
  background: linear-gradient(90deg, var(--pink), var(--violet) 45%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.02em;
}

p.sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.direction {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.intensity-block[hidden] { display: none; }

.example-chip {
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.example-chip:hover {
  border-color: rgba(77, 234, 255, 0.5);
  color: var(--ink);
  background: rgba(77, 234, 255, 0.08);
}

.intensity-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.intensity {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.intensity-btn {
  margin: 0;
  width: auto;
  padding: 10px 8px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  font-family: 'Unbounded', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: none;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.intensity-btn:hover:not(:disabled) {
  transform: none;
  filter: none;
  box-shadow: none;
  border-color: rgba(255, 255, 255, 0.35);
  color: var(--ink);
}
.intensity-btn.active {
  border-color: rgba(162, 89, 255, 0.7);
  background: linear-gradient(90deg, rgba(255, 95, 196, 0.25), rgba(162, 89, 255, 0.3));
  color: var(--ink);
}

textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  background: rgba(0,0,0,0.2);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
textarea::placeholder { color: rgba(245,243,255,0.4); }
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(77, 234, 255, 0.15);
}

.meta-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.char-count {
  font-size: 0.75rem;
  color: var(--muted);
}
.char-count.warn { color: #ffb4e4; }
.char-count.limit { color: #ff7ec8; font-weight: 600; }

.turnstile-wrap {
  margin-top: 14px;
  width: 100%;
}

#translateBtn {
  margin-top: 14px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(90deg, var(--pink), var(--violet));
  color: white;
  font-family: 'Unbounded', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  box-shadow: 0 4px 24px rgba(162, 89, 255, 0.4);
}
#translateBtn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 6px 30px rgba(255, 95, 196, 0.5);
}
#translateBtn:active:not(:disabled) { transform: translateY(0); }
#translateBtn:disabled { opacity: 0.6; cursor: not-allowed; }

.error {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 95, 196, 0.1);
  border: 1px solid rgba(255, 95, 196, 0.4);
  color: #ffd6f0;
  font-size: 0.9rem;
  display: none;
}
.error.visible { display: block; }

.result-wrap {
  margin-top: 22px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.result-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.copy-btn,
.text-btn {
  margin: 0;
  width: auto;
  padding: 6px 10px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.copy-btn:hover,
.text-btn:hover {
  transform: none;
  filter: none;
  box-shadow: none;
  border-color: rgba(77, 234, 255, 0.5);
  color: var(--ink);
}

.result {
  padding: 18px;
  border-radius: 14px;
  background: rgba(77, 234, 255, 0.08);
  border: 1px solid rgba(77, 234, 255, 0.35);
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 1.02rem;
  min-height: 1.55em;
}

.history {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--glass-border);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.history h2 {
  margin: 0;
  font-family: 'Unbounded', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  box-shadow: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.history-item:hover {
  transform: none;
  filter: none;
  box-shadow: none;
  border-color: rgba(77, 234, 255, 0.4);
  background: rgba(77, 234, 255, 0.08);
}
.history-item .from {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.history-item .to {
  display: block;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

footer {
  margin-top: 22px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  opacity: 0.8;
}

@media (max-width: 480px) {
  .card { padding: 24px 18px; }
  h1 { font-size: 1.6rem; }
  .intensity-btn { font-size: 0.68rem; }
}
