/* =============================================
   ハプコメ — ダーク/ライトモード対応デザインシステム
   ============================================= */

/* === CSS変数（ダークモードデフォルト） === */
:root {
    --bbs-bg: #0a0a1a;
    --bbs-bg-secondary: #111128;
    --bbs-surface: rgba(255, 255, 255, 0.07);
    --bbs-surface-hover: rgba(255, 255, 255, 0.12);
    --bbs-border: rgba(255, 255, 255, 0.08);
    --bbs-border-strong: rgba(255, 255, 255, 0.15);
    --bbs-text: #f1f5f9;
    --bbs-text-sub: #cbd5e1;
    --bbs-text-muted: #8b95a5;
    --bbs-accent: #c084fc;
    --bbs-accent-bg: rgba(192, 132, 252, 0.12);
    --bbs-blue: #60a5fa;
    --bbs-pink: #f472b6;
    --bbs-green: #4ade80;
    --bbs-orange: #fb923c;
    --bbs-red: #f87171;
    --bbs-yellow: #fbbf24;
    --bbs-header-bg: rgba(10, 10, 26, 0.92);
    --bbs-input-bg: rgba(0, 0, 0, 0.3);
    --bbs-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --bbs-radius: 14px;
    --bbs-radius-sm: 10px;
    --bbs-radius-pill: 20px;
}

/* ライトモード */
[data-theme="light"] {
    --bbs-bg: #f1f5f9;
    --bbs-bg-secondary: #e2e8f0;
    --bbs-surface: rgba(0, 0, 0, 0.05);
    --bbs-surface-hover: rgba(0, 0, 0, 0.09);
    --bbs-border: rgba(0, 0, 0, 0.12);
    --bbs-border-strong: rgba(0, 0, 0, 0.2);
    --bbs-text: #0f172a;
    --bbs-text-sub: #334155;
    --bbs-text-muted: #64748b;
    --bbs-accent: #7c3aed;
    --bbs-accent-bg: rgba(124, 58, 237, 0.08);
    --bbs-header-bg: rgba(241, 245, 249, 0.92);
    --bbs-input-bg: rgba(0, 0, 0, 0.04);
    --bbs-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --bbs-green: #16a34a;
    --bbs-red: #dc2626;
    --bbs-pink: #db2777;
    --bbs-blue: #2563eb;
    --bbs-orange: #ea580c;
}

/* === リセット＋ベース === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bbs-bg);
    color: var(--bbs-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 80px;
}

a { color: var(--bbs-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === ヘッダー === */
.bbs-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--bbs-header-bg);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--bbs-border);
    padding: 12px 16px;
    display: flex; align-items: center; gap: 12px;
}
.bbs-header-title {
    font-size: 1.1rem; font-weight: 900;
    display: flex; align-items: center; gap: 6px;
}
.bbs-header-right {
    margin-left: auto;
    display: flex; align-items: center; gap: 8px;
}
.bbs-back-btn {
    background: none; border: none;
    color: var(--bbs-text-sub);
    font-size: 1.3rem; cursor: pointer;
    padding: 4px 8px; display: flex; align-items: center;
}

/* テーマトグルボタン */
.theme-toggle {
    background: var(--bbs-surface);
    border: 1px solid var(--bbs-border);
    border-radius: 20px; padding: 6px 10px;
    color: var(--bbs-text); cursor: pointer;
    font-size: 1rem; display: flex; align-items: center;
    transition: background 0.2s;
}
.theme-toggle:hover { background: var(--bbs-surface-hover); }

/* === エリアタブ === */
.bbs-area-tabs {
    display: flex; margin: 12px 0 14px;
    background: var(--bbs-surface);
    border-radius: var(--bbs-radius);
    padding: 4px;
    border: 1px solid var(--bbs-border);
}
.bbs-area-tab {
    flex: 1; padding: 11px 8px;
    border: none; background: transparent;
    color: var(--bbs-text-muted);
    font-size: 0.88rem; font-weight: 700;
    cursor: pointer; border-radius: 11px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center; font-family: inherit;
}
.bbs-area-tab.active {
    background: var(--bbs-accent-bg);
    color: var(--bbs-accent);
    box-shadow: 0 2px 10px rgba(192, 132, 252, 0.15);
}

/* === コンテナ === */
.bbs-container {
    max-width: 700px; margin: 0 auto;
    padding: 16px 16px 30px;
}

/* === 検索バー === */
.bbs-search-bar {
    position: relative; margin-bottom: 16px;
}
.bbs-search-input {
    width: 100%; padding: 12px 16px 12px 42px;
    background: var(--bbs-surface);
    border: 1px solid var(--bbs-border);
    border-radius: var(--bbs-radius);
    color: var(--bbs-text);
    font-size: 0.9rem; font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.bbs-search-input:focus {
    outline: none;
    border-color: var(--bbs-accent);
    box-shadow: 0 0 0 3px var(--bbs-accent-bg);
}
.bbs-search-input::placeholder { color: var(--bbs-text-muted); }
.bbs-search-icon {
    position: absolute; left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--bbs-text-muted); font-size: 1rem;
    pointer-events: none;
}

/* 検索タブ */
.bbs-search-tabs {
    display: flex; gap: 8px; margin-bottom: 16px;
}
.bbs-search-tab {
    flex: 1; padding: 8px; border: 1px solid var(--bbs-border);
    border-radius: var(--bbs-radius-sm);
    background: var(--bbs-surface);
    color: var(--bbs-text-sub);
    font-size: 0.8rem; font-weight: 600;
    cursor: pointer; text-align: center; transition: all 0.2s;
    font-family: inherit;
}
.bbs-search-tab.active {
    background: var(--bbs-accent-bg);
    border-color: var(--bbs-accent);
    color: var(--bbs-accent);
}

/* === 爆サイ風スレッド行 === */
.bbs-thread-row {
    display: flex; align-items: center; gap: 8px;
    padding: 18px 16px;
    border-bottom: 1px solid var(--bbs-border);
    cursor: pointer; transition: background 0.12s;
    text-decoration: none; color: var(--bbs-text);
}
.bbs-thread-row:first-child {
    border-top: 1px solid var(--bbs-border);
}
.bbs-thread-row:hover {
    background: var(--bbs-surface-hover);
    text-decoration: none;
}
.bbs-thread-row.full {
    opacity: 0.6;
}
.bbs-thread-num {
    font-size: 0.85rem; font-weight: 700;
    color: var(--bbs-accent);
    min-width: 24px; text-align: right;
    flex-shrink: 0;
}
.bbs-thread-title-text {
    font-size: 1rem; font-weight: 700;
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    line-height: 1.3;
}
.bbs-thread-time {
    font-size: 0.78rem; color: var(--bbs-text-muted);
    flex-shrink: 0; white-space: nowrap;
}
.bbs-thread-stats {
    display: flex; gap: 8px; flex-shrink: 0;
}
.bbs-stat {
    font-size: 0.75rem; color: var(--bbs-text-muted);
    white-space: nowrap;
}
.bbs-full-badge {
    display: inline-block;
    font-size: 0.6rem; font-weight: 700;
    background: rgba(239, 68, 68, 0.2);
    color: var(--bbs-red);
    padding: 1px 6px; border-radius: 8px;
    margin-left: 4px;
}

/* === スレッド詳細 === */
.bbs-thread-header {
    background: var(--bbs-surface);
    border: 1px solid var(--bbs-border);
    border-radius: var(--bbs-radius);
    padding: 16px; margin-bottom: 16px;
}
.bbs-thread-header-title {
    font-size: 1.15rem; font-weight: 900;
    margin-bottom: 8px;
}
.bbs-thread-header-body {
    font-size: 0.92rem; line-height: 1.6;
    color: var(--bbs-text);
    margin-bottom: 10px;
    white-space: pre-wrap; word-break: break-word;
}
.bbs-thread-header-meta {
    font-size: 0.78rem; color: var(--bbs-text-sub);
    display: flex; gap: 12px; flex-wrap: wrap;
}

/* === コメントカード === */
.bbs-comment {
    background: var(--bbs-surface);
    border: 1px solid var(--bbs-border);
    border-radius: var(--bbs-radius-sm);
    padding: 12px 14px; margin-bottom: 4px;
    transition: background 0.15s;
}
.bbs-comment:hover {
    background: var(--bbs-surface-hover);
}
.bbs-comment-header {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 6px; flex-wrap: wrap;
}
.bbs-comment-number {
    font-size: 0.82rem; font-weight: 700;
    color: var(--bbs-accent);
    cursor: default;
}
.bbs-comment-name {
    font-size: 0.85rem; font-weight: 600;
    color: var(--bbs-text);
}
.bbs-comment-id {
    font-size: 0.68rem;
    color: var(--bbs-text-muted);
    font-family: monospace;
}
.bbs-comment-time {
    font-size: 0.75rem;
    color: var(--bbs-text-muted);
    margin-left: auto;
}
.bbs-comment-body {
    font-size: 0.95rem; line-height: 1.7;
    color: var(--bbs-text);
    white-space: pre-wrap; word-break: break-word;
}

/* アンカーリンク */
.bbs-anchor {
    color: var(--bbs-accent);
    cursor: pointer; font-weight: 600;
    border-bottom: 1px dotted var(--bbs-accent);
}
.bbs-anchor:hover { opacity: 0.8; }

/* アンカーポップアップ */
.bbs-anchor-popup {
    position: fixed;
    background: var(--bbs-bg-secondary);
    border: 1px solid var(--bbs-border-strong);
    border-radius: var(--bbs-radius-sm);
    padding: 12px; max-width: 320px;
    box-shadow: var(--bbs-shadow);
    z-index: 500; font-size: 0.82rem;
    line-height: 1.5;
    animation: fadeIn 0.15s ease;
}

/* === リアクションボタン === */
.bbs-comment-actions {
    display: flex; align-items: center; gap: 8px;
    margin-top: 8px;
}
.bbs-reaction-group {
    display: flex; align-items: center;
    background: var(--bbs-surface);
    border: 1px solid var(--bbs-border);
    border-radius: var(--bbs-radius-pill);
    overflow: hidden;
}
.bbs-reaction-btn {
    display: flex; align-items: center; gap: 4px;
    padding: 5px 10px; border: none;
    background: transparent;
    color: var(--bbs-text-muted);
    cursor: pointer; font-size: 0.78rem;
    font-family: inherit;
    transition: all 0.2s;
}
.bbs-reaction-btn:hover {
    background: var(--bbs-surface-hover);
    color: var(--bbs-text);
}
.bbs-reaction-btn.liked { color: var(--bbs-pink); }
.bbs-reaction-btn.disliked { color: var(--bbs-blue); }
.bbs-reaction-divider {
    width: 1px; height: 16px;
    background: var(--bbs-border);
}

/* === 投稿フォーム === */
.bbs-post-form {
    background: var(--bbs-surface);
    border: 1px solid var(--bbs-border);
    border-radius: var(--bbs-radius);
    padding: 16px; margin-top: 16px;
}
.bbs-post-form-title {
    font-size: 0.85rem; font-weight: 700;
    margin-bottom: 12px; color: var(--bbs-text);
}
.bbs-input, .bbs-textarea {
    width: 100%; padding: 10px 14px;
    background: var(--bbs-input-bg);
    border: 1px solid var(--bbs-border);
    border-radius: var(--bbs-radius-sm);
    color: var(--bbs-text);
    font-size: 0.88rem; font-family: inherit;
    margin-bottom: 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.bbs-input:focus, .bbs-textarea:focus {
    outline: none;
    border-color: var(--bbs-accent);
    box-shadow: 0 0 0 3px var(--bbs-accent-bg);
}
.bbs-input::placeholder, .bbs-textarea::placeholder {
    color: var(--bbs-text-muted);
}
.bbs-textarea {
    resize: vertical; min-height: 80px;
}
.bbs-submit-btn {
    width: 100%; padding: 12px;
    background: linear-gradient(135deg, var(--bbs-accent), #9333ea);
    color: #fff; border: none;
    border-radius: var(--bbs-radius-sm);
    font-size: 0.9rem; font-weight: 700;
    cursor: pointer; font-family: inherit;
    transition: opacity 0.2s, transform 0.1s;
    box-shadow: 0 4px 15px rgba(147, 51, 234, 0.3);
}
.bbs-submit-btn:hover { opacity: 0.9; }
.bbs-submit-btn:active { transform: scale(0.98); }
.bbs-submit-btn:disabled {
    opacity: 0.5; cursor: not-allowed;
}

/* === ソートタブ === */
.bbs-sort-tabs {
    display: flex; gap: 6px; margin-bottom: 14px;
}
.bbs-sort-tab {
    padding: 6px 14px;
    border: 1px solid var(--bbs-border);
    border-radius: var(--bbs-radius-pill);
    background: var(--bbs-surface);
    color: var(--bbs-text-muted);
    font-size: 0.75rem; font-weight: 600;
    cursor: pointer; font-family: inherit;
    transition: all 0.2s;
}
.bbs-sort-tab.active {
    background: var(--bbs-accent-bg);
    border-color: var(--bbs-accent);
    color: var(--bbs-accent);
}

/* === ページネーション === */
.bbs-pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 4px; margin: 16px 0; flex-wrap: wrap;
}
.bbs-page-btn {
    min-width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--bbs-border);
    border-radius: var(--bbs-radius-sm);
    background: var(--bbs-surface);
    color: var(--bbs-text-sub);
    font-size: 0.78rem; font-weight: 600;
    cursor: pointer; font-family: inherit;
    transition: all 0.2s;
}
.bbs-page-btn:hover {
    background: var(--bbs-surface-hover);
}
.bbs-page-btn.active {
    background: var(--bbs-accent);
    color: #fff;
    border-color: var(--bbs-accent);
}
.bbs-page-btn:disabled {
    opacity: 0.4; cursor: not-allowed;
}
.bbs-page-info {
    font-size: 0.72rem; color: var(--bbs-text-muted);
    text-align: center; margin-top: 4px;
}

/* 1000件到達バナー */
.bbs-thread-full-banner {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--bbs-radius-sm);
    padding: 14px; text-align: center;
    margin-top: 16px;
    font-size: 0.85rem; font-weight: 600;
    color: var(--bbs-red);
}

/* === 空状態 === */
.bbs-empty {
    text-align: center; padding: 40px 20px;
    color: var(--bbs-text-muted);
    font-size: 0.85rem;
}
.bbs-empty-icon {
    font-size: 2.5rem; margin-bottom: 10px;
    opacity: 0.5;
}

/* === トースト === */
.bbs-toast {
    position: fixed;
    bottom: 80px; left: 50%;
    transform: translateX(-50%);
    background: var(--bbs-bg-secondary);
    color: var(--bbs-text);
    padding: 12px 24px;
    border-radius: var(--bbs-radius);
    font-size: 0.82rem; font-weight: 600;
    border: 1px solid var(--bbs-border);
    backdrop-filter: blur(12px);
    box-shadow: var(--bbs-shadow);
    opacity: 0; transition: opacity 0.3s;
    pointer-events: none; z-index: 300;
}
.bbs-toast.show { opacity: 1; }

/* === FAB === */
.bbs-fab {
    position: fixed;
    bottom: 85px; right: 20px;
    background: linear-gradient(135deg, var(--bbs-accent), #9333ea);
    color: #fff; border: none;
    width: auto; padding: 14px 20px;
    border-radius: 50px;
    font-size: 0.88rem; font-weight: 700;
    cursor: pointer; display: flex;
    align-items: center; gap: 8px;
    box-shadow: 0 4px 20px rgba(147, 51, 234, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 90; font-family: inherit;
}
.bbs-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(147, 51, 234, 0.5);
}
.bbs-fab:active { transform: scale(0.95); }

/* === モーダル === */
.bbs-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1100;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.bbs-modal-overlay.active { display: flex; }
.bbs-modal {
    background: var(--bbs-bg);
    border: 1px solid var(--bbs-border);
    border-radius: 20px 20px 0 0;
    width: 100%; max-width: 700px;
    max-height: 85vh; overflow-y: auto;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px) + 75px);
    animation: slideUp 0.3s ease;
}
.bbs-modal-title {
    font-size: 1rem; font-weight: 900;
    margin-bottom: 16px;
    display: flex; align-items: center;
    justify-content: space-between;
}
.bbs-modal-close {
    background: none; border: none;
    color: var(--bbs-text-muted);
    font-size: 1.3rem; cursor: pointer;
    padding: 4px;
}

/* === 検索ハイライト === */
.bbs-highlight {
    background: rgba(251, 191, 36, 0.25);
    color: var(--bbs-yellow);
    padding: 1px 3px; border-radius: 3px;
}

/* === アニメーション === */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* === レスポンシブ === */
@media (max-width: 480px) {
    .bbs-container { padding: 12px 12px 30px; }
    .bbs-thread-stats { gap: 6px; }
    .bbs-thread-title-text { font-size: 0.82rem; }
}

/* === iOS自動ズーム防止（font-size 16px未満で発生する） === */
@media screen and (max-width: 768px) {
    .bbs-input,
    .bbs-textarea,
    .bbs-search-input,
    .bbs-delete-key-input {
        font-size: 16px !important;
    }
}
