:root {
    --main: #2563eb;
    --main-dark: #1d4ed8;
    --danger: #dc2626;
    --bg: #f4f6fa;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
}
* { box-sizing: border-box; }
img { max-width: 100%; height: auto; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    line-height: 1.6;
}
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.logo { font-weight: 700; font-size: 18px; color: var(--main); text-decoration: none; }
.site-header nav { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.site-header nav a { color: var(--text); text-decoration: none; }
.nav-btn-login {
    font-weight: 600;
    padding: 6px 14px;
    border: 1.5px solid var(--main);
    border-radius: 999px;
    color: var(--main);
}
.user-name { color: var(--muted); }
.nav-toggle {
    display: none;
    background: none;
    color: var(--text);
    border: none;
    font-size: 22px;
    padding: 4px 8px;
    cursor: pointer;
}

@media (max-width: 680px) {
    .nav-toggle { display: block; }
    .site-header nav {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        background: #fff;
        border-bottom: 1px solid var(--border);
        box-shadow: 0 6px 12px rgba(0,0,0,0.06);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 6px 0;
    }
    .site-header nav.open { display: flex; }
    .site-header nav a,
    .site-header nav .user-name {
        width: 100%;
        padding: 12px 20px;
        box-sizing: border-box;
    }
    .site-header nav a:active,
    .site-header nav a:hover { background: #f1f5f9; }
    .user-name { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 12px; }
    /* ナビ内のボタン(会員登録・マイページへ)もメニュー幅に合わせて自然に見せる */
    .site-header nav a.btn,
    .site-header nav a.nav-btn-cta {
        border-radius: 0;
        text-align: center;
    }
    /* ログインリンクはメニュー内では通常の行として表示(ピル型を解除) */
    .site-header nav a.nav-btn-login {
        border-radius: 0;
        border: none;
        text-align: left;
        color: var(--text);
    }
}
.container { max-width: 760px; margin: 0 auto; padding: 20px 16px 60px; }

.card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 0 0 14px; color: var(--text); }
.hint { font-size: 13px; color: var(--muted); margin-top: -6px; margin-bottom: 14px; }

label { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
input, select, textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--main); }

button {
    background: var(--main);
    color: #fff;
    border: none;
    padding: 11px 18px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
button:hover { background: var(--main-dark); }

.btn {
    display: inline-block;
    background: var(--main);
    color: #fff;
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
}
.btn-secondary {
    display: inline-block;
    background: #fff;
    color: var(--main);
    border: 1px solid var(--main);
    text-decoration: none;
    padding: 9px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}
.btn-secondary:hover { background: #eff6ff; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 8px 12px; font-size: 13px; border-radius: 8px; cursor: pointer; }
.btn-icon { background: none; color: var(--muted); border: none; padding: 4px 6px; font-size: 12px; text-decoration: none; cursor: pointer; }
.btn-icon-danger { color: var(--danger); }
.btn-remove-cat { background: none; color: var(--danger); border: none; padding: 6px 10px; font-size: 14px; cursor: pointer; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash.success { background: #dcfce7; color: #166534; }
.flash.error { background: #fee2e2; color: #991b1b; }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }

/* --- 旅行一覧 --- */
.trip-list { display: grid; gap: 12px; }
.trip-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    text-decoration: none;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: block;
    transition: box-shadow 0.15s;
}
.trip-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.trip-card h2 { margin: 0 0 4px; font-size: 17px; }
.trip-dates { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.trip-desc { color: var(--muted); font-size: 13px; }
.trip-total { font-weight: 700; color: var(--main); margin: 0; }

/* --- 合計 --- */
.total-box {
    background: linear-gradient(135deg, var(--main), var(--main-dark));
    color: #fff;
    padding: 16px 22px;
    border-radius: 14px;
    margin-bottom: 18px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.total-label { font-size: 13px; opacity: 0.85; }
.total-amount { font-size: 24px; font-weight: 700; }

/* --- カテゴリ内訳バー --- */
.category-bars { display: flex; flex-direction: column; gap: 10px; }
.category-bar-row { display: grid; grid-template-columns: 90px 1fr 90px; align-items: center; gap: 10px; font-size: 13px; }
.category-bar-label { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-bar-track { background: #f1f5f9; border-radius: 6px; height: 10px; overflow: hidden; }
.category-bar-fill { height: 100%; border-radius: 6px; }
.category-bar-amount { text-align: right; font-weight: 600; color: var(--muted); }

/* --- 絞り込みフォーム --- */
.filter-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filter-form label { flex: 1; min-width: 130px; margin-bottom: 0; }
.filter-buttons { display: flex; gap: 8px; align-items: center; }

/* --- カテゴリ入力(旅行作成) --- */
.category-input-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.category-input-row { display: flex; gap: 8px; align-items: center; }
.category-input-row input { margin-top: 0; }

/* --- カテゴリ管理(旅行編集) --- */
.category-manage-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.category-manage-list li { display: flex; gap: 10px; align-items: center; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; flex: 1; }
.inline-form input { margin-top: 0; }

/* --- 日付見出し・支出リスト --- */
.date-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 13px;
    color: var(--muted);
    margin: 22px 4px 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.date-subtotal { font-weight: 700; color: var(--text); }
.expense-list { list-style: none; padding: 0; margin: 0 0 8px; }
.expense-item {
    background: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.receipt-thumb img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.expense-info { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.expense-category {
    align-self: flex-start;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    padding: 2px 8px;
    border-radius: 999px;
}
.expense-memo { font-size: 14px; color: #475569; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-amount { font-weight: 700; white-space: nowrap; }
.expense-actions { display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.expense-actions form { margin: 0; }

.ocr-status { font-size: 13px; color: var(--main); min-height: 18px; }
.site-footer { text-align: center; color: #94a3b8; font-size: 12px; padding: 20px; }

/* --- フローティング登録ボタン --- */
.fab {
    position: fixed;
    right: 20px;
    bottom: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--main);
    color: #fff;
    font-size: 30px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(37,99,235,0.4);
    z-index: 40;
    padding: 0;
}
.fab:hover { background: var(--main-dark); }

/* --- 支出登録モーダル --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15,23,42,0.5);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: #fff;
    width: 100%;
    max-width: 480px;
    max-height: 88vh;
    overflow-y: auto;
    border-radius: 18px 18px 0 0;
    padding: 20px;
    animation: modal-up 0.18s ease-out;
}
@media (min-width: 600px) {
    .modal-overlay { align-items: center; }
    .modal-box { border-radius: 16px; }
}
@keyframes modal-up { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head h2 { margin: 0; }
.modal-close { background: none; color: var(--muted); font-size: 18px; padding: 4px 8px; }

/* --- 日付ボタングループ --- */
.date-button-group { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 6px; }
.date-btn {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.date-btn.active { background: var(--main); color: #fff; border-color: var(--main); }
.date-btn-other { background: #fff; border-style: dashed; }
.date-btn-none { background: #fff; }
.date-other-input { margin-top: 4px; }

/* --- 全体費用見出し --- */
.general-heading { border-bottom-color: #cbd5e1; }

/* --- 日ごとの推移グラフ --- */
.trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    min-height: 160px;
}
.trend-bar-col { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; width: 44px; }
.trend-bar-amount { font-size: 10px; color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.trend-bar-track { width: 22px; height: 110px; background: #f1f5f9; border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.trend-bar-fill { width: 100%; background: linear-gradient(180deg, var(--main), var(--main-dark)); border-radius: 6px 6px 0 0; }
.trend-bar-label { font-size: 11px; color: var(--muted); margin-top: 6px; white-space: nowrap; }

/* --- 位置情報 --- */
.location-toggle { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 13px; }
.location-toggle input[type="checkbox"] { width: auto; margin: 0; }
.location-status { font-size: 13px; color: var(--main); min-height: 16px; margin: 6px 0; }

/* --- 旅の記録ページ --- */
.place-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.place-list-item { display: flex; align-items: center; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.place-list-date { color: var(--muted); }
.place-list-memo { flex: 1; }
.place-list-amount { font-weight: 700; }


@media (max-width: 480px) {
    .expense-item { flex-wrap: wrap; }
    .category-bar-row { grid-template-columns: 70px 1fr 70px; font-size: 12px; }
}

.trip-point-count { font-size: 12px; color: var(--muted); font-weight: 400; }
.trip-rank-link { text-decoration: none; color: var(--text); font-weight: 600; }
.trip-rank-link:hover { text-decoration: underline; }

@media (max-width: 680px) {
    .filter-form label { min-width: 100%; }
}
@media (max-width: 480px) {
    .trend-bar-col { width: 36px; }
    .place-list-item { font-size: 12px; }
}

/* --- 記録モード切り替え --- */
.mode-toggle { display: flex; gap: 14px; margin: 8px 0 14px; flex-wrap: wrap; }
.mode-radio { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; margin-bottom: 0; }
.mode-radio input[type="radio"] { width: auto; margin: 0; }

/* --- 振り返りモードの位置選択マップ --- */
.pick-map { height: 220px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }

/* --- 写真アルバム --- */
.photo-grid { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.photo-card { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06); position: relative; flex-shrink: 0; width: 140px; }
.photo-card img { width: 100%; height: 140px; object-fit: cover; display: block; cursor: zoom-in; }
.photo-card-info { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.photo-card-date { font-size: 11px; color: var(--muted); font-weight: 600; }
.photo-card-caption { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-card-geo { font-size: 10px; color: var(--main); }
.photo-delete-btn { position: absolute; top: 6px; right: 6px; background: rgba(255,255,255,0.9); border-radius: 6px; padding: 2px 8px; }

/* --- 旅の記録:写真の横並び表示 --- */
.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding-top: 6px; }
.photo-strip-item { flex-shrink: 0; text-align: center; text-decoration: none; color: var(--muted); font-size: 11px; }
.photo-strip-item img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; display: block; margin-bottom: 4px; cursor: zoom-in; }

/* --- 地図上の写真マーカー(Leaflet divIcon) --- */
.photo-marker { font-size: 20px; text-align: center; line-height: 26px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }

/* --- みんなの旅 一覧 --- */
.public-trip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.public-trip-card {
    background: #fff; border-radius: 12px; overflow: hidden; text-decoration: none; color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); display: block; transition: box-shadow 0.15s;
}
.public-trip-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.public-trip-thumb { width: 100%; height: 130px; object-fit: cover; display: block; background: #eef2ff; }
.public-trip-thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 32px; }
.public-trip-card-body { padding: 12px 14px; }
.public-trip-card-body h2 { font-size: 15px; margin: 0 0 4px; }
.public-trip-meta { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.public-link { font-size: 13px; word-break: break-all; }

/* --- リアクション --- */
.reaction-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.reaction-btn {
    background: #f1f5f9; color: var(--text); border: 1px solid var(--border);
    border-radius: 999px; padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.reaction-btn.active { background: #eff6ff; border-color: var(--main); color: var(--main); font-weight: 700; }

/* --- コメント --- */
.comment-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.comment-item { border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.comment-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.comment-author { font-weight: 700; color: var(--text); }
.comment-body { font-size: 14px; margin: 0; white-space: pre-wrap; }

/* --- トップページ(ルートのindex.php)専用 --- */
.hero { text-align: center; padding: 40px 16px; }
.hero h1 { font-size: 24px; margin: 0 0 10px; }
.hero p { color: var(--muted); font-size: 15px; margin: 0 0 20px; }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.announcement-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.announcement-list li { border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.announcement-title { font-weight: 700; font-size: 15px; }
.announcement-date { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.announcement-body { font-size: 14px; margin: 4px 0 0; white-space: pre-wrap; }

.feature-list { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.9; }

/* --- 画像タップ拡大表示(ライトボックス) --- */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 5000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    cursor: zoom-out;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.lightbox-close {
    position: fixed;
    top: 16px;
    right: 20px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: none;
    font-size: 22px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
}

/* --- 地域選択(国内都道府県/国外国) --- */
.region-multiselect {
    width: 100%;
    min-height: 220px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}
.region-multiselect optgroup { font-weight: 700; color: var(--muted); }
.region-multiselect option { padding: 5px 8px; }
.region-multiselect option:checked { background: #dbeafe; color: var(--main); font-weight: 600; }

/* --- 旅行一覧の公開範囲バッジ --- */
.badge-pill { display: inline-block; color: #fff; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; flex-shrink: 0; }
