/* Login-only overrides: scale the complete composition to suit the viewport. */
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body.signin {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    color: #302b3c;
    background: #f7f8fc;
}

.blockUI.blockOverlay { top: 0 !important; }
label.error { position: inherit; }

.wrapper-loginbox {
    --login-gap: 16px;
    --login-control-height: 48px;
    --login-fill-ratio: 0;
    box-sizing: border-box;
    position: fixed;
    inset: 0;
    top: var(--login-viewport-top, 0px);
    width: 100%;
    height: 100%;
    height: var(--login-viewport-height, 100dvh);
    min-height: 0;
    padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 40%, #eeeaf7 0, #f7f8fc 65%);
}

.login-wrapper {
    box-sizing: border-box;
    width: min(100%, 448px);
    min-width: 0;
    height: auto;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
    background: transparent;
    transform: scale(var(--login-scale, 1));
    transform-origin: center;
}

.login-wrapper,
.login-wrapper *,
.login-wrapper *::before,
.login-wrapper *::after {
    transition: none !important;
    animation: none !important;
}

.login-wrapper .logo-text {
    width: 100%;
    margin: 0 0 24px;
    padding: 0;
    text-align: center;
}

.login-wrapper .logo-text img {
    display: block;
    width: 280px;
    max-width: 72%;
    height: auto;
    margin: 0 auto;
}

.login-container { width: 100%; min-width: 0; margin: 0; padding: 0; }

.login-wrapper .signinpanel {
    box-sizing: border-box;
    float: none;
    width: 100%;
    /* 項目数が違っても、ログイン画面と同じカードの高さに揃えます。 */
    min-height: var(--login-panel-min-height, 0px);
    margin: 0;
    padding: 32px;
    border: 1px solid #e9e6ef;
    border-radius: 20px;
    background: #fff;
    /* The shared theme declares its much heavier shadow with !important. */
    box-shadow: 0 16px 48px rgba(42, 30, 68, .07), 0 2px 8px rgba(42, 30, 68, .03) !important;
}

.login-wrapper .signinpanel p { margin: 0; font-size: 13px; line-height: 1.5; }
.login-note { color: #d1242f; }
.login-summary { display: grid; gap: 12px; }
.login-summary span { display: block; color: #51495f; font-size: 13px; font-weight: 600; line-height: 18px; }
.login-summary strong { display: block; margin-top: 6px; color: #302b3c; font-size: 16px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }

.login-heading { margin-bottom: 24px; text-align: center; }
.login-heading h1 { margin: 0; color: #302b3c; font-size: 24px; font-weight: 700; line-height: 1.4; }

.login-mode-switch {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 4px;
    margin: 0 0 24px;
    padding: 4px;
    border-radius: 11px;
    background: #f3f1f7;
}

.login-mode-button {
    min-width: 0;
    min-height: 40px;
    padding: 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #777080;
    font-family: Impact, Haettenschweiler, 'Arial Narrow', sans-serif;
    font-size: 20px;
    font-weight: 400;
    line-height: 24px;
    cursor: pointer;
}

.login-mode-button.active {
    background: #fff;
    color: #7136c8;
    box-shadow: 0 2px 6px rgba(47, 30, 72, .09);
}

/* Both panes contribute to one stable height, so tab changes never resize or
   rescale the card. The inactive pane is also inert and hidden from assistive tech. */
.login-panes { display: grid; }
.login-panes > .login-pane { grid-area: 1 / 1; min-width: 0; align-self: start; }
.login-pane[aria-hidden="true"] { visibility: hidden; pointer-events: none; }

.login-wrapper .signinpanel form {
    display: grid;
    gap: var(--login-gap);
    float: none;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
}

.login-section { display: grid; gap: var(--login-gap); min-width: 0; }

.login-field { display: grid; gap: 6px; min-width: 0; }
.login-field > label { margin: 0; color: #51495f; font-size: 13px; font-weight: 600; line-height: 18px; }

.login-wrapper .signinpanel .form-control {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: var(--login-control-height) !important;
    margin: 0;
    padding: 0 14px !important;
    border: 1px solid #ddd9e5 !important;
    border-radius: 9px !important;
    background: #fff;
    color: #302b3c;
    box-shadow: none;
    font-size: 16px;
    line-height: 1.5;
}

.login-wrapper .signinpanel .form-control::placeholder { color: #aaa4b3; font-size: 14px; }
.login-wrapper .signinpanel .form-control:focus {
    border-color: #8c61cb !important;
    outline: none;
    box-shadow: 0 0 0 3px rgba(113, 54, 200, .09);
}

.login-pane .checkbox-custom { display: flex; align-items: center; gap: 8px; margin: 0; min-height: 20px; }
.login-pane .checkbox-custom input { width: 16px; height: 16px; margin: 0; accent-color: #7136c8; cursor: pointer; }
.login-wrapper .checkbox-custom label { margin: 0; color: #777080; font-size: 13px; font-weight: 400; line-height: 20px; cursor: pointer; }

.login-wrapper .signinpanel .btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: var(--login-control-height);
    margin: 0;
    padding: 0 16px;
    border: 0;
    border-radius: 9px !important;
    background: #7136c8;
    color: #fff;
    font-size: 16px !important;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(113, 54, 200, .12);
    text-decoration: none;
}

.login-wrapper .signinpanel .btn-primary::before { display: none; }
.login-wrapper .signinpanel .btn-primary:hover,
.login-wrapper .signinpanel .btn-primary:focus,
.login-wrapper .signinpanel .btn-primary:active,
.login-wrapper .signinpanel .btn-primary.active { background: #602bb1; border: 0; transform: none; }
.login-wrapper .signinpanel .btn-primary.is-loading,
.login-wrapper .signinpanel .btn-primary.is-loading:hover { gap: 8px; background: #8c61cb; opacity: 1; cursor: wait; }
.login-wrapper .signinpanel .btn-primary .login-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: login-spin .8s linear infinite;
}
@keyframes login-spin { to { transform: rotate(360deg); } }

.login-wrapper .link-text { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0; font-size: 14px; text-align: center; }
.login-wrapper .link-text a { color: #7b5aab; line-height: 22px; text-decoration: none; }
.login-wrapper .link-text a:hover { color: #602bb1; text-decoration: underline; }
.login-mode-button:focus-visible,
.login-wrapper .btn-primary:focus-visible,
.login-wrapper a:focus-visible { outline: 2px solid #8c61cb; outline-offset: 3px; }

.login-wrapper .signup-footer { width: 100%; margin: 20px 0 0; padding: 0; border: 0; color: #96909f; font-size: 11px; line-height: 18px; text-align: center; overflow-wrap: anywhere; }

/* On desktop, fill most of the available height with the entire composition.
   login-layout.js scales the logo, type and controls together and checks both axes. */
@media (min-width: 900px) and (min-height: 601px) {
    .wrapper-loginbox { --login-fill-ratio: .86; --login-reference-height: 647px; --login-panel-min-height: 510px; }
    .login-wrapper { width: min(100%, 520px); }
}

@media (max-width: 480px) {
    .wrapper-loginbox { padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
    .login-wrapper .signinpanel { padding: 28px 24px; border-radius: 18px; }
    .login-wrapper .logo-text img { width: 240px; }
}

/* Compact spacing follows available height, independently of device width. */
@media (min-width: 900px) and (min-height: 601px) and (max-height: 740px) {
    .wrapper-loginbox { --login-reference-height: 563px; --login-panel-min-height: 451px; }
}

@media (max-height: 740px) {
    .wrapper-loginbox { --login-gap: 12px; --login-control-height: 44px; }
    .login-wrapper .logo-text { margin-bottom: 18px; }
    .login-wrapper .logo-text img { width: 232px; }
    .login-wrapper .signinpanel { padding: 24px; }
    .login-heading, .login-mode-switch { margin-bottom: 20px; }
    .login-heading h1 { font-size: 22px; }
    .login-wrapper .signup-footer { margin-top: 14px; }
}

@media (max-height: 600px) {
    .wrapper-loginbox { --login-gap: 10px; --login-control-height: 40px; padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .login-wrapper .logo-text { margin-bottom: 12px; }
    .login-wrapper .logo-text img { width: 200px; }
    .login-wrapper .signinpanel { padding: 20px 24px; }
    .login-heading { margin-bottom: 14px; }
    .login-mode-switch { margin-bottom: 14px; }
    .login-mode-button { min-height: 36px; padding: 6px; }
    .login-field { gap: 4px; }
    .login-wrapper .signup-footer { margin-top: 10px; }
}

/* A side-by-side brand and form leave more room in phone landscape. */
@media (min-width: 620px) and (max-height: 520px) {
    .login-wrapper { display: grid; grid-template-columns: minmax(140px, 180px) minmax(0, 400px); align-items: center; column-gap: 28px; width: min(100%, 608px); }
    .login-wrapper .logo-text { grid-column: 1; grid-row: 1; align-self: end; margin: 0 0 12px; }
    .login-wrapper .logo-text img { width: 100%; max-width: 100%; }
    .login-container { grid-column: 2; grid-row: 1 / 3; }
    .login-wrapper .signup-footer { grid-column: 1; grid-row: 2; align-self: start; margin: 0; font-size: 10px; }
    .login-heading { display: none; }
    .login-wrapper .signinpanel { padding: 20px 24px; }
}

/* Login notice: shown only beside the form on wide screens. */
.notice-sticky { display: none; }

/* The reserved right padding keeps login-layout.js from scaling the card under the panel. */
@media (min-width: 1100px) {
    .wrapper-loginbox.has-notice {
        --notice-width: clamp(420px, 40vw, 680px);
        padding-right: calc(var(--notice-width) + 60px);
    }
    .notice-sticky {
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        position: fixed;
        z-index: 1000;
        top: 50%;
        right: 20px;
        transform: translateY(-50%);
        width: var(--notice-width);
        max-height: calc(100% - 40px);
        /* Scrolling happens in .notice-body so the scrollbar never cuts the rounded corners. */
        overflow: hidden;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        border-radius: 20px;
        box-shadow:
            0 25px 80px rgba(0, 0, 0, 0.25),
            0 15px 40px rgba(0, 0, 0, 0.15),
            0 8px 20px rgba(0, 0, 0, 0.1),
            0 0 0 1px rgba(0, 0, 0, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    .notice-sticky::before {
        content: '';
        flex: 0 0 4px;
        background: linear-gradient(90deg, #f093fb, #f5576c, #4facfe, #00f2fe);
    }
    .notice-body {
        min-height: 0;
        padding: 28px 32px 16px;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        color: black;
        font-size: 14px;
        line-height: 1.65;
    }
    .notice-body p { margin: 0 0 12px; }
    .notice-body p:first-of-type { margin-bottom: 16px; font-weight: 600; font-size: 16px; }
    .notice-body ul { margin: 0 0 12px; padding-left: 1.4em; }
    .notice-body a { color: #0066cc; text-decoration: none; }
    .notice-body a:hover { text-decoration: underline; }
}

/* Lower desktop screens tighten the notice so it still fits without scrolling. */
@media (min-width: 1100px) and (max-height: 820px) {
    .notice-body { padding: 22px 28px 10px; font-size: 13px; line-height: 1.6; }
    .notice-body p { margin-bottom: 10px; }
    .notice-body p:first-of-type { margin-bottom: 12px; font-size: 15px; }
    .notice-body ul { margin-bottom: 10px; }
}

@media (max-height: 380px) {
    .wrapper-loginbox { --login-gap: 8px; --login-control-height: 36px; }
    .login-wrapper .signinpanel { padding: 14px 20px; }
    .login-heading { display: none; }
    .login-mode-switch { margin-bottom: 10px; }
    .login-mode-button { min-height: 32px; padding: 4px; }
    .login-field > label { font-size: 12px; line-height: 16px; }
    .login-wrapper .link-text { gap: 0; font-size: 13px; }
}
