:root {
  --bg: #1e1e1e;
  --panel-bg: linear-gradient(145deg, rgba(20,20,20,.7) 0%, rgba(30,30,30,.6) 40%, rgba(40,40,40,.5) 70%, rgba(60,60,60,.4) 100%);
  --border: rgba(255,255,255,0.08);
  --accent: #00c8ff;
  --error: #ff4e42;
  --btn: linear-gradient(135deg, #3a3f51, #2c2f3a);
  --btn-hover: linear-gradient(135deg, #4b5168, #343845);
  --switcher-bg: rgba(255,255,255,0.06);
  --switcher-border: rgba(255,255,255,0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

:root {
  scrollbar-gutter: stable both-edges;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: #f5f5f5;
  margin: 0;
  min-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

canvas#background-stars {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  pointer-events: none;
  z-index: -2;
}

.app-shell {
  width: 100%;
  max-width: 720px;
  margin: 40px 0;
  padding: 0 16px;
}

h1 {
  text-align: center;
  margin: 0 0 16px;
  font-size: 2rem;
  text-shadow: 0 0 10px rgba(0, 200, 255, 0.6);
}

.viewport {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  transition: height 420ms cubic-bezier(.2,.8,.2,1);
}

.track {
  display: flex;
  width: 200%;
  transform: translateX(0%);
  transition: transform 420ms cubic-bezier(.2,.8,.2,1);
  will-change: transform;
  align-items: flex-start;
}

.track--show-text {
  transform: translateX(0%);
}

.track--show-file {
  transform: translateX(-50%);
}

.panel {
  position: relative;
  width: 50%;
  padding: 24px 24px 28px 24px;
  background: var(--panel-bg);
  border-right: 1px solid var(--border);
}

.panel:last-child {
  border-right: none;
}

.panel-inner {
  max-width: 560px;
  margin: 0 auto;
}

h2,
h3 {
  margin: 8px 0 12px;
}

.input-group {
  margin-bottom: 16px;
}

.input-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #e0e0e0;
}

input[type="text"],
input[type="password"],
textarea,
input[type="file"] {
  padding: 13px;
  font-size: 1rem;
  width: 100%;
  border: 1px solid #555;
  border-radius: 12px;
  background-color: #444;
  color: #f5f5f5;
  resize: vertical;
}

input:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

textarea::-webkit-scrollbar,
.output-box::-webkit-scrollbar {
  width: 8px;
}

textarea::-webkit-scrollbar-track,
.output-box::-webkit-scrollbar-track {
  background: #111;
  border-radius: 10px;
}

textarea::-webkit-scrollbar-thumb,
.output-box::-webkit-scrollbar-thumb {
  background-color: var(--accent);
  border-radius: 10px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.3rem rgba(0, 200, 255, 0.25);
  outline: none;
}

.input-with-icon-wrapper {
  position: relative;
}

input[type="password"] {
  padding-right: 44px;
}

.icon-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  display: block;
}

.icon-btn .icon-eye-off {
  display: none;
}

.btn {
  padding: 12px 22px;
  background: var(--btn);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.25s ease;
  text-decoration: none;
}

.btn:hover {
  background: var(--btn-hover);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.btn:disabled {
  background: #333;
  cursor: not-allowed;
  transform: none;
}

.reset-btn {
  background: linear-gradient(135deg, var(--error), #8b1d1d);
}

.output {
  margin-top: 16px;
}

.output-box {
  background-color: #111;
  border-radius: 10px;
  padding: 12px;
  color: #28a745;
  word-wrap: break-word;
  font-size: 0.95rem;
  max-height: 10em;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.hidden {
  display: none;
}

.output .input-row {
  margin-top: 12px;
}

.progress-row.hidden {
  display: none !important;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 2px;
  flex-wrap: wrap;
}

progress {
  width: 100%;
  height: 10px;
  appearance: none;
}

progress::-webkit-progress-bar {
  background: #222;
  border-radius: 8px;
}

progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 8px;
}

.hint {
  font-size: 0.9rem;
  color: #cfcfcf;
  opacity: 0.9;
  margin-top: 10px;
}

.switcher {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 32px;
  display: grid;
  place-items: center;
  background: var(--switcher-bg);
  border-left: 1px solid var(--switcher-border);
  border-right: 1px solid var(--switcher-border);
  color: #eaeaea;
  cursor: pointer;
  backdrop-filter: saturate(120%) blur(2px);
  transition: background 0.2s ease, color 0.2s ease;
}

.switcher:hover {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}

.switcher--right {
  right: 0;
  border-radius: 12px 0 0 12px;
}

.switcher--left {
  left: 0;
  border-radius: 0 12px 12px 0;
}

.switcher span {
  display: block;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  letter-spacing: 0.5px;
  font-weight: 600;
}

.drop-zone {
  margin-top: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.9rem;
  text-align: center;
  opacity: 0.7;
  transition: opacity .2s ease, border-color .2s ease, background .2s ease;
  user-select: none;
}

.drop-zone.is-dragover {
  opacity: 1;
  border-color: var(--accent);
  background: rgba(0, 200, 255, 0.08);
}

@media (max-width: 720px) {
  .panel-inner {
    max-width: 100%;
  }

  .app-shell {
    margin: 20px 0;
  }
}

.pass-strength-meter {
  height: 6px;
  width: 0%;
  margin-top: 6px;
  border-radius: 3px;
  background-color: var(--error);
  transition: width 0.3s ease, background-color 0.3s ease;
}

.pass-strength-feedback {
  font-size: 0.85rem;
  text-align: center;
  margin-top: 0;
  margin-bottom: 0;
  color: #d0d0d0;
  overflow: hidden;
  opacity: 0;
  max-height: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
}

.pass-strength-feedback.visible {
  opacity: 1;
  margin-top: 8px;
  max-height: 40px;
}

.api-warning {
  background-color: #5d3a00;
  color: #ffe8cc;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  text-align: center;
  font-size: 0.95rem;
}

#outputBox .hint {
  margin-top: 8px;
  text-align: center;
}

#libraryError {
  margin-bottom: 16px;
}