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

body {
    margin: 0;
    padding: 20px;
    background: #0f172a;
    font-family: 'Segoe UI', sans-serif;
    color: #f1f5f9;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    -webkit-font-smoothing:antialiased;
}

.container {
    width: 92%;
    max-width: 600px;
    text-align: center;
    background: #1e293b;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

.lead { color: #cbd5e1; margin-top: 4px; margin-bottom: 18px; }

/* Mode switch */
.mode-switch { display:flex; width: fit-content; background: rgba(255,255,255,0.03); padding:6px; border-radius:999px; gap:8px; margin: 12px auto 18px auto; align-items:center; justify-content:center; }
.mode-btn { background:transparent; border:none; color:#cbd5e1; padding:8px 12px; border-radius:999px; cursor:pointer; font-weight:700; letter-spacing:0.2px; }
.mode-btn.active { background: linear-gradient(90deg,#0369a1,#06b6d4); color:#07102a; box-shadow: 0 6px 18px rgba(6,182,212,0.12); }

/* Output area controls */
.output-wrap { position: relative; width:100%; }
.output-wrap textarea { width:100%; padding-right: 70px; }
.output-controls { position: absolute; right: 10px; top: 10px; display:flex; align-items:center; gap:8px; z-index:4; }
.output-controls.below { position: relative; top: auto; right: auto; margin-top:8px; justify-content:flex-end; }
.copy-btn { width:40px; height:40px; display:inline-flex; align-items:center; justify-content:center; border-radius:8px; background: rgba(255,255,255,0.03); border:none; color:#38bdf8; cursor:pointer; }
.copy-btn svg { display:block; width:18px; height:18px; }

.primary { background: linear-gradient(90deg,#06b6d4,#0369a1); color: #07102a; padding:10px 18px; border-radius:8px; }
.ghost { background: transparent; color:#94a3b8; border:1px solid rgba(255,255,255,0.04); padding:8px 12px; border-radius:8px; margin-left:8px; }

/* Action row: keep buttons side-by-side and prevent unwanted wrapping on small screens */
.action-row { display:flex; gap:10px; justify-content:center; align-items:center; flex-wrap:nowrap; margin-top:12px; }
.action-row button { flex: 1 1 140px; min-width: 120px; max-width: 250px; }

.hint { color:#94a3b8; margin-top:14px; font-size:13px; }

/* Accessibility helper */
.sr-only { position:absolute; left:-9999px; }

h1 {
    margin-bottom: 20px;
    font-size: 2em;
    color: #38bdf8;
}

textarea {
    width: 100%;
    height: 120px;
    margin: 10px 0;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
    background: #334155;
    color: #f8fafc;
    line-height: 1.4;
    min-height: 80px;
}

input[type="password"] {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    background: #334155;
    color: #f8fafc;
}

button {
    background: #38bdf8;
    border: none;
    color: #0f172a;
    padding: 10px 20px;
    font-size: 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
}

/* Make interactive elements clearly focusable for keyboard users */
textarea:focus, input[type="password"]:focus, button:focus, .copy-btn:focus, .btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(56,189,248,0.15);
}

button:hover {
    background: #0ea5e9;
}

.btn {
    background: #38bdf8;
    padding: 12px 24px;
    color: #0f172a;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    transition: background 0.3s;
}

.btn:hover {
    background: #0ea5e9;
}

.buttons {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

/* Copy feedback alignment */
.copy-container { display:flex; align-items:center; justify-content:flex-end; gap:8px; position:relative; margin-top:10px; text-align:right; }

/* Improve tap targets */
.copy-btn { padding:6px 8px; border-radius:6px; }

.back {
    display: block;
    margin-top: 20px;
    text-decoration: none;
    color: #94a3b8;
    font-size: 14px;
}

.back:hover {
    color: #f1f5f9;
}

.copy-container {
    position: relative;
    margin-top: 10px;
    text-align: right;
}

.copy-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #38bdf8;
    transition: transform 0.2s;
}

.copy-btn:hover {
    transform: scale(1.2);
}

.copy-msg {
    background: #22c55e;
    color: #0f172a;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.copy-msg.show {
    opacity: 1;
    transform: translateY(0);
}

/* Floating background dots */
.bg-dots { position:absolute; inset: -20% -10% -20% -10%; pointer-events:none; z-index:0; }
.bg-dots .dot { position:absolute; border-radius:50%; background: rgba(56,189,248,0.18); filter: blur(6px); animation: float 6s ease-in-out infinite; }
.bg-dots .dot:nth-child(1) { width:120px; height:120px; left:10%; top:10%; animation-duration:8s; }
.bg-dots .dot:nth-child(2) { width:80px; height:80px; left:70%; top:5%; animation-duration:10s; }
.bg-dots .dot:nth-child(3) { width:60px; height:60px; left:30%; top:60%; animation-duration:7s; }
.bg-dots .dot:nth-child(4) { width:40px; height:40px; left:80%; top:70%; animation-duration:9s; }
.bg-dots .dot:nth-child(5) { width:24px; height:24px; left:50%; top:35%; animation-duration:6s; }

@keyframes float {
    0% { transform: translateY(0) translateX(0); opacity: .9 }
    50% { transform: translateY(-18px) translateX(6px); opacity: .6 }
    100% { transform: translateY(0) translateX(0); opacity: .9 }
}

/* Particles canvas */
#particles { position: fixed; inset: 0; width:100vw; height:100vh; z-index:0; pointer-events:none; }

/* Tabs */
.tab-switch { display:flex; gap:8px; justify-content:center; margin-bottom:18px; z-index:2; }
.tab { background: transparent; color:#cbd5e1; border:1px solid rgba(148,163,184,0.08); padding:8px 14px; border-radius:999px; cursor:pointer; }
.tab.active { background: rgba(56,189,248,0.12); color: #38bdf8; border-color: rgba(56,189,248,0.25); }

/* Panels stacking */
.panel { display:none; text-align:left; z-index:2; }
.panel.active { display:block; }

/* Ensure content sits above decorative dots */
.container > * { position: relative; z-index:2; }

/* Responsive tweaks */
@media (max-width: 600px) {
    .container { padding: 24px; border-radius: 10px; }
    h1 { font-size: 1.6em; }
    textarea { height: 140px; font-size: 15px; }
    .buttons { gap: 12px; }
}

@media (max-width: 420px) {
    body { padding: 12px; }
    .container { padding: 18px; }
    h1 { font-size: 1.25em; margin-bottom: 12px; }
    textarea { height: 160px; font-size: 16px; }
    /* avoid forcing all buttons full-width; keep action-row buttons side-by-side */
    button, .btn { padding: 14px; font-size: 16px; }
    .action-row button { width: calc(50% - 6px); flex: 1 1 auto; min-width: 0; }
    .buttons { flex-direction: column; align-items: stretch; }
    .copy-container { justify-content:flex-start; }
    .copy-msg { position: relative; left: auto; top: auto; }
}
