:root {
    --bg: #0f172a;
    --panel: #111827;
    --panel-soft: #1f2937;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --danger: #f87171;
    --good: #34d399;
    --border: #374151;

    --page-background: #020617;
    --card-background: rgba(17, 24, 39, 0.96);
    --notice-background: rgba(192, 77, 0, 0.85);
    --input-background: #020617;
    --shadow-strong: 0 18px 40px rgba(0, 0, 0, 0.25);
}

/* -----------------------------
   Base page layout
----------------------------- */

* {
    box-sizing: border-box;
}

html {
    background: var(--page-background);
    overflow-y: auto;
    scrollbar-gutter: stable;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 24px;

    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;

    background:
        url('https://images.unsplash.com/photo-1708342421457-9c59f4843fe1?q=80&w=2670&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'),
        linear-gradient(135deg, #7ea5c7, #2f3f63);
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
}

main {
    max-width: 980px;
    margin: 0 auto;
}

h1 {
    margin: 0;
    font-size: 2rem;
}

footer {
    margin-top: 28px;
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
}

/* -----------------------------
   Hero / page intro
----------------------------- */

.wide-layout {
    margin-bottom: 18px;
}

.hero {
    display: flex;
    align-items: center;
    gap: 18px;
}

.hero-icon {
    width: 72px;
    height: 72px;
    max-width: 72px;
    max-height: 72px;
    flex-shrink: 0;
    object-fit: contain;

    transition:
        transform 0.2s ease,
        filter 0.2s ease;
}

.hero-icon:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25));
}

.hero-text {
    display: flex;
    flex-direction: column;
}

.hero-text p,
.subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

/* -----------------------------
   Notice / dismissible warning
----------------------------- */

.notice {
    position: relative;
    max-height: 500px;
    margin: 18px 0;
    overflow: hidden;

    background: var(--notice-background);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 10px;
    line-height: 1.5;

    transition:
        max-height 0.3s ease,
        opacity 0.3s ease,
        padding 0.3s ease,
        margin 0.3s ease;
}

.notice.dismissed {
    max-height: 0;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.notice-close {
    position: absolute;
    top: 8px;
    right: 8px;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;

    color: inherit;
    background: transparent;
    border: none;
    border-radius: 50%;

    font-size: 18px;
    line-height: 1;
    cursor: pointer;

    transition: background-color 0.15s ease;
}

.notice-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.notice-close:focus-visible {
    background: rgba(255, 255, 255, 0.25);
    outline: none;
}

/* -----------------------------
   Cards and responsive layout
----------------------------- */

.layout {
    display: grid;
    grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr);
    gap: 20px;
    align-items: start;
}

.card {
    margin-bottom: 18px;
    padding: 20px;

    background: var(--card-background);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-strong);
}

.card h2 {
    padding-top: 8px;
    margin-top: 0;
    font-size: 1.25rem;
}

/* -----------------------------
   Form controls
----------------------------- */

.field {
    margin-bottom: 12px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 50%;
    gap: 10px;
}

label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-weight: 700;
    width: 100%;
}

input[type="checkbox"] {
    width: 16px;
}

input,
select {
    width: 100%;
    padding: 10px 12px;

    color: var(--text);
    background: var(--input-background);
    border: 1px solid var(--border);
    border-radius: 8px;

    font-size: 1rem;
}

input:focus,
select:focus {
    border-color: var(--accent);
    outline: 2px solid rgba(56, 189, 248, 0.45);
}

.cost-row {
    display: grid;
    grid-template-columns: 1fr 45%;
    gap: 10px;
}

.primary-button {
    width: 100%;
    margin-top: 8px;
    padding: 12px 16px;

    color: white;
    background: var(--accent-strong);
    border: 0;
    border-radius: 10px;

    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
}

.primary-button:hover {
    background: #0284c7;
}

.error {
    display: none;
    margin-top: 12px;
    color: var(--danger);
    line-height: 1.5;
}

.form-section {
    margin-top: 1.75rem;
}

.form-section:first-of-type {
    margin-top: 1rem;
}

.section-title {
    margin: 0;
    margin-bottom: .25rem;

    padding-bottom: .4rem;

    font-size: 1.05rem;
    font-weight: 600;

    border-left: 4px solid var(--accent);
    padding-left: .75rem;
}

.section-description {
    margin: .5rem 0 1rem;

    color: var(--muted);
    font-size: .85rem;
}

/* Chrome, Edge, Safari */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Firefox */
input[type="number"] {
    appearance: textfield;
}

/* -----------------------------
   Combo Box
----------------------------- */

.collection-field {
    position: relative;
    z-index: 20;
}

.combobox {
    position: relative;
}

.combobox-control {
    position: relative;
}

.combobox-control input {
    padding-right: 42px;
}

.combobox-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
    margin: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    transform: translateY(-50%);
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);

    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;

    transition:
        color 0.15s ease,
        background-color 0.15s ease,
        transform 0.15s ease;
}

.combobox-toggle.clear {
    font-size: 1.25rem;
}

.combobox-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.combobox-toggle.clear:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
}

.combobox-toggle:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.65);
    outline-offset: 1px;
}

.combobox.open .combobox-toggle:not(.clear) {
    transform: translateY(-50%) rotate(180deg);
}

.combobox-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 100;

    max-height: 260px;
    margin: 0;
    padding: 4px 0;

    overflow-y: auto;
    list-style: none;

    background: #020617;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);

    transform-origin: top;
    animation: comboboxOpen 120ms ease-out;
}

.combobox-options.hidden {
    display: none;
}

.combobox-option {
    display: flex;
    align-items: center;
    gap: 10px;

    min-height: 42px;
    padding: 8px 12px;

    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.combobox-option:hover,
.combobox-option.active {
    background: rgba(56, 189, 248, 0.12);
}

.combobox-option.selected {
    color: var(--accent);
}

.combobox-option-image {
    width: 28px;
    height: 28px;
    flex-shrink: 0;

    border-radius: 50%;
    object-fit: contain;
}

.combobox-option-text {
    min-width: 0;
}

.combobox-option-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.combobox-option-details {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.78rem;
}

.combobox-empty {
    padding: 12px;
    color: var(--muted);
    text-align: center;
}

@keyframes comboboxOpen {
    from {
        opacity: 0;
        transform: translateY(-4px) scaleY(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scaleY(1);
    }
}

/* -----------------------------
   Tooltips
----------------------------- */

.tooltip {
    position: relative;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 18px;
    height: 18px;

    color: var(--accent);
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: 50%;

    font-size: 12px;
    cursor: help;
}

.tooltip:hover::after,
.tooltip:focus::after {
    content: attr(data-tip);
    position: absolute;
    top: -8px;
    left: 24px;
    z-index: 10;

    width: 240px;
    padding: 10px;

    color: var(--text);
    background: var(--page-background);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);

    font-weight: 400;
    line-height: 1.35;
}

/* -----------------------------
   Results
----------------------------- */

.results {
    display: grid;
    gap: 12px;

    opacity: 0;
    transform: translateY(6px);

    transition:
        opacity 180ms ease,
        transform 180ms ease;
}

.results.results-visible {
    opacity: 1;
    transform: translateY(0);
}

.result-box {
    padding: 14px;
    overflow: hidden;

    background: var(--page-background);
    border: 1px solid var(--border);
    border-radius: 10px;

    transition:
        max-height 0.3s ease,
        opacity 0.3s ease,
        padding 0.3s ease,
        margin 0.3s ease;
}

.result-box.hidden {
    max-height: 0;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.result-label {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.9rem;
}

.result-value {
    font-size: 1.65rem;
    font-weight: 900;
}

.result-value.primary {
    color: var(--good);
}

.small-result-value {
    font-size: 0.9rem;
    font-weight: 900;
}

.small-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.small-stats .result-value {
    font-size: 1.2rem;
}

.explanation {
    margin-top: 14px;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.simulation-time {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* -----------------------------
   Advanced / collapsible results
----------------------------- */

.advanced-results {
    padding: 12px 14px;
    background: var(--page-background);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.advanced-results summary {
    color: var(--accent);
    font-weight: 700;
    cursor: pointer;
}

.advanced-results summary:hover {
    color: var(--text);
}

.advanced-results .small-stats {
    margin-top: 12px;
}

.advanced-results[open] .details-body {
    animation: fadeSlideIn 180ms ease both;
}

.details-body {
    transform-origin: top;
}

/* -----------------------------
   Utility classes and animations
----------------------------- */

.hidden {
    display: none;
}

.results.results-visible .cost-output {
    animation: fadeSlideIn 180ms ease both;
}

.results.results-visible .cost-output:nth-child(2) {
    animation-delay: 35ms;
}

.results.results-visible .cost-output:nth-child(3) {
    animation-delay: 70ms;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* -----------------------------
   Responsive adjustments
----------------------------- */

@media (max-width: 760px) {
    .layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .hero {
        flex-direction: column;
        text-align: center;
    }

    .hero-icon {
        width: 64px;
        height: 64px;
        max-width: 64px;
        max-height: 64px;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 600px) {
    .tooltip:hover::after,
    .tooltip:focus::after {
        position: fixed;
        left: 16px;
        right: 16px;
        top: auto;
        bottom: 16px;
        width: auto;
    }
}

@media (max-width: 600px) {
    .combobox-options {
        max-height: min(260px, 45vh);
    }
}