/* 音読ペーサー専用スタイル */

.pacer-input-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.9fr);
    gap: var(--spacing-lg);
    align-items: stretch;
    min-width: 0;
}

.pacer-textarea-group textarea {
    min-height: 220px;
    font-size: 1.05rem;
    line-height: 1.7;
    resize: vertical;
    max-width: 100%;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.pacer-settings-panel {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    background: var(--gray-lighter);
    border: 1px solid var(--gray-light);
    border-radius: var(--border-radius-large);
    min-width: 0;
}

.action-bar {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    flex-wrap: wrap;
    margin: var(--spacing-md) 0;
}

.pacer-settings-panel .input-group {
    margin-bottom: 0;
}

.speed-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 92px;
    gap: var(--spacing-md);
    align-items: center;
}

.speed-row input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
}

.speed-row input[type="number"] {
    min-height: 44px;
    text-align: center;
    font-weight: var(--fw-bold);
}

.mode-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
}

.mode-option {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius);
    background: var(--white);
    color: var(--gray-darkest);
    font-weight: var(--fw-bold);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.mode-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mode-option.is-selected,
.mode-option:has(input:checked) {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: var(--white);
    box-shadow: var(--shadow-small);
}

.pacer-small-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    align-items: end;
}

.pacer-check-option {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0 var(--spacing-md);
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius);
    background: var(--white);
    color: var(--gray-darkest);
    font-weight: var(--fw-bold);
    cursor: pointer;
    white-space: nowrap;
}

.pacer-check-option input {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
}

.pacer-message {
    margin-bottom: var(--spacing-lg);
}

.pacer-message[hidden],
#pauseBtn[hidden] {
    display: none !important;
}

.pacer-stage {
    min-height: 520px;
    padding: clamp(18px, 3vw, 34px);
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-large);
}

.pacer-stage-head {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-lg);
    align-items: flex-start;
    margin-bottom: var(--spacing-md);
}

.pacer-state {
    color: var(--primary-color);
    font-size: 1.35rem;
    font-weight: var(--fw-black);
    line-height: 1.3;
}

.pacer-substate {
    margin-top: 4px;
    color: var(--gray-darker);
    font-size: 0.95rem;
    line-height: 1.5;
}

.pacer-counts {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    justify-content: flex-end;
}

.pacer-counts span {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 0 var(--spacing-md);
    border-radius: var(--border-radius-pill);
    background: var(--gray-lighter);
    color: var(--gray-darkest);
    font-weight: var(--fw-bold);
}

.pacer-progress {
    height: 10px;
    overflow: hidden;
    border-radius: var(--border-radius-pill);
    background: var(--gray-light);
    margin-bottom: var(--spacing-xl);
}

.pacer-progress-bar {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: var(--primary-color);
    transition: width 0.18s linear;
}

.reading-text {
    min-height: 320px;
    padding: clamp(18px, 3vw, 36px);
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius-large);
    background: #fffcf5;
    color: var(--gray-darkest);
    font-size: clamp(2rem, 4.2vw, 4.5rem);
    font-weight: var(--fw-bold);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.reading-line + .reading-line {
    margin-top: 0.3em;
}

.reading-word {
    display: inline-block;
    position: relative;
    margin: 0 0.07em 0.1em 0;
    padding: 0.02em 0.1em 0.08em;
    border-radius: var(--border-radius);
    transition: background-color 0.16s ease, color 0.16s ease, opacity 0.18s ease, transform 0.16s ease;
    cursor: pointer;
}

.reading-word:hover {
    outline: 3px solid rgba(0, 96, 100, 0.18);
}

.reading-word.is-current {
    background: #ffd54f;
    color: #111111;
    box-shadow: 0 0.12em 0 rgba(0, 96, 100, 0.25);
    transform: translateY(-0.04em);
}

.reading-word.is-read {
    color: var(--gray-darker);
}

.reading-text.mode-fade .reading-word.is-read {
    opacity: 0.34;
}

.reading-text.mode-vanish .reading-word.is-read {
    opacity: 0.04;
}

.reading-text.mode-vanish .reading-word.is-current {
    opacity: 1;
}

.reading-empty {
    min-height: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    color: var(--gray-dark);
    text-align: center;
}

.reading-empty i {
    color: var(--primary-color);
    font-size: 4rem;
    opacity: 0.55;
}

.reading-empty p {
    margin: 0;
    font-size: 1.1rem;
    font-weight: var(--fw-bold);
}

.stage-controls {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.stage-btn {
    width: 56px;
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: var(--gray-lighter);
    color: var(--gray-darkest);
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-small);
    transition: var(--transition-smooth);
}

.stage-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    transform: translateY(var(--hover-lift-button));
}

.stage-start {
    background: var(--primary-color);
    color: var(--white);
}

.pacer-stage:fullscreen {
    width: 100vw;
    height: 100vh;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    padding: clamp(18px, 3vw, 42px);
    border: 0;
    border-radius: 0;
    background: var(--background-color);
}

.pacer-stage:fullscreen .reading-text {
    min-height: 0;
    height: 100%;
    overflow: auto;
    font-size: clamp(2.6rem, 5.4vw, 6.8rem);
}

.pacer-stage:fullscreen .stage-controls {
    margin-top: var(--spacing-md);
}

.pacer-stage:fullscreen .stage-btn {
    width: 68px;
    height: 68px;
    font-size: 1.45rem;
}

body.class-mode .input-area,
body.class-mode .instructions,
body.class-mode .ad-horizontal {
    display: none !important;
}

body.class-mode .pacer-stage {
    margin-top: var(--spacing-lg);
}

body.class-mode .reading-text {
    font-size: clamp(2.4rem, 5vw, 6rem);
}

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

    .pacer-stage-head {
        flex-direction: column;
    }

    .pacer-counts {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    html {
        overflow-x: hidden;
    }

    body {
        padding: 0;
        overflow-x: hidden;
    }

    .site-wrapper {
        display: block;
        max-width: 100vw;
        padding: var(--spacing-sm);
        margin: 0;
        overflow: hidden;
    }

    .container,
    header,
    main {
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }

    header {
        padding: var(--spacing-md) var(--spacing-md) 76px;
        overflow: hidden;
    }

    .logo-banner,
    header h1,
    .subtitle {
        position: relative;
        z-index: 2;
    }

    header h1 {
        font-size: 1.55rem;
        line-height: 1.25;
    }

    header h1 i {
        margin-right: var(--spacing-sm);
    }

    .subtitle {
        max-width: 100%;
        font-size: 0.9rem;
        line-height: 1.6;
        overflow-wrap: anywhere;
    }

    main {
        padding: var(--spacing-md);
        overflow: hidden;
    }

    .pacer-textarea-group textarea {
        min-height: 180px;
        font-size: 0.95rem;
    }

    .input-group input,
    .input-group textarea,
    .select-input,
    .speed-row input[type="range"] {
        min-width: 0;
        max-width: 100%;
    }

    .speed-row,
    .pacer-small-grid,
    .mode-options {
        grid-template-columns: 1fr;
    }

    .action-bar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .action-bar .btn {
        width: 100%;
        min-height: 48px;
    }

    .pacer-stage {
        min-height: 420px;
        padding: var(--spacing-md);
    }

    .pacer-stage-head {
        gap: var(--spacing-md);
    }

    .pacer-counts span {
        min-height: 32px;
        padding: 0 var(--spacing-sm);
    }

    .reading-text {
        font-size: 2rem;
        line-height: 1.6;
        min-height: 260px;
        padding: var(--spacing-md);
    }

    .stage-btn {
        width: 52px;
        height: 52px;
    }
}
