/* ── 共通デザイン ──
   色・余白・ボタンはここで定義し、レイアウト側はクラス名だけ付ける。 */
:root {
    --c-primary: #4a90d9;
    --c-primary-dark: #3a7bc0;
    --c-primary-soft: #eef4fb;
    --c-border: #d6dbe3;
    --c-divider: #eceff3;
    --c-text: #222;
    --c-muted: #6b7280;
    --c-success: #1e9e57;
    --c-danger: #c0392b;
    --c-soft-bg: #f6f8fc;
    /* 画面上部に残すヘッダー（タイトル + ログイン）の高さ */
    --header-h: 56px;
}
body {
    margin: 0;
    color: var(--c-text);
    background: #fff;
    font-family: sans-serif;
}

/* ── 共通ヘッダー: タイトル + 右上のログイン + カテゴリ付きタブ ──
   タイトルとログインの行（.site-header-bar）はスクロールしても画面上部に
   残す。タブ（.site-header-wrap）は通常どおりスクロールで流れる */
.site-header-bar {
    position: sticky;
    top: 0;
    z-index: 500;
    background: #fff;
}
/* スクロールしたら下端に影を付ける（対応ブラウザのみ） */
@supports (animation-timeline: scroll()) {
    .site-header-bar {
        animation: header-shadow linear both;
        animation-timeline: scroll();
        animation-range: 0 40px;
    }
}
@keyframes header-shadow {
    to {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
}
.site-header {
    max-width: 1200px;
    min-height: var(--header-h);
    margin: 0 auto;
    padding: 8px 20px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 12px;
}
.site-header-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}
.site-title {
    margin: 0;
    font-size: 1.5rem;
}
/* ログイン / ログイン中の表示（ヘッダー右上） */
.header-account {
    margin-left: auto;
    position: relative;
    flex-shrink: 0;
}
.account-summary {
    padding: 6px 12px;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    font-size: 0.85rem;
    list-style: none;
    cursor: pointer;
    white-space: nowrap;
}
.account-summary::-webkit-details-marker {
    display: none;
}
.account-summary::after {
    content: " ▾";
    color: var(--c-muted);
}
.account-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 600;
    width: 240px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
.account-delete {
    font-size: 0.8rem;
}
.account-delete > summary {
    cursor: pointer;
    color: var(--c-muted);
}

/* ページ切替タブ: カテゴリ（見出し + タブの組）を横に並べる */
.page-tabs {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    border-bottom: 2px solid var(--c-primary);
    /* 狭い画面ではみ出す場合は横スクロール */
    overflow-x: auto;
}
.tab-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}
.tab-group-label {
    padding-left: 4px;
    font-size: 0.7rem;
    color: var(--c-muted);
    white-space: nowrap;
}
.tab-group-tabs {
    display: flex;
    gap: 4px;
}
.page-tab {
    padding: 8px 12px;
    border: 1px solid var(--c-primary);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: var(--c-primary-soft);
    color: var(--c-primary);
    font-size: 0.9rem;
    font-weight: bold;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}
.page-tab-active {
    background: var(--c-primary);
    color: #fff;
}
.page-tab:not(.page-tab-active):hover {
    background: #d4e6f7;
}
@media (max-width: 1200px) {
    .page-tab {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
}

/* 共通フッター */
.site-footer {
    margin-top: 32px;
    padding-top: 12px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: center;
    gap: 6px 20px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: #888;
}

/* ページ本体（各ページ共通の幅・余白） */
.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

/* ページ冒頭の説明（要約1行 + 折りたたみの詳しい説明） */
.page-intro {
    margin-bottom: 16px;
}
.page-intro-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.page-lead {
    margin: 0;
    font-size: 0.9rem;
    color: #444;
}
.page-intro-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.page-details {
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--c-muted);
}
.page-details > summary {
    cursor: pointer;
    color: var(--c-primary);
    width: max-content;
}
.page-details > p {
    margin: 6px 0 0;
    line-height: 1.6;
}

/* パネル（入力・結果のまとまり） */
.panel {
    padding: 12px 14px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: #fff;
    margin-bottom: 16px;
}
.panel-soft {
    background: var(--c-soft-bg);
}
.panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.panel-title {
    font-weight: bold;
    font-size: 1rem;
}
.panel-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.panel-body {
    margin-top: 8px;
}
.hint {
    font-size: 0.8rem;
    color: var(--c-muted);
    margin: 4px 0 0;
    line-height: 1.5;
}
.empty-note {
    color: #888;
    margin: 8px 0;
}
.feedback {
    font-size: 0.85rem;
    margin-top: 6px;
}
.feedback:empty {
    display: none;
}
.link {
    color: var(--c-primary);
    text-decoration: underline;
}

/* 折りたたみパネル（高度な設定など） */
details.panel > summary {
    cursor: pointer;
    font-weight: bold;
}
details.panel[open] > summary {
    margin-bottom: 10px;
}

/* ボタン: その欄で次に押すもの（読み込み・追加・計算）は塗りつぶし
   （btn-primary）、それ以外は枠線。計算は btn-calc で全幅にする */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-sizing: border-box;
    padding: 6px 14px;
    border: 1px solid var(--c-primary);
    border-radius: 6px;
    background: #fff;
    color: var(--c-primary);
    font-family: inherit;
    font-size: 0.85rem;
    line-height: 1.3;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s;
}
.btn:hover {
    background: var(--c-primary-soft);
}
.btn-sm {
    padding: 3px 10px;
    font-size: 0.8rem;
}
.btn-primary {
    background: var(--c-primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--c-primary-dark);
}
.btn-danger {
    border-color: var(--c-danger);
    background: var(--c-danger);
    color: #fff;
}
.btn-danger:hover {
    background: #a93226;
}
.btn-calc {
    width: 100%;
    padding: 12px 24px;
    font-size: 1.05rem;
    font-weight: bold;
}
.btn:disabled {
    opacity: 0.35;
    cursor: default;
    background: #fff;
}
.calc-area {
    margin-bottom: 16px;
}
.icon-btn {
    background: none;
    border: none;
    padding: 0 4px;
    color: #888;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}
.icon-btn:hover {
    color: var(--c-danger);
}
/* 並び替えボタン（▲▼） */
.move-btn {
    padding: 2px 0;
    width: 28px;
    border: 1px solid var(--c-border);
    border-radius: 4px;
    background: #fff;
    color: #555;
    font-size: 0.75rem;
    line-height: 1.2;
    cursor: pointer;
}
.move-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* プリセット / 衣装の追加: 選択欄とボタンを1行に並べる */
.picker-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.picker-row .picker-dropdown {
    flex: 1 1 260px;
    min-width: 0;
    max-width: 420px;
}
.picker-row .picker-radio label {
    margin-right: 10px;
    cursor: pointer;
    font-size: 0.85rem;
}

/* 衣装ごとの入力表（見出し行 + 1衣装1行） */
.costume-table {
    margin-top: 8px;
}
.costume-head,
.costume-row {
    display: grid;
    align-items: center;
    gap: 4px 8px;
    padding: 6px 0;
}
.costume-head {
    padding-top: 0;
    border-bottom: 1px solid var(--c-border);
    font-size: 0.75rem;
    color: var(--c-muted);
}
.costume-row {
    border-bottom: 1px solid var(--c-divider);
}
.costume-row .dash-input-container,
.costume-row input {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}
/* 列が固定幅の表は、見出し・区切り線を列の合計幅までにする（PC 幅のみ。
   スマホ幅では衣装名の列が残りの幅を使うので画面いっぱいのまま） */
@media (min-width: 769px) {
    .costume-table-fit {
        width: fit-content;
        max-width: 100%;
    }
}
/* 行が無い（未読み込み・未追加）ときは見出しを出さない */
.costume-table:not(:has(.costume-row)) .costume-head {
    display: none;
}
.costume-pos {
    font-weight: bold;
    color: #999;
    text-align: right;
}
.costume-name {
    min-width: 0;
}
.span-2 {
    grid-column: span 2;
}
/* 贈り物配分シミュレータ: 優先 / 衣装 / 絆ランク / 残りEXP / 絆ボーナス×7 */
.gs-grid {
    grid-template-columns: 20px 28px 28px minmax(120px, 1.2fr) 64px 76px minmax(0, 3fr);
}
.bonus-cells {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    text-align: center;
    font-size: 0.8rem;
    color: #555;
}
.bonus-label {
    display: none;
}
/* 必要絆経験値: 優先 / 衣装 / 絆ランク / 残りEXP / 目標 / 削除。
   衣装名の列は広げすぎず（入力欄が名前から離れないように）左に詰める。
   行ごとに別のグリッドなので、列幅は全行で同じになる固定の上限にする */
.rb-grid {
    grid-template-columns: 20px 28px 28px minmax(140px, 260px) 64px 76px 64px 28px;
    justify-content: start;
}
/* 絆上げ優先度計算機: 衣装 / 絆ランク / 絆ボーナス×7 */
.co-grid {
    grid-template-columns: minmax(120px, 1.2fr) 80px minmax(0, 3fr);
}
/* 絆ランク管理: 衣装 / 絆ランク / -1 / +1 */
.bm-grid {
    grid-template-columns: minmax(0, 1fr) 76px 40px 40px;
}
.bm-inc-btn {
    width: 100%;
    padding: 4px 0;
}

/* number input のスピナーボタンを非表示 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textbox;
    appearance: textbox;
}

/* Dash 4 の dcc.Input の増減ボタン（−/+）を非表示。
   dcc.Input の style・幅は外側の .dash-input-container に当たる */
.dash-input-stepper {
    display: none !important;
}

/* Dash dcc.Input の増減ボタンを非表示（旧バージョン） */
.dash-input-group .input-group-addon {
    display: none !important;
}
.dash-input-group {
    flex-wrap: nowrap;
}
.dash-input-group input {
    border-radius: 4px !important;
}

/* マニュアルモーダル */
.manual-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}
.manual-modal-content {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    width: 90vw;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.manual-modal-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
}
.manual-modal-content th,
.manual-modal-content td {
    border: 1px solid #ddd;
    padding: 6px 10px;
    text-align: left;
}
.manual-modal-content th {
    background: #f5f5f5;
}

/* ソルバー計算中スピナー */
@keyframes solver-spin {
    to { transform: rotate(360deg); }
}

/* ── dash_daq NumericInput の余白調整 ── */
.numeric-input {
    margin: 0 !important;
}
.numeric-input input {
    font-size: 1rem !important;
}

/* ── 絆上げ優先度計算機: 衣装カード ── */
.student-card {
    padding: 10px 0 12px;
    border-bottom: 1px solid var(--c-divider);
}
.student-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.student-card-header strong {
    white-space: nowrap;
}
.student-card-header .dash-input-container {
    flex: 1;
}
.student-card-header input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    font-size: 0.85rem;
}
.bond-fields {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}
.bond-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.85rem;
    white-space: nowrap;
}
.bond-field .dash-input-container {
    width: 72px;
    max-width: 100%;
}
.bond-field input {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}
.add-row-btn {
    width: 100%;
    margin-top: 10px;
    border-style: dashed;
}
/* 絆ボーナスの手動編集（衣装カード）の折りたたみ */
.manual-edit {
    margin-top: 10px;
    font-size: 0.85rem;
}
.manual-edit > summary {
    cursor: pointer;
    color: var(--c-primary);
    width: max-content;
    max-width: 100%;
}
.manual-edit[open] > summary {
    margin-bottom: 4px;
}
.rank-stepper {
    display: flex;
    align-items: center;
    gap: 1px;
}
.rank-stepper .dash-input-container {
    width: 50px;
}
.rank-stepper input {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}
.rank-stepper-btns {
    display: flex;
    flex-direction: column;
}
.rank-stepper-btns button {
    width: 24px;
    height: 14px;
    padding: 0;
    border: 1px solid #ccc;
    background: #f5f5f5;
    font-size: 0.65rem;
    line-height: 1;
    cursor: pointer;
}
.rank-stepper-btns button:first-child {
    border-radius: 3px 3px 0 0;
}
.rank-stepper-btns button:last-child {
    border-radius: 0 0 3px 3px;
}
.priority-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ── 贈り物逆引きページ ── */
.gl-columns {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.gl-select-col {
    flex: 1;
    min-width: 0;
}
/* 結果カラム: スクロールしても選択部と並んで見えるよう追従させる */
.gl-result-col {
    width: 380px;
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--header-h) + 12px);
    align-self: flex-start;
    max-height: calc(100vh - var(--header-h) - 24px);
    overflow-y: auto;
}
.gl-gift-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 6px;
}
.gl-gift-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 4px;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    text-align: center;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.gl-gift-card:hover {
    border-color: #4a90d9;
}
.gl-gift-card.gl-selected {
    border-color: #4a90d9;
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.35);
}
.gl-high {
    background: #ede7f6;
}
.gl-normal {
    background: #fafafa;
}
/* アイコンに重ねる製造2次ノード名 */
.gl-icon-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    width: 100%;
}
.gl-node-badge {
    position: absolute;
    top: -3px;
    right: -1px;
    font-size: 0.6rem;
    line-height: 1.3;
    font-weight: bold;
    color: #a0304a;
    background: #fdecef;
    border: 1px solid #f3c4cf;
    border-radius: 8px;
    padding: 0 4px;
    white-space: nowrap;
}
.gl-gift-name {
    font-size: 0.7rem;
    line-height: 1.2;
    color: #333;
    word-break: break-word;
}
.gl-tier-counts {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2px;
    font-size: 0.66rem;
    color: #555;
    line-height: 1.3;
}
/* 1つの「特大3人」が途中で折り返さないようにし、区切りの / で改行させる */
.gl-tier-count {
    white-space: nowrap;
}
.gl-tier-sep {
    color: #bbb;
}
.gl-legend {
    border: 1px solid #ccc;
    border-radius: 10px;
    padding: 1px 8px;
}
.gl-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
/* 製造の2次ノード名（花の名前）のバッジ */
.gl-node {
    font-weight: bold;
    background: #fdecef;
    border: 1px solid #f3c4cf;
    border-radius: 10px;
    padding: 1px 10px;
}
.gl-chip {
    font-size: 0.8rem;
    background: #f0f4f8;
    border: 1px solid #dde4ea;
    border-radius: 12px;
    padding: 2px 10px;
    white-space: nowrap;
}

/* ── 2次ノード比較ページ ── */
.nc-weight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 4px 16px;
}
.nc-weight-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.85rem;
}
.nc-weight-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nc-node {
    border-bottom: 1px solid #eee;
}
.nc-node.nc-top > .nc-summary {
    background: #fff8e1;
}
.nc-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    cursor: pointer;
    list-style: none;
}
.nc-summary::-webkit-details-marker {
    display: none;
}
.nc-rank {
    width: 1.6em;
    text-align: right;
    color: #888;
    font-size: 0.85rem;
}
.nc-node-name {
    width: 6.5em;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: center;
}
.nc-category {
    width: 8em;
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.85rem;
    color: #555;
}
.nc-bar {
    flex: 1;
    min-width: 40px;
    height: 10px;
    background: #f0f0f0;
    border-radius: 5px;
    overflow: hidden;
}
.nc-bar-fill {
    display: block;
    height: 100%;
    background: #4a90d9;
}
.nc-ev {
    min-width: 5em;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.nc-gifts {
    padding: 4px 0 8px 2.2em;
}
.nc-gift-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    padding: 2px 0;
}
.nc-gift-name {
    flex: 1;
    min-width: 0;
}
.nc-gift-value {
    width: 5em;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.nc-gift-target {
    width: 12em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.fn-node-name {
    flex: 0 1 15em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fn-star {
    width: 6em;
    font-weight: bold;
}
.fn-gauge {
    color: #555;
}

.nc-craft-panel:not(:empty) {
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin-bottom: 16px;
    background: #fffdf5;
}
.nc-craft-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.nc-craft-total {
    font-size: 1.4rem;
    font-variant-numeric: tabular-nums;
}
.nc-craft-rate {
    width: 7.5em;
    color: #555;
    font-variant-numeric: tabular-nums;
}

/* ── モバイル対応 ── */
@media (max-width: 768px) {
    .nc-category {
        display: none;
    }
    .fn-node-name {
        flex: 1 1 0;
    }
    .nc-gift-target {
        width: auto;
    }
    .nc-gift-row {
        flex-wrap: wrap;
    }
    /* ページ全体のパディングを縮小 */
    .page-container {
        padding: 10px;
    }

    /* 共通ヘッダー */
    :root {
        --header-h: 52px;
    }
    .site-header {
        padding: 6px 10px;
    }
    .site-header-wrap {
        padding: 0 10px;
    }
    .site-title {
        font-size: 1.15rem;
    }

    /* タブバー: はみ出す場合は横スクロール */
    .page-tabs {
        gap: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .page-tab {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    /* ページ冒頭の説明: ボタンは要約の下に */
    .page-intro-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .page-intro-actions {
        margin-left: 0;
    }
    .panel {
        padding: 10px;
    }

    /* 衣装ごとの入力表: 列を詰め、絆ボーナスは次の行に回す */
    /* 順位の番号は ▲▼ の並びで分かるので省き、衣装名の幅を確保する */
    .costume-pos {
        display: none;
    }
    .gs-grid {
        grid-template-columns: 28px 28px minmax(0, 1fr) 48px 60px;
    }
    .costume-head .bonus-cells {
        display: none;
    }
    .costume-row .bonus-cells {
        grid-column: 1 / -1;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        text-align: left;
        font-size: 0.75rem;
    }
    .bonus-label {
        display: inline;
        color: #999;
        margin-right: 4px;
    }
    .rb-grid {
        grid-template-columns: 28px 28px minmax(0, 1fr) 40px 52px 40px 22px;
        gap: 4px;
    }
    .bm-grid {
        grid-template-columns: minmax(0, 1fr) 64px 40px 40px;
    }
    .co-grid {
        grid-template-columns: minmax(0, 1fr) 80px;
    }

    /* 衣装カード */
    .student-card-header input[type="text"] {
        font-size: 0.9rem;
    }

    /* 衣装カード内の絆入力: 4列固定 → 4+3 の2行 */
    .bond-fields {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
    }
    .bond-fields > div {
        min-width: 0 !important;
    }
    .bond-fields input {
        font-size: 0.95rem !important;
        padding: 6px 4px !important;
    }


    /* 全ボタン: タッチしやすい最小高さ */
    .btn:not(.btn-sm),
    .dash-dropdown .Select-control {
        min-height: 44px;
    }
    .btn-sm,
    .move-btn {
        min-height: 32px;
    }


    /* 計算ボタン: 画面下部に固定 */
    .calc-btn-wrapper {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        padding: 10px !important;
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1) !important;
        z-index: 100 !important;
    }
    .calc-btn-wrapper button {
        border-radius: 8px !important;
    }

    /* 結果エリア: 固定ボタン分の余白 */
    .chart-result-area {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 72px !important;
    }

    /* 結果テーブルの可読性向上 */
    .chart-result-area table {
        font-size: 0.85rem !important;
    }
    .chart-result-area th,
    .chart-result-area td {
        padding: 6px 8px !important;
        white-space: nowrap;
    }

    /* プリセット / 衣装の追加: 選択欄を1行、ボタンは次の行 */
    .picker-row .picker-dropdown {
        flex-basis: 100%;
        max-width: none;
    }

    /* モーダル */
    .manual-modal-content {
        width: 95vw !important;
        max-height: 90vh !important;
        padding: 16px !important;
        border-radius: 8px !important;
    }

    /* 贈り物逆引き: 2カラム → 縦積み、カードを詰める */
    .gl-columns {
        flex-direction: column !important;
        gap: 12px !important;
    }
    .gl-select-col,
    .gl-result-col {
        width: 100% !important;
        position: static !important;
        max-height: none !important;
        overflow-y: visible !important;
    }
    .gl-gift-grid {
        grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)) !important;
    }
    .gl-gift-card {
        min-height: 0 !important;
    }

    /* 削除ボタン: タップしやすく */
    .remove-student-btn {
        width: 32px;
        height: 32px;
    }
}

/* ── 小さいスマホ対応 (360px以下) ── */
@media (max-width: 360px) {
    .bond-fields {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* 絆ランク管理: 絞り込みで非表示にした行（インラインの display:flex より優先） */
.bm-hidden {
    display: none !important;
}

/* 絆ランク管理: サーバーへの保存失敗の通知（画面下に固定。空なら出さない） */
.account-sync-error {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 32px);
    box-sizing: border-box;
    padding: 8px 14px;
    background: #fff5f5;
    border: 1px solid #e0a0a0;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    color: #c00;
    font-size: 0.85rem;
    z-index: 1000;
}
.account-sync-error:empty {
    display: none;
}

/* 絆ランク管理: ログイン失敗などの通知 */
.auth-error {
    margin: 0 0 16px;
    padding: 8px 12px;
    border: 1px solid #e0a0a0;
    border-radius: 6px;
    background: #fff5f5;
    color: #c00;
    font-size: 0.85rem;
}

/* 絆ランク管理: 一覧は幅に応じて複数列に分け、左から右へ並べる（グリッド）。
   列ごとの見出しも同じ列数・幅のグリッド（auto-fill）に並べ、2行目に回った
   余りの見出しは高さ 0 の行に入れて隠す */
.bm-rows,
.bm-heads {
    --bm-col-w: 290px;
    --bm-col-gap: 32px;
}
.bm-rows {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--bm-col-w), 1fr));
    column-gap: var(--bm-col-gap);
}
/* 案内文（読み込み中など）は1列目から全幅で出す */
.bm-rows > .empty-note {
    grid-column: 1 / -1;
}
/* 読み取り結果の確認表（1行が長いので列を広く） */
.bm-rows.bm-ocr-rows {
    --bm-col-w: 400px;
}
.bm-heads {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--bm-col-w), 1fr));
    grid-template-rows: auto;
    grid-auto-rows: 0;
    column-gap: var(--bm-col-gap);
    overflow: hidden;
}
/* 読み取り: 画像の選択ボタンは見出しの右。撮り方・サンプル画像は折りたたみ */
.bm-ocr-upload {
    display: inline-block;
}
.bm-ocr-help {
    font-size: 0.8rem;
}
.bm-ocr-help > summary {
    cursor: pointer;
    color: var(--c-primary);
    width: max-content;
}
.bm-ocr-example {
    display: block;
    max-width: min(100%, 480px);
    margin-top: 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
/* 要確認の衣装の行に並べる、読み取ったカードの切り抜き（bond_ocr.js の crops） */
.bm-ocr-crops {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.bm-ocr-crops:empty {
    display: none;
}
.bm-ocr-crop {
    height: 140px;
    border-radius: 4px;
}

/* お気に入り（☆）ボタン */
.fav-btn {
    font-size: 1.1rem;
    padding: 2px 10px;
}

/* 絆ランク統計ページ */
.bs-stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}
.bs-stat {
    border: 1px solid var(--c-border);
    border-radius: 6px;
    background: var(--c-soft-bg);
    padding: 8px 10px;
}
.bs-stat-label,
.bs-stat-sub {
    color: var(--c-muted);
    font-size: 0.75rem;
}
.bs-stat-value {
    font-size: 1.25rem;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}
.bs-bin {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
}
.bs-bin-label {
    color: var(--c-muted);
}
.bs-hist-graph {
    max-width: 760px;
}
.bs-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 4px 16px;
}
.bs-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 0;
    border-bottom: 1px solid var(--c-divider);
    font-size: 0.85rem;
}
.bs-item-name {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.bs-item-value {
    flex: none;
    font-variant-numeric: tabular-nums;
}
