/* =========================
   全体
========================= */

html {
    scrollbar-gutter: stable;
}

@media (hover: hover) and (pointer: fine) {
    html {
        overscroll-behavior-y: none;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-size: 18px;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: #f7f7f7;
}


/* =========================
   ヘッダー
========================= */

header {
    position: sticky;
    top: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 20px;
    height: 60px;
    padding: 0 20px;
    background: white;
    border-bottom: 1px solid #ddd;
}

header h1 {
    margin: 0;
    font-size: 24px;
}

#page-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

/* メニューボタン */

#menu-button {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    font-size: 24px;
    cursor: pointer;
}

#menu-button:hover {
    background: #f0f0f0;
}


/* =========================
   サイドバー
========================= */

#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1100;
    width: 280px;
    height: 100vh;
    padding: 25px 20px;
    background: white;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

#sidebar.open {
    transform: translateX(0);
}


/* サイドバー見出し */

#sidebar h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 22px;
}

#sidebar h2:not(:first-child) {
    margin-top: 30px;
}


/* サイドバーのボタン */

#sidebar button {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    font-size: 18px;
    text-align: left;
    cursor: pointer;
}

#sidebar button:hover {
    background: #f0f0f0;
}


/* =========================
   オーバーレイ
========================= */

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
}

#overlay.open {
    display: block;
}


/* =========================
   メイン
========================= */

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

body.anime-shelf-active > main {
    padding-top: 0;
}


/* =========================
   ホーム
========================= */

#home-page {
    padding: 20px;
}

#home-page h2 {
    margin-top: 0;
}


/* =========================
   アニメ書庫
========================= */

#anime-page {
    display: block;
}

#anime-page h2 {
    margin-top: 0;
}


/* =========================
   作品追加
========================= */

#add-anime-area {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    margin: 0;
}

#edit-mode-controls {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

#edit-mode-controls[hidden] {
    display: none;
}

.edit-mode-button {
    min-height: 42px;
    padding: 9px 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.edit-mode-button.is-active {
    border-color: #855b42;
    background: #855b42;
    color: white;
}

.edit-mode-button:disabled {
    color: #777;
    background: #eee;
    cursor: not-allowed;
}

#add-anime-button {
    min-height: 42px;
    padding: 10px 18px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    font-size: 18px;
    cursor: pointer;
}

#add-anime-button:hover {
    background: #f0f0f0;
}


/* 追加フォーム */

#add-anime-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    padding: 0;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

#add-anime-form {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: white;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
}

#add-anime-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #ddd;
    background: white;
}

#add-anime-form h2 {
	margin: 0;
	font-size: 21px;
}

#add-anime-header #close-add-anime-modal {
	flex: 0 0 auto;
	margin: 0;
	padding: 4px 10px;
	border: 0;
	font-size: 24px;
}

#add-anime-content {
	flex: 1 1 auto;
	min-height: 0;
	padding: 20px;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	scroll-padding-block: 16px;
}

#add-anime-footer {
	display: flex;
	flex: 0 0 auto;
	justify-content: flex-end;
	gap: 10px;
	padding: 12px 20px;
	border-top: 1px solid #ddd;
	background: white;
}

#add-anime-footer button {
	margin-right: 0;
}

#add-anime-content :is(input, textarea, select, button) {
	scroll-margin-block: 16px;
}

#add-anime-form input[type="text"] {
    display: block;
    width: 100%;
    max-width: 500px;
    margin-top: 5px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 17px;
}

#add-anime-form button {
    margin-right: 10px;
    padding: 10px 18px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    font-size: 17px;
    cursor: pointer;
}

#add-anime-form button:hover {
    background: #f0f0f0;
}

/* 制作会社管理オーバーレイ */
.studio-management-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.5);
}

.studio-management-overlay[hidden] {
    display: none;
}

.studio-management-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: white;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
}

.studio-management-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #ddd;
    background: white;
}

.studio-management-header h2,
.studio-management-add-form h3,
.studio-management-content > h3 {
    margin: 0;
}

.studio-management-header button {
    flex: 0 0 auto;
    margin: 0;
    padding: 4px 10px;
    border: 0;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
}

.studio-management-content {
    flex: 1 1 auto;
    min-height: 0;
    padding: 20px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.studio-management-add-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.studio-management-add-form h3,
.studio-management-status {
    grid-column: 1 / -1;
}

.studio-management-add-form h3 {
    margin-bottom: 2px;
}

.studio-management-add-form label,
.studio-management-row label {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.studio-management-add-form input,
.studio-management-row input {
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font: inherit;
}

.studio-management-fields {
    display: grid;
    grid-column: 1 / 3;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 12px;
    min-width: 0;
}

.studio-management-fields .input-with-clear {
    max-width: none;
}

.studio-management-fields .input-with-clear input[type="text"] {
    margin-top: 0;
}

.studio-management-add-actions {
    display: flex;
    align-items: end;
    gap: 8px;
}

.studio-management-add-form button,
.studio-management-row button {
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background: white;
    font: inherit;
    cursor: pointer;
}

.studio-management-add-form button:hover,
.studio-management-row button:hover {
    background: #f0f0f0;
}

.studio-management-add-form p {
    min-height: 1.4em;
    margin: 0;
}

.studio-management-status.is-error {
    color: #b00020;
}

.studio-management-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.studio-management-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.studio-management-value-button {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid transparent !important;
    background: transparent !important;
    text-align: left;
    overflow-wrap: anywhere;
}

.studio-management-value-button:hover {
    border-color: #ccc !important;
    background: #f7f7f7 !important;
}

.studio-management-value-input {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid #855b42;
    border-radius: 5px;
    box-sizing: border-box;
    font: inherit;
}

.studio-management-value-cell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    min-width: 0;
}

.studio-management-field-error {
    color: #b00020;
    font-size: 0.9em;
    overflow-wrap: anywhere;
}

.studio-management-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.studio-management-row .studio-management-delete {
    min-width: 40px;
    font-size: 20px;
}

@media (max-width: 640px) {
    .studio-management-header,
    .studio-management-content {
        padding-right: 14px;
        padding-left: 14px;
    }

    .studio-management-add-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .studio-management-fields {
        grid-column: 1 / -1;
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    .studio-management-add-actions {
        grid-column: 1 / -1;
    }

    .studio-management-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .studio-management-row-actions button {
        flex: 1 1 auto;
    }
}


/* =========================
   入力欄
========================= */

.input-with-clear {
    position: relative;
    width: 100%;
    max-width: 500px;
}

.input-with-clear input[type="text"] {
    width: 100%;
    margin-top: 5px;
    padding: 10px 40px 10px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 17px;
}


/* =========================
   入力欄のクリアボタン
========================= */

.clear-input {
    position: absolute;
    right: 6px;
    top: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px !important;
    height: 24px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 50% !important;
    background: transparent !important;
    font-size: 18px !important;
    line-height: 1;
    color: #777;
    cursor: pointer;
    transform: translateY(-50%);
}

.clear-input:hover {
    background: #eee !important;

    color: #000;
}


/* =========================
   入力項目
========================= */

.input-group {
    margin-bottom: 15px;
}

.input-group p,
#key-visual-area p {
    margin: 0 0 5px 0;
    font-size: 17px;
}

#watched-area {
    margin-top: 5px;
    margin-bottom: 20px;
}


/* =========================
   キービジュアル入力
========================= */

.file-input-label {
    display: block;
    width: fit-content;
}

#new-anime-key-visual {
    display: block;
    margin-top: 5px;
    font-size: 17px;
}


/* =========================
   検索
========================= */

#search-panel {
    position: sticky;
    top: 60px;
    z-index: 450;
    margin-bottom: 10px;
    padding: 0 0 8px;
    background: #f7f7f7;
    border-bottom: 1px solid #ddd;
}

#search-toolbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
}

#search-area {
    flex: 1 1 220px;
    min-width: 0;
    margin: 0;
}

#search-toggle-button {
    padding: 10px 18px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    font-size: 17px;
    cursor: pointer;
}

#search-toggle-button:hover {
    background: #f0f0f0;
}

#search-content {
    display: block;
    max-height: min(42vh, 360px);
    max-height: min(42dvh, 360px);
    overflow-y: auto;
    padding: 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
}

#search-input {
    width: 100%;
    max-width: none;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 18px;
}


/* =========================
   フィルターボタン
========================= */

#filter-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#filter-buttons button {
    padding: 10px 18px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    font-size: 17px;
    cursor: pointer;
}

#filter-buttons button:hover {
    background: #f0f0f0;
}


/* =========================
   50音
========================= */

#kana-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

#kana-buttons button {
    min-width: 45px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    font-size: 16px;
    cursor: pointer;
}

#kana-buttons button:hover {
    background: #f0f0f0;
}

/* =========================
   アニメ一覧
========================= */

#anime-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

#anime-list > li {
	margin-bottom: 20px;
}

#anime-list.edit-mode {
	background: #f4f8fc;
}


/* 作品名ボタン */

#anime-list > li > button {
	width: 100%;
	padding: 15px;
	border: 1px solid #ccc;
	border-radius: 6px;
	background: white;
	font-size: 20px;
	text-align: left;
	cursor: pointer;
}

#anime-list > li > button:hover {
	background: #d5e6f5;
}


/* 編集モード */

body.edit-mode {
	background: #f4f8fc;
}

body.detail-edit-mode {
	background: #f5e1d5;
}

/* 登録情報の削除は「情報を編集」モードで表示 */
.delete-card-button {
    display: none;
}

body.edit-mode:not(.detail-edit-mode) .delete-card-button {
    display: inline-block;
}

/* =========================
   シリーズ
========================= */

.anime-series {
    margin-bottom: 35px;
}

.series-heading-row,
.work-heading-row,
.registration-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}

.series-heading-row {
    width: 100%;
    max-width: 760px;
    justify-content: flex-start;
    box-sizing: border-box;
}

.work-heading-row {
    width: 100%;
    max-width: 760px;
    justify-content: flex-start;
    box-sizing: border-box;
}

.manual-order-notice {
    margin: 0 0 16px;
    padding: 10px 12px;
    border: 1px solid #c9a58e;
    border-radius: 6px;
    background: #fff8f3;
}

.manual-order-controls {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
}

.manual-order-button {
    min-width: 64px;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid #b7a397;
    border-radius: 6px;
    background: #fff;
    font: inherit;
    cursor: pointer;
}

.manual-order-button:disabled {
    opacity: 0.45;
    cursor: default;
}

.manual-order-button:focus-visible,
.season-title:focus-visible {
    outline: 2px solid #4779bd;
    outline-offset: 2px;
}

.series-title {
	display: block;
    flex: 1 1 auto;
    min-width: 0;
	width: 100%;
	margin: 0;
	padding: 0;
	border: none;
	background: none;
	font-size: 24px;
	font-weight: bold;
	text-align: left;
	cursor: pointer;
}

.series-title:disabled,
.work-title:disabled {
    color: inherit;
    opacity: 1;
    cursor: default;
}

.series-title-input {
	display: block;
	width: 100%;
	margin: 0;
	padding: 2px 4px;
	border: 1px solid #999;
	border-radius: 3px;
	background: white;
	font-size: 24px;
	font-weight: bold;
	text-align: left;
	box-sizing: border-box;
}

.series-reading-input {
	display: block;
	width: 100%;
	margin: 5px 0 0 0;
	padding: 2px 4px;
	border: 1px solid #999;
	border-radius: 3px;
	background: white;
	font-size: 16px;
	box-sizing: border-box;
}

.anime-work {
    margin-top: 20px;
}

.work-title {
	display: block;
    flex: 1 1 auto;
    min-width: 0;
	margin: 0 0 10px 0;
	padding: 0;
	border: none;
	background: none;
	font-size: 20px;
	font-weight: normal;
	text-align: left;
	cursor: pointer;
}

.work-title-input {
	display: block;
    width: 100%;
	margin: 0 0 10px 0;
	padding: 2px 4px;
	border: 1px solid #999;
	border-radius: 3px;
	background: white;
	font-size: 20px;
	font-weight: normal;
	text-align: left;
	box-sizing: border-box;
}

.work-reading-input {
	display: block;
	width: 100%;
	margin: 5px 0 10px 0;
	padding: 2px 4px;
	border: 1px solid #999;
	border-radius: 3px;
	background: white;
	font-size: 16px;
	box-sizing: border-box;
}


/* =========================
   アニメカード
========================= */

.anime-card-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-top: 0;
}

.anime-card-wrapper {
    width: 100%;
    max-width: 760px;
    min-width: 0;
    box-sizing: border-box;
}

.anime-card {
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
}


/* キービジュアル */

.key-visual {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: left center;
    margin: 0;
}

.key-visual-container {
    width: 100%;
    max-width: 420px;
    aspect-ratio: 7 / 5;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    box-sizing: border-box;
    margin: 8px 0 12px;
}

.key-visual-link {
	font-size: 13px;
	color: #888;
	text-decoration: none;
}

.key-visual-link:hover {
	color: #555;
	text-decoration: underline;
}

.key-visual-control {
	margin: 6px 0 12px;
}

.key-visual-control button.key-visual-link {
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
}

.key-visual-editor-overlay {
	position: fixed;
	inset: 0;
	z-index: 1500;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 24px 12px;
	box-sizing: border-box;
	background: rgba(0, 0, 0, 0.5);
	overflow-y: auto;
}

.key-visual-editor-dialog {
	width: 100%;
	max-width: 620px;
	max-height: calc(100vh - 48px);
	padding: 24px;
	box-sizing: border-box;
	border: 1px solid #ccc;
	border-radius: 8px;
	background: white;
	overflow-y: auto;
}

.key-visual-editor-dialog h2 {
	margin: 0 0 8px;
}

.key-visual-editor-context {
	margin: 0 0 18px;
	color: #555;
	overflow-wrap: anywhere;
}

.key-visual-editor-import {
	display: grid;
	gap: 8px;
	margin-bottom: 18px;
}

.key-visual-editor-import-target {
	margin: 0;
	color: #555;
	font-size: 0.9rem;
}

.key-visual-editor-import textarea {
	width: 100%;
	min-height: 64px;
	padding: 9px;
	box-sizing: border-box;
	border: 1px solid #ccc;
	border-radius: 6px;
	font: inherit;
}

.key-visual-editor-list {
	display: grid;
	gap: 12px;
	margin-bottom: 16px;
}

.key-visual-editor-file-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 16px;
}

.key-visual-editor-file-actions button {
	flex: 1 1 190px;
	min-width: 0;
}

.key-visual-editor-item {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	padding: 8px;
	border: 1px solid #ddd;
	border-radius: 6px;
}

.key-visual-editor-item.is-replacement-target {
	border-color: #356ac3;
	box-shadow: 0 0 0 2px rgb(53 106 195 / 18%);
}

.key-visual-editor-preview {
	width: 84px;
	height: 64px;
	flex: 0 0 auto;
	object-fit: contain;
	background: #f5f5f5;
}

.key-visual-editor-item input[type="file"] {
	min-width: 0;
	flex: 1 1 160px;
}

.key-visual-editor-item button,
.key-visual-editor-import button,
.key-visual-editor-file-actions button,
.key-visual-editor-dialog > button,
.key-visual-editor-actions button {
	padding: 9px 13px;
	border: 1px solid #ccc;
	border-radius: 6px;
	background: white;
	cursor: pointer;
}

.key-visual-editor-actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 20px;
}

@media (max-width: 520px) {
	.key-visual-editor-dialog {
		padding: 16px;
	}

	.key-visual-editor-item {
		flex-wrap: wrap;
	}

	.key-visual-editor-preview {
		width: 100%;
		height: 140px;
	}

	.key-visual-editor-item input[type="file"] {
		flex-basis: 100%;
	}
}

/* シーズンタイトル */

.season-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 4px 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 20px;
    font-weight: bold;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.season-title:hover {
    text-decoration: underline;
}

.registration-details {
    min-width: 0;
}

.registration-heading-row {
    min-height: 44px;
}

.season-title-input {
	display: block;
	width: 100%;
	margin: 0 0 10px 0;
	padding: 2px 4px;
	border: 1px solid #999;
	border-radius: 3px;
	background: white;
	font-size: 18px;
	font-weight: bold;
	box-sizing: border-box;
}

.season-reading-input {
	display: block;
	width: 100%;
	margin: 5px 0 10px 0;
	padding: 2px 4px;
	border: 1px solid #999;
	border-radius: 3px;
	background: white;
	font-size: 16px;
	box-sizing: border-box;
}

/* カード内の情報 */

.anime-card p {
    margin: 8px 0;
}

.card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-bottom .watched {
    margin: 8px 0;
}

.delete-card-button {
    margin: 0;
    padding: 4px 8px;
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
}

.delete-card-button {
	display: none;
}

.release-date-input {
	margin: 0;
	padding: 2px 4px;
	border: 1px solid #999;
	border-radius: 3px;
	background: white;
	font-size: 16px;
	box-sizing: border-box;
}

.release-date-edit-container {
	display: block;
}

.release-date-error {
	margin: 4px 0 0 0;
	font-size: 13px;
	color: #c33;
}

.studio-select {
	margin: 0;
	padding: 2px 4px;
	border: 1px solid #999;
	border-radius: 3px;
	background: white;
	font-size: 16px;
	box-sizing: border-box;
}

.studio-editor {
	width: 100%;
	max-width: 520px;
	margin: 8px 0;
	padding: 10px;
	border: 1px solid #bbb;
	border-radius: 6px;
	box-sizing: border-box;
}

.studio-editor-label {
	margin: 0 0 8px;
	font-weight: 600;
}

.studio-editor-add-row,
.studio-editor-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
}

.studio-editor-add-row .studio-select {
	flex: 1 1 220px;
	min-width: 0;
}

.studio-editor-list {
	display: grid;
	gap: 6px;
	margin: 10px 0;
}

.studio-editor-row {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	padding: 6px 8px;
	border: 1px solid #ddd;
	border-radius: 4px;
}

.studio-editor-name {
	flex: 1 1 140px;
	min-width: 0;
	overflow-wrap: anywhere;
}

.studio-editor-row-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.studio-editor-button {
	min-height: 36px;
	padding: 6px 10px;
}

.studio-editor-icon-button {
	min-width: 40px;
}

.studio-editor-empty {
	margin: 0;
	color: #666;
}

/* =========================
   準備中ページ
========================= */

#placeholder-page {
    display: none;
    padding: 20px;
}

#placeholder-page h2 {
    margin-top: 0;
}


/* =========================
   タブレット
========================= */

@media (max-width: 900px) {
    .anime-card-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

}


/* =========================
   スマートフォン
========================= */

@media (max-width: 600px) {
    .anime-card-list {
        grid-template-columns: 1fr;
    }

    .series-heading-row,
    .work-heading-row,
    .registration-heading-row {
        align-items: flex-start;
    }

    .work-heading-row {
        max-width: 100%;
    }

    .manual-order-controls {
        gap: 4px;
    }

    .manual-order-button {
        min-width: 48px;
        min-height: 44px;
        padding: 7px 8px;
    }

    .anime-card-wrapper {
        width: 100%;
        max-width: 100%;
    }

    .key-visual-container {
        max-width: 100%;
    }
}


/* =========================
   ログイン画面
========================= */

#login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 30px;
    box-sizing: border-box;
}

#login-form {
    width: 90%;
    max-width: 450px;
    padding: 40px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: white;
    box-sizing: border-box;
}

#login-form h1 {
    margin-top: 0;
    text-align: center;
}

#login-form > p {
    margin-bottom: 30px;
    text-align: center;
}

#login-form .input-group {
    margin-bottom: 20px;
}

#login-form .input-group p {
    margin-bottom: 8px;
}

#login-form input {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
}

#login-button {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
}

#login-error {
    color: #d00;
}


/* ログイン前はアプリ本体を非表示 */
body:not(.logged-in):not(.app-initializing) > header,
body:not(.logged-in):not(.app-initializing) > #overlay,
body:not(.logged-in):not(.app-initializing) > #sidebar,
body:not(.logged-in):not(.app-initializing) > main,
body:not(.logged-in):not(.app-initializing) > #add-anime-modal,
body:not(.logged-in):not(.app-initializing) > #studio-management-overlay {
    display: none;
}

/* 初期化中はログイン画面を非表示 */
body.app-initializing > #login-page {
    display: none;
}

/* 初期化中は書庫の中身を隠す */
body.app-initializing > main > section,
body.app-initializing > main #search-panel,
body.app-initializing > main #anime-list,
body.app-initializing > main #add-anime-area {
    visibility: hidden;
}

/* ログイン済みならログイン画面を非表示 */
body.logged-in > #login-page {
    display: none;
}


/* =========================
   通知ウィンドウ
========================= */

/* 通常通知：画面右下 */
#notification-overlay.toast-mode {
	display: none;
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 2000;
	width: auto;
	max-width: min(420px, calc(100vw - 40px));
	padding: 0;
	background: transparent;
	pointer-events: none;
}

#notification-overlay.toast-mode.open {
	display: block;
}

#notification-overlay.toast-mode #notification-dialog {
	width: 100%;
	max-width: 420px;
	padding: 16px 20px;
	border: 1px solid #ccc;
	border-radius: 10px;
	background: white;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
	pointer-events: auto;
}

/* 通常通知ではタイトルと操作ボタンを隠す */
#notification-overlay.toast-mode #notification-title,
#notification-overlay.toast-mode #notification-actions {
	display: none;
}

/* 中央表示：エラー・確認画面 */
#notification-overlay:not(.toast-mode) {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 2000;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(0, 0, 0, 0.45);
}

#notification-overlay:not(.toast-mode).open {
	display: flex;
}

#notification-overlay:not(.toast-mode) #notification-dialog {
	width: 100%;
	max-width: 420px;
	padding: 25px;
	border: 1px solid #ccc;
	border-radius: 10px;
	background: white;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

#notification-title {
	margin: 0 0 18px;
	font-size: 22px;
}

#notification-message {
	margin: 0;
	line-height: 1.7;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

#notification-actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 25px;
}

#notification-actions button {
	min-width: 90px;
	padding: 10px 18px;
	border: 1px solid #bbb;
	border-radius: 6px;
	background: #f7f7f7;
	font-size: 16px;
	cursor: pointer;
}

#notification-actions button:hover {
	background: #e9e9e9;
}

#notification-actions button:focus-visible {
	outline: 2px solid #4779bd;
	outline-offset: 3px;
}

@media (max-width: 480px) {
	#notification-overlay.toast-mode {
		right: 12px;
		bottom: 12px;
		max-width: calc(100vw - 24px);
	}
}


/* =========================
   Now Loading
========================= */

#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;

    display: none;
    align-items: center;
    justify-content: center;

    padding: 24px;
    box-sizing: border-box;

    background: rgba(15, 18, 24, 0.68);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#loading-overlay.open {
    display: flex;
}

#loading-dialog {
    width: 100%;
    max-width: 320px;
    padding: 32px 24px;

    box-sizing: border-box;
    text-align: center;

    color: #f5f5f5;
    background: #242831;

    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
}

#loading-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    margin-bottom: 24px;
}

#loading-icon span {
    width: 10px;
    height: 10px;

    border-radius: 50%;
    background: #d8c49a;

    animation: loading-pulse 1s ease-in-out infinite;
}

#loading-icon span:nth-child(2) {
    animation-delay: 0.15s;
}

#loading-icon span:nth-child(3) {
    animation-delay: 0.3s;
}

#loading-title {
    margin: 0 0 12px;
    font-size: 1.25rem;
    font-weight: 600;
}

#loading-message {
    margin: 0;
    color: #c5c8cf;
    font-size: 0.9rem;
    line-height: 1.7;
}

@keyframes loading-pulse {
    0%, 60%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-6px);
    }
}

@media (prefers-reduced-motion: reduce) {
    #loading-icon span {
        animation: none;
        opacity: 0.8;
    }
}


/* =========================
   キービジュアル
========================= */
.key-visual-import {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	margin-bottom: 16px;
}
#key-visual-paste-input {
	width: 100%;
	max-width: 420px;
	min-height: 72px;
	box-sizing: border-box;
	padding: 10px;
	resize: vertical;
}
.key-visual-input {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	margin-bottom: 16px;
}
.key-visual-preview {
	display: block;
	width: 100%;
	max-width: 320px;
	max-height: 360px;
	object-fit: contain;
	object-position: left center;
	border-radius: 8px;
}
.key-visual-input input[type="file"] {
	max-width: 100%;
}
.key-visual-input button,
.key-visual-import button {
	cursor: pointer;
}

.detail-work-association {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 8px 0;
	padding: 8px;
	border: 1px dashed #b9aa8b;
	border-radius: 6px;
}

.detail-work-association span {
	font-size: 0.9rem;
}

.detail-work-association button {
	cursor: pointer;
}

.detail-work-name-input {
	min-width: 0;
	max-width: 100%;
	width: 100%;
	padding: 6px 8px;
	box-sizing: border-box;
}

.detail-work-reading-input {
	min-width: 0;
	width: 100%;
	box-sizing: border-box;
	padding: 6px 8px;
}

.detail-existing-work-select {
	max-width: 100%;
	padding: 6px 8px;
}

.detail-work-form-actions {
	display: flex;
	width: 100%;
	gap: 8px;
}

.detail-work-form-actions button {
	flex: 1 1 0;
	min-width: 0;
	padding: 8px 6px;
}


