﻿/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    --bg-page:         #07030f;
    --bg-mystical:     linear-gradient(135deg, rgba(30, 20, 60, 0.9) 0%, rgba(10, 5, 20, 0.95) 100%);
    --bg-glass:        rgba(25, 15, 45, 0.7);
    --bg-input:        rgba(0, 0, 0, 0.5);
    --border-mystical: rgba(138, 43, 226, 0.35);
    --text-primary:    #e0d8f0;
    --text-muted:      #a090c0;
    --text-input:      #fff;
    --accent:          #8a2be2;
    --shadow-page:     inset 0 0 200px rgba(80, 0, 160, 0.15);
    --shadow-mystical: 0 0 40px rgba(138, 43, 226, 0.12);
    --orb-center:      #d4a5ff;
    --orb-glow:        #6a0dad;
}

[data-theme="light"] {
    --bg-page:         #f5f0ff;
    --bg-mystical:     linear-gradient(135deg, rgba(240, 235, 255, 0.95) 0%, rgba(255, 255, 255, 1) 100%);
    --bg-glass:        rgba(255, 255, 255, 0.85);
    --bg-input:        rgba(255, 255, 255, 0.95);
    --border-mystical: rgba(138, 43, 226, 0.2);
    --text-primary:    #2a1540;
    --text-muted:      #6a4a9a;
    --text-input:      #111;
    --shadow-page:     none;
    --shadow-mystical: 0 8px 30px rgba(138, 43, 226, 0.08);
    --orb-center:      #8a2be2;
    --orb-glow:        #e6c3ff;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    min-height: 100vh;
    width: 100%;
    background-color: var(--bg-page);
    background-image: var(--shadow-page);
    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, sans-serif;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* ── Layout ─────────────────────────────────────────────────── */
.droom-shell {
    max-width: 820px;
    margin: 0 auto;
    padding: 60px 24px 80px;
}

/* ── Top Controls ───────────────────────────────────────────── */
.top-controls {
    position: fixed;
    top: 20px;
    right: 24px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.control-btn {
    background: var(--bg-glass);
    border: 1px solid var(--border-mystical);
    color: var(--text-primary);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
    backdrop-filter: blur(12px);
}
.control-btn:hover {
    transform: scale(1.12);
    border-color: var(--accent);
}

/* ── Hero / Input Section ───────────────────────────────────── */
.hero {
    border-radius: 16px;
    padding: 40px 36px;
    margin-bottom: 32px;
}

.mystical {
    background: var(--bg-mystical);
    border: 1px solid var(--border-mystical);
    box-shadow: var(--shadow-mystical);
}

h1 {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 12px;
}

h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.muted { color: var(--text-muted); font-size: 0.95rem; line-height: 1.5; }

.droom-input-container {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

textarea#dreamInput {
    width: 100%;
    min-height: 160px;
    background: var(--bg-input);
    border: 1px solid var(--border-mystical);
    border-radius: 10px;
    padding: 16px;
    color: var(--text-input);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
textarea#dreamInput:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 16px rgba(138, 43, 226, 0.25);
}

/* ── Buttons ────────────────────────────────────────────────── */
.actions { display: flex; gap: 12px; flex-wrap: wrap; }

.button {
    padding: 10px 22px;
    border-radius: 8px;
    border: 1px solid var(--border-mystical);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    text-decoration: none;
}
.button:hover { border-color: var(--accent); transform: translateY(-1px); }
.button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}
.button.primary:hover { background: #6a0dad; border-color: #6a0dad; }
.button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Result Section ─────────────────────────────────────────── */
#resultSection h2 { margin-bottom: 16px; }

.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-mystical);
    border-radius: 12px;
    padding: 28px;
    color: var(--text-primary);
    line-height: 1.7;
}

.result-actions-bar {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.result-btn-group { display: flex; gap: 10px; }
.token-counter { font-size: 0.8rem; font-family: monospace; color: var(--text-muted); }

/* ── Loading Orb ────────────────────────────────────────────── */
#loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px 0;
    color: var(--text-muted);
}

.orb {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--orb-center), var(--orb-glow));
    box-shadow: 0 0 24px var(--orb-glow), 0 0 48px var(--orb-center), inset 0 0 12px rgba(255,255,255,0.7);
    animation: breathe 3s infinite ease-in-out, float 4s infinite ease-in-out;
}

@keyframes breathe {
    0%, 100% { transform: scale(1);   opacity: 0.8; }
    50%       { transform: scale(1.1); opacity: 1; }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-10px); }
}

/* ── Markdown ───────────────────────────────────────────────── */
.markdown-body h3 {
    color: #d4a5ff;
    margin-top: 24px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-mystical);
    padding-bottom: 6px;
}
[data-theme="light"] .markdown-body h3 { color: var(--accent); }
.markdown-body ul { list-style-type: square; color: var(--text-muted); padding-left: 20px; }
.markdown-body strong { color: var(--text-primary); }

/* ── Utilities ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.error-msg { color: #ff6b6b; font-weight: bold; }