:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --secondary-color: #10B981;
    --bg-color: #F3F4F6;
    --surface-color: #FFFFFF;
    --text-main: #111827;
    --text-sub: #6B7280;
    --border-color: #E5E7EB;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* Navbar Modernization */
.navbar {
    background-color: var(--surface-color) !important;
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 1rem;
}

.navbar-brand {
    color: var(--primary-color) !important;
    font-weight: 700;
    font-size: 1.25rem;
}

.nav-link {
    color: var(--text-sub) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.nav-link.active,
.nav-link:hover {
    color: var(--primary-color) !important;
    background-color: rgba(79, 70, 229, 0.05);
}

.navbar-toggler {
    border: none;
    padding: 0.5rem;
    color: var(--text-main) !important;
}

.navbar-toggler:focus {
    box-shadow: none;
}

/* Card Modernization */
.card {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background-color: var(--surface-color);
    margin-bottom: 1rem;
    overflow: hidden;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* Button Modernization */
.btn {
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Floating Action Button (FAB) */
.fab-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
}

.btn-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s;
}

.btn-fab:active {
    transform: scale(0.95);
}

/* Memo Feed Style */
.thread-card {
    margin-bottom: 1rem !important;
    border-radius: var(--radius-lg) !important;
}

.thread-header {
    background: transparent !important;
    padding: 1rem 1.25rem 0.5rem !important;
    border: none !important;
}

.memo-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.thread-meta {
    font-size: 0.8rem;
    color: var(--text-sub);
    margin-bottom: 0.5rem;
}

.memo-content {
    padding: 0 1.25rem 1rem !important;
    color: var(--text-main);
    font-size: 0.95rem;
    line-height: 1.6;
}

.memo-footer {
    background: transparent !important;
    border-top: 1px solid var(--border-color) !important;
    padding: 0.75rem 1.25rem !important;
}

/* Avatar Placeholder */
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    margin-right: 0.75rem;
}

/* Chat/Reply Style */
.reply-item {
    background-color: var(--bg-color) !important;
    border: none !important;
    border-radius: var(--radius-md) !important;
    padding: 1rem !important;
    margin-bottom: 0.75rem !important;
}

.reply-header {
    margin-bottom: 0.5rem;
}

/* Form Elements */
.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-color);
    padding: 0.6rem 1rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Consistent Badge Styling */
.badge-custom {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    height: 22px;
}

.badge-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* LINE-style Chat Bubbles */
.chat-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    max-width: 85%;
}

.chat-message.own {
    flex-direction: row-reverse;
    margin-left: auto;
}

.chat-message.other {
    flex-direction: row;
    margin-right: auto;
}

.chat-bubble {
    background-color: #E5E7EB;
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    position: relative;
    word-wrap: break-word;
    max-width: 100%;
}

.chat-message.own .chat-bubble {
    background-color: var(--primary-color) !important;
    color: white !important;
    border-bottom-right-radius: 0.25rem;
}

.chat-message.other .chat-bubble {
    background-color: #F3F4F6 !important;
    color: var(--text-main) !important;
    border-bottom-left-radius: 0.25rem;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    flex-shrink: 0;
}

.chat-message.own .chat-avatar {
    background-color: var(--primary-color);
}

.chat-message.other .chat-avatar {
    background-color: #6B7280;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.chat-message.own .chat-header {
    flex-direction: row-reverse;
    text-align: right;
}


.chat-message.own .chat-content {
    color: inherit !important;
}

.chat-files {
    margin-top: 0.5rem;
}

.original-message {
    background-color: var(--surface-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-left: 4px solid var(--primary-color);
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .fab-container {
        bottom: 1.5rem;
        right: 1.5rem;
    }

    .memo-title {
        font-size: 1rem;
    }

    .btn {
        padding: 0.6rem 1rem;
    }

    .chat-message {
        max-width: 90%;
    }

    .chat-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }
}

/* Sticky Action Bar for Forms (Floating Capsule Style) */
.sticky-action-bar {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    min-width: 300px;
    max-width: 90%;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    z-index: 1100;
    /* モーダルより上に表示 */
    /* アニメーション */
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Mobile specific adjustments for Sticky Action Bar */
@media (max-width: 768px) {
    .sticky-action-bar {
        bottom: 2.5rem;
        /* iPhoneのホームバーより十分に上に配置 */
        width: 90%;
        justify-content: space-between;
    }

    .sticky-action-bar .btn {
        border-radius: 25px;
        /* ボタン自体も丸くする */
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }
}

.form-footer-spacer {
    height: 120px;
    width: 100%;
}