:root {
    --bg: #0b0f17;
    --panel: #111827;
    --panel-2: #0d1421;
    --text: #e7eefc;
    --muted: #aab6cf;
    --brand: #78cfff;
    --accent: #7bffb2;
    --accent-2: #9c7bff;
    --danger: #ff7b9c;
    --good: #86ffb2;
    --warn: #ffd37b;
    --radius: 18px;
    --shadow: 0 12px 40px rgba(0, 0, 0, .35);
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

body {
    margin: 0;
    color: var(--text);
    font: 16px/1.5 system-ui, Segoe UI, Inter, Arial;
    background: var(--bg)
}

#space {
    position: fixed;
    inset: 0;
    z-index: -1
}

.wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 18px
}

header {
    grid-column: 1/-1;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(120, 207, 255, .12), rgba(120, 207, 255, .03));
    border: 1px solid rgba(120, 207, 255, .22)
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: conic-gradient(from 45deg, var(--brand), var(--accent), var(--accent-2), var(--brand));
    box-shadow: var(--shadow)
}

h1 {
    font-size: 1.35rem;
    margin: 0
}

.tag {
    color: var(--muted)
}

.panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .01));
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--radius);
    box-shadow: var(--shadow)
}

.left {
    position: sticky;
    top: 16px;
    align-self: start;
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 12px
}

.right {
    padding: 12px
}

[data-tilt] {
    transition: transform 140ms ease, box-shadow .2s ease;
    transform-style: preserve-3d
}

[data-tilt]:hover {
    transform: perspective(700px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(6px);
    box-shadow: 0 18px 60px rgba(0, 0, 0, .5)
}

.group {
    padding: 12px;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, .06);
    margin-bottom: 10px
}

.group h3 {
    margin: .2rem 0 10px;
    font-size: 1rem;
    color: var(--muted)
}

.row {
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 10px;
    align-items: center
}

label {
    color: var(--muted)
}

input,
select,
button {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: var(--panel-2);
    color: var(--text)
}

button {
    cursor: pointer;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    font-weight: 700;
    border: none;
    transition: transform .12s ease, box-shadow .12s ease;
    box-shadow: 0 10px 24px rgba(120, 207, 255, .25);
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

button.mag:hover {
    transform: translateZ(0) scale(1.02)
}

button.mag:active {
    transform: scale(.98)
}

.cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 12px
}

.card {
    padding: 14px;
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, .06);
    position: relative
}

.card h4 {
    margin: .1rem 0 .25rem;
    color: var(--muted)
}

.value {
    font-size: 1.6rem;
    font-weight: 800
}

.good {
    color: var(--good)
}

.card.is-active {
    outline: 2px solid var(--accent);
    box-shadow: 0 0 0 6px rgba(123, 255, 178, .12)
}

.span-2 {
    grid-column: span 2
}

.total-card .value {
    font-size: 2.3rem
}

.total-note {
    font-size: .85rem;
    color: var(--muted);
    margin-top: 6px
}

.charts {
    display: grid;
    gap: 12px;
    margin-top: 12px
}

.chart-wrap {
    width: 100%;
    height: 340px;
    min-height: 280px;
    max-height: 420px
}

#breakdown {
    width: 100% !important;
    height: 100% !important;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 16px;
    padding: 10px
}

footer {
    grid-column: 1/-1;
    color: var(--muted);
    font-size: .9rem;
    padding: 12px
}

@media(max-width:980px) {
    .wrap {
        grid-template-columns: 1fr
    }

    .left {
        position: static;
        max-height: none
    }

    .cards {
        grid-template-columns: repeat(2, 1fr)
    }
}

@media(max-width:640px) {
    .cards {
        grid-template-columns: 1fr
    }

    .chart-wrap {
        height: 300px
    }

    .span-2 {
        grid-column: 1
    }
}

/* subtle spacing only */
.group {
    padding: 14px;
}

/* was 12px, tiny bump */
.group h3 {
    margin-bottom: 12px;
}

/* add a little vertical gap between rows (without resizing inputs) */
.group .row+.row {
    margin-top: 8px;
}

/* small gap above the Calculate button */
#calcBtn {
    margin-top: 10px;
}

/* optional: a hair more space inside the left panel */
.left {
    padding: 14px;
}


/* === Word Count validation UI === */
.field-msg {
    color: var(--danger);
    font-size: .9rem;
    margin-top: 4px;
}

input.invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(255, 123, 156, .15);
}


/* Smaller + red warning */
.field-msg {
    color: #ff4757;
    /* stronger red */
    font-size: 0.82rem;
    /* smaller text */
    line-height: 1.15;
    margin-top: 4px;
}

/* match the input highlight to the same red */
input.invalid {
    border-color: #ff4757;
    box-shadow: 0 0 0 2px rgba(255, 71, 87, .25);
}