@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&family=Roboto:wght@400;500;700&display=swap');

/* ==========================================================================
   Base Theme Tokens
   ========================================================================== */
:root {
    --bg: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #2563eb;
    --ring: rgba(37, 99, 235, 0.35);
    --overlay: rgba(2, 6, 23, 0.5);
    --panel: #0b1220;
    --panel-text: #e5e7eb;
    --panel-muted: #a3aed0;

    --main-color: #2B2B2B;
    --primary: #0099EB;
    --primaryRgb: 0, 153, 235;
    --secondary: #38ABE0;
    --thirdly: #51CCE8;
    --background: #E8E8E8;
    --background2: #f5f5f5;
    --category-background: #F0EFEF;
    --line: #E0E0E0;
    --line-rgb: 224, 224, 224;
    --text-sub-color: #C3C3C3;
    --text-sub-color-2: #888888;

    --border: rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: 'Noto Sans JP', system-ui, -apple-system, Segoe UI, Helvetica, Arial, 'Apple Color Emoji', 'Segoe UI Emoji';
    color: var(--main-color);
    background: var(--bg);
    letter-spacing: .02em;
    line-height: 1.6;
    font-weight: 400;
    width: 100%;
    padding-top: 56px;
}

@media (min-width: 1024px) {
    body { padding-top: 72px; }
}

a { text-decoration: none; color: inherit; }

.heading,
h1,
h2,
h3,
h4,
h5,
h6 { font-weight: 700; }

.num {
    font-family: 'Roboto', 'Noto Sans JP', sans-serif;
    font-feature-settings: 'lnum' 1, 'tnum' 1;
    font-weight: 500;
}

.section { max-width: 1080px; margin: 0 auto; padding: 16px; }
.center { text-align: center; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.display { font-weight: 700; font-size: clamp(28px, 6vw, 44px); line-height: 1.2; }
.w-100 { width: 100%; }
.mt-4 { margin-top: 4px; }
.mt-12 { margin-top: 12px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    line-height: 1;
    transition: transform .08s ease, filter .18s ease;
}
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn:hover { filter: brightness(0.99); }
.btn:active { transform: translateY(1px); }
.btn--primary { border-color: #0099EB; color: #0099EB; background: #fff; }
.btn--primary:hover { background: #0099EB; color: #fff; }
.btn-outline { border-color: #cbd5e1; background: #fff; color: var(--text); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

.btn-primary {
    position: relative;
    width: 285px;
    height: 60px;
    border-radius: 30px;
    font-size: 16px;
    line-height: 24px;
    letter-spacing: .08em;
    border: 1px solid var(--primary);
    color: var(--primary);
    background-image: linear-gradient(90deg, var(--primary), var(--primary));
    background-position: left;
    background-size: 0% 100%;
    background-repeat: no-repeat;
    background-color: #fff;
    transition: background-size .35s ease, transform .08s ease;
}
.btn-primary:active { transform: translateY(1px); }
@media (min-width: 1025px) {
    .btn-primary { width: 248px; }
    .btn-primary:hover { background-size: 100% 100%; color: #fff; }
}

.spinner {
    --sz: 40px;
    inline-size: var(--sz);
    block-size: var(--sz);
    border-radius: 999px;
    border: 3px solid rgba(15, 23, 42, .12);
    border-top-color: #0099EB;
    animation: spin 1s linear infinite;
    margin-inline: auto;
}
.spinner.lg { --sz: 54px; border-width: 4px; }

.sr-only {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.op {
    position: fixed;
    inset: 0;
    z-index: 99;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlay-hide 0s 2.1s forwards;
}
.op img { animation: img-fade-up 0.8s ease forwards 0.7s; }
.op::before,
.op::after { content: ""; position: absolute; inset: 0; }
.op::before { background: #fff; z-index: -1; animation: white-fade 0.6s ease forwards 1.2s; }
.op::after {
    background: linear-gradient(var(--primary), var(--thirdly));
    z-index: -2;
    animation: grad-slide-up 0.6s ease-in-out forwards 1.5s;
}
@keyframes img-fade-up { to { transform: translateY(-100px); opacity: 0; } }
@keyframes white-fade { to { opacity: 0; } }
@keyframes grad-slide-up { 99% { transform: translateY(-100%); opacity: 1; } 100% { opacity: 0; } }
@keyframes overlay-hide { to { z-index: 0; visibility: hidden; pointer-events: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

#loading-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
    z-index: 90;
}
#loading-overlay[hidden] { display: none; }
.loading-overlay__panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 32px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--main-color);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}
.loading-overlay__spinner {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 4px solid rgba(15, 23, 42, 0.14);
    border-top-color: var(--primary);
    animation: spin 0.9s linear infinite;
}
.loading-overlay__message {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: .05em;
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header { position: fixed; top: 0; left: 0; right: 0; background: rgba(255,255,255,.85); backdrop-filter: saturate(150%) blur(10px); border-bottom: 1px solid var(--border); z-index: 50; transition: transform .28s ease; will-change: transform; }
.site-header.header-hidden { transform: translateY(-100%); }
.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.header-row { height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-logo { width: auto; height: 26px; display: block; }
.nav-inline { display: none; align-items: center; gap: 20px; }
.nav-inline a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; cursor: pointer; user-select: none; }
.nav-inline a:hover,
.nav-inline a:focus { color: var(--text); }
.fcm { display: none; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.fcm button { border: 1px solid var(--border); background: transparent; border-radius: 999px; padding: 6px 10px; cursor: pointer; }
.fcm button[aria-pressed="true"] { background: #eef2ff; color: #0099EB; border-color: #0099EB; }
.user-avatar { display: none; width: 40px; height: 40px; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.user-avatar img { width: 40px; height: 40px; display: block; object-fit: cover; }
.menu-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; cursor: pointer; user-select: none; }
.menu-toggle:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.menu-toggle .bars { position: relative; width: 18px; height: 14px; }
.menu-toggle .bars::before,
.menu-toggle .bars::after,
.menu-toggle .bars span { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: var(--text); border-radius: 2px; transition: transform .25s ease, opacity .2s ease; }
.menu-toggle .bars::before { top: 0; }
.menu-toggle .bars span { top: 6px; }
.menu-toggle .bars::after { bottom: 0; }
.menu-toggle[aria-expanded="true"] .bars::before { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .bars span { opacity: 0; }
.menu-toggle[aria-expanded="true"] .bars::after { transform: translateY(-6px) rotate(-45deg); }
.menu-icon { font-weight: 600; font-size: 14px; color: var(--muted); }
.offcanvas-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.offcanvas-overlay { position: absolute; inset: 0; background: var(--overlay); opacity: 0; transition: opacity .3s ease; }
.offcanvas-panel { position: absolute; inset-block: 0; inset-inline-end: 0; width: min(92vw,420px); background: linear-gradient(135deg, rgb(0, 153, 235) 0%, rgb(56, 171, 224) 52.22%, rgb(81, 204, 232) 100%); color: #fff; display: grid; grid-template-rows: auto 1fr auto; gap: 12px; transform: translateX(100%); transition: transform .35s cubic-bezier(.22,1,.36,1); }
.offcanvas-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid rgba(255,255,255,.25); }
.offcanvas-title { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.menu-avatar { display: inline-block; width: 36px; height: 36px; border-radius: 999px; overflow: hidden; border: 1px solid rgba(255,255,255,.6); }
.menu-avatar img { width: 36px; height: 36px; display: block; object-fit: cover; }
.close-btn { inline-size: 36px; block-size: 36px; border-radius: 999px; border: none; cursor: pointer; background: rgba(255,255,255,.25); color: #fff; display: inline-grid; place-items: center; }
.close-btn:focus-visible { outline: 2px solid rgba(255,255,255,.6); outline-offset: 2px; }
.offcanvas-content { padding: 12px 16px 24px; overflow: auto; }
.menu-list { list-style: none; margin: 0; padding: 8px 0; display: grid; gap: 6px; }
.menu-list a { display: block; text-decoration: none; color: #fff; padding: 14px 12px; border-radius: 12px; font-weight: 700; font-size: 18px; letter-spacing: .2px; background: transparent; transition: background .2s ease, transform .08s ease; cursor: pointer; user-select: none; }
.menu-list a[role="button"] { cursor: pointer; }
.menu-list a:hover { background: rgba(255,255,255,.15); }
.menu-list a:active { transform: translateY(1px); }
.offcanvas-footer { padding: 16px 18px 20px; border-top: 1px solid rgba(255,255,255,.25); color: rgba(255,255,255,.95); font-size: 13px; }
.socials { display: flex; gap: 10px; margin-top: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: #fff; border: 1px solid rgba(255,255,255,.6); border-radius: 999px; padding: 6px 10px; font-size: 13px; background: transparent; }
.pill[aria-pressed="true"] { background: rgba(255,255,255,.28); border-color: rgba(255,255,255,.95); color: #fff; }
.offcanvas-root[data-open="true"] { pointer-events: auto; }
.offcanvas-root[data-open="true"] .offcanvas-overlay { opacity: 1; }
.offcanvas-root[data-open="true"] .offcanvas-panel { transform: translateX(0%); }
@media (prefers-reduced-motion: reduce) {
    .offcanvas-overlay,
    .offcanvas-panel,
    .menu-toggle .bars::before,
    .menu-toggle .bars::after,
    .menu-toggle .bars span { transition: none; }
}
@media (min-width: 1024px) {
    .brand-logo { height: 43.4px; }
    .header-row { height: 72px; }
    .nav-inline,
    .fcm { display: flex; }
    .fcm button { display: none; }
    .user-avatar { display: inline-block; }
}
body.is-locked { overflow: hidden; }

/* ==========================================================================
   Index Page
   ========================================================================== */
.posts { display: grid; gap: 20px; }
.article-link { display: block; color: inherit; }
.article { display: grid; gap: 12px; padding: 16px 0 36px; border-bottom: 1px solid var(--line); cursor: pointer; }
.article-inner { display: grid; gap: 16px; }
.thumb { width: 100%; aspect-ratio: 16/9; background: var(--background2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: contain; object-position: center; display: block; -webkit-user-drag: none; user-select: none; -webkit-touch-callout: none; }
.meta { display: flex; align-items: center; gap: 10px; }
.badge { display: none; padding: 2px 8px; border-radius: 999px; background: #e5f2ff; color: var(--accent); font-size: 12px; font-weight: 700; }
.article.is-unread .badge { display: inline-block; }
.date { color: var(--text-sub-color-2); font-size: 14px; }
.title { font-size: clamp(16px, 2.4vw, 20px); line-height: 1.4; margin: 4px 0; color: var(--main-color); }
.subtitle { color: var(--main-color); font-size: 14px; }
.article-reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; min-height: 20px; }
.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    font-size: 13px;
    color: var(--main-color);
}
.reaction-pill__emoji { font-size: 14px; }
.reaction-pill__count { font-weight: 700; font-size: 12px; }
.reaction-stats { font-size: 13px; }
.reaction-stats .reaction-counts { font-weight: 700; }
@media (min-width: 768px) {
    .article-inner { grid-template-columns: 260px 1fr; align-items: start; }
}
@media (max-width: 767px) {
    .thumb:empty { display: none; }
}
.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 36px 0 36px; column-gap: 16px; }
.pagination__left { justify-self: end; }
.pagination__pages { justify-self: center; display: flex; align-items: center; gap: 10px; }
.pagination__right { justify-self: start; }
.page-btn { width: 50px; height: 50px; border-radius: 999px; border: 2px solid var(--line); background: none; color: var(--main-color); display: grid; place-items: center; text-decoration: none; cursor: pointer; font-size: 16px; }
.page-nav { background: none; border: none; width: auto; height: auto; padding: 0 8px; color: var(--main-color); font-weight: 700; cursor: pointer; }
.page-btn .num { font-weight: 700; }
.page-btn[aria-current="page"],
.page-btn.active { border-color: var(--primary); }
.page-btn:disabled { opacity: .45; cursor: not-allowed; }
.page-nav:disabled { opacity: .45; cursor: not-allowed; }
@media (min-width: 1024px) {
    .page-btn { width: 60px; height: 60px; font-size: 18px; }
}

/* ==========================================================================
   News Detail Page
   ========================================================================== */
#post-container .center { padding: 48px 0; }
@media (main-with: 768px) {
    #post-container .center { padding: 64px 0; }
}
.news-post { display: grid; gap: 24px; }
.news-post-header { display: grid; gap: 12px; }
.news-post-text { display: grid; gap: 8px; }
.news-post-date { color: var(--text-sub-color-2); font-size: 14px; }
.news-post-title { font-weight: 700; font-size: clamp(22px, 4vw, 32px); line-height: 1.3; margin: 0; color: var(--text); }
.news-post-subtitle { color: #475569; font-size: 16px; }
.news-post-body { font-size: 16px; line-height: 1.8; }
.news-post-hero { margin: 0; }
.news-post-hero img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--border);
    background: var(--bg);
    pointer-events: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.news-post-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.news-post-gallery { display: grid; gap: 24px; justify-items: center; }
.news-post-gallery-item { display: flex; justify-content: center; width: 100%; }
.news-post-gallery-item img {
    width: min(640px, 100%);
    height: auto;
    display: block;
    border: 1px solid var(--border);
    background: var(--bg);
}
.news-post-gallery-item.is-square img { width: min(500px, 100%); }
.news-post-body a { color: #48c5f4; }
.news-reactions {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    background: #f8fafc;
}
.news-reactions__list { display: flex; flex-wrap: wrap; gap: 10px; }
.reaction-button {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 14px;
    background: #fff;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: transform .08s ease, box-shadow .18s ease;
}
.reaction-button[aria-pressed="true"],
.reaction-button.is-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 153, 235, 0.18);
}
.reaction-button__emoji { font-size: 20px; line-height: 1; }
.reaction-button__count { font-weight: 700; font-size: 14px; color: var(--text-sub-color-2); }

/* ==========================================================================
   Auth Page
   ========================================================================== */
body[data-route="auth"] { padding-top: 0; }
@media (min-width: 1024px) {
    body[data-route="auth"] { padding-top: 0; }
}

.logo { display: block; margin: 12px auto 20px; height: 40px; width: auto; }
.auth-page { max-width: 440px; margin: 0 auto; padding: 24px 16px; }
.auth-title { font-weight: 700; font-size: 22px; margin: 0 0 12px; }
.auth-subtitle { font-weight: 700; font-size: 18px; margin: 18px 0 12px; }
.auth-note { color: var(--muted); font-size: 14px; margin: 6px 0 16px; }
.auth-form { display: grid; gap: 10px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; font-weight: 700; }
.field > input {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
}
.field > input:focus { box-shadow: 0 0 0 3px var(--ring); border-color: #93c5fd; }
.checkbox { font-size: 14px; color: var(--muted); }
.auth-actions { display: grid; gap: 12px; margin-top: 12px; }
.form-row { display: grid; gap: 8px; margin-top: 12px; }
.form-row label { font-weight: 700; font-size: 14px; color: var(--text); }
.readonly {
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    color: var(--muted);
}
input[type="text"],
input[type="password"],
input[type="file"],
input[type="email"] {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus {
    box-shadow: 0 0 0 3px var(--ring);
    border-color: #93c5fd;
}
.seg { display: inline-grid; grid-auto-flow: column; gap: 6px; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg label {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    color: var(--muted);
    background: #fff;
}
.seg input:checked + label {
    background: #eef2ff;
    color: #0099EB;
    border-color: #0099EB;
}
.avatar-row { display: flex; gap: 12px; align-items: center; }
.avatar { width: 128px; height: 128px; border-radius: 12px; border: 1px solid var(--border); background: #fff; object-fit: cover; }
.avatar-ctrls { display: grid; gap: 6px; }
.avatar-ctrls .btn { width: 180px; justify-self: start; }
.avatar-ctrls .btn + .btn { margin-top: 4px; }
.hint { font-size: 12px; color: var(--muted); }
.note { margin-top: 10px; font-size: 13px; color: var(--muted); }
.fcm-local { display: flex; align-items: center; gap: 8px; }
.card { border: none; border-radius: 0; padding: 8px 0; background: transparent; box-shadow: none; }
.settings-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.header-spacer { height: 56px; }
@media (min-width: 1024px) {
    .header-spacer { height: 72px; }
}
.field-label { font-weight: 700; font-size: 14px; color: var(--text); }
.fcm-local .btn[aria-pressed="true"] {
    background: linear-gradient(135deg, #00A8FF 0%, #0DA3E2 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 16px rgba(0, 168, 255, .18);
}
.fcm-local .btn[aria-pressed="false"] { background: #fff; color: var(--text); }
#logoutButton { border-color: #ef4444; color: #ef4444; background: #fff; }
#logoutButton:hover { background: #ef4444; color: #fff; }
#resetForm .btn { border-color: #eab308; color: #a16207; background: #fff; }
#resetForm .btn:hover { background: #eab308; color: #fff; }
.copyright { color: var(--muted); font-size: 12px; text-align: center; margin: 24px 0; }

/* PDF viewer */
.pdf-content { display: flex; flex-direction: column; gap: 18px; }
.pdf-image {
    width: 100%;
    height: auto;
    display: block;
    border: none;
    border-radius: 0;
    background: transparent;
    pointer-events: none;
    user-select: none;
}
.pdf-download { text-align: center; margin-top: 4px; }
.pdf-download__link { color: #48c5f4; font-weight: 700; }
.pdf-download__link:hover { text-decoration: underline; }
.pdf-error {
    max-width: 640px;
    margin: 0 auto;
    padding: 20px 16px;
    border-radius: 12px;
    background: #fef2f2;
    color: #991b1b;
    line-height: 1.6;
}
