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

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: #e8e4dc;
    min-height: 100vh;
    color: #4a4a4a;
}

/* Layout: paper (main) + sidebar right */
.app {
    display: flex;
    min-height: 100vh;
}

.paper {
    flex: 1;
    min-width: 0;
    display: flex;
    padding: 3rem 4rem 4rem;
    background: #f5f0e8;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.06);
}

#textDisplay {
    width: 100%;
    max-width: 42rem;
    margin: 0 auto;
    min-height: 60vh;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 1.35rem;
    line-height: 1.9;
    color: #5c5c5c;
    word-wrap: break-word;
    white-space: pre-wrap;
    position: relative;
    outline: none;
}

#textDisplay::before {
    content: 'Start typing...';
    position: absolute;
    top: 0;
    left: 0;
    color: #a8a8a8;
    font-family: 'Courier New', 'Consolas', monospace;
    pointer-events: none;
}

#textDisplay:not(:empty)::before {
    display: none;
}

.letter {
    display: inline-block;
    color: #5c5c5c;
    animation: letterAppear 0.2s ease-out;
}

.letter.space {
    min-width: 0.35em;
    overflow: hidden;
}

/* Playback ball – subtle on paper */
.playback-ball {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #7a7a7a;
    pointer-events: none;
    opacity: 0;
    transition: left 0.2s ease-out, top 0.2s ease-out, opacity 0.15s ease;
    z-index: 5;
}

.playback-ball.playing {
    opacity: 0.85;
}

.playback-ball.bounce {
    animation: ballBounce 0.3s ease-out;
}

@keyframes ballBounce {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.4); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

@keyframes letterAppear {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

/* Sidebar */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    padding: 2rem 1.5rem;
    background: #ebe7e0;
    border-left: 1px solid #ddd9d0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.logo {
    font-size: 0.95rem;
    font-weight: 600;
    color: #6b6b6b;
    letter-spacing: 0.02em;
    margin-bottom: 0.25rem;
}

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

button {
    background: transparent;
    border: 1px solid #c4c0b8;
    color: #5c5c5c;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    border-radius: 3px;
}

button:hover {
    background: #e2ded6;
    border-color: #b0aca4;
}

button:active {
    background: #d8d4cc;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.volume-control {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.volume-control label {
    font-size: 0.75rem;
    color: #8a8a8a;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd9d0;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #5c5c5c;
    cursor: pointer;
    border: none;
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #5c5c5c;
    cursor: pointer;
    border: none;
}

.scale-selector {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.scale-selector label {
    font-size: 0.75rem;
    color: #8a8a8a;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

select {
    background: #faf8f5;
    border: 1px solid #c4c0b8;
    color: #5c5c5c;
    padding: 0.5rem 0.6rem;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    border-radius: 3px;
}

select:hover,
select:focus {
    border-color: #b0aca4;
}

select option {
    background: #faf8f5;
    color: #5c5c5c;
}

.hint {
    font-size: 0.75rem;
    color: #9a9a9a;
    line-height: 1.4;
    margin-top: auto;
}

/* Note particle – subtle on paper */
.note-particle {
    position: fixed;
    pointer-events: none;
    font-size: 1.25rem;
    color: #9a9a9a !important;
    z-index: 1000;
    animation: floatUp 1.8s ease-out forwards;
}

@keyframes floatUp {
    0% {
        opacity: 0.7;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-120px) scale(0.6);
    }
}

/* Narrow viewport: stack sidebar below */
@media (max-width: 720px) {
    .app {
        flex-direction: column;
    }

    .paper {
        padding: 2rem 1.5rem 2rem;
    }

    #textDisplay {
        font-size: 1.15rem;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 1rem;
        padding: 1rem 1.5rem;
        border-left: none;
        border-top: 1px solid #ddd9d0;
    }

    .controls {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .hint {
        width: 100%;
        margin-top: 0;
    }
}
