/* ============================================================================
 * kk tools · 液态玻璃工具箱样式（密码生成器 + 编解码）
 *   - 中亮浅紫蓝底 + 柔和彩色光斑
 *   - 多层半透叠加 + 玻璃边缘高光
 *   - 严格无图片、无外部字体；本地 fallback
 * ============================================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  width: 100%;
  color: #3a5074;
  font: 15px/1.55 -apple-system, "SF Pro Text", "PingFang SC",
                 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  overscroll-behavior: none;
}

/* ===== 背景：中亮 + 柔和彩色 ===== */
body {
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%,
                    rgba(255, 255, 255, 0.55) 0%,
                    rgba(255, 255, 255, 0) 65%),
    radial-gradient(ellipse 55% 45% at 15% 25%,
                    rgba(240, 195, 230, 0.55) 0%,
                    rgba(240, 195, 230, 0) 55%),
    radial-gradient(ellipse 50% 45% at 85% 20%,
                    rgba(190, 220, 240, 0.55) 0%,
                    rgba(190, 220, 240, 0) 55%),
    radial-gradient(ellipse 60% 50% at 75% 75%,
                    rgba(210, 200, 235, 0.50) 0%,
                    rgba(210, 200, 235, 0) 55%),
    radial-gradient(ellipse 50% 40% at 20% 85%,
                    rgba(240, 215, 200, 0.45) 0%,
                    rgba(240, 215, 200, 0) 55%),
    linear-gradient(180deg, #b8c4dc 0%, #c0b8d4 50%, #c8b8c8 100%);
}

/* ===== 噪点磨砂 ===== */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ===== 背景轨道 ===== */
.backdrop {
  position: fixed; inset: 0;
  z-index: 0;
  pointer-events: none;
}
.orbit {
  position: absolute; inset: -10%;
  animation: orbit 90s linear infinite;
  transform-origin: 50% 50%;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  mix-blend-mode: screen;
}
.b1 { width: 600px; height: 600px; left: -10%; top: -10%;
      background: radial-gradient(circle, #f0c5e6 0%, transparent 70%); }
.b2 { width: 640px; height: 640px; right: -12%; top: 20%;
      background: radial-gradient(circle, #b8dcf0 0%, transparent 70%); }
.b3 { width: 560px; height: 560px; left: 30%; bottom: -15%;
      background: radial-gradient(circle, #d8c8f0 0%, transparent 70%); }
.b4 { width: 580px; height: 580px; right: 15%; bottom: -10%;
      background: radial-gradient(circle, #f0d8c0 0%, transparent 70%); }

@keyframes orbit {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ===== 主体 ===== */
.stage {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 5vh 5vw 6vh;
  z-index: 1;
}

/* ===== 标题 ===== */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
  position: relative; /* 让 .lang-switch 绝对定位依赖 */
}

/* ===== 语言切换 (右上角玻璃胶囊) ===== */
.lang-switch {
  position: absolute;
  top: -2px;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 4px 14px rgba(80, 110, 160, 0.10);
  font-size: 12px;
  letter-spacing: 0.04em;
  user-select: none;
  -webkit-user-select: none;
}
.lang-btn {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 2px 4px;
  cursor: pointer;
  color: rgba(50, 70, 110, 0.65);
  font: inherit;
  border-radius: 999px;
  transition: color .18s, background .18s;
}
.lang-btn[aria-pressed="true"] {
  color: rgba(50, 70, 110, 1);
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 3px rgba(80, 110, 160, 0.18);
  font-weight: 600;
}
.lang-btn:hover:not([aria-pressed="true"]) {
  color: rgba(50, 70, 110, 0.85);
  background: rgba(255, 255, 255, 0.30);
}
.lang-btn:focus-visible {
  outline: 2px solid rgba(140, 180, 240, 0.7);
  outline-offset: 1px;
}
.lang-btn:active { transform: scale(.94); }
.lang-divider {
  color: rgba(50, 70, 110, 0.35);
  padding: 0 1px;
  font-weight: 300;
}
@media (max-width: 520px) {
  .lang-switch { top: -10px; right: -4px; padding: 3px 6px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .lang-btn:active { transform: none; }
}
.title {
  width: 88vw;
  max-width: 720px;
  cursor: pointer;
  position: relative;
  filter:
    drop-shadow(0 2px 8px rgba(255, 255, 255, 0.55))
    drop-shadow(0 8px 24px rgba(160, 180, 255, 0.25));
}
.title svg { width: 100%; height: auto; display: block; }
.subtitle {
  font-size: clamp(13px, 1.4vw, 15px);
  color: rgba(50, 70, 110, 0.7);
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.30);
  backdrop-filter: blur(10px) saturate(180%);
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.50);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.tab {
  appearance: none;
  background: rgba(255, 255, 255, 0.40);
  border: 1px solid rgba(255, 255, 255, 0.65);
  color: rgba(50, 70, 110, 0.85);
  padding: 9px 22px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: all .2s;
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  min-height: 38px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 4px 14px rgba(120, 140, 200, 0.18);
  -webkit-tap-highlight-color: transparent;
  font-weight: 500;
}
.tab:hover {
  background: rgba(255, 255, 255, 0.62);
  border-color: rgba(255, 255, 255, 0.85);
}
.tab[aria-selected="true"] {
  background: rgba(255, 255, 255, 0.92);
  color: #1a3a6b;
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    inset 0 -2px 6px rgba(120, 160, 220, 0.18),
    0 6px 20px rgba(120, 160, 220, 0.25);
}
.tab:focus-visible { outline: 2px solid #4a90e2; outline-offset: 2px; }
.tab:focus:not(:focus-visible) { outline: none; }

/* ===== 面板 ===== */
.panel { animation: fade .25s ease; }
.panel.hidden { display: none; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== 卡片：中亮玻璃 ===== */
.single-card {
  max-width: 920px;
  margin: 0 auto;
}
.card {
  background:
    linear-gradient(180deg,
      rgba(255, 255, 255, 0.32) 0%,
      rgba(255, 255, 255, 0.15) 30%,
      rgba(255, 255, 255, 0.08) 100%);
  border: 1px solid rgba(255, 255, 255, 0.50);
  border-radius: 20px;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    0 10px 40px rgba(60, 80, 130, 0.22),
    0 2px 8px rgba(60, 80, 130, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -1px 0 rgba(255, 255, 255, 0.30);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 60%; height: 60%;
  background: radial-gradient(ellipse at 30% 20%,
              rgba(255, 255, 255, 0.30) 0%,
              rgba(255, 255, 255, 0) 60%);
  pointer-events: none;
  border-radius: 20px 0 0 0;
}
.card::after {
  content: '';
  position: absolute; bottom: 0; right: 0;
  width: 50%; height: 50%;
  background: radial-gradient(ellipse at 80% 90%,
              rgba(160, 180, 230, 0.20) 0%,
              rgba(160, 180, 230, 0) 60%);
  pointer-events: none;
  border-radius: 0 0 20px 0;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.55);
  position: relative;
  z-index: 2;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: rgba(50, 70, 110, 0.9);
  letter-spacing: 0.04em;
  flex: 1;
}

/* ===== 按钮 ===== */
.btn-primary, .btn-ghost, .btn-danger {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.7);
  color: #1a3a6b;
  cursor: pointer;
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  min-height: 32px;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(8px) saturate(180%);
  -webkit-backdrop-filter: blur(8px) saturate(180%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 2px 6px rgba(80, 100, 160, 0.12);
  font-weight: 500;
}
.btn-primary {
  background: rgba(140, 200, 255, 0.55);
  border-color: rgba(140, 200, 255, 0.85);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.45);
}
.btn-primary:hover { background: rgba(140, 200, 255, 0.75); }
.btn-ghost:hover   { background: rgba(255, 255, 255, 0.70); }
.btn-primary:active, .btn-ghost:active { transform: scale(.94); }
.btn-primary:focus-visible, .btn-ghost:focus-visible {
  outline: 2px solid #4a90e2; outline-offset: 2px;
}
.btn-primary:focus:not(:focus-visible), .btn-ghost:focus:not(:focus-visible) {
  outline: none;
}
.btn-primary:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.btn-large {
  padding: 10px 22px;
  font-size: 14px;
  min-height: 40px;
}
.btn-mini {
  padding: 3px 8px;
  font-size: 12px;
  min-height: 24px;
}

/* ===== 密码生成器 ===== */
.pw-output-row {
  display: flex;
  gap: 8px;
  padding: 14px 18px 8px;
  position: relative;
  z-index: 2;
}
.pw-output {
  flex: 1;
  appearance: none;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 10px;
  padding: 10px 14px;
  color: #1a3a6b;
  font: 15px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
  outline: none;
  min-height: 42px;
  letter-spacing: 1px;
  word-break: break-all;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.pw-output:focus { border-color: rgba(140, 200, 255, 0.9); background: rgba(255, 255, 255, 0.65); }

.pw-strength-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 18px 12px;
  position: relative;
  z-index: 2;
}
.pw-strength-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.pw-strength-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff6b6b, #ffd93d, #6bcf7f);
  border-radius: 999px;
  transition: width .3s, background .3s;
}
.pw-strength-label {
  font-size: 12px;
  font-weight: 600;
  min-width: 70px;
  text-align: right;
  color: rgba(50, 70, 110, 0.75);
}

.pw-control {
  padding: 8px 18px;
  position: relative;
  z-index: 2;
}
.pw-control > label {
  display: block;
  font-size: 12px;
  color: rgba(50, 70, 110, 0.7);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 6px;
}
.pw-control-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.pw-control-head label {
  margin-bottom: 0;
}
.pw-length-val {
  font-size: 14px;
  font-weight: 700;
  color: #1a3a6b;
  font-variant-numeric: tabular-nums;
  background: rgba(140, 200, 255, 0.30);
  padding: 2px 10px;
  border-radius: 999px;
  min-width: 36px;
  text-align: center;
}

.pw-slider {
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.40);
  border-radius: 999px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.pw-slider::-webkit-slider-thumb {
  appearance: none;
  width: 20px; height: 20px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(140, 200, 255, 0.85);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(80, 100, 160, 0.25);
}
.pw-slider::-moz-range-thumb {
  width: 20px; height: 20px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(140, 200, 255, 0.85);
  border-radius: 50%;
  cursor: pointer;
}

.pw-charset {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.pw-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.30);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: rgba(50, 70, 110, 0.85);
  transition: all .15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.pw-check:hover { background: rgba(255, 255, 255, 0.50); }
.pw-check input {
  appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid rgba(50, 70, 110, 0.4);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  background: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}
.pw-check input:checked {
  background: rgba(140, 200, 255, 0.85);
  border-color: rgba(140, 200, 255, 0.95);
}
.pw-check input:checked::after {
  content: '✓';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.pw-generate-row {
  padding: 12px 18px;
  display: flex;
  justify-content: center;
  position: relative;
  z-index: 2;
}
.btn-large {
  width: 100%;
  max-width: 320px;
}

.pw-history {
  border-top: 1px solid rgba(255, 255, 255, 0.45);
  padding: 10px 18px 14px;
  position: relative;
  z-index: 2;
}
.pw-history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.pw-history-head label {
  font-size: 12px;
  color: rgba(50, 70, 110, 0.7);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}
.pw-history-list {
  list-style: none;
  max-height: 160px;
  overflow-y: auto;
  padding: 0;
  scrollbar-width: thin;
}
.pw-history-list::-webkit-scrollbar { width: 6px; }
.pw-history-list::-webkit-scrollbar-thumb { background: rgba(80, 100, 160, 0.3); border-radius: 3px; }
.pw-history-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font: 12.5px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: rgba(50, 70, 110, 0.75);
  border-radius: 6px;
  margin-bottom: 2px;
  cursor: pointer;
  word-break: break-all;
}
.pw-history-list li:hover { background: rgba(255, 255, 255, 0.35); }
.pw-history-list .pw-history-text { flex: 1; }
.pw-history-list .pw-history-meta { font-size: 10px; color: rgba(50, 70, 110, 0.5); }

.meta { font-size: 12px; color: rgba(50, 70, 110, 0.55); }

/* ===== 编解码 ===== */
.codec-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.codec-tab {
  appearance: none;
  background: rgba(255, 255, 255, 0.40);
  border: 1px solid rgba(255, 255, 255, 0.65);
  color: rgba(50, 70, 110, 0.80);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  min-height: 30px;
  -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  font-weight: 500;
}
.codec-tab:hover { background: rgba(255, 255, 255, 0.60); }
.codec-tab[aria-selected="true"] {
  background: rgba(140, 200, 255, 0.70);
  color: #1a3a6b;
  border-color: rgba(140, 200, 255, 0.90);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 2px 8px rgba(120, 160, 220, 0.20);
}

.codec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px 18px;
  position: relative;
  z-index: 2;
}
.codec-side { display: flex; flex-direction: column; min-height: 320px; }
.codec-side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.codec-side-head label {
  font-size: 12px;
  color: rgba(50, 70, 110, 0.7);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}
.codec-side-actions { display: flex; gap: 4px; }
.codec-input, .codec-output {
  flex: 1;
  appearance: none;
  background: rgba(255, 255, 255, 0.40);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 10px;
  padding: 10px 12px;
  color: #1a3a6b;
  font: 13px/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  outline: none;
  resize: none;
  min-height: 220px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  word-break: break-all;
  white-space: pre-wrap;
}
.codec-input:focus {
  border-color: rgba(140, 200, 255, 0.9);
  background: rgba(255, 255, 255, 0.55);
}
.codec-output { background: rgba(255, 255, 255, 0.25); cursor: default; }

.codec-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: rgba(50, 70, 110, 0.55);
  padding: 4px 2px 0;
  min-height: 18px;
}
.codec-status { font-weight: 500; }
.codec-status.error { color: #c0392b; }
.codec-status.ok { color: #2c8c4f; }

.codec-help {
  padding: 10px 18px 14px;
  font-size: 12px;
  color: rgba(50, 70, 110, 0.55);
  border-top: 1px solid rgba(255, 255, 255, 0.45);
  position: relative;
  z-index: 2;
}

/* footer */
.foot {
  margin-top: 30px;
  text-align: center;
  color: rgba(50, 70, 110, 0.50);
  font-size: 12px;
  position: relative;
  z-index: 1;
}

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(255, 255, 255, 0.70);
  border: 1px solid rgba(255, 255, 255, 0.85);
  color: #1a3a6b;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 8px 24px rgba(80, 100, 160, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  font-weight: 500;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== 涟漪 ===== */
.ripple {
  position: fixed;
  width: 40px; height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 60%);
  pointer-events: none;
  z-index: 50;
  animation: rippleAnim 800ms ease-out forwards;
  mix-blend-mode: screen;
}
@keyframes rippleAnim {
  from { transform: scale(.15); opacity: 1; }
  to   { transform: scale(8);   opacity: 0; }
}

/* ===== 兼容 ===== */
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .card  { background: rgba(255, 255, 255, 0.85); }
  .tab   { background: rgba(255, 255, 255, 0.85); color: #1a3a6b; }
  .toast { background: rgba(255, 255, 255, 0.95); }
}
@supports (padding: max(0px)) {
  .stage { padding-bottom: max(6vh, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .orbit { animation: none; }
  .ripple { display: none; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* ===== 响应式 ===== */
@media (max-width: 700px) {
  .stage { padding: 4vh 4vw 5vh; }
  .codec-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .codec-side { min-height: 180px; }
  .codec-input, .codec-output { min-height: 140px; }
  .pw-charset { grid-template-columns: 1fr; }
  .codec-tabs { gap: 4px; }
  .codec-tab { padding: 5px 10px; font-size: 11px; }
}