:root {
    color-scheme: dark;
    font-family: "Fira Code", monospace;
    background: #0a0a0b;
    color: #e4e4e7;
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
}

body {
    overflow: hidden;
    background: #0a0a0b;
}

.reader {
    --line-height: min(6rem, calc((var(--reader-height, 100vh) - 10rem) / 6));
    --line-height: min(6rem, calc((var(--reader-height, 100dvh) - 10rem) / 6));
    display: flex;
    width: var(--reader-width, 100%);
    height: var(--reader-height, 100vh);
    height: var(--reader-height, 100dvh);
    margin-left: var(--reader-left, 0px);
    margin-top: var(--reader-top, 0px);
}

.reader:focus {
    outline: none;
}

.reader-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.verse-progress-bar {
    flex: 0 0 var(--bar-width, 3px);
    background: #2dd4bf;
    transform-origin: bottom;
    transform: scaleY(var(--verse-remaining));
    pointer-events: none;
}

.verse-progress-bar.is-playing {
    animation: verse-countdown var(--verse-time) linear both;
}

@keyframes verse-countdown {
    from {
        transform: scaleY(var(--verse-remaining));
    }
    to {
        transform: scaleY(0);
    }
}

.reading-window {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    --lyrics-fade: linear-gradient(
        to bottom,
        transparent calc(50% - var(--line-height) * 1.5),
        black calc(50% - var(--line-height) * 0.5),
        black calc(50% + var(--line-height) * 0.5),
        transparent calc(50% + var(--line-height) * 1.5)
    );
    mask-image: var(--lyrics-fade);
    -webkit-mask-image: var(--lyrics-fade);
}

.lyrics {
    width: calc(100% - 3rem);
    --current-offset: calc((var(--active-line) - var(--first-line) + 0.5 - var(--visible-lines) / 2) * var(--line-height) * -1);
    --previous-offset: calc((var(--previous-line) - var(--first-line) + 0.5 - var(--visible-lines) / 2) * var(--line-height) * -1);
    transform: translateY(var(--current-offset));
}

.lyrics.has-advanced {
    animation: move-line 650ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.lyrics.has-seeked {
    animation: move-line 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes move-line {
    from {
        transform: translateY(var(--previous-offset));
    }
    to {
        transform: translateY(var(--current-offset));
    }
}

.lyric-line {
    height: var(--line-height);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: min(clamp(1.25rem, 3.5vw, 2.5rem), calc(var(--line-height) / 2.4));
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.035em;
    color: #a1a1aa;
    overflow-wrap: break-word;
    transition: color 450ms ease;
}

.lyric-line.is-active {
    color: #fafafa;
}

.lyric-line.is-adjacent {
    opacity: 0.3;
}

.playback-control {
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    gap: 0.5rem;
    padding: max(1rem, env(safe-area-inset-top)) 1rem 1.25rem;
}

.playback-control .playback-button {
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.playback-control .playback-button:focus {
    outline: none;
    box-shadow: none;
}

.playback-button svg {
    width: 1.1rem;
    height: 1.1rem;
    flex-shrink: 0;
}

.playback-button, .playback-button *, .lyric-line, .lyric-line * {
    cursor: pointer;
}

.duration-editor {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: normal;
    color: #fafafa;
}

.duration-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-inline: 0.75rem;
    height: var(--editor-control-height, 2.75rem);
    border: 1px solid #3f3f46;
    border-radius: 5px;
    background: #0a0a0b;
}

.duration-field input {
    width: 7ch;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: inherit;
    text-align: right;
    line-height: 1.6;
    -webkit-user-select: text;
    user-select: text;
    font-variant-numeric: tabular-nums;
}

.duration-field input[aria-invalid="true"] {
    color: #ff9292;
}

.duration-field span {
    color: #a1a1aa;
    font-size: 0.75rem;
}

.duration-editor .counter-button {
    width: var(--editor-control-height, 2.75rem);
    height: var(--editor-control-height, 2.75rem);
    padding: 0;
    flex-shrink: 0;
}

.counter-button svg {
    width: 1rem;
    height: 1rem;
}

.stop-icon {
    width: 0.65rem;
    height: 0.65rem;
    background: currentColor;
}

.is-recording .duration-field {
    border-color: #2dd4bf;
}

.button-icon {
    display: inline-block;
    width: 0.75rem;
    height: 0.85rem;
    flex-shrink: 0;
}

.play-icon {
    width: 0;
    height: 0;
    margin-left: 0.06rem;
    border-top: 0.425rem solid transparent;
    border-bottom: 0.425rem solid transparent;
    border-left: 0.69rem solid currentColor;
}

.pause-icon {
    background: linear-gradient(to right, currentColor 33.333%, transparent 33.333% 66.667%, currentColor 66.667%);
}

@media (max-width: 600px) {
    .lyrics {
        width: calc(100% - 2rem);
    }

}

@media (prefers-reduced-motion: reduce) {
    .lyrics.has-advanced,
    .lyrics.has-seeked {
        animation: none;
    }

    .lyric-line {
        transition: none;
    }
}
