/* === ヘッダーのボタン・入力欄 === */

header>div {
    position: absolute;
    right: 4.5vh;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 1em;
    z-index: 5;
}

header .edit-btn {
    height: 4.5vh;
}

.edit-btn {
    padding: 1vh 2vh;
    background: #466398;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.pass-input {
    width: calc(100% - 2em);
    margin: 1em;
    padding: 0.8em;
    background-color: #050949;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1em;
    outline: none;
}

.pass-input::placeholder {
    color: #E0E0E0;
}

/* === モーダル (ポップアップ) === */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #322E7B;
    border: 2px solid white;
    padding: 2em;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
}

.modal-content h3 {
    color: white;
    margin-top: 0;
}

/* === プロフィール画像・基本ステータス === */

.profile-image-wrapper img {
    border: none;
}

/* 縦画面のとき（スマホなど：横幅を基準にする） */
@media screen and (orientation: portrait) {
    header .title {
        display: none !important;
    }

    .profile-image-wrapper img {
        width: 50vw;
        height: auto;
    }
}

/* 横画面のとき（PCなど：高さを基準にする） */
@media screen and (orientation: landscape) {
    .profile-image-wrapper img {
        height: 50vh;
        width: auto;
    }
}

.editable-title {
    color: white;
    font-size: 2em;
    margin: 0.5em 0;
    transition: background 0.3s;

    /* ▼ 追加：長すぎる名前を枠内で自動的に折り返す */
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    max-width: 100%;
}

.param-row {
    display: flex;
    gap: 8px;
    /* スマホ向けに少しだけ隙間を詰める */
    margin-bottom: 10px;
    align-items: center;
    flex-wrap: wrap;
    /* ▼ 追加：画面が狭い時は折り返して表示する */
}

/* ▼ 追加：スマホで入力欄が押し出されないようにサイズと余白を再調整 */
.param-row .pass-input {
    margin: 0;
    min-width: 0;
    /* これを追加することで画面に合わせて縮小できるようになります */
    padding: 0.6em;
}

.param-input-label {
    flex: 1;
    min-width: 80px;
    /* 項目名の最低限の幅 */
}

.param-input-value {
    width: 3.5em !important;
    /* スマホでも収まるように文字数基準（約3.5文字分）で固定 */
}

/* ▼ 追加：折り返した際に「削除」ボタンが綺麗に右端に寄るようにする */
.param-row .setting-btn {
    margin-left: auto;
}

.add-resource-btn {
    width: 100%;
    padding: 12px;
    background-color: #466398;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
    margin-top: 10px;
}

/* === アコーディオン・メモ枠組み === */

.chara-box-wrapper {
    color: white;
    line-height: 2;
    margin: 3em auto;
    max-width: 80vw;
    font-family: ShinMaruGo;
}

.chara-box {
    background: #322E7B;
    border: 1px solid white;
    /* 2pxから1pxに細くスタイリッシュに */
    border-bottom-right-radius: 1.5em;
    corner-bottom-right-shape: bevel;
    padding: 0;
    /* 枠の端まで横線を伸ばすために0に */
    margin-bottom: 2em;
    overflow-x: auto;
}

.chara-box-wrapper summary {
    cursor: pointer;
    list-style: none;
    display: block;
    /* 全幅をクリック可能に */
}

.chara-box-wrapper summary::-webkit-details-marker {
    display: none;
}

.sheet-header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    padding: 0.75em 1.5em;
    /* ここにヘッダー用の余白を設定 */
    background-color: #322E7B;
}

.sheet-title-text {
    flex: 1;
}

.setting-btn {
    padding: 0.5em;
    background: #466398;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1em;
    cursor: pointer;
}

/* アコーディオンが開いている時、タイトル下に直線を引く */
details[open]>summary {
    border-bottom: 1px solid white;
}

/* === メモの中身（親テキストと子メモ） === */

.sheet-content-container {
    padding: 0.75em;
    /* 大枠の線と、中身の要素との間の余白 */
    background-color: #050949;
}

.sheet-text {
    background-color: transparent;
    color: white;
    margin: 0;
    padding: 0;
    transition: all 0.3s ease;
}

/* テキストボックス（ベータです。など） */
.text-content {
    min-height: 1.5em;
    white-space: pre-wrap;
    margin-bottom: 0;
    border: 1px solid white;
    padding: 0.75em;

    /* ▼ 追加：右下の角を外枠と同じ形にカットして重なりを防ぐ */
    border-bottom-right-radius: 1.5em;
    corner-bottom-right-shape: bevel;
}

/* 子メモのグループ枠 */
.nested-field {
    background-color: transparent;
    border: 1px solid white;
    border-bottom-right-radius: 1.5em;
    /* 角ばったデザインを維持 */
    corner-bottom-right-shape: bevel;
    padding: 0;
    margin-top: 0.75em;
    /* テキストボックスとの隙間 */
    overflow: hidden;
    /* ← ★この1行を追加！（内側の背景が枠線からはみ出ないようにする） */
}

.nested-field.empty-nested {
    border: none;
    padding: 0;
    margin-top: 0;
}

/* 子メモ単体の区切り線（リストのように表示） */
.nested-field>details {
    border-bottom: 1px solid white;
}

.nested-field>details:last-of-type {
    border-bottom: none;
    /* 最後の子メモの下には線を引かない */
}

/* 子メモ追加ボタンの余白 */
.nested-field>.edit-btn {
    margin: 0.75em;
    width: calc(100% - 30px);
    /* 横幅を揃える */
}

/* === 編集モード専用のUIとハイライト設定 === */

.edit-only-ui {
    display: none;
}

main.edit-mode .edit-only-ui {
    display: block;
}

/* キャラクター名の編集ハイライト */
main.edit-mode .editable-title[contenteditable="true"] {
    outline: 2px dashed #44AEF3;
    background-color: rgba(255, 255, 255, 0.1);
    cursor: text;
    padding: 0 10px;
    display: inline-block;
}

main.edit-mode .editable-title[contenteditable="true"]:focus {
    outline: 2px solid #44AEF3;
    background-color: rgba(255, 255, 255, 0.2);
}

/* メモテキストの編集ハイライト（重複箇所を解消） */
main.edit-mode .text-content[contenteditable="true"] {
    outline: 2px dashed #44AEF3;
    background-color: transparent;
    cursor: text;
    padding: 0.5em;
    border: none;
}

main.edit-mode .text-content[contenteditable="true"]:focus {
    outline: 2px solid #44AEF3;
    background-color: transparent;
}

/* === キャラクター一覧（ダッシュボード） === */

.chara-list-card {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #466398;
    border-radius: 8px;
    padding: 15px;
    color: white;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.chara-list-card:hover {
    background: rgba(68, 174, 243, 0.2);
    border-color: #44AEF3;
}

.chara-list-card img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 50%;
    margin-right: 15px;
    border: 2px solid white;
}

.chara-list-card .chara-info {
    flex: 1;
    overflow: hidden;
}

.chara-list-card .chara-info h4 {
    margin: 0 0 5px 0;
    font-size: 1.3em;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chara-list-card .chara-info p {
    margin: 0;
    font-size: 0.9em;
    color: #E0E0E0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === 編集モード専用のUIとハイライト設定 === */
.edit-only-ui {
    display: none;
}

main.edit-mode .edit-only-ui {
    display: block;
}

/* ▼ ★ここから3行を追加 ★ ▼ */
main.edit-mode .view-only-ui {
    display: none !important;
    /* 編集モードの時は閲覧用のテキストを強制的に消す */
}

/* ▲ ★ここまで追加 ★ ▲ */

/* --- 一覧画面：キャラクター削除ボタン --- */
.chara-delete-btn {
    background-color: #e74c3c;
    color: white;
    border: 2px solid transparent;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 0.9em;
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.2s;
    font-family: inherit;
}

.chara-delete-btn:hover {
    background-color: transparent;
    color: #e74c3c;
    border: 2px solid #e74c3c;
}