/* Cozy Journaling mobile entry gate. The app remains usable if this file fails. */
.pwa-gate {
    display: none;
}

html.cozy-pwa-gate-active {
    background: #1B1428 !important;
}

html.cozy-pwa-gate-active body {
    overflow: hidden !important;
    overscroll-behavior: none;
    background: #1B1428 !important;
}

html.cozy-pwa-gate-active body > .container,
html.cozy-pwa-gate-active body > .app-topfade,
html.cozy-pwa-gate-active body > #menuTransition {
    visibility: hidden !important;
}

html.cozy-pwa-gate-active .pwa-gate {
    position: fixed;
    inset: 0;
    z-index: 30000;
    display: flex;
    align-items: stretch;
    justify-content: center;
    min-height: 100vh;
    min-height: 100svh;
    overflow-x: hidden;
    overflow-y: auto;
    color: #F8F0DE;
    background-color: #1B1428;
    background-image:
        linear-gradient(rgba(18, 14, 31, 0.82), rgba(27, 20, 40, 0.94)),
        url('/static/diary_night.webp');
    background-size: cover;
    background-position: center;
    -webkit-overflow-scrolling: touch;
}

.pwa-gate * {
    box-sizing: border-box;
}

.pwa-gate:focus {
    outline: none;
}

.pwa-gate [hidden] {
    display: none !important;
}

.pwa-gate-shell {
    position: relative;
    width: min(100%, 440px);
    min-height: 100%;
    margin: auto;
    padding:
        calc(env(safe-area-inset-top, 0px) + 34px)
        max(22px, env(safe-area-inset-right, 0px))
        calc(env(safe-area-inset-bottom, 0px) + 34px)
        max(22px, env(safe-area-inset-left, 0px));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

html[data-pwa-gate-mode='ios'] .pwa-gate-shell {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 34px);
}

.pwa-gate-icon {
    width: 96px;
    height: 96px;
    flex: 0 0 auto;
    display: block;
    border-radius: 24px;
    box-shadow:
        0 18px 42px rgba(4, 3, 10, 0.42),
        0 0 0 1px rgba(235, 207, 144, 0.32);
}

.pwa-gate-kicker {
    margin-top: 18px;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 15px;
    line-height: 1.2;
    letter-spacing: 0;
    color: #DFC58B;
}

.pwa-gate-title {
    max-width: 350px;
    margin: 13px 0 0;
    font-family: 'Shippori Mincho', 'Yu Mincho', serif;
    font-size: 22px;
    font-weight: 500;
    line-height: 1.75;
    letter-spacing: 0;
    color: #FFF8E9;
    text-wrap: balance;
}

.pwa-gate-copy {
    margin: 10px 0 0;
    font-family: 'Shippori Mincho', 'Yu Mincho', serif;
    font-size: 12.5px;
    line-height: 1.9;
    letter-spacing: 0;
    color: rgba(241, 229, 204, 0.76);
}

.pwa-gate-panel {
    width: 100%;
    margin-top: 24px;
}

.pwa-gate-steps {
    width: 100%;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 9px;
    list-style: none;
}

.pwa-gate-step {
    min-height: 72px;
    padding: 11px 12px;
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    text-align: left;
    border: 1px solid rgba(222, 197, 139, 0.25);
    border-radius: 8px;
    background: rgba(15, 12, 27, 0.54);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.pwa-gate-step-number {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(222, 197, 139, 0.55);
    border-radius: 50%;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 17px;
    font-weight: 600;
    color: #E4CC96;
}

.pwa-gate-step-body {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
}

.pwa-gate-step-body strong {
    min-width: 0;
    font-family: 'Shippori Mincho', 'Yu Mincho', serif;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.65;
    color: #F8F0DE;
}

.pwa-gate-compact-toolbar {
    width: 112px;
    height: 32px;
    padding: 0 5px 0 7px;
    display: flex;
    align-items: center;
    gap: 5px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    background: rgba(246, 244, 241, 0.97);
    box-shadow: 0 3px 10px rgba(2, 2, 8, 0.22);
}

.pwa-gate-toolbar-back {
    flex: 0 0 auto;
    color: #777781;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 18px;
    line-height: 1;
}

.pwa-gate-url-pill {
    height: 20px;
    flex: 1 1 auto;
    border-radius: 10px;
    background: #E2E2E5;
}

.pwa-gate-toolbar-more {
    width: 23px;
    height: 23px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #C7A75A;
    color: #221A13;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(199, 167, 90, 0.24);
}

.pwa-gate-share-icon {
    position: relative;
    width: 18px;
    height: 16px;
    display: block;
    border: 1.5px solid #1677D2;
    border-radius: 3px;
    border-top: 0;
}

.pwa-gate-share-icon::before {
    content: '';
    position: absolute;
    left: 7px;
    top: -6px;
    width: 1.5px;
    height: 11px;
    background: #1677D2;
}

.pwa-gate-share-icon::after {
    content: '';
    position: absolute;
    left: 4.5px;
    top: -6px;
    width: 5px;
    height: 5px;
    border-top: 1.5px solid #1677D2;
    border-left: 1.5px solid #1677D2;
    transform: rotate(45deg);
}

.pwa-gate-menu-row {
    width: 118px;
    min-height: 34px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 7px;
    background: rgba(247, 246, 244, 0.97);
    color: #25242A;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 9.5px;
    line-height: 1.25;
    white-space: nowrap;
}

.pwa-gate-share-row {
    width: 88px;
}

.pwa-gate-menu-row i {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #65656C;
    border-radius: 4px;
    font-style: normal;
    font-size: 15px;
    line-height: 1;
}

.pwa-gate-after,
.pwa-gate-alternative,
.pwa-gate-status {
    margin: 13px auto 0;
    max-width: 330px;
    font-family: 'Shippori Mincho', 'Yu Mincho', serif;
    font-size: 11.5px;
    line-height: 1.8;
    letter-spacing: 0;
    color: rgba(241, 229, 204, 0.72);
}

.pwa-gate-alternative {
    margin-top: 12px;
    padding-top: 11px;
    border-top: 1px solid rgba(222, 197, 139, 0.18);
    color: rgba(241, 229, 204, 0.62);
    font-size: 10.5px;
}

.pwa-gate-install,
.pwa-gate-close {
    width: min(100%, 310px);
    min-height: 50px;
    margin: 0 auto;
    padding: 12px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid rgba(246, 226, 179, 0.65);
    border-radius: 8px;
    background: #C7A75A;
    color: #221A13;
    font-family: 'Shippori Mincho', 'Yu Mincho', serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0;
    box-shadow: 0 10px 24px rgba(2, 2, 8, 0.3);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.pwa-gate-install:active,
.pwa-gate-close:active {
    transform: scale(0.98);
}

.pwa-gate-install:focus-visible,
.pwa-gate-close:focus-visible {
    outline: 2px solid #FFF2C9;
    outline-offset: 3px;
}

.pwa-gate-phone-icon {
    position: relative;
    width: 17px;
    height: 24px;
    display: inline-block;
    border: 1.5px solid currentColor;
    border-radius: 4px;
}

.pwa-gate-phone-icon i {
    position: absolute;
    right: -6px;
    top: -6px;
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #221A13;
    color: #F6DE9F;
    font-family: sans-serif;
    font-size: 12px;
    font-style: normal;
    line-height: 1;
}

.pwa-gate-android-fallback,
/* リンク化 (タップでSafari/Chrome直接起動) してもボタン風の見た目を維持 */
a.pwa-gate-open-row { text-decoration: none; color: inherit; -webkit-tap-highlight-color: transparent; cursor: pointer; }
.pwa-gate-open-row {
    width: min(100%, 310px);
    min-height: 56px;
    margin: 0 auto;
    padding: 11px 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 13px;
    border: 1px solid rgba(222, 197, 139, 0.25);
    border-radius: 8px;
    background: rgba(15, 12, 27, 0.54);
    font-family: 'Shippori Mincho', 'Yu Mincho', serif;
    font-size: 12.5px;
    line-height: 1.65;
    color: #F8F0DE;
}

.pwa-gate-dots,
.pwa-gate-more {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(222, 197, 139, 0.48);
    border-radius: 50%;
    color: #E4CC96;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 23px;
    line-height: 1;
}

.pwa-gate-done-mark {
    width: 52px;
    height: 52px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(228, 204, 150, 0.58);
    border-radius: 50%;
    color: #E4CC96;
    font-family: Georgia, serif;
    font-size: 24px;
}

.pwa-gate-close {
    margin-top: 20px;
}

.pwa-gate-live {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 400px) {
    .pwa-gate-step:nth-child(3) .pwa-gate-step-body {
        grid-template-columns: minmax(0, 1fr);
    }
    .pwa-gate-step:nth-child(3) .pwa-gate-menu-row {
        margin-top: 4px;
    }
}

@media (max-width: 340px) {
    .pwa-gate-shell {
        padding-left: max(16px, env(safe-area-inset-left, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
    }
    .pwa-gate-icon { width: 82px; height: 82px; border-radius: 21px; }
    .pwa-gate-title { font-size: 18.5px; text-wrap: nowrap; white-space: nowrap; }
    .pwa-gate-step-body { grid-template-columns: minmax(0, 1fr); }
    .pwa-gate-compact-toolbar,
    .pwa-gate-menu-row { margin-top: 4px; }
}

@media (max-height: 720px) {
    .pwa-gate-shell { justify-content: flex-start; }
    .pwa-gate-icon { width: 76px; height: 76px; border-radius: 19px; }
    .pwa-gate-kicker { margin-top: 12px; }
    .pwa-gate-title { margin-top: 8px; font-size: 20px; line-height: 1.6; }
    .pwa-gate-copy { margin-top: 6px; }
    .pwa-gate-panel { margin-top: 17px; }
}

@media (prefers-reduced-motion: reduce) {
    .pwa-gate-install:active,
    .pwa-gate-close:active { transform: none; }
}

/* 実機FB (2026-08-22): 下バーに共有ボタンが直接見えるSafariを手順1の主役に */
.pwa-gate-classic-toolbar {
    width: 112px;
    height: 32px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    background: rgba(246, 244, 241, 0.97);
    box-shadow: 0 3px 10px rgba(2, 2, 8, 0.22);
}
.pwa-gate-tb-side {
    color: #9A9AA2;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1;
}
.pwa-gate-tb-share {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(199, 167, 90, 0.22);
    box-shadow: 0 0 0 2px #C7A75A;
}
.pwa-gate-alt-box {
    margin: 14px 0 0;
    padding: 12px 14px;
    border: 1px dashed rgba(255, 255, 255, 0.28);
    border-radius: 12px;
    text-align: left;
}
.pwa-gate-alt-title {
    margin: 0 0 8px;
    font-family: 'Shippori Mincho', 'Yu Mincho', serif;
    font-size: 12px;
    color: #D9C89B;
    letter-spacing: 0.06em;
}
.pwa-gate-alt-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.pwa-gate-alt-row .pwa-gate-compact-toolbar { flex: 0 0 auto; }
.pwa-gate-alt-body {
    font-size: 11.5px;
    line-height: 1.7;
    color: rgba(248, 240, 222, 0.9);
}
