* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: linear-gradient(to bottom right, #0f172a, #1e293b, #0f172a);
    min-height: 100vh;
    padding: 20px;
    color: white;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* ナビゲーションヘッダー */
.nav-header {
    background: #111827;
    color: white;
    padding: 8px 0;
    margin: -20px -20px 20px -20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-header a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    font-weight: bold;
    color: white;
    text-decoration: none;
    font-size: 1.125rem;
    transition: color 0.3s ease;
}

.nav-header a:hover {
    color: #e5e7eb;
}

.nav-header img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: transparent;
    backdrop-filter: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
    width: 100%;
}

.header {
    background: transparent;
    padding: 30px 20px;
    text-align: center;
    color: white;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: none;
}

.header p {
    opacity: 0.9;
    font-size: 1rem;
}

.post-form {
    padding: 30px;
    background: #1e293b;
    border-bottom: none;
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    margin-bottom: 1.5rem;
    width: 100%;
    max-width: 100%;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #cbd5e1;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #334155;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: #0f172a;
    color: white;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
    transform: translateY(-2px);
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.submit-btn {
    background: linear-gradient(to right, #2563eb, #1d4ed8);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    display: block;
    margin: 0 auto;
    width: fit-content;
}

.submit-btn:hover {
    background: linear-gradient(to right, #1d4ed8, #1e40af);
    transform: scale(1.05);
}

.posts-section {
    padding: 30px;
    background: #1e293b;
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    min-height: 500px;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.posts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 10px;
}

.posts-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.posts-count {
    background: #334155;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.posts-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.refresh-btn {
    background: linear-gradient(to right, #2563eb, #1d4ed8);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.refresh-btn:hover {
    background: linear-gradient(to right, #1d4ed8, #1e40af);
    transform: scale(1.05);
}

.refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.refresh-btn.loading {
    background: linear-gradient(to right, #334155, #475569);
}

.auto-refresh-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #cbd5e1;
}

.notification-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #cbd5e1;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 24px;
    background: #334155;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-switch.active {
    background: linear-gradient(to right, #2563eb, #1d4ed8);
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active .toggle-slider {
    transform: translateX(26px);
}

.last-update {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-left: 10px;
}

.new-posts-indicator {
    background: #22c55e;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* チャット形式の投稿 */
.post {
    display: flex;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 自分の投稿は右寄せ */
.post.my-post {
    flex-direction: row-reverse;
}

.post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
    margin-right: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* 自分の投稿のアバター */
.post.my-post .post-avatar {
    margin-right: 0;
    margin-left: 12px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.post-bubble {
    flex: 1;
    max-width: 85%;
    min-width: 0;
    overflow: hidden;
}

.post-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 6px;
}

/* 自分の投稿のヘッダーは右寄せ */
.post.my-post .post-header {
    justify-content: flex-end;
}

.post-name {
    font-weight: 700;
    color: #e2e8f0;
    font-size: 0.95rem;
}

.post-time {
    color: #64748b;
    font-size: 0.8rem;
}

.post-content-wrapper {
    background: #334155;
    border-radius: 18px;
    padding: 14px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
}

/* チャット吹き出しの尾 */
.post-content-wrapper::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 8px 0;
    border-color: transparent #334155 transparent transparent;
}

/* 自分の投稿の吹き出し */
.post-content-wrapper.my-content {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

/* 自分の投稿の吹き出しの尾（右側） */
.post-content-wrapper.my-content::before {
    left: auto;
    right: -8px;
    border-width: 0 0 8px 8px;
    border-color: transparent transparent transparent #1d4ed8;
}

.post-content {
    line-height: 1.6;
    color: #e2e8f0;
    margin-bottom: 10px;
    word-wrap: break-word;
    font-size: 0.95rem;
}

/* 自分の投稿のテキストは白色 */
.post-content-wrapper.my-content .post-content {
    color: #ffffff;
}

/* 投稿内のリンクスタイル */
.post-content .post-link {
    color: #60a5fa;
    text-decoration: underline;
    word-break: break-all;
    transition: color 0.2s ease;
}

.post-content .post-link:hover {
    color: #93c5fd;
    text-decoration: none;
}

/* リンクプレビューカード */
.link-previews {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link-preview-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(71, 85, 105, 0.6);
    border-radius: 12px;
    padding: 12px 14px;
    text-decoration: none;
    transition: all 0.2s ease;
    gap: 12px;
    max-width: 100%;
    overflow: hidden;
}

.link-preview-card:hover {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(96, 165, 250, 0.5);
    transform: translateX(2px);
}

/* 自分の投稿のリンクプレビュー */
.post-content-wrapper.my-content .link-preview-card {
    background: rgba(15, 23, 42, 0.4);
    border-color: rgba(147, 197, 253, 0.3);
}

.post-content-wrapper.my-content .link-preview-card:hover {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(147, 197, 253, 0.6);
}

.link-preview-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.link-preview-favicon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(51, 65, 85, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.link-preview-favicon img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.link-preview-info {
    flex: 1;
    min-width: 0;
}

.link-preview-domain {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-preview-url {
    font-size: 0.8rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-preview-icon {
    font-size: 1.2rem;
    opacity: 0.6;
    flex-shrink: 0;
}

.post-actions {
    display: flex;
    gap: 15px;
    margin-top: 8px;
}

.action-btn {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid #475569;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 12px;
}

.action-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    color: #60a5fa;
    transform: scale(1.05);
}

.like-btn.liked {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #fca5a5;
}

/* 画像関連のスタイル */
.image-upload-section {
    margin-top: 15px;
    padding: 15px;
    border: 2px dashed #334155;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.image-upload-section:hover {
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.1);
}

.image-upload-section.has-image {
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.1);
}

.image-upload-btn {
    background: linear-gradient(to right, #2563eb, #1d4ed8);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.image-upload-btn:hover {
    background: linear-gradient(to right, #1d4ed8, #1e40af);
    transform: scale(1.05);
}

.image-preview {
    margin-top: 15px;
    position: relative;
    display: inline-block;
}

.image-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.image-remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.post-image {
    margin-top: 10px;
    margin-bottom: 8px;
}

.post-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s ease;
    display: block;
}

.post-image img:hover {
    transform: scale(1.02);
}

/* 画像モーダル */
.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.image-modal img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
        overflow-x: hidden;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .post-form,
    .posts-section {
        padding: 15px;
        max-width: 100%;
    }

    .posts-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .posts-controls {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        width: 100%;
    }

    .auto-refresh-toggle {
        justify-content: center;
    }

    .post {
        max-width: 100%;
    }

    .post-avatar {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        margin-right: 8px;
    }

    .post.my-post .post-avatar {
        margin-left: 8px;
        margin-right: 0;
    }

    .post-bubble {
        max-width: calc(100% - 50px);
        min-width: 0;
    }

    .post-name {
        font-size: 0.9rem;
    }

    .post-content {
        font-size: 0.9rem;
        word-break: break-word;
    }

    .link-preview-url,
    .link-preview-domain {
        font-size: 0.8rem;
    }

    .form-group input,
    .form-group textarea {
        font-size: 16px;
        padding: 12px;
    }
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #94a3b8;
    background: rgba(51, 65, 85, 0.3);
    border-radius: 16px;
    border: 2px dashed #475569;
}

.empty-state h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: #cbd5e1;
}

.empty-state p {
    font-size: 0.95rem;
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
