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

:root {
  --brand:    #202f55;
  --brand-d:  #172240;
  --brand-l:  #2d4275;
  --brand-xs: #eef1f8;
  --brand-s:  #d4daf0;
  --bg:       #f3f5f9;
  --surface:  #ffffff;
  --border:   #dde1ea;
  --text:     #1a1d23;
  --muted:    #6b7280;
  --gold-l:   #fef3c7;
  --gold-d:   #92400e;
  --blue-l:   #dbeafe;
  --blue-d:   #1e40af;
  --green-l:  #d1fae5;
  --green-d:  #065f46;
  --danger:   #dc2626;
  --danger-s: #fef2f2;
  --success:  #16a34a;
  --success-s:#f0fdf4;
  --warn:     #d97706;
  --sans:     'Noto Sans JP', sans-serif;
  --serif:    'Noto Serif JP', serif;
  --mono:     'JetBrains Mono', monospace;
  --radius:   8px;
  --radius-lg:14px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }

/* ── ヘッダー ── */
.site-header { background: var(--brand); padding: 0 28px; height: 60px; display: flex; align-items: center; flex-wrap: nowrap; gap: 16px; position: sticky; top: 0; z-index: 200; flex-shrink: 0; box-shadow: 0 2px 12px rgba(32,47,85,.2); }
.site-header .logo-img { height: 36px; width: auto; cursor: pointer; user-select: none; flex-shrink: 0; }
.app-name-label { color: #fff; font-size: 14px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.app-name-label .beta-badge { margin-left: 6px; }
.header-menu { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; margin-left: auto; }
.header-nav { display: flex; align-items: center; flex-wrap: nowrap; gap: 4px; }
.header-nav a { color: rgba(255,255,255,.78); text-decoration: none; font-size: 13px; font-weight: 500; padding: 6px 14px; border-radius: 6px; white-space: nowrap; flex-shrink: 0; transition: background .15s, color .15s; }
.header-nav a:hover, .header-nav a.nav-active { background: rgba(255,255,255,.15); color: #fff; }
.header-auth { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.18); flex-shrink: 0; }
.btn-login { background: rgba(255,255,255,.15) !important; color: #fff !important; border: 1px solid rgba(255,255,255,.3) !important; font-size: 13px !important; padding: 5px 14px !important; border-radius: 6px; cursor: pointer; white-space: nowrap; font-family: var(--sans); }
.btn-login:hover { background: rgba(255,255,255,.25) !important; }
.user-chip { display: flex; align-items: center; flex-wrap: nowrap; gap: 6px; font-size: 13px; color: rgba(255,255,255,.85); white-space: nowrap; }

/* ── ハンバーガーメニュー（ロゴ＋アプリ名＋ナビ＋ログインが1行に収まらない
      画面幅ではPC表示を諦め、ハンバーガーに切り替える。768pxだと
      「平野先生のビジネス文書タイピング」のようなアプリ名付きヘッダーが
      収まりきらずリンク文字が折り返してしまうため、900pxに拡大） ── */
.hamburger-btn { display: none; flex-direction: column; justify-content: center; align-items: center; gap: 5px; width: 36px; height: 36px; background: transparent; border: none; cursor: pointer; margin-left: auto; padding: 0; flex-shrink: 0; }
.hamburger-btn span { display: block; width: 22px; height: 2px; background: #fff; border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 900px) {
  .hamburger-btn { display: flex; }
  .header-menu { display: none; position: absolute; top: 100%; left: 0; right: 0; margin-left: 0; flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 0; background: var(--brand); padding: 8px 14px 16px; box-shadow: 0 10px 24px rgba(0,0,0,.2); }
  .header-menu.open { display: flex; }
  .header-nav { flex-direction: column; align-items: stretch; gap: 2px; }
  .header-nav a { padding: 11px 12px; font-size: 14px; }
  .header-auth { border-left: none; padding-left: 0; padding-top: 10px; margin-top: 8px; border-top: 1px solid rgba(255,255,255,.18); justify-content: space-between; }
  .user-chip { font-size: 14px; }
}

/* スマホの狭い画面では、ロゴ＋ハンバーガーだけを残しアプリ名テキストは
   非表示にする（ロゴ画像に既に名称が入っているアプリでは情報の重複はないが、
   入っていないアプリでも、この幅ではアプリ名より操作性を優先する）。 */
@media (max-width: 480px) {
  .app-name-label { display: none; }
}
/* 480〜900pxの中間幅では、アプリ名は残しつつ「β版」バッジだけ先に隠して
   ヘッダーがはみ出さないようにする（app-name-label側もellipsisで保険）。 */
@media (max-width: 900px) {
  .app-name-label .beta-badge { display: none; }
}
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; }

/* ── 広告スロット ── */
.ad-slot { position: relative; border: 2px solid var(--brand-s); border-radius: var(--radius); background: var(--surface); overflow: visible; }
.ad-slot::before { content: '広告'; position: absolute; top: -10px; left: 12px; background: var(--brand); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .1em; padding: 1px 8px; border-radius: 99px; }
.ad-inner { display: flex; align-items: center; justify-content: center; min-height: 90px; }
.ad-slot-728 { width: 100%; max-width: 728px; }
.ad-slot-300 { width: 300px; }

/* ── ボタン ── */
button { font-family: var(--sans); cursor: pointer; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 500; padding: 10px 24px; transition: opacity .15s, transform .1s, background .15s; white-space: nowrap; }
button:active { transform: scale(.97); }
button:disabled { opacity: .38; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-l); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }
.btn-danger { background: var(--danger-s); color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fee2e2; }

/* ── バッジ ── */
.badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.badge-1 { background: var(--gold-l); color: var(--gold-d); }
.badge-2 { background: var(--blue-l); color: var(--blue-d); }
.badge-3 { background: var(--green-l); color: var(--green-d); }
.badge-4  { background:#e5ede0; color:#4d6b3a; }
.badge-j2 { background:#d6f2f2; color:#0e7490; }
.badge-j1 { background:#fde3c8; color:#c2670f; }
.badge-wordpro { background: #ede9fe; color: #6d28d9; }
.badge-business { background: var(--brand-xs); color: var(--brand); }

/* ── フッター ── */
.site-footer { width: 100%; border-top: 1px solid var(--border); background: var(--surface); padding: 22px 24px; margin-top: auto; flex-shrink: 0; }
.footer-inner { max-width: 1000px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 22px; }
.footer-copy { font-size: 12px; color: var(--muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.footer-links a { font-size: 12px; color: var(--muted); text-decoration: none; transition: color .15s; }
.footer-links a:hover { color: var(--brand); text-decoration: underline; }
@media (max-width: 480px) {
  .footer-inner { flex-direction: column; gap: 8px; text-align: center; }
}
.beta-badge { display:inline-block; font-size:11px; font-weight:700; letter-spacing:.04em; color:#6d28d9; background:#ede9fe; border:1px solid #ddd6fe; border-radius:99px; padding:2px 10px; vertical-align:middle; margin-left:8px; }

/* ── モーダル ── */
/* 不具合修正：position:fixed + align-items/justify-content:center の組み合わせは、
   中身がビューポートより高い場合に上下が見切れてもスクロールできなくなる典型的な
   バグを引き起こす（特にスマホ縦画面で発生しやすい）。
   overflow-y:auto を付与し、中央寄せには padding を用いることで解消する。 */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(10,15,30,.65); backdrop-filter: blur(4px); z-index: 500; overflow-y: auto; }
.modal-overlay.show { display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; }
.modal-card { background: var(--surface); border-radius: var(--radius-lg); padding: 36px 40px; width: 420px; max-width: 94vw; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: popIn .2s cubic-bezier(.22,.87,.47,1); }
.modal-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions button { flex: 1; }
.input-field { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--sans); font-size: 14px; outline: none; transition: border-color .15s; margin-bottom: 10px; }
.input-field:focus { border-color: var(--brand); }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; display: block; }
.auth-error { color: var(--danger); font-size: 12px; min-height: 16px; margin-bottom: 8px; }
.auth-success { color: var(--success); font-size: 12px; min-height: 16px; margin-bottom: 8px; }
.auth-divider { text-align: center; font-size: 12px; color: var(--muted); margin: 10px 0; }

/* ── 公開停止レイヤー（メンテナンス/緊急） ── */
.maint-overlay { display: none; position: fixed; inset: 0; z-index: 2000; overflow-y: auto; }
.maint-overlay.show { display: flex; align-items: flex-start; justify-content: center; padding: 48px 24px; }
.maint-overlay.maintenance { background: rgba(55,60,70,.96); }
.maint-overlay.emergency { background: rgba(60,10,10,.97); }
.maint-card { background: var(--surface); border-radius: var(--radius-lg); padding: 40px 36px; width: 440px; max-width: 92vw; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.maint-icon { font-size: 40px; margin-bottom: 12px; }
.maint-title { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.maintenance .maint-title { color: #92400e; }
.emergency .maint-title { color: var(--danger); }
.maint-desc { font-size: 13px; color: var(--muted); line-height: 1.8; margin-bottom: 18px; }
.maint-card .btn-ghost { width: 100%; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
@keyframes popIn { from { opacity:0; transform:scale(.9) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }
