* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #0d0e14;
    color: #c0caf5;
    font-family:
        "Segoe UI",
        system-ui,
        -apple-system,
        sans-serif;
    position: relative;
    overflow-x: hidden;
}

/* Ambient background glow */
.background-glow {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(ellipse at 15% 25%, rgba(34, 197, 94, 0.18) 0%, transparent 45%),
        radial-gradient(ellipse at 85% 75%, rgba(168, 85, 247, 0.2) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 50%, rgba(147, 51, 234, 0.12) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
    animation: glow-drift 20s ease-in-out infinite alternate;
}

@keyframes glow-drift {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }
    100% {
        transform: translate(2%, 2%) rotate(2deg);
    }
}

.container {
    position: relative;
    z-index: 1;
    max-width: 1000px;
    margin: 0 auto;
    padding: 60px 30px;
    overflow: visible;
}

/* Header styles */
.header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

h1 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 3rem;
    font-weight: 700;
    margin: 0 0 12px 0;
    background: linear-gradient(135deg, #22c55e 0%, #a855f7 50%, #9333ea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    text-shadow: 0 0 60px rgba(34, 197, 94, 0.4);
    animation: title-shimmer 3s ease-in-out infinite;
}

@keyframes title-shimmer {
    0%,
    100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.15);
    }
}

.notebook-icon {
    width: 120px;
    height: 120px;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(255, 200, 100, 0.4));
    animation: notebook-float 3s ease-in-out infinite;
}

@keyframes notebook-float {
    0%,
    100% {
        transform: translateY(0) rotate(-2deg);
    }
    50% {
        transform: translateY(-6px) rotate(2deg);
    }
}

.subtitle {
    color: #565f89;
    font-size: 1.1rem;
    margin: 0;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* Code card styles */
.code-card {
    background: linear-gradient(145deg, #1a1f2e 0%, #151822 100%);
    border-radius: 16px;
    border: 1px solid rgba(34, 197, 94, 0.2);
    overflow: visible;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.3),
        0 25px 60px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(34, 197, 94, 0.05) inset,
        0 0 60px rgba(34, 197, 94, 0.15),
        0 0 120px rgba(168, 85, 247, 0.1);
    transition:
        transform 0.3s ease,
        box-shadow 0.3s ease;
    animation: card-enter 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes card-enter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.code-card:hover {
    box-shadow:
        0 8px 16px rgba(0, 0, 0, 0.35),
        0 35px 70px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(34, 197, 94, 0.08) inset,
        0 0 80px rgba(34, 197, 94, 0.2),
        0 0 150px rgba(168, 85, 247, 0.15);
}

/* Code header with window controls */
.code-header {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    background: rgba(10, 12, 18, 0.7);
    border-bottom: 1px solid rgba(34, 197, 94, 0.1);
    backdrop-filter: blur(10px);
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

.window-controls {
    display: flex;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: opacity 0.2s ease;
}

.dot.red {
    background: #9333ea;
}
.dot.yellow {
    background: #a855f7;
}
.dot.green {
    background: #22c55e;
}

.code-card:hover .dot {
    opacity: 0.9;
}

.filename {
    margin-left: 20px;
    color: #565f89;
    font-size: 0.85rem;
    font-family: "Consolas", "Monaco", monospace;
}

.connection-status {
    margin-left: 16px;
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid rgba(158, 206, 106, 0.35);
    color: #9ece6a;
    font-size: 0.74rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    box-shadow: 0 0 8px rgba(158, 206, 106, 0.25);
    transition: all 300ms ease;
}

.connection-status.offline {
    border-color: rgba(247, 118, 142, 0.35);
    color: #f7768e;
    box-shadow: 0 0 8px rgba(247, 118, 142, 0.25);
    animation: pulse-offline 1.5s ease-in-out infinite;
}

@keyframes pulse-offline {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.participants {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 14px;
}

.typing-status {
    margin-left: 10px;
    color: #22c55e;
    font-size: 0.78rem;
    letter-spacing: 0.01em;
    min-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.action-buttons {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    border: 1px solid rgba(34, 197, 94, 0.35);
    background: rgba(26, 31, 46, 0.85);
    color: #c0caf5;
    border-radius: 8px;
    padding: 5px 9px;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all 180ms ease;
}

.action-btn:hover {
    border-color: rgba(34, 197, 94, 0.6);
    background: rgba(34, 50, 40, 0.95);
}

.action-btn.danger {
    border-color: rgba(168, 85, 247, 0.45);
    color: #a855f7;
}

.action-btn.danger:hover {
    border-color: rgba(168, 85, 247, 0.75);
    background: rgba(50, 25, 70, 0.9);
}

.participant-chip {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow:
        0 0 0 2px rgba(0, 0, 0, 0.18),
        0 0 8px currentColor;
    animation: chip-pulse 2s ease-in-out infinite;
}

.participant-chip:nth-child(1) {
    animation-delay: 0ms;
}
.participant-chip:nth-child(2) {
    animation-delay: 250ms;
}
.participant-chip:nth-child(3) {
    animation-delay: 500ms;
}
.participant-chip:nth-child(4) {
    animation-delay: 750ms;
}
.participant-chip:nth-child(5) {
    animation-delay: 1000ms;
}
.participant-chip:nth-child(6) {
    animation-delay: 1250ms;
}
.participant-chip:nth-child(7) {
    animation-delay: 1500ms;
}
.participant-chip:nth-child(8) {
    animation-delay: 1750ms;
}

@keyframes chip-pulse {
    0%,
    100% {
        box-shadow:
            0 0 0 2px rgba(0, 0, 0, 0.18),
            0 0 6px currentColor;
        transform: scale(1);
    }
    50% {
        box-shadow:
            0 0 0 2px rgba(0, 0, 0, 0.18),
            0 0 14px currentColor;
        transform: scale(1.1);
    }
}

.spacer {
    flex: 1;
}

.editor-shell {
    display: grid;
    position: relative;
    min-height: 500px;
    overflow: hidden;
    padding: 24px;
}

.color-layer,
.cursor-layer,
.content-editor {
    grid-area: 1 / 1;
    margin: 0;
    width: 100%;
    min-height: 500px;
    font-size: 13px;
    font-family: "Consolas", "Monaco", "Fira Code", monospace;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
    tab-size: 4;
}

.color-layer {
    color: #c0caf5;
    pointer-events: none;
    overflow: hidden;
    opacity: 1;
}

.cursor-layer {
    pointer-events: none;
    overflow: hidden;
    position: relative;
    z-index: 2;
}

.rock-salt-regular {
    font-family: "Rock Salt", cursive;
    font-weight: 400;
    font-style: normal;
}

.remote-cursor {
    position: absolute;
    display: inline-flex;
    align-items: flex-start;
    pointer-events: none;
    transform: translate3d(0, 0, 0);
}

.remote-caret {
    width: 2px;
    height: 1.45em;
    border-radius: 2px;
    box-shadow: 0 0 8px currentColor;
    animation: remote-caret-blink 1s steps(1, end) infinite;
}

.remote-label {
    margin-left: 6px;
    margin-top: -2px;
    padding: 2px 6px;
    border-radius: 999px;
    color: #0d0e14;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

@keyframes remote-caret-blink {
    0%,
    49% {
        opacity: 1;
    }
    50%,
    100% {
        opacity: 0.25;
    }
}

.content-editor {
    padding: 0;
    border: 0;
    background: transparent;
    color: transparent;
    caret-color: #22c55e;
    resize: none;
    outline: none;
    overflow: hidden;
    animation: caret-glow 1.2s ease-in-out infinite;
}

@keyframes caret-glow {
    0%,
    100% {
        caret-color: #22c55e;
    }
    50% {
        caret-color: #a855f7;
    }
}

.author-range {
    font-weight: 600;
}

.wave-word {
    display: inline-block;
    opacity: 0;
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform: translateY(0);
    animation: word-wave-in 400ms ease-out forwards;
}

@keyframes word-wave-in {
    0% {
        opacity: 0;
        transform: translateY(4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.wave-fast {
    animation-duration: 400ms !important;
}

/* Syntax highlighting - Tokyo Night */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #565f89;
    font-style: italic;
}

.token.keyword {
    color: #a855f7;
}

.token.function {
    color: #22c55e;
}

.token.string,
.token.attr-value {
    color: #9ece6a;
}

.token.number {
    color: #ff9e64;
}

.token.operator {
    color: #89ddff;
}

.token.punctuation {
    color: #c0caf5;
}

.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
    color: #c026d3;
}

.token.boolean {
    color: #ff9e64;
}

.token.selector,
.token.attr-name,
.token.char,
.token.builtin,
.token.inserted {
    color: #9ece6a;
}

.token.class-name {
    color: #2ac3de;
}

.heart {
    color: #a855f7;
    display: inline-block;
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 30px 16px;
    }

    h1 {
        font-size: 2rem;
    }

    .code-card {
        border-radius: 12px;
    }

    .editor-shell {
        padding: 16px;
    }

    .color-layer,
    .cursor-layer,
    .content-editor {
        font-size: 11px !important;
    }

    .typing-status {
        display: none;
    }

    .action-buttons {
        gap: 5px;
    }

    .action-btn {
        font-size: 0.68rem;
        padding: 4px 7px;
    }
}

.sparkle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 0 12px 0;
    padding: 4px 12px;
    min-height: 64px;
    width: fit-content;
    overflow: visible;
    font-size: 3rem;
    font-weight: 300;
    letter-spacing: -0.02em;
    line-height: 1.1;
    text-transform: none;
    background: linear-gradient(
        90deg,
        #e0c3fc 0%,
        #8ec5fc 16.66%,
        #ffecd2 33.33%,
        #fcb69f 50%,
        #a1c4fd 66.66%,
        #c2e9fb 83.33%,
        #e0c3fc 100%
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: title-shimmer 3s ease-in-out infinite, gradient-shift 12s linear infinite;
}

@keyframes gradient-shift {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 100% 50%;
    }
}

.star {
    --star-size: 8px;
    --star-life: 1.4s;
    --start-left: 0px;
    --start-top: 0px;
    --end-left: 0px;
    --end-top: 0px;
    --star-color: #22c55e;

    position: absolute;
    left: var(--start-left);
    top: var(--start-top);
    width: var(--star-size);
    height: var(--star-size);
    z-index: 5;
    pointer-events: none;
    background: var(--star-color);
    border-radius: 2px;
    transform: rotate(45deg) scale(0.7);
    box-shadow: 0 0 10px var(--star-color);
    animation: star-float var(--star-life) ease-out forwards;
}

.star::before,
.star::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    background: var(--star-color);
    transform: translate(-50%, -50%);
    opacity: 0.95;
}

.star::before {
    width: 150%;
    height: 1.5px;
}

.star::after {
    width: 1.5px;
    height: 150%;
}

@keyframes star-float {
    0% {
        left: var(--start-left);
        top: var(--start-top);
        transform: rotate(45deg) scale(0.55);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        left: var(--end-left);
        top: var(--end-top);
        transform: rotate(180deg) scale(0.35);
        opacity: 0;
    }
}

@media (max-width: 768px) {
    .sparkle {
        font-size: 2rem;
    }
}
