/* Base styles */
:root {
    --primary-color: #6200ee;
    --primary-rgb: 98, 0, 238;
    --secondary-color: #03dac6;
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --error-color: #cf6679;
    --warning-color: #efb233;
    --warning-rgb: 239, 178, 51;
    --text-primary: rgba(255, 255, 255, 0.87);
    --text-secondary: rgba(255, 255, 255, 0.6);
    --border-color: rgba(255, 255, 255, 0.2);
    --disabled-color: #757575;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 120px;
    /* Footer height */
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin-bottom: 0.5rem;
    font-weight: 700;
}

/* Header */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.site-name {
    font-size: 1.5rem;
    margin: 0;
}

/* Main content */
#main {
    padding: 1rem;
    margin-top: 70px;
    /* Adjusted by JS */
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Ensure main content flows vertically */
}

.page-title {
    text-align: left;
    margin-bottom: 1.5rem;
}

/* Authentication */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--background-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
    padding: 1rem;
    padding-bottom: 100px;
    /* Space for fixed footer */
}

.auth-box {
    background-color: var(--surface-color);
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.auth-box h2 {
    margin-bottom: 1.5rem;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Inputs and buttons */
input,
button,
select {
    /* Added select here */
    font-family: inherit;
    font-size: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(98, 0, 238, 0.3);
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 700;
}

button:hover {
    background-color: #7a36ff;
}

button:active {
    transform: translateY(1px);
}

/* Element Selectors */
#element-selectors {
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping on smaller screens */
    gap: 1rem;
    margin-bottom: 1rem;
    flex-direction: row;
    /* Default to vertical stacking */
}

.element-selector {
    flex: 1;
    /* Make selectors take full width in column layout */
    min-width: 200px;
    /* Minimum width for selectors */
    display: flex;
    flex-direction: column;
}

.selector-label {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

select {
    width: 100%;
    padding: 12px 16px;
    height: 48px;
    line-height: 24px;
    border-radius: 4px;
    border: 1px solid #ccc;
    color: white;
    background-color: rgb(82, 82, 82);
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

select:hover {
    border-color: #888;
}

select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, .25);
}


#display-selectors {
    margin-bottom: 1rem;
    width: auto;
    /* Adjust width to content */
    align-self: flex-start;
    /* Align to the start of the flex container */
}


/* Story List */
#story-list {
    display: flex;
    flex-direction: column;
    /* Stack story items vertically */
    /* gap: 1rem; */
}

.story-item {
    background-color: var(--surface-color);
    border-radius: 8px;
    padding: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.story-item:last-child {
    margin-bottom: 0;
}

.story-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 0.5rem;
}

.story-info {
    /* New class to wrap file name and text */
    flex-grow: 1;
    /* Allows this section to take available space */
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Prevents overflow issues with long text */
}

.story-file-name {
    font-size: 0.8rem;
    /* Adjusted font size */
    color: var(--text-secondary);
    background-color: rgba(0, 0, 0, 0.3);
    /* Slightly less opaque */
    padding: 0.2rem 0.4rem;
    /* Adjusted padding */
    border-radius: 4px;
    /* Consistent border radius */
    margin-bottom: 0.5rem;
    /* Space below file name */
    align-self: flex-start;
    /* Align to the start of the story-info container */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    flex-shrink: 1;
    /* 必要に応じて縮むように */
    min-width: 50px;
    /* あまりにも縮みすぎないように */
}

/* データ不足インジケーターのスタイル */
.data-missing-indicator {
    display: flex;
    align-items: center;
    background-color: #1e3a8a;
    /* 蒼系の背景 (例: Tailwind blue-800) */
    color: #bfdbfe;
    /* 青系のアイコン・テキスト (例: Tailwind blue-200) */
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    /* 少し丸みを持たせる */
    font-size: 0.75rem;
    /* flex-grow: 1; /* 中央に配置したい場合は調整 */
    margin-left: auto;
    /* ファイル名の右、メニューボタンの左に配置 */
    margin-right: 0.5rem;
    /* メニューボタンとの間隔 */
    white-space: nowrap;
    /* テキストが折り返さないように */
    order: 1;
    /* 必要であれば表示順を調整 */
}

.data-missing-icon {
    font-size: 16px;
    /* アイコンサイズ調整 */
    margin-right: 0.3rem;
    cursor: help
}

.story-item-menu-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    /* 縮まないように */
    order: 2;
    /* 必要であれば表示順を調整 */
}

.story-item-menu-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.story-item-menu-btn .material-icons {
    font-size: 20px;
}

.story-item-content {
    display: flex;
    align-items: center;
    /* アイコン、セリフ、コントロールを垂直中央揃え */
    gap: 0.5rem;
    /* アイコン、セリフ、コントロール間の隙間 */
    width: 100%;
}

.story-character-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    /* デフォルトアイコンの背景 */
    color: var(--text-primary);
    flex-shrink: 0;
    /* 縮まないように */
}

.dialogue-character-icon-img {
    /* キャラクター画像用の新しいクラス */
    width: 100%;
    /* 親要素(.story-character-icon)のサイズに合わせる */
    height: 100%;
    /* 親要素(.story-character-icon)のサイズに合わせる */
    border-radius: 50%;
    /* 親要素と同じ形状 */
    object-fit: cover;
    /* 画像が指定サイズに収まるように調整 */
    /* border: 1px solid #ddd; */
    /* 任意: アイコンに枠線をつける場合 */
}

.story-character-icon .material-icons {
    font-size: 24px;
    /* 修正: デフォルトアイコンのサイズを調整 (親要素のサイズに合わせる) */
    /* color: #757575; */
    /* デフォルトアイコンの色は既存の var(--text-primary) を使用 */
}

.story-dialogue {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    /* 利用可能な最大の幅を取る */
    min-width: 0;
    /* テキストがはみ出ないように */
    gap: 0.25rem;
    /* キャラクター名とセリフの間の隙間 */
}

.story-character-name {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-primary);
    background-color: var(--primary-color);
    /* 丸形背景の色 */
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    /* 丸みを帯びた形 */
    align-self: flex-start;
    /* 左寄せ */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.story-text {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-secondary);
    word-break: break-word;
}

.undefined-text {
    color: #9e9e9e;
    /* 未定義テキストの色 (例: グレー) */
    font-style: italic;
}

.story-controls {
    /* New class for buttons */
    display: flex;
    flex-direction: column;
    /* Stack buttons vertically */
    gap: 0.4rem;
    /* Space between buttons */
    flex-shrink: 0;
    /* Prevent controls from shrinking */
}

.play-btn,
.download-btn {
    width: 32px;
    /* Consistent button size */
    height: 32px;
    padding: 0;
    /* Reset padding, icon will center */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    background-color: var(--primary-color);
    /* Default background */
    color: white;
}

.play-btn:hover {
    background-color: #7a36ff;
    /* Darker shade on hover */
    transform: scale(1.05);
}

.download-btn {
    background-color: var(--secondary-color);
    color: var(--background-color);
    /* Ensure contrast */
}

.download-btn:hover {
    background-color: #00bfa5;
    /* Darker shade for secondary */
    transform: scale(1.05);
}

.play-btn .material-icons,
.download-btn .material-icons {
    font-size: 18px;
    /* Ensure icons are well-sized */
}

.story-item.playing {
    /* Style for when an item is playing */
    border: 2px solid var(--error-color);
    box-shadow: 0 0 10px rgba(207, 102, 121, 0.3);
    /* Use error color for playing indication */
}

.play-btn.playing {
    /* Style for the play button when it's active (playing) */
    background-color: var(--error-color);
}

.play-btn.playing:hover {
    background-color: #b74c5c;
    /* Darker error color on hover */
}

/* Warning and info messages */
.warnings-container {
    text-align: center;
    margin: 1rem auto;
    width: 100%;
    max-width: 700px;
}

.info,
.warn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.info {
    background-color: rgba(239, 178, 51, 0.1);
    border-left: 4px solid var(--warning-color);
}

.warn {
    background-color: rgba(255, 60, 60, 0.1);
    border-left: 4px solid var(--error-color);
    max-width: 700px;
}

.info svg,
.warn svg {
    margin-right: 0.75rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Error messages */
.error-message {
    background-color: var(--error-color);
    color: white;
    padding: 1rem;
    text-align: center;
    margin: 1rem 0;
    border-radius: 4px;
}

/* Footer */
footer {
    background-color: var(--surface-color);
    color: var(--text-secondary);
    padding: 0.75rem;
    text-align: center;
    font-size: 0.875rem;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 90;
}

footer .site-name {
    font-size: 1rem;
    margin-bottom: 0;
}

/* Language Switcher */
.lang-switch {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
    gap: 0.5rem;
}

.lang-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
}

.lang-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}


/* Status Info */
.status-info,
.status-error {
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    text-align: center;
    font-size: 0.9rem;
}

.time-remaining {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--warning-color);
}

.status-error p {
    color: var(--error-color);
}

.required-selection-message {
    text-align: center;
    padding: 1rem;
    color: var(--text-secondary);
    font-style: italic;
}


/* Responsive adjustments */
@media (max-width: 768px) {
    .site-name {
        font-size: 1.25rem;
    }

    .auth-box {
        padding: 1.5rem;
    }

    input,
    select,
    button {
        padding: 0.6rem 0.8rem;
    }

    footer .site-name {
        font-size: 0.875rem;
    }

    #element-selectors {
        flex-direction: column;
        /* Stack selectors vertically on small screens */
    }

    .element-selector {
        min-width: unset;
        /* Allow full width */
    }

    .data-missing-text {
        display: none;
        /* スマホ表示ではテキストを非表示 */
    }

    .data-missing-icon {
        margin-right: 0;
        /* テキストがないのでアイコンの右マージン不要 */
    }

    .data-missing-indicator {
        padding: 0.2rem 0.3rem;
        /* アイコンのみなのでパディング調整 */
        /* margin-left: 0.5rem; */
        /* スマホ時の配置調整が必要な場合 */
    }

    .story-file-name {
        /* スマホではファイル名が長すぎるとレイアウトが崩れる可能性があるので調整 */
        /* max-width: calc(100% - 100px); 例: インジケーターとメニューボタンの幅を考慮 */
    }
}

.tooltip-message {
    position: absolute;
    background-color: #2a2a2e;
    color: var(--text-primary);
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.35);
    z-index: 1050;
    font-size: 0.8rem;
    line-height: 1.45;
    max-width: 280px;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
    /* 吹き出しのしっぽ（右下向き）を追加 */
    /* position: relative; /* しっぽの基準にするため */
}

/* Story Item Context Menu */
.story-item-context-menu {
    position: absolute;
    background-color: var(--surface-color);
    /* bodyの背景色より少し明るい色 */
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    /* 他の要素より手前 */
    min-width: 160px;
}

.story-item-context-menu ul {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
}

.story-item-context-menu li {
    padding: 0.3rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.story-item-context-menu li:hover {
    background-color: rgba(255, 255, 255, 0.08);
    /* ホバー時の背景色 */
}


/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    /* 半透明の黒背景 */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1040;
    /* ツールチップやメニューより手前 */
    padding: 1rem;
    /* スマホでの端の余白 */
    overflow-y: auto;
    /* コンテンツが多い場合にスクロール */
}

/* Part 1 Edit Warning in Modal */
.part1-edit-warning {
    background-color: rgba(var(--warning-rgb, 239, 178, 51), 0.1);
    border: 1px solid var(--warning-color, #efb233);
    border-left: 4px solid var(--warning-color, #efb233);
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    border-radius: 4px;
    color: var(--text-secondary);
}

.part1-edit-warning p {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.part1-edit-warning ul {
    list-style-position: inside;
    padding-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 0;
    /* Ensure no extra bottom margin for the list itself */
}

.part1-edit-warning li {
    margin-bottom: 0.25rem;
}

.part1-edit-warning li:last-child {
    margin-bottom: 0;
    /* Remove bottom margin from the last list item */
}

.part1-edit-warning a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    /* Make links slightly bolder */
}

.part1-edit-warning a:hover {
    text-decoration: underline;
}

.modal-content {
    background-color: var(--background-color);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 600px;
    /* モーダルの最大幅 */
    max-height: 90vh;
    /* モーダルの最大高さ */
    display: flex;
    flex-direction: column;
    position: relative;
    /* 子要素の絶対配置の基準 */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--text-primary);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    flex-grow: 1;
    /* 残りの高さを埋める */
    overflow-y: auto;
    /* 内容が多い場合にスクロール */
    padding-right: 0.5rem;
    /* スクロールバー用の余白 */
}

.current-info-audio-container {
    /* 新しいコンテナ */
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    /* テキストが多い場合も考慮 */
    background-color: var(--surface-color);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}

.modal-body .current-info {
    flex-grow: 1;
    /* テキスト情報が幅を取るように */
    padding: 0;
    /* コンテナ側でパディングするのでリセット */
    margin-bottom: 0;
    /* コンテナ側でマージン */
    background-color: transparent;
    /* コンテナ側で背景色 */
}

.modal-audio-player {
    flex-shrink: 0;
    /* ボタンが縮まないように */
    margin-left: 1rem;
    /* テキスト情報との間隔 */
    display: flex;
    align-items: center;
    /* ボタンを垂直中央に */
}

.modal-audio-play-btn {
    /* モーダル内再生ボタンの個別スタイル */
    width: 38px;
    /* サイズ調整 */
    height: 38px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    background-color: var(--primary-color);
    color: white;
    transition: background-color 0.2s;
}

.modal-audio-play-btn:hover {
    background-color: #4a00b3;
}

.modal-audio-play-btn .material-icons {
    font-size: 22px;
}

.modal-body .current-info h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: var(--text-primary);
}

.modal-body .current-info p {
    margin: 0.3rem 0;
    color: var(--text-secondary);
}

.modal-body .current-info p strong {
    color: var(--text-primary);
}


.modal-body form div {
    margin-bottom: 1.2rem;
}

.modal-body form label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.required-asterisk {
    /* 必須マーク */
    color: var(--error-color, red);
    margin-left: 0.25rem;
    font-weight: bold;
}

/* モーダル内のフォームフィールドコンテナ */
.modal-body .form-field-container {
    margin-bottom: 1.2rem;
}

/* ラベルと注釈を横並びにするコンテナ */
.label-note-container {
    display: flex;
    align-items: center;
    margin-bottom: 0.1rem !important;
    flex-wrap: wrap;
}

.label-note-container label {
    margin-right: 6px;
    /* ラベルと注釈の間のスペースを少し詰める */
}

/* モーダル内のフィールド注釈 */
.field-note {
    display: inline-flex;
    align-items: center;
    padding: 1px 5px;
    /* パディングをさらに小さく */
    border-radius: 8px;
    /* 丸みを少し調整 */
    font-size: 0.6em;
    /* フォントサイズをさらに小さく */
    line-height: 1.2;
    /* 行間を詰める */
    background-color: #1e3a8a;
    color: #bfdbfe;
    /* margin-left: auto; */
    /* 右寄せにする場合はコメント解除 */
}

/* data-missing-indicator と small-note を併用する場合の調整 */
.field-note.small-note .data-missing-icon {
    font-size: 12px;
    /* アイコンサイズをさらに小さく */
    margin-right: 2px;
    /* アイコンとテキストの間隔を詰める */
}

.field-note.small-note .data-missing-text {
    font-size: 0.9em;
    /* テキストサイズを親要素基準で調整 (0.6em * 0.9em) */
    white-space: nowrap;
    /* テキストが折り返さないようにする（短い注釈向け） */
}

/* スマホ表示での注釈テキストの表示 (以前は非表示だった部分を修正) */
@media (max-width: 480px) {
    .label-note-container {
        /* スマホではラベルと注釈が縦に並ぶことも許容する (必要に応じて) */
        /* align-items: flex-start; */
    }

    .field-note.small-note .data-missing-text {
        display: inline;
        /* テキストを常に表示 */
        white-space: normal;
        /* スマホではテキストの折り返しを許可 */
    }

    .field-note {
        font-size: 0.55em;
        /* スマホではさらに少しだけフォントを小さく */
        margin-top: 2px;
        /* ラベルとの間に少しマージン */
    }
}

.contributor-details {
    margin-bottom: 1.2rem;
    /* 他のフォーム要素との間隔 */
}

.contributor-details summary {
    cursor: pointer;
    color: var(--primary-color);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.3rem 0;
    list-style-position: inside;
    /* マーカーを内側に */
    outline: none;
    /* フォーカス時のデフォルトアウトラインを消す場合 */
}

.contributor-details summary:hover {
    text-decoration: underline;
}

.contributor-section-content {
    /* details内のコンテンツエリア */
    padding: 1rem;
    background-color: rgba(var(--primary-rgb, 98, 0, 238), 0.05);
    /* 薄い背景色、--primary-rgbがなければデフォルト値 */
    border: 1px solid rgba(var(--primary-rgb, 98, 0, 238), 0.1);
    border-radius: 5px;
    margin-top: 0.5rem;
}

.modal-footer button:disabled {
    /* 非活性時のスタイル */
    background-color: var(--disabled-color, #757575);
    /* --disabled-color を定義するか直接指定 */
    cursor: not-allowed;
    opacity: 0.7;
}

.modal-body form input[type="text"],
.modal-body form select,
.modal-body form textarea {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--surface-color);
    color: var(--text-primary);
    font-size: 1rem;
    box-sizing: border-box;
    /* paddingとborderをwidthに含める */
}

.modal-body form input[type="text"]:focus,
.modal-body form select:focus,
.modal-body form textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
    /* --primary-rgb が定義されている前提 */
}

.modal-body form textarea {
    resize: vertical;
    /* 縦方向のみリサイズ可能 */
    min-height: 80px;
}

.modal-body .contributor-info-toggle button {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 0.5rem 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s, color 0.2s;
}

.modal-body .contributor-info-toggle button:hover {
    background-color: var(--primary-color);
    color: white;
}

.modal-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
    text-align: right;
}

.modal-footer button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.modal-footer button:hover {
    background-color: #4a00b3;
    /* 少し暗いprimary-color */
}

/* Responsive adjustments for modal */
@media (max-width: 768px) {
    .modal-content {
        padding: 1rem;
        max-height: 95vh;
        /* スマホでは高さを少し大きく */
    }

    .modal-header h2 {
        font-size: 1.2rem;
    }

    .modal-body {
        padding-right: 0;
        /* スマホではスクロールバー余白不要な場合が多い */
    }
}

/* Bulk Controls */
.bulk-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: auto;
    margin-bottom: 1rem;
    max-width: 600px;
    /* Center and add bottom margin */

}

.bulk-controls button {
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex: 1;
    /* Distribute space equally */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    /* Space between icon and text */
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    min-height: 44px;
    min-width: 150px;
    /* Optional: Set a minimum width similar to .element-selector's content */
    /* max-width: 250px; */
    /* Optional: Set a maximum width if needed */
}

.bulk-controls button span {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    white-space: nowrap;
}

.bulk-controls .material-icons {
    font-size: 1.2em;
    /* Adjust icon size */
}

.bulk-controls .play-all-btn {
    background-color: var(--primary-color);
    color: white;
}

.bulk-controls .play-all-btn:hover {
    background-color: #7a36ff;
    /* Darker primary */
}

.bulk-controls .download-btn {
    background-color: var(--secondary-color);
    color: var(--background-color);
    /* For contrast */
}

.bulk-controls .download-btn:hover {
    background-color: #00bfa5;
    /* Darker secondary */
}

.bulk-controls .play-all-btn.playing {
    background-color: var(--error-color);
}

.bulk-controls .play-all-btn.playing:hover {
    background-color: #b74c5c;
    /* Darker error */
}

/* Progress Overlay */
.progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1050;
    /* Higher than modal */
}

.progress-box {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    min-width: 300px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.progress-text {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    /* Slightly thicker bar */
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin: 1rem 0;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Scroll into view helper */
.scrolled-into-view {
    scroll-margin-top: 80px;
    /* Adjust based on fixed header height */
}

.scrolled-into-view {
    scroll-margin-top: 80px;
    /* Adjust based on fixed header height */
}

/* Scroll to top button */
.scroll-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary-color);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 99;
    border: none;
    /* Ensure no default border */
}

.scroll-top:hover {
    transform: scale(1.1);
    -webkit-transform: scale(1.1);
    -moz-transform: scale(1.1);
    -ms-transform: scale(1.1);
    -o-transform: scale(1.1);
}

.scroll-top.visible {
    opacity: 1;
}

.scroll-top .material-icons {
    font-size: 24px;
}

/* Hide elements when printing */
@media print {
    body * {
        visibility: hidden;
    }

    .auth-overlay,
    header,
    footer,
    #display-selectors,
    .lang-switch {
        display: none;
    }

    #main,
    #story-list,
    .story-item,
    .story-file-name,
    .story-text,
    .story-item audio {
        visibility: visible;
    }

    #main {
        margin-top: 0;
        padding: 0;
    }
}