:root {
    --bg: #eef1f6;
    --card: #ffffff;
    --border: #e1e7ef;
    --ink: #1b2533;
    --muted: #6b7685;
    --primary: #2f6bff;
    --primary-dark: #5a3df0;
    --name: #1f9d6b;
    --badge-bg: #eaf0ff;
    --field-bg: #f7f9fc;
    --shadow: 0 4px 14px rgba(26, 38, 77, 0.06);
    --radius: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP",
        "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }

.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== ヘッダー（グラデーション＋吹き出しモチーフ） ===== */
.site-header {
    position: relative;
    overflow: hidden;
    background: linear-gradient(120deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 34px 0;
}
.site-header .container { position: relative; z-index: 1; }
.hero-bubbles {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 60%;
    max-width: 520px;
    z-index: 0;
    pointer-events: none;
}
.site-title {
    display: inline-block;
    font-size: 1.7rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    letter-spacing: 0.02em;
}
.site-tagline {
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: #e7ecff;
    max-width: 36em;
}

/* ===== フッター ===== */
.site-footer {
    margin-top: 48px;
    padding: 24px 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.78rem;
    text-align: center;
}
.footer-tools { margin-top: 8px; }
.footer-tools a { color: var(--primary); text-decoration: none; }
.footer-tools a:hover { text-decoration: underline; }

main.container { padding-top: 28px; }

h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 4px 0 14px;
}

/* ===== カード共通 ===== */
.new-thread,
.reply,
.thread-list li,
.thread-heading,
.post {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.new-thread,
.reply {
    padding: 22px;
    margin-bottom: 26px;
}

/* 投稿にあたってのお願い（モラル） */
.moral-notice {
    background: #f3f8ff;
    border: 1px solid #cfe0ff;
    border-left: 4px solid var(--primary);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 22px;
    font-size: 0.88rem;
    line-height: 1.8;
    color: #2c3a4f;
}
.moral-notice p { margin: 0; }
.moral-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px !important;
}
.moral-notice strong { color: #1b2533; }
.moral-disclaimer {
    margin-top: 10px !important;
    padding-top: 10px;
    border-top: 1px dashed #cfe0ff;
    font-size: 0.83rem;
    color: #5a6b80;
}
.moral-disclaimer strong { color: #b45309; }

/* 使い方 */
.usage-notice {
    background: #f7faf7;
    border: 1px solid #d8e6d8;
    border-left: 4px solid var(--name);
    border-radius: 10px;
    padding: 14px 18px 14px 20px;
    margin-bottom: 22px;
    font-size: 0.86rem;
    line-height: 1.75;
    color: #2c3a4f;
}
.usage-title { font-weight: 700; color: #15803d; margin: 0 0 6px; }
.usage-notice ul { margin: 0; padding-left: 1.2em; }
.usage-notice li { margin: 2px 0; }

/* 「＋ 新しいスレッドを作る」トグル */
.create-thread { margin-bottom: 26px; }
.create-thread-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: filter 0.15s;
}
.create-thread-btn::-webkit-details-marker { display: none; }
.create-thread-btn::marker { content: ""; }
.create-thread-btn:hover { filter: brightness(1.05); }
.create-thread[open] .create-thread-btn { border-radius: 8px 8px 0 0; }
.create-thread-body {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0 10px 10px 10px;
    box-shadow: var(--shadow);
    padding: 22px;
}
.new-thread h2,
.reply h3 { margin-top: 0; }

/* ===== フォーム ===== */
form label {
    display: block;
    margin-bottom: 14px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
}
form input[type="text"],
form textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 11px 12px;
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
form input[type="text"]::placeholder,
form textarea::placeholder { color: #9aa4b2; }
form input[type="text"]:focus,
form textarea:focus {
    outline: none;
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.15);
}
form textarea { resize: vertical; min-height: 96px; }

.form-actions { text-align: right; }

button {
    background: var(--primary);
    color: #fff;
    border: 0;
    padding: 11px 26px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: filter 0.15s, transform 0.05s;
}
button:hover { filter: brightness(1.05); }
button:active { transform: translateY(1px); }

/* honeypot は非表示 */
.hp {
    position: absolute;
    left: -9999px;
    height: 0;
    overflow: hidden;
}

/* ===== スレッド一覧 ===== */
.thread-list ul { list-style: none; padding: 0; margin: 0; }
.thread-list li {
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.thread-list li:hover {
    border-color: #c7d4ec;
    box-shadow: 0 6px 18px rgba(26, 38, 77, 0.1);
    transform: translateY(-1px);
}
.thread-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-decoration: none;
}
.thread-title {
    color: var(--primary);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.4;
}
.thread-meta {
    flex: none;
    background: var(--badge-bg);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.thread-excerpt {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 0.83rem;
    line-height: 1.6;
}

/* 固定（ピン留め）スレッド */
.thread-list li.pinned {
    border-color: #ffd98a;
    background: linear-gradient(0deg, #fffdf6, #fffdf6), var(--card);
}
.pin-badge {
    display: inline-block;
    background: #fff1c9;
    color: #8a6300;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    vertical-align: middle;
    white-space: nowrap;
}
.empty {
    color: var(--muted);
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

/* ===== スレッド詳細 ===== */
.breadcrumb { margin: 0 0 16px; }
.breadcrumb a { color: var(--primary); text-decoration: none; font-weight: 500; font-size: 0.9rem; }
.breadcrumb a:hover { text-decoration: underline; }

.thread-heading {
    font-size: 1.25rem;
    padding: 16px;
    margin: 0 0 16px;
}

.posts { display: flex; flex-direction: column; gap: 10px; }
.post { padding: 14px 16px; scroll-margin-top: 16px; }
.post:target { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.15); }
.post-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    margin-bottom: 7px;
    flex-wrap: wrap;
}
.reply-btn {
    margin-left: auto;
    background: #eef2f9;
    color: var(--primary);
    border: 1px solid var(--border);
    padding: 3px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 999px;
}
.reply-btn:hover { background: #e2e9f6; filter: none; }

/* 引用（添付）カード：どのコメントへの返信かを示す */
.quote-card {
    display: block;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: #f7f9fc;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.8rem;
    line-height: 1.5;
}
.quote-card:hover { background: #eef2f9; }
.quote-no { color: var(--primary); font-weight: 700; margin-right: 6px; }
.quote-name { color: var(--name); font-weight: 700; margin-right: 8px; }
.quote-text { color: var(--muted); }

/* 返信フォームの「返信先」添付プレビュー */
.reply-target {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px 12px;
    background: #f7f9fc;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    font-size: 0.85rem;
}
.reply-target-mark {
    background: var(--primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    flex: none;
}
.reply-target-label { color: var(--ink); flex: 1; word-break: break-word; }
.reply-clear {
    flex: none;
    background: transparent;
    color: var(--muted);
    border: 0;
    padding: 2px 6px;
    font-size: 0.9rem;
    cursor: pointer;
}
.reply-clear:hover { color: var(--ink); filter: none; }
.post-no {
    background: #f0f3f9;
    color: var(--primary);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
}
.post-name { color: var(--name); font-weight: 700; }
.post-date { color: var(--muted); }
.post-body {
    word-break: break-word;
    line-height: 1.7;
}
.anchor { color: var(--primary); text-decoration: none; font-weight: 600; }
.anchor:hover { text-decoration: underline; }

.reply h3 { font-size: 1.05rem; }

/* ===== メッセージ ===== */
.alert {
    background: #fff4d6;
    border: 1px solid #ffe08a;
    color: #7a5b00;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 0.9rem;
}

/* ===== 集計ダッシュボード ===== */
.stats-cards { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.stat-card {
    flex: 1 1 130px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-label { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.stat-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}
.stat-section h3 { margin: 0 0 12px; font-size: 1rem; }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 5px 0; font-size: 0.82rem; }
.bar-label { flex: none; width: 56px; color: var(--muted); text-align: right; }
.bar-track { flex: 1; background: #eef2f9; border-radius: 6px; overflow: hidden; height: 16px; display: block; }
.bar-fill { display: block; background: var(--primary); height: 100%; border-radius: 6px; min-width: 2px; }
.bar-val { flex: none; width: 36px; color: var(--ink); text-align: right; }
.bar-label.word { width: 120px; text-align: left; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-sub { font-size: 0.72rem; color: var(--muted); font-weight: normal; }
.thread-stat { margin-bottom: 12px; }
.thread-stat a { font-weight: 600; text-decoration: none; }
.thread-stat-count { color: var(--muted); font-size: 0.8rem; margin-left: 6px; }
.thread-stat .bar-track { margin-top: 5px; }
.stat-note { font-size: 0.85rem; color: var(--muted); }

/* ===== レスポンシブ ===== */
@media (max-width: 600px) {
    .site-title { font-size: 1.4rem; }
    .hero-bubbles { width: 75%; opacity: 0.85; }
    main.container { padding-top: 20px; }
}
