/* LPL写真選定 — vanilla CSS。スマホ優先。 */
:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --ink: #1c2330;
    --muted: #6b7280;
    --line: #e3e6eb;
    --accent: #2563eb;
    --accent-ink: #ffffff;
    --ok: #16a34a;
    --warn: #dc2626;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- ヘッダ / フッタ ---------- */
.app-header {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.home-link { font-weight: 700; font-size: 16px; color: var(--ink); }
.home-link:hover { text-decoration: none; }
.counter {
    margin-left: auto;
    font-size: 14px; font-weight: 600;
    padding: 4px 10px; border-radius: 999px;
    background: #eef2ff; color: var(--accent);
    white-space: nowrap;
}
.counter.over { background: #fee2e2; color: var(--warn); }
.admin-link { font-size: 14px; }
.app-header .counter + .admin-link { margin-left: 12px; }

.app-footer {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px;
    max-width: 1100px; margin: 32px auto 12px; padding: 12px 16px;
    font-size: 13px; color: var(--muted);
    border-top: 1px solid var(--line);
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.page-title { font-size: 18px; margin: 8px 0 16px; }

/* ---------- ログイン ---------- */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
}
.login-card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 28px 24px;
    width: 100%; max-width: 360px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.login-card input[type=text], .login-card input[type=password] {
    width: 100%; margin-top: 6px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 8px; font-size: 16px;
}
.btn-primary {
    background: var(--accent); color: var(--accent-ink);
    border: none; border-radius: 8px; padding: 10px 16px;
    font-size: 15px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn-primary:hover { filter: brightness(1.05); }
.alert {
    background: #fef2f2; color: var(--warn);
    border: 1px solid #fecaca; border-radius: 8px;
    padding: 10px 12px; margin-bottom: 16px; font-size: 14px;
}
.alert.ok { background: #f0fdf4; color: var(--ok); border-color: #bbf7d0; }

/* ---------- フォルダ一覧 ---------- */
.folder-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.folder-card {
    display: block; background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px; border: 1px solid var(--line);
    color: var(--ink);
}
.folder-card:hover { text-decoration: none; border-color: var(--accent); }
.folder-card .fname { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.folder-card .fstat { font-size: 22px; font-weight: 700; }
.folder-card .fstat .sep { color: var(--muted); font-weight: 400; font-size: 16px; }
.folder-card .ftotal { color: var(--muted); font-size: 13px; margin-top: 4px; }
.folder-card.over .fstat { color: var(--warn); }

/* ---------- ギャラリー ---------- */
.gallery-top { display: flex; align-items: baseline; gap: 12px; }
.back { font-size: 14px; }
.filter-tabs { display: flex; gap: 8px; margin: 4px 0 16px; flex-wrap: wrap; }
.filter-tabs button {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer;
    color: var(--ink);
}
.filter-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-tabs .cnt { font-weight: 700; }

.photo-grid {
    display: grid; gap: 8px;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
@media (min-width: 700px) {
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
.cell {
    position: relative; aspect-ratio: 3/2; overflow: hidden;
    border-radius: 8px; background: #e5e7eb; cursor: pointer;
    border: 3px solid transparent;
}
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell.selected { border-color: var(--ok); }
.cell .badge {
    position: absolute; top: 6px; left: 6px;
    background: var(--ok); color: #fff; border-radius: 999px;
    width: 24px; height: 24px; display: none;
    align-items: center; justify-content: center; font-size: 15px; font-weight: 700;
}
.cell.selected .badge { display: flex; }
.cell .chk {
    position: absolute; top: 6px; right: 6px;
    width: 30px; height: 30px; border-radius: 50%;
    border: 2px solid #fff; background: rgba(0,0,0,.35);
    color: #fff; font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.cell.selected .chk { background: var(--ok); border-color: #fff; }
.cell .by {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: linear-gradient(transparent, rgba(0,0,0,.6));
    color: #fff; font-size: 11px; padding: 10px 6px 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

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

/* ---------- ライトボックス ---------- */
.lightbox {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(10,12,18,.92);
    display: flex; flex-direction: column;
}
.lightbox[hidden] { display: none; }
.lb-stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 8px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-close {
    position: absolute; top: 10px; right: 14px; z-index: 2;
    background: none; border: none; color: #fff; font-size: 34px; cursor: pointer; line-height: 1;
}
.lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,.12); border: none; color: #fff;
    font-size: 40px; width: 54px; height: 80px; cursor: pointer; z-index: 2;
}
.lb-prev { left: 6px; border-radius: 0 8px 8px 0; }
.lb-next { right: 6px; border-radius: 8px 0 0 8px; }
.lb-bar {
    display: flex; align-items: center; justify-content: center; gap: 16px;
    padding: 14px; background: rgba(0,0,0,.4);
}
.lb-by { color: #cbd5e1; font-size: 13px; }
.btn-toggle-lg {
    background: var(--card); color: var(--ink); border: 2px solid var(--ok);
    border-radius: 999px; padding: 10px 24px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-toggle-lg.on { background: var(--ok); color: #fff; }

/* ---------- トースト ---------- */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    background: #111827; color: #fff; padding: 10px 18px; border-radius: 999px;
    font-size: 14px; z-index: 100; box-shadow: var(--shadow); max-width: 90vw;
}
.toast[hidden] { display: none; }
.toast.err { background: var(--warn); }

/* ---------- 管理画面 ---------- */
.admin .card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px; margin-bottom: 20px;
}
.admin h2 { margin-top: 0; font-size: 16px; }
.admin h3 { font-size: 14px; margin: 18px 0 8px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
.tbl.small { font-size: 12px; }
.tbl .muted, .muted { color: var(--muted); }
.row-ops { display: flex; flex-wrap: wrap; gap: 8px; }
.inline { display: inline; }
.form-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin input[type=text], .admin input[type=password], .admin select, .admin textarea {
    padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px;
}
.admin textarea { width: 100%; max-width: 520px; display: block; margin-bottom: 8px; font-family: inherit; }
.admin button {
    padding: 8px 12px; border: 1px solid var(--line); background: #f9fafb;
    border-radius: 6px; cursor: pointer; font-size: 13px;
}
.admin button.btn-primary { width: auto; background: var(--accent); color: #fff; border-color: var(--accent); }
.hint { color: var(--muted); font-size: 13px; }
.hint code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
.progress { height: 10px; background: var(--line); border-radius: 999px; margin: 12px 0; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
