/* CLANE 標準デザイン — マイページ
   紫グラデ #461787 → #A057A2 / Noto Sans / 角丸 / Material Icons / 絵文字なし */

:root {
  --clane-1: #461787;
  --clane-2: #A057A2;
  --grad: linear-gradient(135deg, #461787 0%, #A057A2 100%);
  --ink: #2a2233;
  --ink-sub: #6b6478;
  --line: #e7e3ee;
  --bg: #f6f4fa;
  --card: #ffffff;
  --ok: #1f9d63; --ok-bg: #e6f5ee;
  --warn: #c98a00; --warn-bg: #fbf2dc;
  --danger: #b3261e; --danger-bg: #fbe9e8;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(70,23,135,.08), 0 8px 24px rgba(70,23,135,.07);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Noto Sans JP", "Hiragino Sans", system-ui, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.6; -webkit-font-smoothing: antialiased;
}
.topbar { background: #fff; color: var(--ink); padding: 12px 24px; display: flex; align-items: center; gap: 12px; position: fixed; top: 0; left: 0; right: 0; z-index: 100; box-shadow: 0 1px 8px rgba(0,0,0,.06); }
body { padding-top: 54px; }
/* 固定ヘッダー直下の余白マスク：ヘッダー(白)の下にページ背景の帯を敷き、スクロールしても
   AIサポート／タグの上に余白を保つ＋その帯にカードが透けないようにする（z: カード<帯<アカウントメニュー<ヘッダー）。 */
body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: 70px; background: var(--bg); z-index: 40; pointer-events: none; }
.topbar .material-icons { font-size: 24px; }
.topbar h1 { font-size: 17px; font-weight: 700; margin: 0; }
.topbar-logo { height: 26px; width: auto; display: block; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; opacity: .95; display: flex; align-items: center; gap: 8px; }

.wrap { max-width: 1140px; margin: 28px auto; padding: 0 20px; }
/* ログイン/オンボーディングのカードは広げず中央寄せ（ポータルだけ全幅を使う） */
#loginView, #onboardView { max-width: 460px; margin-left: auto; margin-right: auto; }
.notice { background: var(--warn-bg); border: 1px solid #ecd9a6; color: #7a5b00; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: 13px; }
.notice.hidden { display: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.center { text-align: center; }
.logo-badge { width: 56px; height: 56px; border-radius: 16px; background: var(--grad); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.logo-badge .material-icons { color: #fff; font-size: 30px; }
h2 { font-size: 20px; margin: 0 0 6px; }
.sub { color: var(--ink-sub); font-size: 14px; margin: 0 0 22px; }

.btn {
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; border: none; border-radius: 10px;
  padding: 12px 20px; color: #fff; background: var(--grad); display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.05); }
.btn.ghost { background: #fff; color: var(--clane-1); border: 1px solid var(--line); }
.btn.google { background: #fff; color: #3c4043; border: 1px solid #dadce0; font-weight: 600; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.section-title { font-size: 12px; letter-spacing: .04em; color: var(--ink-sub); font-weight: 700; margin: 26px 0 10px; }
.product {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 10px;
}
.product .icon { width: 40px; height: 40px; border-radius: 10px; background: #f1ecf8; display: inline-flex; align-items: center; justify-content: center; }
.product .icon .material-icons { color: var(--clane-1); }
.product .meta { flex: 1; }
.product .name { font-weight: 700; }
.product .updated { font-size: 12px; color: var(--ink-sub); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; }
.badge.active { background: var(--ok-bg); color: var(--ok); } .badge.active .dot { background: var(--ok); }
.badge.suspended { background: var(--warn-bg); color: var(--warn); } .badge.suspended .dot { background: var(--warn); }
.badge.cancelled { background: var(--danger-bg); color: var(--danger); } .badge.cancelled .dot { background: var(--danger); }

.empty { color: var(--ink-sub); font-size: 14px; padding: 18px 0; text-align: center; }
.foot { margin-top: 24px; display: flex; justify-content: flex-end; }
.hidden { display: none !important; }

/* ---- フォーム入力 ---- */
.input { width: 100%; font: inherit; font-size: 15px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.input:focus { outline: none; border-color: var(--clane-2); box-shadow: 0 0 0 3px rgba(160,87,162,.12); }
.form-row { text-align: left; margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.form-row .req { color: var(--danger); font-size: 11px; font-weight: 700; margin-left: 6px; }
.form-msg { min-height: 18px; font-size: 13px; color: var(--danger); margin: 4px 0 14px; text-align: left; }

/* ---- 認証タブ（新規登録 / ログイン） ---- */
.auth-tabs { display: flex; gap: 8px; margin: 0 0 18px; }
.auth-tab { flex: 1; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink-sub); border-radius: 10px; padding: 10px 0; }
.auth-tab:hover { border-color: var(--clane-2); }
.auth-tab.on { background: var(--grad); color: #fff; border-color: transparent; }

/* ヘッダーのプラン小タグ（有料プラン） */
.plan-tag { font-size: 11px; font-weight: 700; background: #efeaf7; border: 1px solid var(--line); color: var(--clane-1); padding: 2px 9px; border-radius: 999px; margin-left: 8px; }

/* ---- ログイン（メール/パスワード） ---- */
.or-sep { display: flex; align-items: center; gap: 12px; color: var(--ink-sub); font-size: 12px; margin: 20px 0 16px; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.pw-form { text-align: left; }
.pw-form .input { margin-bottom: 10px; }
.pw-actions { display: flex; gap: 10px; margin-top: 4px; }
.pw-actions .btn { flex: 1; }

/* ---- プラン状態バナー ---- */
.plan-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); padding: 12px 20px; margin-bottom: 18px; }
.plan-banner .pb-main { display: flex; align-items: center; gap: 12px; }
.plan-banner .pb-main > .material-icons { font-size: 24px; }
.plan-banner .pb-title { font-size: 15px; font-weight: 700; }
.plan-banner .pb-sub { font-size: 13px; color: var(--ink-sub); margin-top: 2px; }
.plan-banner.ok { border-color: #bfe6d2; } .plan-banner.ok .pb-main > .material-icons { color: var(--ok); }
.plan-banner.warn { border-color: #ecd9a6; background: var(--warn-bg); } .plan-banner.warn .pb-main > .material-icons { color: var(--warn); }
.plan-banner.danger { border-color: #f1c5c2; background: var(--danger-bg); } .plan-banner.danger .pb-main > .material-icons { color: var(--danger); }
.pb-cta .btn { font-size: 13px; padding: 9px 16px; }

/* ---- カテゴリー絞り込みチップ ---- */
.cat-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.cat-chip { font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink-sub); border-radius: 999px; padding: 6px 14px; }
.cat-chip:hover { border-color: var(--clane-2); }
.cat-chip.on { background: var(--grad); color: #fff; border-color: transparent; }

/* ---- 製品カード（サムネイル付き） ---- */
.product-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.pc-thumb-wrap { position: relative; }
.pc-thumb { width: 100%; aspect-ratio: 16 / 7; background: #f1ecf8; overflow: hidden; }
.pc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pc-thumb.noimg { display: flex; align-items: center; justify-content: center; background: #e9e7ee; }
.pc-thumb.noimg img { display: none; }
.pc-thumb.noimg .material-icons { color: #a7a3b3; font-size: 36px; }
/* サムネ上部に薄いグラデーションを重ね、左上タグの視認性を上げる */
.pc-thumb-wrap::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 56px; background: linear-gradient(to bottom, rgba(0,0,0,.38), rgba(0,0,0,0)); pointer-events: none; z-index: 1; }
/* カテゴリー＋種別タグをサムネイル左上に重ねる */
.pc-tags { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 2; display: flex; flex-wrap: wrap; gap: 6px; }
.pc-tag { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.pc-cat { color: var(--clane-1); background: rgba(255,255,255,.95); }
.pc-kind { color: #fff; border: 1px solid rgba(255,255,255,.35); background: rgba(70,23,135,.85); }
/* 種別ごとの色分け */
.pc-kind.k-desktop { background: rgba(37,99,235,.92); }   /* デスクトップ＝青 */
.pc-kind.k-saas    { background: rgba(13,148,136,.92); }  /* Webサービス＝ティール */
.pc-kind.k-file    { background: rgba(202,138,4,.95); }   /* ファイル配布＝アンバー */
.pc-kind.k-wp      { background: rgba(124,58,177,.92); }  /* WPプラグイン＝パープル */
.pc-kind.k-other   { background: rgba(90,92,104,.92); }   /* その他＝グレー */
.pc-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.pc-name { font-weight: 700; font-size: 16px; line-height: 1.35; margin-bottom: 2px; }
.pc-sub { font-size: 12px; color: var(--ink-sub, #6b6478); line-height: 1.3; margin-bottom: 8px; }
.pc-sum { font-size: 13px; color: var(--ink-sub); line-height: 1.7; flex: 1; margin: 0 0 16px; }
/* ボタン: 2つは横並び1行、3つ(詳細+DL2)は詳細を上段・DLを下段2列 */
.pc-foot { display: flex; flex-direction: column; gap: 8px; }
.pc-row { display: flex; gap: 8px; }
.pc-row .btn { flex: 1; justify-content: center; font-size: 13.5px; padding: 10px 12px; }
/* Markdown 説明 */
.pc-sum.md :first-child { margin-top: 0; }
.pc-sum.md h1, .pc-sum.md h2, .pc-sum.md h3 { font-size: 14px; margin: 10px 0 4px; color: var(--ink); }
.pc-sum.md p { margin: 0 0 8px; }
.pc-sum.md ul, .pc-sum.md ol { margin: 0 0 8px; padding-left: 20px; }
.pc-sum.md a { color: var(--clane-1); font-weight: 600; }
.pc-sum.md code { background: #f1ecf8; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---- トースト ---- */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: #2a2233; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--ok); } .toast.error { background: var(--danger); }

/* ---- アカウントメニュー（アイコンhover/クリックで展開） ---- */
.acct { position: relative; }
.acct-btn { background: transparent; border: none; color: var(--clane-1); cursor: pointer; display: inline-flex; padding: 4px; border-radius: 50%; }
.acct-btn .material-icons { font-size: 28px; }
.acct-btn:hover { background: var(--bg); }
.acct-menu { position: absolute; top: 100%; right: 0; margin-top: 10px; min-width: 220px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; display: none; z-index: 60; }
/* アイコンとメニューの隙間を透明な橋でつなぎ、ホバーが途切れないようにする */
.acct-menu::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 12px; }
.acct:hover .acct-menu, .acct.open .acct-menu { display: block; }
.acct-email { font-size: 12px; color: var(--ink-sub); padding: 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; word-break: break-all; }
.acct-item { width: 100%; display: flex; align-items: center; gap: 8px; font: inherit; font-size: 14px; color: var(--ink); background: transparent; border: none; border-radius: 8px; padding: 9px 10px; cursor: pointer; }
.acct-item:hover { background: var(--bg); }

/* ---- サポートチャット ---- */
.chat-fab { position: fixed; right: 22px; bottom: 22px; width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--grad); color: #fff; cursor: pointer; box-shadow: 0 8px 24px rgba(70,23,135,.35); display: flex; align-items: center; justify-content: center; z-index: 90; }
.chat-fab:hover { filter: brightness(1.06); }
.chat-fab .material-icons { font-size: 26px; }
/* FAB の位置から展開（右下固定・上方向へ伸びる）。展開時はFABを隠す。
   ヘッダードラッグで移動、右下グリップでリサイズ可能。 */
.chat-panel { position: fixed; right: 22px; bottom: 22px; width: min(380px, calc(100vw - 32px)); height: min(560px, calc(100vh - 60px)); background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 50px rgba(70,23,135,.28); display: flex; flex-direction: column; overflow: hidden; z-index: 95; resize: both; min-width: 300px; min-height: 340px; max-width: 96vw; max-height: 94vh; }
.chat-input textarea.input { resize: none; line-height: 1.5; max-height: 120px; font-family: inherit; }
.chat-head { background: #fff; color: var(--ink); padding: 12px 16px; display: flex; align-items: center; gap: 8px; font-size: 14px; border-bottom: 1px solid var(--line); }
.chat-close { margin-left: auto; background: transparent; border: none; color: #fff; cursor: pointer; display: inline-flex; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #fff; }
.cmsg { max-width: 85%; font-size: 13.5px; line-height: 1.6; padding: 9px 12px; border-radius: 12px; word-break: break-word; }
.cmsg.me { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 4px; }
.cmsg.ai { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.cmsg.ai p { margin: 0 0 6px; } .cmsg.ai :last-child { margin-bottom: 0; }
.cmsg.ai ul, .cmsg.ai ol { margin: 4px 0; padding-left: 18px; }
.cmsg.typing { color: var(--ink-sub); letter-spacing: 2px; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: #fff; }
.chat-input .input { flex: 1; }
.chat-input .btn { padding: 10px 14px; }

/* ポータル2カラム（左:常設AIチャット / 右:製品一覧）。画面高に収め、製品グリッドだけスクロール */
.portal-2col { display: flex; gap: 22px; align-items: flex-start; }
.chat-col { flex: 0 0 58%; max-width: 720px; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: none; overflow: hidden; position: sticky; top: 70px; height: calc(100vh - 92px); }
.chat-col .chat-head { cursor: default; }
.products-col { flex: 1; min-width: 0; }
/* 「製品一覧」見出し＋タグは固定、その下のカードだけスクロール（ページスクロール） */
/* タグ行の上端を「AIサポート」見出し（chat-head の padding-top:12px）と揃える。
   上パディングは sticky 枠の内側なので、スクロールしてもタグ上の余白として残る。 */
/* 左右に余白(負マージン)を取り、タグ帯の背景をカード幅より広く敷く＝スクロール時に
   カードのドロップシャドウがタグ帯の左右へはみ出して見えるのを防ぐ。 */
.products-head { position: sticky; top: 70px; background: var(--bg); z-index: 5; margin: 0 -14px; padding: 12px 14px 10px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.products-head .cat-filter { flex: 1 1 auto; min-width: 0; }
/* 製品一覧モードのみ：左側にキーワード検索フォーム（タグは残す） */
.prod-search { display: none; flex: 0 0 auto; width: 240px; max-width: 46%; font: inherit; font-size: 13px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); }
.prod-search:focus { outline: none; border-color: var(--clane-1); }
#portalView.list-mode .prod-search { display: block; }
/* 運営管理者向け「管理画面」ボタン（CLANE専用） */
.btn.admin { background: var(--ink); color: #fff; }
.btn.admin:hover { opacity: .92; }
@media (max-width: 600px) { .prod-search { width: 100%; max-width: none; } }
/* ヘッダーのホーム／製品一覧 切替 */
.topnav { display: flex; gap: 6px; margin-left: 12px; }
.topnav button { font: inherit; font-size: 13px; font-weight: 600; border: none; background: transparent; color: var(--ink-sub); padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.topnav button:hover { background: var(--bg); }
.topnav button.on { background: #efeaf7; color: var(--clane-1); }
@media (max-width: 600px) { .topnav { margin-left: 4px; gap: 2px; } .topnav button { padding: 6px 10px; font-size: 12.5px; } }
/* 製品一覧モード：チャットを隠し、製品を全幅マルチカラムで一覧表示 */
#portalView.list-mode .chat-col { display: none; }
#portalView.list-mode .portal-2col { display: block; }
#portalView.list-mode .products-col { width: 100%; }
#portalView.list-mode .product-grid { grid-template-columns: repeat(auto-fill, minmax(264px, 1fr)); }
@media (max-width: 860px) {
  .portal-2col { flex-direction: column; }
  .products-col { order: 1; width: 100%; }
  .chat-col { order: 2; flex: none; width: 100%; max-width: none; position: static; height: auto; max-height: 72vh; }
}

/* ログイン/新規登録の切替リンク（freee風） */
.auth-switch { margin: 18px 0 0; font-size: 13px; color: var(--ink-sub); }
.auth-switch a { color: var(--clane-1); font-weight: 700; text-decoration: underline; }

/* 利用規約リンク（新規登録画面） */
.terms-note { margin: 12px 0 0; font-size: 12px; color: var(--ink-sub); }
.terms-note a { color: var(--clane-1); text-decoration: underline; }

/* ── AI利用料ダッシュボード ── */
.ai-usage { background: var(--card,#fff); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-top: 18px; }
.ai-usage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ai-period { font-size: 12px; color: var(--ink-sub); font-weight: 500; letter-spacing: 0; }
.btn.sm { font-size: 12px; padding: 7px 12px; }
.ai-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.ai-stat { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--bg); }
.ai-stat-label { font-size: 11px; color: var(--ink-sub); font-weight: 700; margin-bottom: 6px; }
.ai-stat-val { font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.ai-stat-sub { font-size: 11px; color: var(--ink-sub); margin-top: 6px; }
.ai-gauge { height: 8px; border-radius: 6px; background: #ece8f2; overflow: hidden; margin: 4px 0; }
.ai-gauge-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--clane-1), var(--clane-2)); transition: width .4s; }
.ai-gauge-fill.warn { background: linear-gradient(90deg, #c98a00, #e0a72a); }
.ai-gauge-fill.full { background: linear-gradient(90deg, #b3261e, #d4564e); }
.ai-breakdown { margin-top: 16px; }
.ai-bd-title { font-size: 12px; font-weight: 700; color: var(--ink-sub); margin-bottom: 8px; }
.ai-bd-list { display: flex; flex-direction: column; gap: 6px; }
.ai-bd-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.ai-bd-row .ai-bd-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ai-bd-row .ai-bd-meta { font-size: 11px; color: var(--ink-sub); }
.ai-bd-row .ai-bd-amt { font-weight: 700; min-width: 80px; text-align: right; }
.ai-mode-tag { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.ai-mode-tag.clane { background: #efe9f7; color: var(--clane-1); }
.ai-mode-tag.byok { background: var(--warn-bg); color: var(--warn); }
.ai-note { font-size: 11px; margin: 12px 0 0; }
@media (max-width: 560px) { .ai-summary { grid-template-columns: 1fr; } }
.ai-notice { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 13px; line-height: 1.7; }
.terms-back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--clane-1); font-weight: 600; text-decoration: none; }
.terms-back:hover { text-decoration: underline; }
