/**
 * ======================================================================
 * 1. DESIGN TOKENS & RESET
 * ======================================================================
 */

/* Beta / Environment Indicators */
.beta-label {
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    white-space: nowrap;
}

#beta-indicator {
    position: fixed;
    top: 10px;
    right: 10px;
    background: var(--accent-color);
    color: white;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    letter-spacing: 1px;
    opacity: 0.9;
}

:root {
    --primary-color: #2D3436;
    --accent-color: #D4AF37;
    --bg-color: #F9F9F9;
    --text-color: #333;
    --white: #FFF;
    --error-color: #E74C3C;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: "Noto Sans JP", sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Dashboard Typography Override (No Mincho) */
h1,
h2,
h3,
h4,
.page-title {
    font-family: var(--body-font) !important;
}

/**
 * ======================================================================
 * 2. AUTHENTICATION PAGES (Login / Signup)
 * ======================================================================
 */
.auth-container {
    margin: auto;
    background: var(--white);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    text-decoration: none;
}

.auth-logo img {
    height: 48px;
    width: auto;
}

/* Dashboard Header adjustments when inside header */
.app-header .auth-logo {
    margin-bottom: 0;
}

.app-header .auth-logo img {
    height: 32px;
    /* Smaller in header */
    width: auto;
}

/* Responsive Logo Switching */
.logo-desktop {
    display: block;
}

.logo-mobile {
    display: none;
}

.auth-links {
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.auth-links a {
    color: var(--accent-color);
    text-decoration: none;
}

/**
 * ======================================================================
 * 3. LAYOUT & DASHBOARD COMMON
 * ======================================================================
 */
.dashboard-body {
    display: flex;
    flex-direction: column;
    /* Override flex center from body */
    justify-content: flex-start;
    padding-top: 60px;
    /* Header height */
    min-height: 100vh;
    align-items: stretch;
}

/* Ensure container expands in dashboard */
.dashboard-body>main,
.dashboard-body>.container {
    flex: 1;
    width: 100%;
    /* Ensure full width */
}

.app-header {
    background: var(--white);
    height: 60px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 100;
    transition: height 0.3s;
}

/* Mobile Header Adjustments */
@media (max-width: 600px) {

    /* Remove top padding since header is relative */
    .app-content {
        padding-top: 0 !important;
    }

    .app-header {
        position: relative;
        height: auto;
        padding: 10px 15px;
        width: 100%;
        box-sizing: border-box;

        /* GRID LAYOUT: Strict control */
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        grid-template-rows: 32px auto;
        /* Reserve top row for absolute elements */
        grid-template-areas:
            "badge logo menu"
            "vital vital vital";
        align-items: center;
        gap: 5px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }

    /* 2. LOGO (Center Absolute) */
    .auth-logo {
        /* grid-area: logo; - reset */
        position: absolute !important;
        left: 50%;
        transform: translateX(-50%) translateY(-50%) !important;
        top: 26px;
        /* Center of 32px row + padding */
        margin: 0;
        justify-self: center;
        align-self: center;
        z-index: 5;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .auth-logo .beta-label {
        position: absolute;
        left: 50%;
        /* Half of logo width (approx 16px) + gap (4px) */
        margin-left: 20px;
        top: 50%;
        transform: translateY(-50%);
        /* Reset any inherited margins */
        margin-top: 0 !important;
        top: auto;
    }

    .logo-desktop {
        display: none;
    }

    .logo-mobile {
        display: block;
        height: 32px;
        vertical-align: middle;
    }

    /* Plan Badge (Restored LHS - Grid) */
    #badge-container-mobile {
        grid-area: badge;
        display: inline-flex !important;
        align-items: center;
        justify-self: start;
        align-self: center;
        margin: 0;
        /* Remove absolute */
        position: static !important;
        transform: none !important;
        z-index: 10;
    }

    /* 3. MENU (Right - Grid) */
    .user-menu {
        grid-area: menu;
        justify-self: end;
        align-self: center;
        margin: 0;
        display: flex;
        align-items: center;
        gap: 0;
        /* Remove absolute */
        position: static !important;
        transform: none !important;
        z-index: 5;
    }

    #badge-container-desktop {
        display: none !important;
    }

    .user-menu #user-email {
        display: none !important;
    }

    /* Logout Button: New User Specs */
    .btn-logout,
    .btn-back {
        text-decoration: none !important;
        white-space: nowrap !important;
        font-size: 0.8rem;
        padding: 4px 10px;
        background: linear-gradient(to bottom, #f1f5f9, #cbd5e1);
        border: 1px solid #94a3b8;
        border-radius: 4px;
        color: #334155;
        font-weight: 600;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
        transition: all 0.2s ease;
        display: inline-flex;
        align-items: center;
        gap: 3px;
    }

    .btn-logout::before {
        content: '\f2f5';
        /* FontAwesome sign-out-alt */
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        font-size: 0.75rem;
    }

    .btn-logout:hover,
    .btn-back:hover {
        background-color: #f1f5f9;
        border-color: #94a3b8;
        color: #0f172a;
    }

    /* 4. VITAL CHECK (Bottom Row - Full Width) */
    .vital-check-area {
        grid-area: vital;
        grid-column: 1 / -1;
        width: 100%;
        margin-top: 0;
        padding-top: 8px;
        border-top: 1px solid #f0f0f0;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .vital-text {
        font-size: 0.75rem;
    }

    .page-title {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }

    .desktop-text {
        display: none !important;
    }

    .mobile-text {
        display: inline !important;
    }
}

/* PC Defaults (Outside Media Query or Default) */
#badge-container-mobile {
    display: none;
}

#badge-container-desktop {
    display: inline-block;
    margin: 0 10px;
}

/* Ensure PC Layout is untouched */
@media (min-width: 601px) {
    .app-header {
        position: fixed;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
    }

    .auth-logo {
        margin-right: 20px;
        order: 0;
        flex-shrink: 0;
    }

    /* Vital Check: Move to Right */
    .vital-check-area {
        margin-left: auto;
        /* Push to Right */
        margin-right: 15px;
        /* Gap to Menu */
        flex-grow: 0;
        flex-shrink: 0;
        width: auto;
        justify-content: flex-start;
        display: flex;
        align-items: center;
        white-space: nowrap;
        order: 0;
    }

    .vital-check-area .btn-alive {
        width: auto;
        min-width: 120px;
    }

    .user-menu {
        margin-left: 0;
        display: flex;
        align-items: center;
        gap: 15px;
        order: 0;
        flex-shrink: 0;
    }
}

/* Modal Restructuring Styles */
.modal-lg {
    max-width: 600px;
    /* Slightly wider */
}

.form-section {
    background: #fdfdfd;
    border: 1px solid #eee;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.form-section-title {
    font-size: 1rem;
    font-weight: bold;
    color: #444;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 8px;
    margin-bottom: 15px;
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-required {
    background: #ff4d4f;
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 5px;
    vertical-align: middle;
}

/* Radio Group Styling (Updated for Stacking) */
.radio-group {
    display: flex;
    flex-direction: column;
    /* Stack vertically */
    gap: 10px;
    /* Space between options */
    margin-top: 5px;
}

.radio-group label {
    margin-right: 0;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    margin-bottom: 0;
    /* Ensure no extra margin if not needed, or add if desired for spacing */
}

.radio-group input[type="radio"] {
    margin-right: 8px;
    transform: scale(1.1);
}

/* Adjust dashboard padding for Mobile because Header is relative */
@media (max-width: 600px) {
    .dashboard-body {
        padding-top: 0 !important;
        /* Header is relative, so no padding needed */
    }
}

.add-recipient-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.line-invite-box {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 12px;
    border-radius: 6px;
    margin-top: 10px;
}

.media-section {
    background: #fefef2;
    border-color: #fef3c7;
}

.media-upload-area {
    text-align: center;
    padding: 10px;
}

.media-actions-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.media-preview-container {
    margin-top: 15px;
    position: relative;
    display: inline-block;
}

.media-preview-content {
    max-width: 100%;
    max-height: 250px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-media-delete {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff4d4f;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.sticky-actions {
    position: sticky;
    bottom: -30px;
    /* Offset parent padding */
    background: white;
    padding: 15px 0;
    border-top: 1px solid #eee;
    z-index: 10;
    margin-bottom: -30px;
    /* Extend to bottom */
}

.btn-test-send {
    background: #6c757d;
    color: white;
}

/* Ensure channel select is visible */
.channel-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.channel-chip {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
}

.channel-chip.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.channel-panel {
    display: none;
    padding: 10px;
    background: #fff;
    border-radius: 4px;
}

.channel-panel.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.switch-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #000;
}

/* X Color */
input:checked+.slider:before {
    transform: translateX(24px);
}

/* Utility for Text Toggling */
.mobile-text {
    display: none;
}


.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

.page-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

/**
 * ======================================================================
 * 4. COMPONENTS: FORMS & BUTTONS
 * ======================================================================
 */
.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #666;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.checkbox-group input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label {
    font-size: 0.85rem;
    color: #666;
}

.checkbox-label a {
    color: var(--accent-color);
    font-weight: 500;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 12px;
    width: 100%;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary:hover {
    background-color: #000;
}

.btn-secondary {
    background-color: #636e72;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background-color: #2d3436;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.85rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    color: white;
}

.btn-edit {
    background-color: #3498db;
}

.btn-edit:hover {
    background-color: #2980b9;
}

.btn-delete {
    background-color: #e74c3c;
}

.btn-delete:hover {
    background-color: #c0392b;
}

.btn-warning {
    background-color: #f39c12;
    color: white;
}

.btn-warning:hover {
    background-color: #e67e22;
}

/* Logout Button (Global) */
.btn-logout,
.btn-back {
    text-decoration: none !important;
    white-space: nowrap;
    padding: 4px 10px;
    background: linear-gradient(to bottom, #f1f5f9, #cbd5e1);
    border: 1px solid #94a3b8;
    border-radius: 4px;
    color: #334155;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    cursor: pointer;
}

.btn-logout::before {
    content: '\f2f5';
    /* FontAwesome sign-out-alt */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.9rem;
    color: #64748b;
}

.btn-logout:hover,
.btn-back:hover {
    background: linear-gradient(to bottom, #f8fafc, #e2e8f0);
    border-color: #94a3b8;
    color: #1e293b;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.error-message {
    color: var(--error-color);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    display: none;
}

/**
 * ======================================================================
 * 5. COMPONENTS: MESSAGE CARDS (Accordion)
 * ======================================================================
 */
.message-card {
    background: var(--white);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    border: 1px solid transparent;
}

.message-card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    background-color: #fafafa;
    border-color: #eee;
}

.msg-card-border-sent {
    border-left: 5px solid #27ae60;
}

.msg-card-border-pending {
    border-left: 5px solid #f39c12;
}

.msg-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    align-items: center;
}

.msg-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
    margin-right: 5px;
}

.status-badge-sent {
    background: #eafaf1;
    color: #27ae60;
}

.status-badge-pending {
    background: #fef9e7;
    color: #f39c12;
}

.msg-subject {
    font-size: 1.1em;
    font-weight: bold;
}

.msg-date {
    color: #666;
    font-size: 0.85em;
}

.accordion-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--accent-color);
    font-weight: 500;
}

.accordion-circle {
    width: 28px;
    height: 28px;
    background: #f0f0f0;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.message-card.expanded .accordion-circle {
    background: var(--accent-color);
    color: white;
}

.accordion-icon {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
}

.message-card.expanded .accordion-icon {
    transform: rotate(180deg);
}

.msg-recipient-row {
    font-size: 0.9em;
    color: #555;
    margin-bottom: 10px;
}

.msg-actions {
    margin-top: 5px;
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.msg-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
}

.message-card.expanded .msg-details {
    max-height: 2000px;
    opacity: 1;
}

.msg-divider {
    border: none;
    border-top: 1px solid #eee;
    margin: 10px 0;
}

.msg-body {
    white-space: pre-wrap;
    color: #333;
}

.msg-sent-time {
    margin-top: 10px;
    font-size: 0.85em;
    color: #27ae60;
}

.msg-error {
    color: var(--error-color);
}

/**
 * ======================================================================
 * 6. VITAL CHECK & SETTINGS
 * ======================================================================
 */
.vital-check-area {
    margin-left: auto;
    margin-right: 20px;
    display: flex;
    flex-direction: column;
    /* 常に縦並び */
    align-items: center;
    /* 中央揃え */
    justify-content: center;
    gap: 5px;
    /* 隙間を調整 */
}

.vital-text {
    font-size: 0.8rem;
    color: #666;
}

.btn-alive {
    padding: 5px 15px;
    font-size: 0.9rem;
    background-color: #27ae60;
}

.settings-section {
    margin-top: 40px;
}

.settings-title {
    font-size: 1.3rem;
    margin-bottom: 20px;
    padding-left: 10px;
    border-left: 4px solid var(--primary-color);
}

.settings-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    margin-bottom: 25px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.settings-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.settings-label {
    font-weight: bold;
    display: block;
    margin-bottom: 8px;
}

.settings-desc {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
}

.settings-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
}

.input-days {
    width: 100px;
}

.btn-save {
    margin-left: auto;
}

.settings-hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 20px 0;
}

/**
 * ======================================================================
 * 7. MODALS (Core & Specific)
 * ======================================================================
 */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
}

.close-modal,
.close-test-modal,
.close-passcode-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover,
.close-test-modal:hover,
.close-passcode-modal:hover {
    color: black;
}

/* Test Send Modal Specifics */
.modal-test-header {
    border-bottom: 2px solid var(--accent-color) !important;
    color: var(--accent-color) !important;
    margin-bottom: 15px;
    padding-bottom: 10px;
}

.modal-actions {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.static-info {
    padding: 12px;
    background: #f5f5f5;
    border-radius: 6px;
    font-weight: 500;
    margin-bottom: 15px;
    border: 1px solid #e0e0e0;
}

/* Passcode Modal Specifics */
.passcode-modal-content {
    max-width: 320px;
    text-align: center;
}

.passcode-inputs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.pass-digit {
    width: 45px;
    height: 55px;
    font-size: 24px;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
}

.pass-digit:focus {
    border-color: var(--accent-color);
    outline: none;
    background: #fff;
}

.input-passcode-field {
    width: 100px;
    letter-spacing: 5px;
    text-align: center;
}

/**
 * ======================================================================
 * 8. PREMIUM & MEDIA FEATURES
 * ======================================================================
 */
.badge-premium {
    background: linear-gradient(135deg, #D4AF37, #F9D976);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-left: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.media-upload-group {
    background: #fdfdfd;
    padding: 15px;
    border: 1px dashed #ddd;
    border-radius: 8px;
    margin-top: 10px;
}

.media-placeholders {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.btn-media-disabled {
    background: #f0f0f0;
    color: #999;
    border: 1px solid #ddd;
    padding: 8px 15px;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: not-allowed;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-media-disabled:hover {
    background: #e8e8e8;
}

/** LINE Integration */
.btn-line {
    background-color: #06C755;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
}

.btn-line:hover {
    background-color: #05a346;
}

.btn-x {
    background-color: #000;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
}

.btn-x:hover {
    background-color: #333;
}

.line-status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.line-status-linked {
    background: #e6f7ef;
    color: #06C755;
    border: 1px solid #06C755;
}

.line-status-unlinked {
    background: #f5f5f5;
    color: #999;
    border: 1px solid #ddd;
}

.media-hint {
    width: 100%;
    font-size: 0.8rem;
    color: #888;
    margin-top: 8px;
    font-style: italic;
}

.form-line-help {
    margin-top: 8px;
    padding: 10px;
    background: #f8f9fa;
    border-left: 3px solid #00b900;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #444;
    line-height: 1.5;
}

.form-line-help strong {
    color: #00b900;
}

/* --- Premium Lock & Badges --- */
.premium-locked {
    position: relative;
    opacity: 0.8;
}

.premium-locked::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    cursor: not-allowed;
    z-index: 5;
}

.badge-premium {
    background: linear-gradient(135deg, #ffd700, #ffa500);
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.badge-admin {
    background: #000;
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #333;
}

.badge-basic {
    background: #3498db;
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.badge-free {
    background: #95a5a6;
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-test {
    background-color: var(--accent-color) !important;
    color: white !important;
}

.btn-test:hover {
    filter: brightness(1.1);
}

/* --- Multi-Channel Delivery UI --- */
.channel-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.channel-chip {
    padding: 8px 16px;
    border-radius: 20px;
    background: #f0f0f0;
    color: #666;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
}

.channel-chip.active {
    background: var(--primary-color);
    color: white;
}

.channel-chip.active.line {
    background: #00b900;
}

.channel-chip.active.x {
    background: #1da1f2;
}

.channel-panel {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.channel-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.recipient-list {
    margin-top: 10px;
}

.recipient-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid #eee;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.recipient-info {
    flex: 1;
}

.recipient-name {
    font-weight: bold;
    font-size: 0.95rem;
    display: block;
}

.recipient-detail {
    font-size: 0.8rem;
    color: #888;
}

.btn-remove-recipient {
    color: #ff4757;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 1.1rem;
    transition: opacity 0.2s;
}

.btn-remove-recipient:hover {
    opacity: 0.7;
}

/* Toggle Switch */
.switch-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #1da1f2;
}

input:checked+.slider:before {
    transform: translateX(30px);
}

/**
 * ======================================================================
 * 9. MISCELLANEOUS
 * ======================================================================
 */
.fab-add {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--accent-color);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 24px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    border: none;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab-add.disabled {
    background: #bdc3c7 !important;
    cursor: not-allowed;
    box-shadow: none;
    pointer-events: none;
    transform: none !important;
}


.fab-add:hover {
    transform: scale(1.1);
}

/* Admin */
.admin-body {
    font-family: monospace;
    padding: 20px;
    background: #f0f0f0;
    display: block !important;
}

.admin-panel {
    background: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 800px;
    margin: 0 auto;
}

.log-area {
    background: #333;
    color: #0f0;
    padding: 15px;
    height: 300px;
    overflow-y: scroll;
    border-radius: 4px;
    margin-top: 20px;
    font-size: 0.9em;
}

.admin-h1 {
    margin-top: 0;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

/**
 * ======================================================================
 * 10. RESPONSIVE DESIGN (Media Queries)
 * ======================================================================
 */
@media (max-width: 768px) {
    .dashboard-body {
        padding-top: 110px;
    }

    .app-header {
        height: auto;
        flex-direction: column;
        padding: 10px;
        gap: 10px;
    }

    .vital-check-area {
        margin: 0 !important;
        width: 100%;
        justify-content: space-between;
    }

    #user-email {
        display: none;
    }

    .user-menu {
        position: absolute;
        top: 15px;
        right: 15px;
    }

    .container {
        padding: 15px;
    }

    .settings-card .form-group>div {
        flex-wrap: wrap;
    }

    .settings-card .btn-primary {
        margin-left: 0 !important;
        margin-top: 10px;
        width: 100%;
    }
}

@media (max-height: 500px) {
    .modal {
        align-items: flex-start;
        padding: 20px 0;
    }

    .modal-content {
        margin-top: 20px;
        margin-bottom: 20px;
        max-height: none;
    }
}

/* Test Modal Channel Options */
.test-channel-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 10px;
    background-color: #f9f9f9;
    cursor: pointer;
    transition: background-color 0.2s;
}

.test-channel-option:hover {
    background-color: #f0f0f0;
}

.test-channel-option label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
}

.test-dest-info {
    font-size: 0.85rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #1da1f2;
}

input:checked+.slider:before {
    transform: translateX(30px);
}


/**
 * ======================================================================
 * 9. MISCELLANEOUS
 * ======================================================================
 */
#create-message-btn {
    position: fixed;
    bottom: 30px;
    /* Default: Mobile/Small screen behavior (Stick to right window edge) */
    right: 30px;
    left: auto;
    margin: 0;

    background: var(--accent-color);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 24px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 900;
}

/* PC: Align to container (max-width 800px) */
@media (min-width: 860px) {
    #create-message-btn {
        right: auto;
        left: 50%;
        /* 400px(half container) - 60px(btn) - 10px(gap) = 330px */
        margin-left: 330px;
    }
}

#create-message-btn:hover {
    transform: scale(1.1);
}

/* Admin */
.admin-body {
    font-family: monospace;
    padding: 20px;
    background: #f0f0f0;
    display: block !important;
}

.admin-panel {
    background: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 800px;
    margin: 0 auto;
}

.log-area {
    background: #333;
    color: #0f0;
    padding: 15px;
    height: 300px;
    overflow-y: scroll;
    border-radius: 4px;
    margin-top: 20px;
    font-size: 0.9em;
}

.admin-h1 {
    margin-top: 0;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

/**
 * ======================================================================
 * 9. ONBOARDING (Tooltips & Welcome Guide)
 * ======================================================================
 */
/* --- Tooltips (CSS Only) --- */
/* --- Tooltips (Common) --- */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Tooltip Arrow */
[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 1000;
}

[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
}

/* --- Mobile Tooltip Adjustments --- */
@media (max-width: 768px) {

    /* Limit width and allow wrapping to prevent overflow */
    [data-tooltip]::after {
        white-space: normal;
        max-width: 200px;
        text-align: center;
        width: max-content;
    }

    /* FAB Tooltip: Align right to prevent right-side overflow */
    .fab-add[data-tooltip]::after {
        left: auto;
        right: 0;
        transform: none;
        bottom: 75px;
        /* Above the button */
        width: 150px;
        /* Fixed width for text wrap */
    }

    .fab-add[data-tooltip]::before {
        left: auto;
        right: 20px;
        /* Align arrow roughly with button center */
        transform: none;
        bottom: 65px;
    }

    /* Logout/User Menu Tooltip: Align right */
    .user-menu [data-tooltip]::after {
        left: auto;
        right: 0;
        transform: none;
        top: 130%;
        bottom: auto;
    }

    .user-menu [data-tooltip]::before {
        left: auto;
        right: 15px;
        transform: none;
        top: 120%;
        bottom: auto;
        border-color: transparent transparent #333 transparent;
    }
}

/* --- Welcome Modal --- */
.welcome-modal-content {
    text-align: center;
    max-width: 450px;
}

.welcome-icon {
    font-size: 3rem;
    color: var(--accent-color);
    margin-bottom: 20px;
}

.welcome-steps {
    text-align: left;
    margin: 20px 0;
    padding: 0 10px;
}

.welcome-step {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: flex-start;
}

.step-num {
    background: var(--accent-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.step-text {

    font-size: 0.95rem;
    line-height: 1.5;
}

.step-text strong {
    display: block;
    margin-bottom: 2px;
}

/* ==================== APP FOOTER ==================== */
.app-footer {
    text-align: center;
    padding: 20px;
    font-size: 0.75rem;
    color: #999;
    margin-top: 30px;
}

/* For Auth Pages (fixed positioning to keep centered layout intact) */
body:not(.dashboard-body) .app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: transparent;
    padding-bottom: 10px;
}

/* Message Card Channel Status */
.msg-recipient-row {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-top: 5px;
}

.channel-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #ccc;
    /* Default inactive color */
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.channel-status.active {
    font-weight: 500;
}

.channel-status.active .fa-envelope,
.channel-status.active .fa-line,
.channel-status.active .fa-x-twitter {
    color: #06C755;
    /* Unified Active Green */
}

.channel-count {
    font-size: 0.85rem;
    color: #666;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 2px;
}

.channel-status.inactive .channel-count {
    display: none;
}

/* ==================== ENVIRONMENT BADGES & THEMES ==================== */
/* Development Theme: Darker Header to distinguish */
body.env-development .app-header {
    background: #333;
    /* Dark background */
    border-bottom: 2px solid #000;
    /* Distinct border */
    color: #fff;
}

/* Ensure logo and text remain visible/contrasted */
body.env-development .app-header .page-title {
    color: #fff;
}

body.env-development .app-header .logo-text {
    color: #fff;
}

/* --- Development Access Gate --- */
#dev-access-gate {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-family: 'Noto Sans JP', sans-serif;
}

#dev-access-gate .gate-container {
    background: #1a1a1a;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #444;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    max-width: 90%;
    width: 320px;
}

#dev-access-gate h2 {
    color: #ffcc00;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

#dev-access-gate p {
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

#dev-access-gate input {
    width: 100%;
    padding: 10px;
    margin-bottom: 1rem;
    border-radius: 4px;
    border: 1px solid #555;
    background: #333;
    color: #fff;
    font-size: 1rem;
}

#dev-access-gate button {
    width: 100%;
    padding: 10px;
    border-radius: 4px;
    border: none;
    background: #06C755;
    color: #fff;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

#dev-access-gate button:hover {
    background: #05a546;
}

/* Vital Check Alert Enhanced Styles */
.vital-alert {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.vital-alert-content p {
    margin: 8px 0 0 0;
}

.vital-process-box {
    background: rgba(255, 255, 255, 0.5);
    padding: 12px;
    border-radius: 6px;
    margin-top: 10px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.process-step.active {
    color: #c53030;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.step-num {
    background: #c53030;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

.process-desc {
    font-size: 0.85rem;
    opacity: 0.9;
}

.process-timeline {
    display: flex;
    align-items: center;
    margin-top: 12px;
    font-size: 0.75rem;
    gap: 4px;
}

.time-item {
    padding: 4px 8px;
    border-radius: 4px;
    background: #edf2f7;
    color: #4a5568;
}

.time-item.done {
    background: #c6f6d5;
    color: #22543d;
    text-decoration: line-through;
    opacity: 0.7;
}

.time-item.current {
    background: #fed7d7;
    color: #822727;
    font-weight: bold;
    border: 1px solid #feb2b2;
}

.time-divider {
    flex: 1;
    height: 1px;
    background: #cbd5e0;
}

.alert-action-hint {
    font-size: 0.8rem;
    margin-top: 10px !important;
    font-weight: bold;
}

.vital-info-sub {
    border-left: 2px solid #ed8936;
    padding-left: 10px;
    margin-top: 8px;
    font-size: 0.85rem;
}

/* --- Advanced Settings (Spacing Improvements) --- */
.settings-advanced {
    background-color: #f8f9fa;
    /* 視覚的にセクションを区切るための背景色 */
    padding: 20px;
    /* 内部の余白 */
    border-radius: 8px;
    margin-top: 30px;
    /* 上の要素との間隔 */
}

.advanced-item {
    margin-bottom: 25px;
    /* 項目間の間隔 (例: 配信タイミングと代理人設定の間) */
}

.advanced-item:last-child {
    margin-bottom: 0;
}

.advanced-label {
    display: block;
    margin-bottom: 10px;
    /* ラベルとコントロールの間隔 */
    font-weight: 600;
    color: #2d3748;
}

.radio-group {
    display: flex;
    flex-direction: column;
    /* スマホで見やすいよう縦並びを明示（または gap を調整） */
    gap: 12px;
    /* 選択肢同士の間隔 */
    margin-top: 5px;
}

.radio-group label {
    cursor: pointer;
}

.dashed-hr {
    margin: 25px 0;
    /* 区切り線の上下余白 */
    border: none;
    border-top: 1px dashed #cbd5e0;
}