:root {
    --bg: #faf7f2;
    --fg: #2f2a22;
    --accent: #b5651d;
    --accent-dark: #8a4d15;
    --card-bg: #ffffff;
    --border: #e4ddd0;
    --muted: #7a7264;
    --danger: #b3261e;
    --success: #2e7d32;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.6;
}

a { color: var(--accent-dark); }

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.site-header .brand {
    font-weight: bold;
    font-size: 1.2rem;
    text-decoration: none;
    color: var(--fg);
}

.site-header nav a {
    margin-left: 16px;
    text-decoration: none;
    font-size: 0.9rem;
}

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

.site-footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 24px;
}

.search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-form input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

.search-form button {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-size: 1rem;
    cursor: pointer;
}

.search-form button:hover { background: var(--accent-dark); }

.clear-link {
    align-self: center;
    font-size: 0.9rem;
}

.result-count { color: var(--muted); font-size: 0.9rem; }

.empty { color: var(--muted); padding: 40px 0; text-align: center; }

.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.post-card {
    position: relative;
    display: block;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: var(--fg);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.photo-count-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.75rem;
    padding: 2px 7px;
    border-radius: 10px;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.post-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.post-card .no-photo {
    width: 100%;
    height: 150px;
    background: var(--border);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.post-card-body { padding: 12px; }
.post-card-body h2 { margin: 0 0 6px; font-size: 1.05rem; }
.post-card-body .address { margin: 4px 0; font-size: 0.85rem; color: var(--muted); }
.post-card-body .excerpt { margin: 4px 0; font-size: 0.9rem; color: var(--fg); }
.post-card-body .date { margin: 4px 0 0; font-size: 0.78rem; color: var(--muted); }

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 24px;
    color: var(--muted);
}

.back-link { display: inline-block; margin-bottom: 16px; text-decoration: none; }

.post-detail h1 { margin-bottom: 4px; }
.post-detail .date { color: var(--muted); font-size: 0.85rem; margin-top: 0; }

.photo-gallery {
    display: grid;
    gap: 8px;
    margin: 16px 0;
    grid-template-columns: 1fr;
}
.photo-gallery-2, .photo-gallery-3 { grid-template-columns: 1fr 1fr; }
.photo-gallery img {
    width: 100%;
    height: 220px;
    max-height: 480px;
    object-fit: cover;
    border-radius: 12px;
    display: block;
}
.photo-gallery-3 a:first-child { grid-column: 1 / -1; }
.photo-gallery-3 img { height: 220px; }
.photo-gallery-1 img { height: auto; max-height: 480px; }

.body-text { white-space: pre-wrap; font-size: 1.02rem; }

.map-block { margin-top: 24px; }
.map-block .address {
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.map-embed {
    width: 100%;
    height: 320px;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-top: 8px;
}

.flashes { list-style: none; padding: 0; margin: 0 0 16px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 0.92rem; }
.flash-success { background: #e6f4ea; color: var(--success); }
.flash-error { background: #fdecea; color: var(--danger); }

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.button, .button-secondary {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
}
.button { background: var(--accent); color: white; }
.button:hover { background: var(--accent-dark); }
.button-secondary { background: var(--border); color: var(--fg); }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
}
.admin-table th, .admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.9rem;
    vertical-align: middle;
}
.admin-table thead th { background: #f2ede3; }
.thumb-wrap { position: relative; display: inline-block; }
.admin-table .thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; display: block; }
.thumb-count {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 0.65rem;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 1px 5px;
    border-radius: 8px;
}
.row-actions { display: flex; gap: 10px; align-items: center; white-space: nowrap; }
.link-button {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
    text-decoration: underline;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 520px;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
}
.admin-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--muted);
}
.admin-form .required { color: var(--danger); font-size: 0.75rem; }
.admin-form input[type="text"],
.admin-form input[type="password"],
.admin-form input[type="file"],
.admin-form textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--fg);
}
.admin-form textarea { resize: vertical; }
.form-actions { display: flex; gap: 12px; }
.form-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-size: 1rem;
    cursor: pointer;
}
.form-actions button:hover { background: var(--accent-dark); }

.field-label { font-size: 0.9rem; color: var(--muted); margin: 0 0 4px; }
.existing-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}
.existing-photo-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--fg);
    cursor: default;
}
.existing-photo-item .thumb-large {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.login-form { margin: 0 auto; }

.map-page-hint { color: var(--muted); font-size: 0.9rem; margin-top: -8px; }
.full-map {
    width: 100%;
    height: 70vh;
    min-height: 320px;
    border-radius: 12px;
    border: 1px solid var(--border);
}
.map-popup { font-size: 0.9rem; }
.map-popup-address { color: var(--muted); font-size: 0.8rem; }

@media (max-width: 480px) {
    .container { padding: 14px; }
    .site-header { padding: 12px 14px; }
}
