@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --text: #e4e6f0;
  --text-secondary: #9ca3c2;
  --muted: #7a7f9a;
  --primary: #a855f7;
  --primary-glow: #c084fc;
  --primary-deep: #7c3aed;
  --accent: #f472b6;
  --error: #fb7185;
  --success: #34d399;
  --info: #38bdf8;
  --surface: rgba(30, 27, 45, 0.75);
  --surface-hover: rgba(40, 36, 58, 0.85);
  --border: rgba(168, 85, 247, 0.15);
  --border-active: rgba(168, 85, 247, 0.5);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(168, 85, 247, 0.06);
  --shadow-elevated: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(168, 85, 247, 0.08);
  --radius: 16px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #0d0b1a;
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(168, 85, 247, 0.15), transparent),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(244, 114, 182, 0.08), transparent),
    radial-gradient(ellipse 50% 40% at 20% 80%, rgba(56, 189, 248, 0.06), transparent);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
}

::selection {
  background: rgba(168, 85, 247, 0.35);
  color: #fff;
}

.app {
  width: min(92vw, 820px);
  margin: 0 auto;
  padding: 32px 16px 48px;
}

.hero {
  margin-bottom: 28px;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(168, 85, 247, 0.4), transparent);
}

.hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.hero-content {
  margin-top: 14px;
  position: relative;
  z-index: 1;
}

.hero.is-collapsed {
  padding: 28px;
}

.hero.is-collapsed .hero-content {
  display: none;
}

h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-glow) 0%, var(--primary) 40%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.intro {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
}

label {
  display: block;
  margin: 22px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

textarea,
input,
select {
  width: 100%;
  border: 1.5px solid rgba(168, 85, 247, 0.3);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  background: rgba(36, 31, 56, 0.85);
  color: var(--text);
  transition: all 0.25s ease;
  font-family: inherit;
  resize: vertical;
}

textarea:hover,
input:hover,
select:hover {
  border-color: rgba(168, 85, 247, 0.45);
  background: rgba(40, 35, 62, 0.88);
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: rgba(168, 85, 247, 0.65);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.18), 0 0 32px rgba(168, 85, 247, 0.1);
  background: rgba(42, 36, 66, 0.92);
}

textarea {
  min-height: 140px;
}

input[type="range"] {
  padding: 0;
  height: 6px;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(90deg, var(--primary), var(--primary-glow));
  border: none;
  border-radius: 99px;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.4);
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.password-actions {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.password-actions-left,
.password-actions-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.input-actions {
  margin-bottom: 12px;
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.length-control {
  margin-top: 16px;
  background: rgba(22, 19, 36, 0.5);
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.length-control label {
  margin: 0 0 8px;
  text-transform: none;
  letter-spacing: normal;
}

.preview-toggle-row {
  margin-top: 16px;
}

.preview-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 10px 16px;
  background: rgba(22, 19, 36, 0.5);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all 0.25s ease;
  user-select: none;
}

.preview-toggle:hover {
  border-color: rgba(168, 85, 247, 0.3);
  background: rgba(30, 27, 45, 0.7);
}

.preview-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.markdown-preview-panel {
  margin-top: 16px;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.markdown-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.markdown-preview-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.markdown-preview {
  color: var(--text);
  line-height: 1.7;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.markdown-preview::-webkit-scrollbar {
  width: 6px;
}

.markdown-preview::-webkit-scrollbar-track {
  background: transparent;
}

.markdown-preview::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.3);
  border-radius: 99px;
}

.markdown-preview pre {
  background: #0d0b1a;
  color: #e4e6f0;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid rgba(168, 85, 247, 0.1);
  overflow-x: auto;
}

.markdown-preview code {
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  border-radius: 6px;
  background: rgba(168, 85, 247, 0.1);
}

.markdown-preview pre code {
  padding: 0;
  background: transparent;
}

.markdown-preview a {
  color: var(--primary-glow);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.markdown-preview mark.md-highlight {
  padding: 0.08em 0.35em;
  border-radius: 0.4em;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.3), rgba(244, 114, 182, 0.3));
  color: var(--text);
}

.markdown-preview blockquote {
  padding-left: 16px;
  border-left: 3px solid rgba(168, 85, 247, 0.4);
  color: var(--text-secondary);
  margin: 0 0 0.95em;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin: 1.2em 0 0.45em;
  line-height: 1.25;
  color: var(--text);
}

.markdown-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.markdown-preview-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 11, 26, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.markdown-preview-modal-panel {
  position: relative;
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: #1a1632;
  box-shadow: var(--shadow-elevated);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.footerbar {
  margin-top: 36px;
  padding: 20px 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.version-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: rgba(22, 19, 36, 0.6);
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

.language-picker select {
  appearance: none;
  -webkit-appearance: none;
  background:
    linear-gradient(135deg, rgba(168, 85, 247, 0.08), rgba(244, 114, 182, 0.04)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23a855f7' d='M6 8 .8 1.4 2.2 0 6 4.7 9.8 0 11.2 1.4z'/%3E%3C/svg%3E")
      no-repeat right 14px center / 12px 8px;
  padding-right: 40px;
  cursor: pointer;
  min-width: 150px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
}

button {
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary-deep), var(--primary));
  color: #fff;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.25);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  font-family: inherit;
}

button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(168, 85, 247, 0.35);
}

button:hover::after {
  opacity: 1;
}

button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.2);
}

.hero-toggle-btn {
  background: rgba(168, 85, 247, 0.1);
  color: var(--primary-glow);
  box-shadow: none;
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.hero-toggle-btn::after {
  display: none;
}

.hero-toggle-btn:hover {
  background: rgba(168, 85, 247, 0.18);
  box-shadow: none;
}

#togglePassword {
  background: rgba(168, 85, 247, 0.12);
  color: var(--primary-glow);
  box-shadow: none;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(168, 85, 247, 0.15);
}

#togglePassword::after {
  display: none;
}

#togglePassword:hover {
  background: rgba(168, 85, 247, 0.22);
}

.status {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--radius);
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 260px;
}

.status-success {
  color: var(--success);
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.status-error {
  color: var(--error);
  background: rgba(251, 113, 133, 0.1);
  border: 1px solid rgba(251, 113, 133, 0.2);
}

.status-info {
  color: var(--info);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.output-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .app {
    padding: 16px 12px 32px;
  }

  .hero {
    padding: 20px;
    border-radius: 20px;
  }

  .hero.is-collapsed {
    padding: 20px;
  }

  h1 {
    font-size: 20px;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .hero-header {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-toggle-btn {
    width: 100%;
  }

  .password-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .password-actions-left,
  .password-actions-right {
    width: 100%;
  }

  .password-actions-right {
    justify-content: flex-start;
  }

  .footerbar {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
}
