/* ==========================================================================
   妖精 ZWC — 视觉样式
   © 花林妖精 · CC BY-SA 4.0
   ========================================================================== */

@font-face {
  font-family: "Lolita";
  src: url("/fonts/lolita-latin.woff2") format("woff2");
  font-weight: 100 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F, U+3000-303F, U+FF00-FFEF, U+2190-21FF, U+2460-27BF;
}

/* 汉字走独立分片，首屏不阻塞渲染 */
@font-face {
  font-family: "Lolita";
  src: url("/fonts/lolita-cjk.woff2") format("woff2");
  font-weight: 100 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+4E00-9FFF;
}

:root {
  --ink: #4a3540;
  --ink-soft: #7d6270;
  --ink-faint: #a48d99;
  --pink: #fc5889;
  --pink-deep: #e8407a;
  --pink-soft: #ffd9e6;
  --glass: rgba(255, 255, 255, 0.42);
  --glass-strong: rgba(255, 255, 255, 0.62);
  --glass-line: rgba(255, 255, 255, 0.72);
  --shadow: 0 18px 48px -22px rgba(196, 116, 150, 0.55);
  --radius: 22px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

[hidden] {
  display: none !important;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.5rem, 2vh, 1.4rem);
  padding: clamp(1rem, 3vh, 2.2rem) clamp(1rem, 4vw, 2.4rem);
  font-family: "Lolita", "Heiti SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-weight: 300;
  color: var(--ink);
  background: #f7dfe8;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ---------- 背景 ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 60% 42%;
  z-index: -2;
  transform: scale(1.04);
  filter: saturate(1.02);
  animation: float 40s var(--ease) infinite alternate;
}

@keyframes float {
  from {
    transform: scale(1.04) translate3d(0, 0, 0);
  }
  to {
    transform: scale(1.09) translate3d(-1.2%, -1%, 0);
  }
}

.veil {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 90% at 78% 22%, rgba(255, 255, 255, 0.42), transparent 62%),
    linear-gradient(180deg, rgba(255, 244, 249, 0.5), rgba(255, 240, 246, 0.18) 42%, rgba(255, 238, 245, 0.46));
  backdrop-filter: saturate(1.04);
}

/* ---------- 顶栏 ---------- */

.topbar {
  width: min(100%, 44rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
}

.brand__logo {
  width: 2rem;
  height: 2rem;
  filter: drop-shadow(0 4px 10px rgba(232, 64, 122, 0.28));
  transition: transform 0.5s var(--ease);
}

.brand:hover .brand__logo {
  transform: rotate(-8deg) scale(1.06);
}

.brand__name {
  font-size: 1.06rem;
  letter-spacing: 0.14em;
  text-shadow: 0 1px 12px rgba(255, 255, 255, 0.8);
}

/* ---------- 模式开关 ---------- */

.switch {
  display: inline-block;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.switch__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch__track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 8.4rem;
  height: 2.3rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: background 0.35s var(--ease);
}

.switch__thumb {
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: calc(50% - 0.2rem);
  height: calc(100% - 0.4rem);
  border-radius: 999px;
  background: linear-gradient(150deg, #fff, #ffe4ee 60%, #ffd0e0);
  box-shadow: 0 4px 14px -4px rgba(220, 80, 130, 0.55), inset 0 1px 0 #fff;
  transition: transform 0.42s var(--ease);
}

.switch__label {
  position: relative;
  z-index: 1;
  text-align: center;
  font-size: 0.86rem;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  transition: color 0.35s var(--ease);
  user-select: none;
}

.switch__label--enc {
  color: var(--pink-deep);
}

.switch__input:checked ~ .switch__track .switch__thumb {
  transform: translateX(100%);
}

.switch__input:checked ~ .switch__track .switch__label--enc {
  color: var(--ink-faint);
}

.switch__input:checked ~ .switch__track .switch__label--dec {
  color: var(--pink-deep);
}

.switch__input:focus-visible ~ .switch__track {
  outline: 2px solid rgba(232, 64, 122, 0.55);
  outline-offset: 3px;
}

/* ---------- 主面板 ---------- */

.stage {
  width: min(100%, 44rem);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  animation: rise 0.5s var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ---------- 输入区 ---------- */

.entry {
  display: flex;
  gap: 0.55rem;
  padding: 0.42rem;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(20px) saturate(1.35);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition: box-shadow 0.35s var(--ease), background 0.35s var(--ease);
}

.entry:focus-within {
  background: var(--glass-strong);
  box-shadow: var(--shadow), 0 0 0 3px rgba(252, 88, 137, 0.16), inset 0 1px 0 #fff;
}

.entry--stack {
  flex-direction: column;
  align-items: stretch;
  border-radius: var(--radius);
}

.entry__input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 1.1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  outline: none;
}

.entry__input::placeholder,
.entry__area::placeholder {
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}

.entry__area {
  width: 100%;
  min-height: 7.5rem;
  padding: 0.9rem 1.05rem;
  border: 0;
  border-radius: calc(var(--radius) - 8px);
  background: transparent;
  font: inherit;
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--ink);
  resize: vertical;
  outline: none;
}

/* ---------- 按钮 ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.68rem 1.4rem;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  color: #fff;
  cursor: pointer;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.btn--primary {
  background: linear-gradient(150deg, #ff85ab, var(--pink) 45%, var(--pink-deep));
  box-shadow: 0 12px 26px -12px rgba(224, 56, 110, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px -12px rgba(224, 56, 110, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.btn--primary:active {
  transform: translateY(0) scale(0.985);
}

.btn--block {
  width: 100%;
  padding-block: 0.78rem;
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.8);
  color: var(--pink-deep);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 #fff;
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.78);
}

.btn[disabled] {
  cursor: default;
  opacity: 0.6;
  transform: none;
}

.btn__spin {
  display: none;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

.btn.is-loading .btn__spin {
  display: inline-block;
}

.btn.is-loading .btn__text {
  opacity: 0.75;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.icon {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- 提示 ---------- */

.notice {
  margin: 0;
  padding: 0.55rem 1rem;
  border-radius: 14px;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  color: #a3305c;
  background: rgba(255, 226, 236, 0.72);
  border: 1px solid rgba(255, 190, 210, 0.7);
  backdrop-filter: blur(10px);
}

.notice[data-tone="ok"] {
  color: #3f7a63;
  background: rgba(224, 250, 238, 0.72);
  border-color: rgba(170, 226, 203, 0.75);
}

/* ---------- 结果 ---------- */

.output {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: clamp(0.85rem, 2.4vw, 1.3rem);
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(22px) saturate(1.35);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  animation: rise 0.45s var(--ease) both;
}

.cover {
  position: relative;
  margin: 0;
  overflow: hidden;
  border-radius: 16px;
  aspect-ratio: 16 / 9;
  background: linear-gradient(120deg, rgba(255, 240, 246, 0.9), rgba(255, 226, 238, 0.9));
  box-shadow: 0 14px 30px -20px rgba(190, 100, 140, 0.8);
}

.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.cover__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.7s var(--ease), opacity 0.4s var(--ease);
}

.cover__img[data-loaded="false"] {
  opacity: 0;
}

.cover:hover .cover__img {
  transform: scale(1.025);
}

.cover__link {
  position: absolute;
  inset: 0;
}

.title {
  margin: 0;
  font-size: clamp(0.98rem, 2.6vw, 1.12rem);
  font-weight: 300;
  line-height: 1.6;
  letter-spacing: 0.03em;
  color: var(--ink);
}

/* ---------- 密文 ---------- */

.cipher {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 #fff;
}

.cipher__strip {
  position: relative;
  height: 4.2rem;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 245, 249, 0.72), rgba(255, 236, 244, 0.72));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  transition: height 0.3s var(--ease);
}

.cipher__canvas {
  display: block;
  width: 100%;
}

.cipher__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-inline: 0.15rem;
}

.cipher__meta {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}

.cipher__copy {
  flex: none;
  padding: 0.46rem 0.95rem;
  font-size: 0.86rem;
  letter-spacing: 0.1em;
}

.hint {
  margin: 0;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}

/* ---------- 解密结果 ---------- */

.plain {
  margin: 0;
  padding: 0.2rem 0.35rem;
  font-size: 1.04rem;
  line-height: 1.85;
  letter-spacing: 0.03em;
  white-space: pre-wrap;
  word-break: break-word;
}

.plain__link {
  align-self: flex-start;
  font-size: 0.86rem;
  color: var(--pink-deep);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.plain__link:hover {
  opacity: 1;
}

/* ---------- 页脚 ---------- */

.footer {
  width: min(100%, 44rem);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  text-shadow: 0 1px 10px rgba(255, 255, 255, 0.85);
}

.footer a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(164, 141, 153, 0.5);
  transition: color 0.25s;
}

.footer a:hover {
  color: var(--pink-deep);
}

.dot {
  opacity: 0.6;
}

/* ---------- 轻提示 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: clamp(1.2rem, 5vh, 2.6rem);
  translate: -50% 0;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  font-size: 0.86rem;
  letter-spacing: 0.1em;
  color: #6c3a51;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px -20px rgba(180, 100, 140, 0.7);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  pointer-events: none;
  z-index: 10;
}

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

/* ---------- 响应式 ---------- */

@media (max-width: 560px) {
  body {
    justify-content: flex-start;
    gap: 0.85rem;
    padding-top: 1.1rem;
  }

  .entry {
    flex-direction: column;
    align-items: stretch;
    border-radius: var(--radius);
  }

  .entry__input {
    padding: 0.72rem 1rem;
    text-align: center;
  }

  .btn--primary {
    width: 100%;
  }

  .switch__track {
    width: 7.2rem;
    height: 2.1rem;
  }

  .brand__logo {
    width: 1.7rem;
    height: 1.7rem;
  }

  .cipher {
    flex-direction: column;
    align-items: stretch;
    padding: 0.7rem;
  }

  .cipher__copy {
    width: 100%;
  }
}

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

/* ---------- 密文可视化 ---------- */

.zw-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}
