:root {
    --primary-color: #D81B60;
    --secondary-color: #FFB7C5;
    --text-color: #5D4037;
    --bg-gradient: linear-gradient(135deg, #FFF0F5 0%, #FFE4E1 100%);
    --header-bg: #ffffff;
    --chat-bg: #FFF1F7;
    --bubble-ai: #ffffff;
    --bubble-user: #FFE0EC;
}

body {
    margin: 0;
    padding: 0;
    font-family: "M PLUS Rounded 1c", "Saysettha OT", sans-serif;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg-gradient);
    color: var(--text-color);
    overflow: hidden;
    user-select: text;
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: border-box;
}

.page-title-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    text-align: center;
    padding: 8px 10px;
    font-size: 14px;
    font-weight: bold;
    color: var(--primary-color);
    background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
    text-shadow: none;
}

/* Header Styles */
#header {
    min-height: 60px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--header-bg);
    box-shadow: none;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

.header-left-group {
    display: flex;
    gap: 8px;
    z-index: 200;
    align-items: center;
}

.header-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-color) !important;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 100;
}

.header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #FFF;
    border: 1px solid var(--secondary-color);
    color: var(--text-color);
    padding: 5px 8px;
    border-radius: 50px;
    transition: 0.2s;
    box-shadow: none;
    min-width: 44px;
    /* Standardize for touch */
    min-height: 44px;
    /* Standardize for touch */
    text-decoration: none;
    font-size: 18px;
    box-sizing: border-box;
}

.header-btn:active {
    background: #FFE4E1;
    transform: scale(0.95);
}

.header-nav-group {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: space-around;
    flex-wrap: wrap;
}

.header-nav-group .header-btn {
    min-width: 40px;
    height: 40px;
    font-size: 16px;
}
.header-globe-icon {
    width: 22px;
    height: 22px;
    object-fit: cover;
    border-radius: 6px;
    vertical-align: middle;
}
.header-lang-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.header-lang-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #FFF;
    border: 1px solid var(--secondary-color);
    font-size: 11px;
    font-weight: bold;
    color: var(--text-color);
    box-shadow: none;
    pointer-events: none;
}
.header-lang-select {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    font-size: 16px;
}
.tts-result-btn {
    margin-left: 6px;
    padding: 2px 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
    vertical-align: middle;
    flex-shrink: 0;
}
.tts-result-btn:active { opacity: 0.8; }
.result-container .translated-text-large { font-size: 34px; }
.result-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
}

/* Sound Switch */
.switch-container {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: bold;
    color: var(--text-color);
    cursor: pointer;
    background: #FFF;
    border: 1px solid var(--secondary-color);
    padding: 5px 10px;
    border-radius: 50px;
    box-shadow: none;
    z-index: 200;
}

.toggle-input {
    appearance: none;
    width: 36px;
    height: 20px;
    background: #FFCDD2;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    outline: none;
}

.toggle-input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-input:checked {
    background: #A5D6A7;
}

.toggle-input:checked::after {
    left: 18px;
}

#soundStatus {
    font-size: 10px;
    min-width: 20px;
    text-align: center;
}

/* Mascot Styles */
.mascot-container {
    position: fixed;
    bottom: 15px;
    right: 15px;
    z-index: 50;
    pointer-events: none;
}

.mascot-container img,
.corner-mascot {
    width: 80px;
    height: auto;
    opacity: 0.9;
    filter: none;
}

@keyframes mascotGlow {
    0% {
        filter: none;
        transform: scale(1);
    }

    50% {
        filter: none;
        transform: scale(1.05);
    }

    100% {
        filter: none;
        transform: scale(1);
    }
}

.glowing-mascot {
    animation: mascotGlow 3s ease-in-out infinite;
}

/* Common Control/Action Bar Foundation */
#controls,
#translatorControls {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid var(--secondary-color);
    display: flex;
    flex-direction: column;
    padding-bottom: calc(env(safe-area-inset-bottom) + 30px);
    box-sizing: border-box;
    width: 100%;
}

/* @media (display-mode: standalone) ブロックは削除 */

/* Common Action Button */
#mainActionBtn {
    background: linear-gradient(145deg, #F48FB1, #D81B60);
    color: white;
    border: 2px solid #C2185B;
    border-bottom-width: 5px;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90%;
    height: 60px;
    /* Unified height */
    border-radius: 50px;
    margin: 10px auto;
    cursor: pointer;
    text-shadow: none;
    box-shadow: none;
    transition: all 0.1s;
    box-sizing: border-box;
}

#mainActionBtn:active {
    transform: translateY(3px);
    border-bottom-width: 2px;
}

#mainActionBtn:disabled {
    opacity: 0.5;
    background: #ccc;
    border-color: #999;
}

/* Translation Result Styles */
.result-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin: auto 0;
    position: relative;
    z-index: 20;
}

.translated-text-large {
    font-size: 22px;
    /* Standardize large text */
    font-weight: bold;
    color: inherit;
}

.source-text-small {
    font-size: 14px;
    color: #ccc;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 10px;
    margin-top: 5px;
}

/* Install Button Foundation */
/* Install Button Foundation */
#installBtn {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    background: #FFF;
    border: 2px solid var(--secondary-color);
    color: var(--primary-color);
    box-shadow: none;
    cursor: pointer;
    z-index: 2000;
    font-size: 20px;
    font-weight: bold;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#installBtn:active {
    transform: scale(0.90);
    background: #FFE4E1;
}

/* Install Button in Header Group */
.header-left-group #installBtn {
    position: static;
    transform: none;
    margin-left: 10px;
    display: flex;
}

/* Hide if installed (standalone mode) */
@media (display-mode: standalone) {
    #installBtn {
        display: none !important;
    }
}

.selector-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}
.share-btn-header {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
    padding: 6px 12px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    box-shadow: none;
}
.share-btn-header:active {
    transform: scale(0.95);
}
.share-btn-app {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 14px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    box-shadow: none;
    animation: shareGlow 2.5s ease-in-out infinite;
}
.share-btn-app .share-btn-lao { font-size: 15px; font-weight: bold; }
.share-btn-app .share-btn-en { font-size: 10px; opacity: 0.9; margin-top: 2px; }
.share-btn-app:active { transform: scale(0.96); }
@keyframes shareGlow {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: none; }
}
.share-btn-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    min-width: 36px;
    min-height: 36px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 18px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: none;
}
.share-btn-inline:active { transform: scale(0.95); }
.controls-action-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: nowrap;
}
.share-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    border: none;
    font-size: 24px;
    cursor: pointer;
    z-index: 9000;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.share-fab:active {
    transform: scale(0.95);
}
@keyframes fadeOut {
    to { opacity: 0; }
}
.main-scroll-wrap {
    position: relative;
    -webkit-overflow-scrolling: touch;
}
.nav-link-bar {
    margin-top: 20px;
    flex-shrink: 0;
}
.main-scroll-wrap #display {
    flex: none !important;
    min-height: max(20vh, calc(100dvh - 380px)) !important;
}
.main-scroll-wrap #mainArea {
    flex: none !important;
    min-height: max(20vh, calc(100dvh - 380px)) !important;
}
.main-scroll-wrap #jankenArea {
    flex: none !important;
    min-height: max(20vh, calc(100dvh - 380px)) !important;
}

/* ════════════════════════════════════════════════════════════
   かわいいリデザイン強化 (v68)
   ・やわらかいパステルの影を復活（上の box-shadow:none を後勝ちで上書き）
   ・PC 向けホバー演出
   ・大画面ではアプリを中央のスマホ型カードで表示
   ════════════════════════════════════════════════════════════ */

/* やわらかい背景に奥行きを足す */
body {
    background:
        radial-gradient(circle at 15% 0%, rgba(255, 216, 176, 0.30) 0, transparent 30%),
        radial-gradient(circle at 100% 12%, rgba(200, 162, 224, 0.25) 0, transparent 32%),
        var(--bg-gradient);
}

/* やさしい影を戻す */
#header {
    box-shadow: 0 4px 16px rgba(216, 27, 96, 0.08);
    border-bottom: 1px solid #FFE0EA;
    border-radius: 0 0 22px 22px;
}
.header-btn,
.header-lang-btn,
.switch-container {
    box-shadow: 0 3px 8px rgba(216, 27, 96, 0.12);
}
#mainActionBtn {
    box-shadow: 0 8px 20px rgba(216, 27, 96, 0.28);
}
.share-btn-header,
.share-btn-app,
.share-btn-inline {
    box-shadow: 0 6px 16px rgba(216, 27, 96, 0.28);
}
.share-fab {
    background: linear-gradient(145deg, #F48FB1, #D81B60);
    box-shadow: 0 8px 22px rgba(216, 27, 96, 0.40);
}
#installBtn {
    box-shadow: 0 4px 12px rgba(216, 27, 96, 0.20);
}
.swap-btn {
    box-shadow: 0 3px 8px rgba(216, 27, 96, 0.15);
}

/* かわいい入力欄：ピンクのやわらかフォーカスリング */
input,
textarea {
    transition: border-color .2s, box-shadow .2s;
}
input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(255, 183, 197, 0.45);
}

/* PC（マウス）でだけホバー演出。タッチ端末には影響しない */
@media (hover: hover) and (pointer: fine) {
    .header-btn:hover,
    .swap-btn:hover {
        transform: translateY(-2px);
        background: #FFF0F5;
        box-shadow: 0 6px 14px rgba(216, 27, 96, 0.20);
    }
    #mainActionBtn:hover {
        transform: translateY(-2px);
        box-shadow: 0 12px 26px rgba(216, 27, 96, 0.38);
        filter: brightness(1.04);
    }
    .share-btn-header:hover,
    .share-btn-app:hover,
    .share-btn-inline:hover,
    .share-fab:hover {
        transform: translateY(-2px);
        filter: brightness(1.05);
    }
}

/* かわいい細スクロールバー */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--secondary-color) transparent;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 8px;
}
::-webkit-scrollbar-track { background: transparent; }

/* ── タブレット/PC：中央のスマホ型カードで表示（崩れ防止・どの幅でも整う） ── */
@media (min-width: 600px) {
    html {
        min-height: 100dvh;
        display: flex;
        justify-content: center;
        background:
            radial-gradient(circle at 18% 18%, rgba(255, 183, 197, 0.32) 0, transparent 40%),
            radial-gradient(circle at 84% 80%, rgba(200, 162, 224, 0.30) 0, transparent 42%),
            linear-gradient(160deg, #FFF0F6 0%, #FCE7F3 50%, #F1E6FF 100%);
    }
    /* アプリ内部は 100dvh 前提。フルハイトの中央カラムにして見切れ／崩れを防ぐ */
    body {
        width: 440px;
        max-width: 100vw;
        height: 100dvh;
        margin: 0 auto;
        box-shadow: 0 0 50px rgba(216, 27, 96, 0.18);
        border-left: 1px solid rgba(255, 183, 197, 0.6);
        border-right: 1px solid rgba(255, 183, 197, 0.6);
    }
    /* 画面隅の固定要素を中央カラム付近へ寄せる */
    .mascot-container { display: none; }
    .share-fab { left: 50%; right: auto; margin-left: 150px; }
    #installBtn { left: calc(50% - 205px); }
}