/* === characters.html 专属样式（base/nav/shared 已在对应 css/ 文件中）=== */

/* ----- layout ----- */
#layout { display: flex; flex: 1; overflow: hidden; }
#sidebar { width: 340px; min-width: 220px; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
#filters { padding: 7px 8px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
#filters input[type=text] { width: 100%; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg3); color: var(--text); font-size: 13px; outline: none; }
#filters input[type=text]:focus { border-color: var(--accent); }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-row select { flex: 1; min-width: 0; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg3); color: var(--text); font-size: 12px; outline: none; cursor: pointer; }
.filter-row2 { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.filter-toggles.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); }
.filter-toggles.grid-6 { display: grid; grid-template-columns: repeat(6, max-content); gap: 3px; }
#sort-dir { flex-shrink: 0; padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg3); color: var(--text); font-size: 13px; cursor: pointer; }
#sort-dir:hover { border-color: var(--accent); color: var(--accent); }
#char-count { font-size: 11px; color: var(--text2); text-align: right; padding: 2px 2px 0; }
.search-row { display: flex; align-items: center; gap: 8px; }
.search-row input { flex: 1; min-width: 0; }
#char-count-mob { display: none; font-size: 11px; color: var(--text2); white-space: nowrap; }
.actions-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.actions-row select { flex: 1; min-width: 80px; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg3); color: var(--text); font-size: 12px; outline: none; cursor: pointer; }
.btn-reset-filters { font-size: 11px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg3); color: var(--text2); cursor: pointer; flex-shrink: 0; }
.btn-reset-filters:hover { color: var(--text); }
.filter-toggle-btn { display: none; flex-shrink: 0; }  /* base style in shared.css */
#filters-body { display: flex; flex-direction: column; gap: 8px; }
#char-list { flex: 1; overflow-y: auto; }
#char-list::-webkit-scrollbar { width: 4px; }
#char-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ----- mobile nav bar ----- */
#detail-mob-bar { display: none; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; z-index: 10; background: var(--bg2); border-bottom: 1px solid var(--border); padding: 8px 12px; box-shadow: 0 -100vh 0 0 var(--bg2), 0 2px 8px rgba(0,0,0,.4); }
.mob-bar-mask { display: none; }
#detail-mob-bar button { background: var(--bg3); border: 1px solid var(--border); color: var(--text); font-size: 14px; padding: 6px 14px; border-radius: 6px; cursor: pointer; min-width: 56px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#detail-mob-bar button:hover { border-color: var(--accent); }
#detail-mob-bar button:disabled { opacity: 0.3; cursor: default; }
#detail-mob-bar .nav-label { font-size: 12px; color: var(--text2); flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; -webkit-user-select: none; }

/* ----- char list items ----- */
.char-item { padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; gap: 8px; transition: background .1s; }
.char-item:hover { background: var(--bg3); }
.char-item.active { background: #1e2d5a; border-left: 3px solid var(--accent); }
.char-item .badges { display: flex; gap: 4px; flex-shrink: 0; }
/* 全 badge (rarity / element / weapon) は inline-flex で文字中央寄せ — 高さ統一・字が上寄りにならない */
.char-item .badges .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
/* rarity 専用：A / AA / S / SS の幅を 26px に固定（base padding:1px 5px を水平 0 に上書き） */
.char-item .badges .badge.A,
.char-item .badges .badge.AA,
.char-item .badges .badge.S,
.char-item .badges .badge.SS {
  width: 24px;
  padding-left: 0;
  padding-right: 0;
}
.chara-check-cb { flex-shrink: 0; width: 14px; height: 14px; margin: 0; cursor: pointer; accent-color: var(--accent); }
/* .badge.SS / .S / .AA / .A の着色は shared.css 側 — characters / hensei 共通 */
.elem-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.char-item .char-name { flex: 1; font-size: 12px; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.char-item .sort-val { font-size: 11px; font-weight: 700; color: var(--accent); white-space: nowrap; flex-shrink: 0; padding: 1px 6px; border-radius: 4px; background: rgba(91,127,255,.12); border: 1px solid rgba(91,127,255,.3); }
.state-dots { display: flex; gap: 2px; flex-shrink: 0; }
.state-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.state-dot.has { background: var(--accent); }

/* ----- detail panel ----- */
#detail { flex: 1; overflow-y: auto; padding: 0 24px 20px; }
#detail::-webkit-scrollbar { width: 5px; }
#detail::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
#placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text2); gap: 8px; }
#placeholder svg { opacity: .3; }
#chara-detail { /* padding inherited from #detail */ }

/* ----- chara header -----
   flex column 3 行布局（HTML 用 .ch-row 包裹每行）：
   显示モード:
     行 1: chara-title 左 | chara-actions 右
     行 2: chara-meta  左 | btn-edit  右
     行 3: chara-tags 满行
   编辑モード:
     行 1: chara-title 左 | edit-actions 右
     行 2: chara-edit-meta 满行
     行 3: chara-tag-row 满行 */
.chara-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px; padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: var(--sticky-bar-h, 0px); z-index: 6; background: var(--bg);
}
.ch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.chara-header .chara-title   { flex: 1; min-width: 0; }
.chara-header .chara-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.chara-header .chara-meta    { flex: 1; min-width: 0; }
.chara-header .chara-tags    { display: flex; gap: 4px; flex-wrap: wrap; }
.chara-title { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.chara-title > span.name-text { min-width: 0; word-break: break-all; }
.chara-icon { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.chara-header.edit-mode-active .chara-edit-meta { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.chara-header.edit-mode-active .edit-actions   { display: flex; gap: 6px; flex-shrink: 0; }
.chara-header.edit-mode-active .chara-tag-row  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.btn-latent, .chara-header .btn-edit { padding: 5px 12px; border-radius: 6px; border: 1px solid #5b7fff; background: rgba(91,127,255,.15); color: #7b9fff; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; flex-shrink: 0; width: 80px; text-align: center; }
.btn-latent:hover, .chara-header .btn-edit:hover { background: rgba(91,127,255,.3); }
.chara-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meta-chip { display: flex; align-items: center; gap: 4px; background: var(--bg3); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: 12px; }
.meta-chip .elem-dot { width: 8px; height: 8px; }

/* ----- state tabs ----- */
.state-tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--border); position: sticky; top: calc(var(--sticky-bar-h, 0px) + var(--sticky-header-h, 100px)); z-index: 4; background: var(--bg); }
.state-tab { padding: 8px 20px; font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; color: var(--text2); transition: color .15s; }
.state-tab:hover { color: var(--text); }
.state-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.state-content { display: none; }
.state-content.active { display: block; }

/* ----- stats ----- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.stat-card { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.stat-label { font-size: 11px; color: var(--text2); margin-bottom: 4px; }
.stat-value { font-size: 16px; font-weight: 700; }
.stat-sub   { font-size: 11px; color: var(--text2); margin-top: 2px; }
.stat-row   { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; }
.stat-row-label { font-size: 11px; color: var(--text2); }
.stat-row-value { font-size: 14px; font-weight: 700; }
.stat-row-value.init { color: var(--text2); font-size: 13px; font-weight: 600; }

/* ----- info table ----- */
.info-table { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border-radius: 8px; overflow: hidden; }
.info-cell { background: var(--bg3); padding: 7px 12px; }
.info-cell.label { color: var(--text2); font-size: 12px; }
.info-cell.value { font-weight: 600; font-size: 13px; }
.hit-phases { display: flex; gap: 4px; align-items: center; }
.hit-phase { background: var(--bg2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 12px; }
.hit-arrow { color: var(--text2); font-size: 10px; }

/* ----- skills list ----- */
.skills-list { display: flex; flex-direction: column; gap: 6px; }

/* ----- BD card ----- */
.bd-card { background: #1a1040; border: 1px solid #4433aa; border-radius: 8px; padding: 12px 14px; }
.bd-label { font-size: 10px; font-weight: 700; color: #aa88ff; letter-spacing: .1em; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.bd-cost-tag { font-size: 10px; color: #aa88ff; font-weight: 600; }
.bd-top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.bd-name   { font-weight: 700; font-size: 14px; color: #cc99ff; }
.bd-effect { font-size: 13px; line-height: 1.6; }
.bd-tags   { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; flex-shrink: 0; }
/* .bd-sp-tag + .bd-sp-{id} + .bd-dur-tag + .bd-hit-tag は shared.css 側で定義 — 全 viewer 共通 */

/* ----- profile ----- */
.profile-toggle { cursor: pointer; color: var(--text2); font-size: 12px; display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.profile-toggle:hover { color: var(--text); }
.profile-table { display: grid; grid-template-columns: max-content 1fr; gap: 1px; background: var(--border); border-radius: 8px; overflow: hidden; }
.profile-key { background: var(--bg3); padding: 6px 12px; color: var(--text2); font-size: 12px; white-space: nowrap; }
.profile-val { background: var(--bg3); padding: 6px 12px; font-size: 12px; line-height: 1.5; }

/* ----- latent modal ----- */
#latent-modal { display: none; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; }
#prompt-modal  { display: none; position: fixed; inset: 0; z-index: 2000; align-items: center; justify-content: center; }
.prompt-panel  { position: relative; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; width: min(360px, 92vw); z-index: 1; padding: 20px 20px 16px; display: flex; flex-direction: column; gap: 12px; }
.prompt-title   { font-size: 14px; font-weight: 700; }
.prompt-actions { display: flex; gap: 8px; justify-content: flex-end; }
.latent-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.6); touch-action: none; }
.latent-panel   { position: relative; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; width: min(520px, 92vw); max-height: 80vh; display: flex; flex-direction: column; z-index: 1; }
@media (min-width: 769px) { #masou-modal .latent-panel { width: 672px; } }
.masou-card { display: flex; gap: 12px; align-items: stretch; }
.masou-img  { width: 80px; height: auto; align-self: flex-start; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: var(--bg2); }
.masou-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.latent-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.latent-panel-header span { font-size: 15px; font-weight: 700; }
.latent-close { background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.latent-close:hover { color: var(--text); background: var(--bg3); }
.latent-body { overflow-y: auto; padding: 12px 18px 16px; flex: 1; }
.latent-body::-webkit-scrollbar { width: 4px; }
.latent-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.omoide-row   { margin-bottom: 16px; }
.omoide-label { font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.omoide-slots { display: flex; flex-direction: column; gap: 4px; }
.latent-slot  { display: grid; grid-template-columns: 1fr 1fr minmax(4.5em, auto); align-items: baseline; gap: 6px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 12px; }
.latent-slot-koka    { font-weight: 600; color: var(--text); }
.latent-slot-syosai  { color: var(--text2); }
.latent-slot-bairitu { font-size: 11px; color: var(--accent); white-space: pre-line; text-align: right; }
.latent-slot-bairitu.empty { color: var(--border); }

/* ----- edit mode (characters-specific overrides on top of shared.css) ----- */
.edit-mode-active { background: var(--bg2); border: 1px solid rgba(91,127,255,.3); border-bottom: 2px solid rgba(91,127,255,.4); border-radius: 10px 10px 0 0; padding: 14px; }
.edit-actions { align-items: flex-start; }
.btn-save   { padding: 7px 16px; }
.btn-cancel { padding: 7px 16px; }
.btn-cancel:hover { border-color: var(--text2); }
.edit-input.title  { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.edit-stat-num { width: 80px; background: var(--bg); border: 1px solid var(--accent); border-radius: 4px; color: var(--text); padding: 2px 6px; font-size: 14px; font-weight: 700; text-align: right; flex-shrink: 0; }
.edit-stat-num:focus { outline: none; border-color: #8aabff; }
.edit-stat-num.init { color: var(--text2); font-size: 13px; font-weight: 600; }
.edit-readonly { font-size: 13px; color: var(--text2); padding: 4px 2px; line-height: 1.6; }
.hit-inputs { display: flex; gap: 4px; align-items: center; }
.hit-num { width: 52px; background: var(--bg); border: 1px solid var(--accent); border-radius: 4px; color: var(--text); padding: 2px 6px; font-size: 13px; text-align: center; }
.hit-num:focus { outline: none; border-color: #8aabff; }
/* .btn-skill-tomb base style in shared.css */
.skill-edit-card.deleted .skill-name { text-decoration: line-through; color: var(--text2); }

/* ----- latent edit ----- */
.latent-edit-container { padding: 4px 2px; }
.latent-edit-row   { margin-bottom: 8px; }
.latent-edit-label { font-size: 11px; font-weight: 700; color: var(--text2); margin-bottom: 3px; }
.latent-edit-slots { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.latent-edit-chip  { display: inline-flex; align-items: center; background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 1px 2px 1px 6px; }
.lcs-trigger { background: var(--bg3); border: 1px solid var(--border); border-radius: 3px; color: var(--text); font-size: 11px; padding: 2px 8px; cursor: pointer; max-width: 180px; min-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.lcs-trigger:hover { border-color: var(--accent); }
.lcs-dropdown { position: fixed; background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; z-index: 3000; width: 240px; box-shadow: 0 4px 16px rgba(0,0,0,.6); display: none; }
.lcs-search { width: 100%; background: var(--bg3); border: none; border-bottom: 1px solid var(--border); color: var(--text); font-size: 12px; padding: 6px 10px; outline: none; border-radius: 6px 6px 0 0; box-sizing: border-box; }
.lcs-list { max-height: 200px; overflow-y: auto; }
.lcs-list::-webkit-scrollbar { width: 4px; }
.lcs-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.lcs-opt { padding: 5px 10px; cursor: pointer; font-size: 11px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcs-opt:hover { background: var(--bg3); }
.lcs-opt.lcs-selected { color: var(--accent); font-weight: 600; }

/* ----- mobile ----- */
@media (max-width: 900px) {
  body { height: auto; overflow-y: auto; }
  #page-wrap { overflow: visible; }
  #layout { flex-direction: column; overflow: visible; flex: none; }
  #sidebar { width: 100%; height: auto; min-width: unset; border-right: none; border-bottom: 1px solid var(--border); overflow: visible; }
  #char-list { height: auto; flex: none; overflow: visible; }
  #detail { display: none; position: fixed; inset: 0; z-index: 200; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; padding: 0; }
  button, [onclick], .ftog, .char-item { touch-action: manipulation; }
  #chara-detail { padding: 0 16px 14px; }
  #detail.show-mob { display: block; }
  #placeholder { display: none; }
  #detail-mob-bar { display: flex; }
  .chara-header { margin-bottom: 0; padding-top: 12px; box-shadow: 0 -100vh 0 0 var(--bg); }
  .state-tabs { margin-top: 0; }
  .filter-toggle-btn { display: block; }
  #filters-body { display: none; }
  #char-count-mob { display: block; }
  #char-count { display: none; }
  #filters { position: sticky; top: 52px; z-index: 50; background: var(--bg2); }
  .btn-latent, .chara-header .btn-edit { width: 70px; padding: 5px 10px; }
  /* chara-header 不再重排 — flex 3 行布局桌面 / mobile 统一 */
}

/* 横屏 + 矮屏：chara-header 单行化 — 左 title + meta + tags，右 actions + edit。
   display: contents 让 .ch-row 退化（其子节点直接作为 .chara-header flex 子），
   配合 order 重排 + margin-left:auto 把 actions 推到右侧。 */
@media (orientation: landscape) and (max-height: 600px) {
  .chara-header { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
  .chara-header > .ch-row { display: contents; }
  .chara-header .chara-title                            { order: 1; }
  .chara-header .chara-meta,
  .chara-header .chara-edit-meta                        { order: 2; }
  .chara-header .chara-tags,
  .chara-header .chara-tag-row                          { order: 3; }
  .chara-header .chara-actions,
  .chara-header .edit-actions                           { order: 4; margin-left: auto; }
  .chara-header .btn-edit                               { order: 5; }
}

