<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NeonChat</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            font-family: 'Segoe UI', system-ui, sans-serif;
            background: #0a0a0f;
            color: #e0e0e8;
            min-height: 100vh;
        }
        .container { max-width: 1200px; margin: 0 auto; padding: 20px; }
        h1 {
            font-size: 2rem; font-weight: 700;
            background: linear-gradient(135deg, #ff006e, #8338ec, #3a86ff);
            -webkit-background-clip: text; -webkit-text-fill-color: transparent;
            margin-bottom: 8px;
        }
        .subtitle { color: #6b6b80; font-size: 0.95rem; margin-bottom: 30px; }
        .char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
        .char-card {
            background: #15151f; border: 1px solid #252535; border-radius: 14px;
            padding: 20px; cursor: pointer; transition: all 0.2s;
            display: flex; gap: 14px; align-items: center;
        }
        .char-card:hover { border-color: #8338ec; transform: translateY(-2px); box-shadow: 0 4px 20px rgba(131,56,236,0.15); }
        .char-avatar { font-size: 2rem; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; background: #1e1e2e; border-radius: 50%; }
        .char-info h3 { font-size: 1.1rem; margin-bottom: 4px; }
        .char-info p { font-size: 0.85rem; color: #6b6b80; line-height: 1.4; }
        .new-card {
            background: transparent; border: 2px dashed #353545; border-radius: 14px;
            display: flex; align-items: center; justify-content: center;
            min-height: 90px; cursor: pointer; color: #6b6b80; transition: all 0.2s;
        }
        .new-card:hover { border-color: #ff006e; color: #ff006e; }
    </style>
</head>
<body>
    <div class="container">
        <h1>✦ NeonChat</h1>
        <p class="subtitle">Lokaler RP-Chatbot · Wähle einen Charakter oder erstelle einen neuen</p>
        {% if passcode %}
        <p style="color: var(--accent); font-size: 0.85rem; margin-bottom: 20px; padding: 8px 14px; background: #15151f; border: 1px solid var(--accent); border-radius: 8px; display: inline-block;">
            🔑 Session-Passcode: <b style="font-family: monospace; letter-spacing: 4px;">{{ passcode }}</b>
            <br><span style="color: #6b6b80; font-size: 0.8rem;">Auf anderem Gerät: <a href="/join" style="color: var(--accent);">/join</a> öffnen und Code eingeben</span>
        </p>
        {% endif %}
        <div class="char-grid">
            {% for c in characters %}
            <div class="char-card" onclick="location.href='/chat/{{ c.filename | urlencode }}'">
                <div class="char-avatar">{{ c.avatar }}</div>
                <div class="char-info">
                    <h3>{{ c.name }}</h3>
                    <p>{{ c.description[:80] }}{% if c.description|length > 80 %}...{% endif %}</p>
                </div>
                <a href="/edit/{{ c.filename | urlencode }}" onclick="event.stopPropagation()" style="color: #6b6b80; text-decoration: none; font-size: 1.1rem; padding: 4px 8px;" title="Bearbeiten">✏️</a>
            </div>
            {% endfor %}
            <div class="new-card" onclick="location.href='/create'">
                <span style="font-size: 1.5rem;">＋ Neuer Charakter</span>
            </div>
        </div>
    </div>
</body>
</html>