/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-danger: #dc2626;
    --color-success: #16a34a;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --font-body: 'Noto Sans JP', 'Hiragino Sans', 'Meiryo', sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

html { font-size: 16px; }

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

img { max-width: 100%; height: auto; }

/* ===== Layout ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.site-main { flex: 1; padding: 2rem 0 3rem; }

/* ===== Header ===== */
.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 1rem;
}

.site-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: -.01em;
}
.site-logo:hover { text-decoration: none; color: var(--color-primary); }

.site-nav { display: flex; gap: 1.25rem; align-items: center; }
.site-nav a { font-size: .9rem; color: var(--color-text-muted); font-weight: 500; }
.site-nav a:hover { color: var(--color-primary); text-decoration: none; }

/* ===== Footer ===== */
.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--color-text-muted);
    font-size: .85rem;
}

/* ===== Page Header ===== */
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.75rem; font-weight: 700; }
.page-header p { color: var(--color-text-muted); margin-top: .35rem; }

/* ===== Cards / Post List ===== */
.post-list { display: flex; flex-direction: column; gap: 1.25rem; }

.post-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: box-shadow .15s, transform .15s;
}
.post-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.post-card__meta {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .8rem;
    color: var(--color-text-muted);
    margin-bottom: .5rem;
}

.post-card__title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: .5rem;
}
.post-card__title a { color: var(--color-text); }
.post-card__title a:hover { color: var(--color-primary); text-decoration: none; }

.post-card__excerpt { color: var(--color-text-muted); font-size: .9rem; }

.badge {
    display: inline-block;
    background: #eff6ff;
    color: var(--color-primary);
    border-radius: 999px;
    padding: .15rem .6rem;
    font-size: .75rem;
    font-weight: 600;
}

/* ===== Single Post ===== */
.post-single { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }

.post-single__title { font-size: 1.75rem; font-weight: 700; margin-bottom: .75rem; line-height: 1.35; }

.post-single__meta {
    display: flex;
    gap: 1rem;
    font-size: .85rem;
    color: var(--color-text-muted);
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
    align-items: center;
}

.post-single__body { line-height: 1.9; font-size: 1rem; }
.post-single__body p { margin-bottom: 1.25rem; }

.back-link { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; color: var(--color-text-muted); margin-bottom: 1.25rem; }
.back-link:hover { color: var(--color-primary); }

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: .5rem;
    margin-top: 2.5rem;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .9rem;
    background: var(--color-surface);
    color: var(--color-text);
}
.pagination a:hover { background: #eff6ff; border-color: var(--color-primary); color: var(--color-primary); text-decoration: none; }
.pagination .current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); font-weight: 700; }
.pagination .disabled { color: var(--color-border); cursor: default; }

/* ===== Forms ===== */
.form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    max-width: 640px;
    margin: 0 auto;
}

.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .4rem; }

.form-control {
    display: block;
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .95rem;
    color: var(--color-text);
    background: var(--color-bg);
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
}
.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
    background: #fff;
}

textarea.form-control { resize: vertical; min-height: 240px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1.25rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s, transform .1s;
    text-decoration: none;
    line-height: 1.5;
}
.btn:active { transform: scale(.97); }
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }

.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-sm { padding: .3rem .75rem; font-size: .8rem; }

/* ===== Alerts ===== */
.alert {
    padding: .85rem 1rem;
    border-radius: var(--radius);
    font-size: .9rem;
    margin-bottom: 1.25rem;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--color-success); }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: var(--color-danger); }

/* ===== Admin Layout ===== */
.admin-header {
    background: #1e293b;
    color: #f1f5f9;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.admin-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.admin-logo { color: #f1f5f9; font-weight: 700; font-size: 1.1rem; }
.admin-logo:hover { color: #fff; text-decoration: none; }
.admin-nav { display: flex; gap: 1rem; align-items: center; }
.admin-nav a { color: #94a3b8; font-size: .875rem; font-weight: 500; }
.admin-nav a:hover { color: #f1f5f9; text-decoration: none; }

.admin-main { padding: 2rem 0 3rem; }

.admin-table-wrap { overflow-x: auto; }

table.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.admin-table th {
    background: #f1f5f9;
    text-align: left;
    padding: .75rem 1rem;
    font-weight: 700;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}
.admin-table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #f8fafc; }

.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* ===== Login ===== */
.login-wrap {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 380px;
}
.login-card h1 { font-size: 1.4rem; font-weight: 700; text-align: center; margin-bottom: 1.75rem; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .site-header__inner { height: 56px; }
    .site-logo { font-size: 1.05rem; }
    .site-nav { gap: .75rem; }
    .site-nav a { font-size: .82rem; }
    .post-card { padding: 1.1rem; }
    .post-single { padding: 1.25rem; }
    .post-single__title { font-size: 1.35rem; }
    .form-card { padding: 1.25rem; }
    .page-header h1 { font-size: 1.35rem; }
    .admin-table th, .admin-table td { padding: .6rem .75rem; }
}
