.childtalk-page {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: #0b1220;
    color: #fff;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 1rem;
    padding: 1rem;
    overflow: hidden;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

.childtalk-banner {
    background: #1f2937;
    color: #fef3c7;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    font-size: clamp(0.9rem, 1.2vw, 1rem);
}

.childtalk-top {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.childtalk-main {
    display: grid;
    gap: 1rem;
    min-height: 0;
    grid-template-rows: minmax(120px, auto) minmax(0, 1fr);
}

.childtalk-status {
    background: #111a2e;
    border-radius: 24px;
    padding: 0.5rem;
    font-size: clamp(1.6rem, 3.2vw, 3.2rem);
    font-weight: 700;
    text-align: center;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.childtalk-status__primary {
    font-size: clamp(1.1rem, 3vw, 2.8rem);
}

.childtalk-status__secondary {
    font-size: clamp(1rem, 2.2vw, 1.8rem);
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    min-height: 1.4em;
}

.childtalk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.2 rem;
    min-height: 0;
}

.comm-tile {
    background: #111a2e;
    border: 2px solid #1f2a44;
    border-radius: 24px;
    padding: 1.1rem;
    color: #fff;
    min-height: 96px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    font-size: clamp(1.05rem, 2vw, 1.4rem);
    font-weight: 600;
}

.comm-tile--icon {
    padding: 0.6rem;
}

.comm-tile:active,
.childtalk-btn:active,
.osk-key:active {
    transform: scale(0.98);
}

.comm-tile__icon {
    font-size: clamp(2rem, 4.5vw, 3.2rem);
}

.childtalk-bottom {
    display: grid;
    gap: 0.2rem;
}

.childtalk-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.3rem;
    align-items: center;
}

.childtalk-rate {
    background: #111a2e;
    border-radius: 18px;
    padding: 0.75rem;
    display: grid;
    gap: 0.4rem;
    color: #fff;
}

.childtalk-rate input {
    width: 100%;
}

.childtalk-btn {
    background: #1f2a44;
    border: 2px solid #2c3b5f;
    color: #fff;
    border-radius: 20px;
    padding: 0.9rem 1rem;
    font-size: clamp(1rem, 2vw, 1.3rem);
    font-weight: 700;
    min-height: 60px;
}

.childtalk-btn--primary {
    background: #2563eb;
    border-color: #1d4ed8;
}

.childtalk-btn--danger {
    background: #dc2626;
    border-color: #b91c1c;
    font-size: clamp(1.1rem, 2.2vw, 1.5rem);
}

.childtalk-btn--yes {
    background: #16a34a;
    border-color: #15803d;
}

.childtalk-btn--no {
    background: #f97316;
    border-color: #ea580c;
}

.osk {
    background: #0f172a;
    border-radius: 24px;
    padding: 0.75rem;
    display: grid;
    gap: 0.5rem;
}

.osk-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
    gap: 0.5rem;
}

.osk-row--phrases {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.osk-key {
    background: #111a2e;
    color: #fff;
    border: 2px solid #1f2a44;
    border-radius: 18px;
    min-height: 60px;
    font-size: clamp(1.15rem, 2.4vw, 1.5rem);
    font-weight: 600;
}

.osk-key--wide {
    min-height: 60px;
    padding: 0 0.5rem;
}

.osk-key--action {
    background: #1f2a44;
}

.osk-key--primary {
    background: #2563eb;
    border-color: #1d4ed8;
}

@media (max-width: 640px) {
    .childtalk-page {
        padding: 0.75rem;
    }
}

@media (max-height: 900px) {
    .childtalk-page {
        gap: 0.75rem;
    }

    .childtalk-top {
        gap: 0.5rem;
    }

    .childtalk-status {
        padding: 1rem;
        font-size: clamp(1.4rem, 3vw, 2.6rem);
        min-height: 110px;
    }

    .comm-tile {
        min-height: 88px;
        padding: 0.6rem;
    }

    .childtalk-btn {
        min-height: 56px;
        padding: 0.7rem 0.9rem;
    }

    .osk-key,
    .osk-key--wide {
        min-height: 54px;
        font-size: clamp(1.05rem, 2.2vw, 1.35rem);
    }
}

@media (max-height: 800px) {
    .childtalk-page {
        gap: 0.5rem;
    }

    .childtalk-status {
        min-height: 96px;
    }

    .comm-tile {
        min-height: 76px;
    }

    .osk-row--phrases {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

.childtalk-btn--pain {
    background: #facc15;
    border-color: #eab308;
    color: #111827;
}

.pain-page {
    position: fixed;
    inset: 0;
    z-index: 210;
    background: #0b1220;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
    overflow: hidden;
    align-items: stretch;
}

.pain-topbar {
    display: grid;
    grid-template-columns: minmax(180px, auto) 1fr;
    gap: 0.75rem;
    align-items: center;
}

.pain-status {
    background: #111a2e;
    border-radius: 16px;
    padding: 0.75rem 1rem;
    font-size: clamp(1rem, 2.3vw, 1.4rem);
    font-weight: 700;
    min-height: 60px;
    display: flex;
    align-items: center;
}

.pain-board {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: 1;
    background: #0f172a;
    border-radius: 18px;
    overflow: hidden;
    touch-action: none;
    border: 2px solid #0a3f5f;
    min-height: 0;
}

.pain-hint {
    width: 100%;
    margin: 0;
    background: #111a2e;
    border-radius: 12px;
    padding: 0.5rem 0.75rem;
    font-size: clamp(0.9rem, 1.7vw, 1rem);
    color: rgba(255, 255, 255, 0.88);
}

.pain-canvas {
    position: relative;
    width: 100%;
    height: auto;
    transform-origin: top left;
}

.pain-image {
    width: 100%;
    height: auto;
    display: block;
}

.pain-spot-wrap {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

[data-label-side="left"].pain-spot-wrap {
    flex-direction: row-reverse;
}

.pain-spot {
    width: clamp(28px, 3.6vw, 46px);
    height: clamp(28px, 3.6vw, 46px);
    border-radius: 999px;
    border: 2px solid #0b3f63;
    background: rgba(250, 204, 21, 0.68);
    flex-shrink: 0;
}

.pain-spot--active {
    background: rgba(251, 146, 60, 0.82);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4);
}

.pain-spot-label {
    background: rgba(17, 26, 46, 0.92);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 0.25rem 0.55rem;
    font-size: clamp(0.7rem, 1.25vw, 0.92rem);
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.pain-workspace {
    display: grid;
    grid-template-columns: minmax(0, 55fr) minmax(120px, 15fr) minmax(260px, 30fr);
    gap: 0.75rem;
    flex: 1 1 auto;
    min-height: 0;
}

.pain-map-column {
    min-height: 0;
    display: flex;
}

.pain-indicator-column {
    min-height: 0;
    border-radius: 18px;
    border: 2px solid #0a3f5f;
    background: #d9e3e8;
    color: #0b1724;
    padding: 0.5rem;
}

.pain-level-card {
    --pain-scale-height: clamp(240px, 42vh, 460px);
    border: 2px solid #0a3f5f;
    border-radius: 18px;
    background: #e5eaee;
    padding: 0.35rem;
    height: 100%;
    display: grid;
    grid-template-rows: auto 1fr;
}

.pain-level-title {
    font-size: clamp(0.82rem, 1.1vw, 1.15rem);
    font-weight: 800;
    margin-bottom: 0.2rem;
    line-height: 1.15;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.pain-level-body {
    display: grid;
    min-height: 0;
}

.pain-scale-wrap {
    display: grid;
    grid-template-columns: 62px 1fr;
    gap: 0.35rem;
    min-height: 0;
    margin-top: 20px;
}

.pain-scale-track {
    position: relative;
    min-height: 0;
    height: var(--pain-scale-height);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pain-scale-gradient {
    width: 42px;
    height: var(--pain-scale-height);
    border: 2px solid #0a3f5f;
    border-radius: 12px;
    background: linear-gradient(
        to top,
        #38bdf8 0%,
        #22c55e 28%,
        #f6f400 52%,
        #f59e0b 76%,
        #ef4444 100%
    );
}

.pain-level-slider {
    position: absolute;
    width: var(--pain-scale-height);
    height: 42px;
    margin: 0;
    transform: rotate(-90deg);
    transform-origin: center center;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.pain-level-slider::-webkit-slider-runnable-track {
    background: transparent;
    border: none;
    height: 8px;
}

.pain-level-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 18px;
    border-radius: 5px;
    border: 2px solid #0a3f5f;
    background: #f8fafc;
    margin-top: -5px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

.pain-level-slider::-moz-range-track {
    background: transparent;
    border: none;
    height: 8px;
}

.pain-level-slider::-moz-range-thumb {
    width: 30px;
    height: 18px;
    border-radius: 5px;
    border: 2px solid #0a3f5f;
    background: #f8fafc;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

.pain-level-labels {
    position: relative;
    height: var(--pain-scale-height);
}

.pain-level-label {
    position: absolute;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #111827;
    text-align: left;
    font-size: clamp(0.62rem, 0.8vw, 0.9rem);
    font-weight: 700;
    line-height: 1.1;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.pain-level-arrow {
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-right: 11px solid #0a3f5f;
    flex-shrink: 0;
}

.pain-level-current {
    margin-top: 0.35rem;
    text-align: center;
    font-size: clamp(0.78rem, 0.95vw, 1rem);
    font-weight: 800;
    color: #111827;
}

.pain-actions-column {
    min-height: 0;
    border-radius: 18px;
    border: 2px solid #0a3f5f;
    background: #d9e3e8;
    color: #0b1724;
    padding: 0.5rem;
    display: flex;
}

.pain-actions-card {
    background: #0f6a91;
    border-radius: 26px;
    border: 2px solid #0a3f5f;
    padding: 0.45rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    align-content: start;
    overflow-y: auto;
    width: 100%;
}

.pain-action-btn {
    border: 2px solid #0a3f5f;
    border-radius: 16px;
    background: #e6ecef;
    color: #111827;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.45rem 0.35rem;
    font-size: clamp(0.78rem, 0.95vw, 1rem);
    font-weight: 700;
    text-align: center;
    min-height: 122px;
}

.pain-action-img {
    width: clamp(66px, 6.4vw, 90px);
    height: clamp(58px, 5.8vw, 80px);
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
}

@media (max-width: 1080px) {
    .pain-workspace {
        grid-template-columns: 1fr;
    }

    .pain-level-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }

    .pain-level-card {
        --pain-scale-height: 260px;
    }

    .pain-level-labels {
        height: 260px;
    }
}

@media (max-width: 768px) {
    .pain-topbar {
        grid-template-columns: 1fr;
    }

    .pain-board {
        min-height: 0;
        height: auto;
    }

    .pain-actions-card {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pain-action-img {
        width: 62px;
        height: 54px;
    }
}


