:root {
    --bg-color: #0d0a1a;
    --primary-text: #e0e0e0;
    --glow-color: #00ffcc;
    --accent-color: #9f3ffb;
    --border-color: rgba(0, 255, 204, 0.2);
    --font-body: 'Cutive Mono', monospace;
    --font-heading: 'Orbitron', sans-serif;
    --ui-bg: rgba(20, 16, 38, 0.7);
    --ui-border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
  width: 8px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--glow-color);
}

body {
    background-color: var(--bg-color);
    background-image: url(./background.png);
    background-attachment: fixed;
    background-size: cover;
    color: var(--primary-text);
    font-family: var(--font-body);
    line-height: 1.7;
    font-size: 18px;
}

h1, h2, h3, h4, summary {
    font-family: var(--font-heading);
    color: var(--glow-color);
    text-shadow: 0 0 5px var(--glow-color), 0 0 10px rgba(0, 255, 204, 0.5);
    letter-spacing: 1px;
}

header {
    text-align: center;
    padding: 3rem 1rem;
    border-bottom: 1px solid var(--ui-border);
    background: linear-gradient(180deg, rgba(13, 10, 26, 0.9) 0%, rgba(13, 10, 26, 0.8) 80%, rgba(13, 10, 26, 0) 100%);
    backdrop-filter: blur(5px);
    position: relative;
    z-index: 10;
}

header h1 {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
}

header .subtitle {
    font-family: var(--font-body);
    color: var(--accent-color);
    text-shadow: 0 0 5px var(--accent-color);
    margin-top: 0.5rem;
}

main {
    padding: 0;
    max-width: none;
}

.main-container {
    display: grid;
    grid-template-columns: 400px 1fr;
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem 1rem;
    gap: 2rem;
    align-items: flex-start; /* Important for sticky positioning */
}

#sidebar {
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    top: 2rem;
    height: calc(100vh - 4rem); /* Adjust based on main container padding */
    display: flex; /* Use flexbox for layout */
    flex-direction: column;
}

#sidebar-toggle {
    display: none;
    margin-bottom: 1rem;
}

#sidebar-content {
    overflow-y: auto; /* This will make the content scrollable */
    flex-grow: 1; /* Allows the content to fill available space */
    padding-right: 15px; /* Space for scrollbar */
}

#sidebar .content-block {
    padding: 1rem 1.5rem;
}

#sidebar h2 {
    font-size: 1.5rem;
}

#main-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

#creator-container {
    flex-grow: 1;
}

.content-block, details {
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(15px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all 0.3s ease;
}

.content-block:hover, details:hover {
    border-color: rgba(0, 255, 204, 0.4);
}

details summary {
    cursor: pointer;
    font-size: 1.2rem;
    list-style: none;
    position: relative;
    padding-left: 1.5rem;
}
details summary::before {
    content: '▶';
    position: absolute;
    left: 0;
    top: 0;
    color: var(--glow-color);
    transition: transform 0.2s;
}
details[open] summary::before {
    transform: rotate(90deg);
}

details summary::-webkit-details-marker {
  display: none;
}
details[open] summary {
    margin-bottom: 1rem;
}
details > div {
    border-left: 3px solid var(--accent-color);
    padding-left: 1.5rem;
}

ul {
    list-style-type: none;
    padding-left: 0;
}

ul li {
    position: relative;
    padding-left: 25px;
    margin-bottom: 0.5rem;
}

ul li::before {
    content: '✦';
    position: absolute;
    left: 0;
    color: var(--accent-color);
    text-shadow: 0 0 5px var(--accent-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

table th, table td {
    padding: 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table th {
    color: var(--glow-color);
}

table tr {
    transition: all 0.2s ease-in-out;
}

table tr:hover {
    background-color: rgba(0, 255, 204, 0.1);
    color: white;
}

footer {
    text-align: center;
    padding: 2rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
}

/* --- Doll Creator Styles --- */
#doll-creator {
    text-align: center;
}

#doll-creator .error {
    color: #ff4d4d;
    margin-top: 1rem;
    border: 1px solid #ff4d4d;
    padding: 1rem;
    border-radius: 8px;
    background: rgba(255, 77, 77, 0.1);
}

.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.preset-button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-heading);
    color: var(--primary-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    backdrop-filter: blur(10px);
}

.preset-button:hover {
    background: rgba(0, 255, 204, 0.1);
    border-color: var(--glow-color);
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 255, 204, 0.2);
}

.preset-button img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    -webkit-filter: drop-shadow(0 0 8px rgba(0, 255, 204, 0.5));
    filter: drop-shadow(0 0 8px rgba(0, 255, 204, 0.5));
}

.preset-button span {
    font-size: 1rem;
}

.targets-grid {
    display: none;
}

.target-button {
    /* This style is now scoped inside the lit component */
}

.target-button:hover {
    /* This style is now scoped inside the lit component */
}

.intention-recap {
    /* This style is now scoped inside the lit component */
}

.intention-recap em {
    /* This style is now scoped inside the lit component */
}

.custom-intention h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: var(--primary-text);
    text-shadow: none;
}

#doll-creator p {
    margin-bottom: 1.5rem;
}

textarea {
    width: 100%;
    min-height: 100px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    color: var(--primary-text);
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 1rem;
    resize: vertical;
    margin-bottom: 1rem;
}

textarea:focus {
    outline: none;
    border-color: var(--glow-color);
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.5);
}

button {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    background: linear-gradient(45deg, var(--accent-color), #be6cff);
    color: #fff;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    box-shadow: 0 4px 15px rgba(159, 63, 251, 0.3);
}

button:hover, button:focus {
    background: linear-gradient(45deg, var(--glow-color), #63ffde);
    color: var(--bg-color);
    box-shadow: 0 0 20px var(--glow-color);
    transform: translateY(-2px);
}

button:disabled {
    background: #555;
    cursor: not-allowed;
    box-shadow: none;
    color: #aaa;
    transform: translateY(0);
}

#result-container {
    margin-top: 2rem;
    animation: fadeIn 1s ease-in-out;
}

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

#doll-image {
    max-width: 100%;
    height: auto;
    border: 2px solid var(--ui-border);
    border-radius: 12px;
    box-shadow: 0 0 20px var(--accent-color);
    animation: pulse 4s infinite ease-in-out;
    transition: filter 0.5s ease-in-out;
}

@keyframes pulse {
    0% { box-shadow: 0 0 20px var(--accent-color); }
    50% { box-shadow: 0 0 35px var(--glow-color); }
    100% { box-shadow: 0 0 20px var(--accent-color); }
}

#incantation-text {
    margin-top: 1.5rem;
    font-style: italic;
    font-size: 1.2rem;
    color: var(--glow-color);
    white-space: pre-wrap;
    padding: 1rem;
    background: rgba(0,0,0,0.4);
    border-radius: 8px;
    border-left: 3px solid var(--glow-color);
}

#loader {
    /* This style is now scoped inside the lit component */
}

#confirmation-overlay {
    background: var(--ui-bg);
    border: 1px solid var(--accent-color);
    border-radius: 12px;
    padding: 2.5rem;
    margin: 1rem 0;
    backdrop-filter: blur(15px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    animation: fadeIn 0.5s ease-in-out;
}

#confirmation-overlay h3 {
    color: var(--glow-color);
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

#confirmation-overlay p {
    font-size: 1.1rem;
    color: var(--primary-text);
    margin-bottom: 2rem;
    max-width: 60ch;
    margin-left: auto;
    margin-right: auto;
}

#safety-alignment {
    margin-top: 1.5rem;
    padding: 1rem;
    border: 1px solid var(--glow-color);
    background: rgba(0, 255, 204, 0.05);
    border-radius: 8px;
}

#safety-alignment h4 {
    color: var(--glow-color);
    text-shadow: none;
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
#safety-alignment h4::before {
    content: '✓';
    display: inline-block;
    border: 1px solid var(--glow-color);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
}

#safety-alignment p {
    font-size: 1rem;
    color: var(--primary-text);
    margin: 0;
    padding-left: 28px;
}

/* --- Analysis Log Styles --- */
#analysis-log {
    margin-top: 2rem;
    padding: 1.5rem;
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    background: rgba(13, 10, 26, 0.7);
    backdrop-filter: blur(5px);
}

#analysis-log h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--accent-color);
    font-size: 1.5rem;
}

.analysis-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-label {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-body);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    align-items: center; /* Align items vertically */
}

.tooltip-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 1px solid var(--primary-text);
    border-radius: 50%;
    color: var(--primary-text);
    font-size: 12px;
    text-align: center;
    line-height: 16px;
    cursor: help;
    margin-left: 8px;
}

.metric-value {
    color: var(--glow-color);
    font-family: var(--font-heading);
}

.metric.miracle .metric-value {
    color: #ffc300;
}

.metric-bar-bg {
    width: 100%;
    height: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 2px;
}

.metric-bar-fg {
    height: 100%;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--accent-color) 0%, var(--glow-color) 100%);
    box-shadow: 0 0 8px var(--glow-color);
    animation: fillBar 1.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    transform-origin: left;
}

@keyframes fillBar {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

#overall-success {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--ui-border);
    text-align: center;
}

#overall-success .metric-label {
    font-size: 1.2rem;
    justify-content: center;
    color: var(--glow-color);
    flex-wrap: wrap; /* Allow wrapping for longer labels */
}

#overall-success .metric-value {
    font-size: 3rem;
    line-height: 1;
    text-shadow: 0 0 15px var(--glow-color);
    margin-top: 0.5rem; /* Added margin */
}

/* --- Responsive Layout --- */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 350px 1fr;
    }
}

@media (max-width: 992px) {
    .main-container {
        grid-template-columns: 1fr;
        align-items: stretch; /* Reset alignment */
    }

    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 320px;
        background: var(--bg-color);
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        box-shadow: 5px 0 15px rgba(0,0,0,0.5);
        padding: 1rem;
        border-right: 1px solid var(--border-color);
        height: 100vh; /* Full viewport height */
    }

    #sidebar.open {
        transform: translateX(0);
    }
    
    #sidebar-content {
        overflow-y: auto;
        padding: 0; /* Reset padding for mobile view */
        height: auto; /* Reset height */
    }

    #sidebar-toggle {
        display: block;
        position: relative; /* Change from fixed */
        top: 0;
        left: 0;
        z-index: 1001;
        background: var(--ui-bg);
        color: var(--primary-text);
        border: 1px solid var(--border-color);
        font-family: var(--font-heading);
        padding: 0.5rem 1rem;
        border-radius: 8px;
        cursor: pointer;
        backdrop-filter: blur(10px);
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2.5rem;
    }
    .content-block, details {
        padding: 1.5rem;
    }
}