        @font-face {
            font-family: 'Memorial Noto Sans CJK';
            src: url('../fonts/woff2/NotoSansCJKjp-Regular.woff2') format('woff2');
            font-weight: 400;
            font-style: normal;
            font-display: swap;
        }

        @font-face {
            font-family: 'Memorial Noto Sans JP';
            src: url('../fonts/woff2/NotoSansJP.woff2') format('woff2');
            font-weight: 100 900;
            font-style: normal;
            font-display: swap;
        }

        @font-face {
            font-family: 'Memorial Noto Serif JP';
            src: url('../fonts/woff2/NotoSerifJP.woff2') format('woff2');
            font-weight: 100 900;
            font-style: normal;
            font-display: swap;
        }

        @font-face {
            font-family: 'Memorial M PLUS 1p';
            src: url('../fonts/woff2/MPLUS1p-Regular.woff2') format('woff2');
            font-weight: 400;
            font-style: normal;
            font-display: swap;
        }

        @font-face {
            font-family: 'Memorial M PLUS Rounded 1c';
            src: url('../fonts/woff2/MPLUSRounded1c-Regular.woff2') format('woff2');
            font-weight: 400;
            font-style: normal;
            font-display: swap;
        }

        @font-face {
            font-family: 'Memorial Zen Kaku Gothic';
            src: url('../fonts/woff2/ZenKakuGothicNew-Regular.woff2') format('woff2');
            font-weight: 400;
            font-style: normal;
            font-display: swap;
        }

        @font-face {
            font-family: 'Memorial Zen Maru Gothic';
            src: url('../fonts/woff2/ZenMaruGothic-Regular.woff2') format('woff2');
            font-weight: 400;
            font-style: normal;
            font-display: swap;
        }

        @font-face {
            font-family: 'Memorial Sawarabi Gothic';
            src: url('../fonts/woff2/SawarabiGothic-Regular.woff2') format('woff2');
            font-weight: 400;
            font-style: normal;
            font-display: swap;
        }

        /* NEW HORIZONTAL CONTAINER DESIGN */
        .media-container {
            background: var(--white);
            border: 1px solid var(--border);
            border-radius: 12px;
            margin-bottom: 1.5rem;
            overflow: hidden;
            transition: all 0.3s;
            position: relative;
        }

        .media-container:has(.caption-font-picker[open]) {
            overflow: visible;
            z-index: 40;
        }

        .media-container:hover {
            box-shadow: 0 4px 16px var(--shadow);
        }

        .media-row {
            display: grid;
            grid-template-columns: 1fr 1.5fr 1fr;
            gap: 0;
        }

        .media-section {
            padding: 1.5rem;
            border-right: 1px solid var(--border);
        }

        .media-section:last-child {
            border-right: none;
        }

        .caption-editor {
            padding: 0.75rem 1.5rem 1rem;
            border-top: 1px solid var(--border);
            position: relative;
            z-index: 2;
        }

        .caption-editor .section-label {
            font-size: 0.8rem;
            margin-bottom: 0.5rem;
        }

        .caption-editor {
            --caption-control-height: 50px;
        }

        .caption-controls {
            display: grid;
            grid-template-columns: auto minmax(200px, 1fr) auto;
            grid-template-areas:
                "age input selects"
                ". count .";
            column-gap: 0.75rem;
            row-gap: 0.25rem;
            align-items: center;
        }

        .caption-input {
            grid-area: input;
            width: 100%;
            min-height: var(--caption-control-height);
            min-width: 0;
            padding: 0.5rem 0.75rem;
            border: 2px solid var(--border);
            border-radius: 6px;
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.85rem;
            background: var(--cream);
            transition: all 0.2s;
        }

        .caption-input:focus {
            outline: none;
            border-color: var(--sage);
            background: var(--white);
        }

        .caption-count {
            grid-area: count;
            width: auto;
            justify-self: end;
            text-align: right;
            font-size: 0.8rem;
            color: var(--slate);
        }

        .age-era-input,
        .clip-length-static,
        .prompt-static {
            min-height: var(--caption-control-height);
            padding: 0.5rem 0.75rem;
            border: 2px solid var(--border);
            border-radius: 6px;
            background: var(--white);
            color: var(--dark);
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.85rem;
        }

        .age-era-input-wrap {
            grid-area: age;
            display: inline-flex;
            align-items: center;
            flex: 0 0 auto;
            gap: 0.6rem;
            align-self: center;
            white-space: nowrap;
        }

        .age-era-input-group {
            display: inline-flex;
            align-items: center;
            gap: 0.45rem;
        }

        .age-era-input {
            width: 8ch;
            min-width: 8ch;
            max-width: 8ch;
            padding-right: 0.5rem;
            text-align: right;
        }

        .age-era-input::placeholder {
            color: #bbb;
        }

        .age-era-input:focus {
            outline: none;
        }

        .age-era-suffix {
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.85rem;
            color: var(--dark);
            white-space: nowrap;
        }

        .age-era-alignment-control {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            font-size: 0.8rem;
            margin-bottom: 0;
            white-space: nowrap;
        }

        .age-era-alignment-control select {
            padding: 0.35rem 0.5rem;
            font-size: 0.8rem;
        }

        .clip-length-static,
        .prompt-static {
            display: inline-flex;
            align-items: center;
            min-height: 38px;
        }

        .caption-selects {
            grid-area: selects;
            display: flex;
            gap: 0.5rem;
            align-items: center;
            align-self: center;
        }

        @media (max-width: 1280px) {
            .caption-controls {
                grid-template-columns: 1fr;
                grid-template-areas:
                    "age"
                    "input"
                    "count"
                    "selects";
                align-items: stretch;
            }

            .caption-selects {
                justify-content: flex-start;
                flex-wrap: wrap;
            }
        }

        .caption-selects label {
            display: flex;
            align-items: center;
            gap: 0.35rem;
            font-size: 0.8rem;
            margin-bottom: 0;
        }

        .caption-selects select {
            min-height: var(--caption-control-height);
            padding: 0.35rem 0.5rem;
            font-size: 0.8rem;
        }

        .caption-font-picker {
            position: relative;
            min-width: 240px;
            z-index: 1;
        }

        .caption-font-picker[open] {
            z-index: 50;
        }

        .caption-font-picker summary {
            list-style: none;
        }

        .caption-font-picker summary::-webkit-details-marker {
            display: none;
        }

        .caption-font-summary {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.9rem;
            min-height: var(--caption-control-height);
            min-width: 240px;
            padding: 0.48rem 0.65rem;
            border: 2px solid var(--border);
            border-radius: 10px;
            background: var(--white);
            cursor: pointer;
            user-select: none;
        }

        .caption-font-picker[open] .caption-font-summary {
            border-color: var(--sage);
            box-shadow: 0 0 0 4px rgba(201, 168, 76, 0.12);
        }

        .caption-font-summary-name,
        .caption-font-option-name {
            font-size: 0.8rem;
            color: var(--text);
            white-space: nowrap;
        }

        .caption-font-summary-sample,
        .caption-font-option-sample {
            font-size: 1.15rem;
            color: #111;
            line-height: 1;
            white-space: nowrap;
        }

        .caption-font-menu {
            position: absolute;
            top: calc(100% + 0.35rem);
            left: 0;
            z-index: 20;
            min-width: 100%;
            padding: 0.35rem;
            border: 1px solid var(--border);
            border-radius: 14px;
            background: rgba(255, 255, 255, 0.98);
            box-shadow: 0 18px 34px rgba(44, 62, 80, 0.12);
            backdrop-filter: blur(10px);
        }

        .caption-font-option {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            padding: 0.55rem 0.7rem;
            border: none;
            border-radius: 10px;
            background: transparent;
            text-align: left;
            cursor: pointer;
        }

        .caption-font-option:hover,
        .caption-font-option.selected {
            background: rgba(201, 168, 76, 0.12);
        }

        .media-delete-btn {
            position: absolute;
            top: 0.75rem;
            right: 0.75rem;
            border: 2px solid var(--border);
            background: var(--white);
            color: var(--slate);
            border-radius: 8px;
            padding: 0.35rem 0.5rem;
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.75rem;
            font-weight: 600;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            transition: all 0.2s;
        }

        .media-delete-btn:hover {
            border-color: #E74C3C;
            color: #E74C3C;
        }

        .section-label {
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.75rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: var(--slate);
            margin-bottom: 1rem;
            display: flex;
            align-items: baseline;
            gap: 0.5rem;
        }

        .section-label.with-actions {
            justify-content: space-between;
            flex-wrap: wrap;
            align-items: flex-start;
            row-gap: 0.4rem;
        }

        .section-label-stack {
            display: inline-flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 0.15rem;
            min-width: 0;
            flex: 1 1 200px;
        }

        .section-label-stack > span:first-child {
            display: inline-flex;
            align-items: baseline;
            gap: 0.5rem;
        }

        .section-label .section-label-main {
            display: inline-flex;
            align-items: baseline;
            gap: 0.5rem;
            flex-shrink: 0;
            white-space: nowrap;
        }

        .section-label .section-hint {
            font-size: 0.50rem;
            font-weight: 400;
            text-transform: none;
            letter-spacing: normal;
            color: var(--slate);
            margin-left: 0.25rem;
            line-height: 1.4;
            white-space: pre-line;
        }

        .section-label .section-hint--ai {
            margin-left: 0;
            max-width: 100%;
            white-space: normal;
        }

        .form-inline-label {
            display: inline-flex;
            align-items: center;
            gap: 0.25rem;
            flex-wrap: nowrap;
        }

        .form-inline-label-main {
            flex: 0 0 auto;
        }

.form-inline-label-hint {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--dark);
    line-height: 1.2;
    white-space: nowrap;
}

.intro-furigana-label {
    flex-wrap: wrap;
}

.form-inline-label-error {
    font-size: 0.7rem;
    font-weight: 600;
    color: #e53e3e;
    line-height: 1.2;
}

.intro-furigana-input--invalid {
    border-color: #e53e3e !important;
    box-shadow: 0 0 0 1px rgba(229, 62, 62, 0.12);
}

/* Photo Upload Section */
.photo-upload-area {
            border: 2px dashed var(--border);
            border-radius: 8px;
            padding: 2rem;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
            background: var(--cream);
            min-height: 200px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .photo-upload-area:hover {
            border-color: var(--sage);
            background: var(--white);
        }

        .photo-upload-area.dragging {
            border-color: var(--sage);
            background: var(--white);
            box-shadow: 0 0 0 3px rgba(132, 181, 159, 0.2);
        }

        .photo-upload-area.is-disabled {
            cursor: not-allowed;
            opacity: 0.68;
            border-color: var(--border);
            background: #f4f1ea;
        }

        .photo-upload-area.is-disabled:hover {
            border-color: var(--border);
            background: #f4f1ea;
        }

        .photo-preview {
            width: 100%;
            height: 200px;
            background: linear-gradient(135deg, #E8F4F8, #D4E8E4);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 4rem;
            position: relative;
        }

        .photo-preview img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 8px;
        }

        .photo-thumb {
            width: 100%;
            height: 200px;
            object-fit: contain;
            border-radius: 8px;
        }

        .photo-name {
            margin-top: 0.5rem;
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.85rem;
            color: var(--slate);
        }

        /* Prompt Section */
        .prompt-textarea {
            width: 100%;
            min-height: 150px;
            padding: 1rem;
            border: 2px solid var(--border);
            border-radius: 8px;
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.9rem;
            line-height: 1.6;
            resize: vertical;
            background: var(--cream);
            transition: all 0.2s;
        }

        .prompt-textarea:disabled,
        .prompt-textarea.is-disabled {
            background: #ebe4d6;
            color: rgba(44, 62, 80, 0.62);
            border-color: rgba(180, 140, 50, 0.2);
            cursor: not-allowed;
            opacity: 0.92;
        }

        .ai-help-btn {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 1rem;
            background: linear-gradient(135deg, var(--sage), var(--eucalyptus));
            color: var(--white);
            border: none;
            border-radius: 6px;
            font-family: 'Helvetica Neue', sans-serif;
            font-weight: 600;
            font-size: 0.85rem;
            cursor: pointer;
            transition: all 0.2s;
            margin-top: 0.75rem;
        }

        .ai-help-btn:disabled,
        .ai-help-btn.is-loading {
            background: linear-gradient(135deg, rgba(123, 109, 84, 0.7), rgba(123, 109, 84, 0.58));
            color: rgba(255, 255, 255, 0.92);
            cursor: not-allowed;
            opacity: 0.82;
            box-shadow: none;
        }

        .ai-help-btn:disabled:hover,
        .ai-help-btn.is-loading:hover {
            transform: none;
        }

        .ai-help-actions {
            display: inline-flex;
            align-items: center;
            gap: 0.6rem;
            flex-wrap: wrap;
            justify-content: flex-end;
            flex: 0 1 auto;
            margin-left: auto;
        }

        .ai-help-note {
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.75rem;
            color: var(--slate);
            white-space: nowrap;
            display: inline-block;
        }

        .ai-help-note.hidden {
            display: inline-block !important;
            visibility: hidden;
        }

        @media (max-width: 1200px) {
            .section-label.with-actions {
                align-items: flex-start;
            }

            .section-label-stack {
                flex-basis: 100%;
            }

            .ai-help-actions {
                width: 100%;
                margin-left: 0;
                justify-content: flex-start;
            }
        }

        .prompt-controls .ai-help-btn {
            margin-top: 0;
        }

        .section-label .ai-help-btn {
            margin-top: 0;
        }

        .prompt-controls {
            display: flex;
            flex-wrap: wrap;
            gap: 0.75rem;
            margin-top: 0.75rem;
            align-items: center;
            justify-content: space-between;
        }

        .prompt-selects {
            display: inline-flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            align-items: center;
        }

        .prompt-selects select {
            padding: 0.4rem 0.6rem;
            border: 2px solid var(--border);
            border-radius: 6px;
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.85rem;
            background: var(--white);
            color: var(--dark);
        }

        .prompt-wrapper {
            position: relative;
        }

        .outro-greeting-text {
            width: 100%;
            min-height: 19rem;
            line-height: 1.65;
        }

        .outro-editor-grid {
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(240px, 0.92fr);
            column-gap: 1.5rem;
            row-gap: 0.85rem;
            align-items: start;
        }

        .outro-grid-preview { grid-column: 1; grid-row: 1; }
        .outro-grid-wallpaper { grid-column: 2; grid-row: 1; }
        .outro-grid-template { grid-column: 1; grid-row: 2; }
        .outro-grid-message { grid-column: 1; grid-row: 3; }
        .outro-grid-signoff { grid-column: 2; grid-row: 3; }

        .outro-message-group {
            display: flex;
            flex-direction: column;
            align-items: stretch;
            width: 100%;
            max-width: none;
        }

        .outro-template-group {
            width: 100%;
            max-width: none;
            margin-bottom: 0;
        }

        .outro-template-select--compact {
            width: 50%;
        }

        .outro-wallpaper-column {
            width: 100%;
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }

        .outro-signoff-group {
            display: flex;
            flex-direction: column;
            align-items: stretch;
            margin-bottom: 0;
            width: 100%;
        }

        .outro-signoff-select {
            width: 100%;
        }

        .outro-wallpaper-panel {
            width: 100%;
        }

        .outro-grid-preview {
            align-self: stretch;
        }

        .outro-preview-slot {
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            height: 100%;
            margin-bottom: 0;
        }

        .outro-preview-slot label {
            margin-bottom: 0.5rem;
        }

        .outro-preview-slot > label {
            margin-top: auto;
        }

        .outro-template-select {
            width: 100%;
            margin-bottom: 0.6rem;
        }

        .outro-greeting-count {
            width: 100%;
            text-align: right;
            font-size: 0.75rem;
            color: var(--text-secondary);
            margin-top: 4px;
        }

        @media (max-width: 900px) {
            .outro-editor-grid {
                grid-template-columns: 1fr;
            }

            .outro-template-select--compact {
                width: 100%;
            }

            .outro-grid-preview,
            .outro-grid-wallpaper,
            .outro-grid-template,
            .outro-grid-message,
            .outro-grid-signoff {
                grid-column: 1;
                grid-row: auto;
            }

            .outro-voice-controls {
                grid-template-columns: 1fr;
            }
        }

        .ai-hint-status {
            position: absolute;
            inset: 0;
            display: none;
            align-items: center;
            justify-content: center;
            pointer-events: none;
        }

        .ai-hint-status.active {
            display: flex;
        }

        .spinner-grow {
            display: inline-block;
            width: 2rem;
            height: 2rem;
            border-radius: 50%;
            background-color: var(--sage);
            animation: spinner-grow 0.8s ease-in-out infinite;
        }

        .visually-hidden {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            border: 0;
        }

        .intro-preview-slot {
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            height: 100%;
            margin-bottom: 0;
        }

        .intro-preview-slot label {
            margin-bottom: 0.5rem;
        }

        .intro-age-actions {
            margin-top: 0.75rem;
            display: flex;
            flex-direction: column;
            gap: 0.875rem;
        }

        .intro-voice-controls {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 0.85rem;
            margin-bottom: 1rem;
        }

        .intro-voice-controls .form-group {
            margin-bottom: 0;
        }

        .intro-preview-actions {
            margin-top: auto;
        }

        .intro-preview-actions--top {
            margin-top: auto;
        }

        .intro-duration-group {
            margin-bottom: 0;
        }

        .intro-preview-slot .intro-duration-group {
            margin-bottom: 0.85rem;
        }

        .outro-preview-actions {
            margin-top: 1rem;
        }

        .outro-preview-actions--top {
            margin-top: 0;
        }

        .outro-voice-controls {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 0.85rem;
            margin-bottom: 1rem;
        }

        .outro-voice-controls .form-group {
            margin-bottom: 0;
        }

        .outro-voice-actor-slot {
            margin-top: 0;
            margin-bottom: 0;
        }

        .outro-voice-actor-control {
            position: relative;
        }

        .outro-voice-native-select {
            display: none;
        }

        .outro-voice-dropdown {
            position: relative;
            width: 100%;
        }

        .outro-voice-dropdown-trigger {
            width: 100%;
            min-height: 54px;
            padding: 0.875rem 1rem;
            border: 2px solid var(--border);
            border-radius: 8px;
            background: var(--white);
            color: var(--dark);
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.95rem;
            text-align: left;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            cursor: pointer;
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }

        .outro-voice-dropdown.is-open .outro-voice-dropdown-trigger,
        .outro-voice-dropdown-trigger:focus-visible {
            outline: none;
            border-color: var(--sage);
            box-shadow: 0 0 0 4px rgba(201, 168, 76, 0.12);
        }

        .outro-voice-dropdown-label {
            display: inline-flex;
            align-items: center;
            gap: 0.45rem;
            flex: 1 1 auto;
            min-width: 0;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        .outro-voice-dropdown-icon {
            color: #111;
            font-size: 1.25rem;
        }

        .outro-voice-dropdown-trigger-chevron {
            font-size: 0.9rem;
            color: #666;
            transition: transform 0.2s ease;
        }

        .outro-voice-dropdown.is-open .outro-voice-dropdown-trigger-chevron {
            transform: rotate(180deg);
        }

        .outro-voice-dropdown-menu {
            position: absolute;
            top: calc(100% + 0.4rem);
            left: 0;
            right: 0;
            z-index: 30;
            display: none;
            padding: 0.35rem;
            border: 1px solid var(--border);
            border-radius: 12px;
            background: rgba(255, 255, 255, 0.98);
            box-shadow: 0 18px 34px rgba(44, 62, 80, 0.12);
            backdrop-filter: blur(10px);
        }

        .outro-voice-dropdown.is-open .outro-voice-dropdown-menu {
            display: block;
        }

        .outro-voice-dropdown-option {
            width: 100%;
            padding: 0.7rem 0.85rem;
            border: none;
            border-radius: 10px;
            background: transparent;
            color: var(--dark);
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.92rem;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 0.65rem;
            cursor: pointer;
        }

        .outro-voice-dropdown-option:hover,
        .outro-voice-dropdown-option.is-selected {
            background: rgba(201, 168, 76, 0.12);
        }

        .outro-voice-dropdown-option-icon {
            color: #111;
            flex: 0 0 auto;
            font-size: 1.3rem;
        }

        @media (max-width: 900px) {
            .intro-voice-controls {
                grid-template-columns: 1fr;
            }

            .outro-voice-dropdown-trigger {
                min-height: 50px;
                padding: 0.75rem 0.9rem;
            }
        }

        .intro-preview-btn,
        .outro-preview-btn,
        .export-final-btn {
            width: 100%;
            min-height: 2.9rem;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            position: relative;
            overflow: hidden;
        }

        .intro-preview-btn:disabled,
        .outro-preview-btn:disabled,
        .export-final-btn:disabled {
            cursor: default;
            opacity: 0.8;
        }

        .intro-preview-btn:disabled:hover,
        .outro-preview-btn:disabled:hover,
        .export-final-btn:disabled:hover {
            background: var(--white);
            color: var(--sage);
            transform: none;
        }

        .intro-preview-btn.is-loading,
        .outro-preview-btn.is-loading,
        .export-final-btn.is-loading {
            cursor: progress;
        }

        .intro-preview-btn.is-loading .intro-preview-btn-label,
        .outro-preview-btn.is-loading .outro-preview-btn-label,
        .export-final-btn.is-loading .export-final-btn-label {
            opacity: 0;
        }

        .intro-preview-btn-label,
        .outro-preview-btn-label,
        .export-final-btn-label {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            transition: opacity 0.2s ease;
        }

        .export-final-btn-label {
            position: relative;
            z-index: 1;
        }

        .intro-preview-btn-status,
        .outro-preview-btn-status,
        .export-final-btn-status {
            position: absolute;
            inset: 0;
            display: none;
            align-items: center;
            justify-content: center;
            pointer-events: none;
        }

        .intro-preview-btn-status.active,
        .outro-preview-btn-status.active,
        .export-final-btn-status.active {
            display: flex;
        }

        .export-final-btn-status {
            z-index: 2;
        }

        .intro-preview-btn .spinner-grow,
        .outro-preview-btn .spinner-grow {
            width: 1.2rem;
            height: 1.2rem;
            background-color: var(--sage);
        }

        .export-final-btn .spinner-grow {
            width: 1.2rem;
            height: 1.2rem;
            background-color: #fff;
        }

        .intro-preview-btn.is-loading:disabled:hover .spinner-grow,
        .outro-preview-btn.is-loading:disabled:hover .spinner-grow {
            background-color: var(--sage);
        }

        .export-final-btn.is-loading:disabled:hover .spinner-grow {
            background-color: var(--sage);
        }

        .intro-preview-modal-content,
        .outro-preview-modal-content {
            max-width: 980px;
            width: min(96vw, 980px);
            padding: 1rem 1rem 1.25rem;
        }

        .intro-preview-modal-header,
        .outro-preview-modal-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            margin-bottom: 0.75rem;
        }

        .intro-preview-modal-header .modal-header,
        .outro-preview-modal-header .modal-header {
            margin-bottom: 0;
        }

        .intro-preview-close {
            margin-left: auto;
        }

        .intro-preview-modal-body,
        .outro-preview-modal-body {
            border: 1px solid var(--border);
            border-radius: 12px;
            background: linear-gradient(135deg, #F8F3EA, #FBF9F3);
            overflow: hidden;
        }

        .intro-preview-image,
        .intro-preview-video,
        .outro-preview-video {
            display: block;
            width: 100%;
            height: auto;
        }

        .clip-length {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.8rem;
            color: var(--slate);
            margin-left: auto;
            line-height: 1;
        }

        .clip-length-input {
            width: 80px;
            padding: 0.4rem 0.6rem;
            border: 2px solid var(--border);
            border-radius: 6px;
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.85rem;
            background: var(--white);
        }

        .ai-help-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(132, 181, 159, 0.3);
        }

        .generate-video-btn {
            width: 100%;
            padding: 0.75rem;
            background: var(--dark);
            color: var(--white);
            border: none;
            border-radius: 6px;
            font-family: 'Helvetica Neue', sans-serif;
            font-weight: 600;
            cursor: pointer;
            margin-top: 1rem;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
        }

        .generate-video-btn:hover {
            background: var(--slate);
        }

        .generate-video-btn:disabled,
        .generate-video-btn.is-disabled {
            background: #bcc4c6;
            color: rgba(255, 255, 255, 0.92);
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }

        .generate-video-btn:disabled:hover,
        .generate-video-btn.is-disabled:hover {
            background: #bcc4c6;
        }

        .generate-video-count {
            min-width: 3.2rem;
            padding: 0.18rem 0.55rem;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.18);
            font-size: 0.8rem;
            font-weight: 700;
            text-align: center;
            font-variant-numeric: tabular-nums;
            flex-shrink: 0;
        }

        .generate-video-label {
            display: inline-flex;
            flex-wrap: wrap;
            align-items: baseline;
            gap: 0.4rem;
            text-align: left;
            min-width: 0;
        }

        .generate-video-hint {
            font-size: 0.7rem;
            font-weight: 400;
            color: rgba(255, 255, 255, 0.75);
        }

        .floating-add-photo {
            position: fixed;
            right: auto;
            bottom: 1.5rem;
            z-index: 1100;
            padding: 0.75rem 1.3rem;
            background: linear-gradient(135deg, var(--sage), var(--eucalyptus));
            color: var(--white);
            border: none;
            border-radius: 999px;
            font-family: 'Helvetica Neue', sans-serif;
            font-weight: 600;
            font-size: 0.9rem;
            cursor: pointer;
            box-shadow: 0 12px 24px rgba(44, 62, 80, 0.22);
            opacity: 0;
            transform: translateY(16px);
            pointer-events: none;
            transition: opacity 0.2s ease, transform 0.2s ease;
        }

        .floating-add-photo.is-visible {
            opacity: 1;
            transform: translateY(0);
            pointer-events: auto;
        }

        .floating-add-photo:hover {
            transform: translateY(-2px);
            box-shadow: 0 16px 28px rgba(44, 62, 80, 0.28);
        }

        /* Video Section */
        .video-placeholder {
            width: 100%;
            height: 200px;
            background: var(--dark);
            border-radius: 8px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: var(--white);
            font-size: 3rem;
            cursor: pointer;
            transition: all 0.2s;
            position: relative;
        }

        .video-placeholder:hover {
            background: var(--slate);
            transform: scale(1.02);
        }

        .video-status {
            font-size: 0.9rem;
            margin-top: 0.5rem;
            font-family: 'Helvetica Neue', sans-serif;
        }

        .sora-badge {
            position: absolute;
            top: 0.75rem;
            right: 0.75rem;
            background: rgba(255, 255, 255, 0.9);
            color: var(--dark);
            padding: 0.25rem 0.75rem;
            border-radius: 12px;
            font-size: 0.7rem;
            font-family: 'Helvetica Neue', sans-serif;
            font-weight: 700;
        }

        .video-actions {
            display: flex;
            gap: 0.5rem;
            margin-top: 1rem;
        }

        .video-action-btn {
            flex: 1;
            padding: 0.5rem;
            border: 2px solid var(--border);
            background: var(--white);
            border-radius: 6px;
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.8rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }

        .video-action-btn:hover {
            border-color: var(--sage);
            color: var(--sage);
        }

        .flatpickr-calendar,
        .flatpickr-months,
        .flatpickr-current-month,
        .flatpickr-weekdays,
        .flatpickr-weekday,
        .flatpickr-days,
        .flatpickr-day,
        .flatpickr-time,
        .numInputWrapper,
        .flatpickr-current-month input.cur-year {
            font-family: 'Helvetica Neue', 'Noto Sans JP', sans-serif;
            font-variant-numeric: lining-nums tabular-nums;
            font-feature-settings: "lnum" 1, "tnum" 1;
        }

        .video-list {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
            gap: 0.75rem;
            align-items: start;
        }

        .video-item {
            display: flex;
            flex-direction: column;
            gap: 0.55rem;
            align-items: center;
            padding: 0.75rem;
            border: 2px solid var(--border);
            border-radius: 12px;
            background: var(--cream);
        }

        .video-thumb-wrap {
            position: relative;
            width: 100%;
        }

        .video-thumb-button {
            position: relative;
            width: 100%;
            aspect-ratio: 1 / 1;
            padding: 0;
            border: 2px solid rgba(44, 62, 80, 0.18);
            border-radius: 10px;
            overflow: hidden;
            background: #f1ede4;
        }

        .video-thumb-button img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .video-thumb-fallback {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: rgba(44, 62, 80, 0.45);
            font-size: 2rem;
            background: linear-gradient(135deg, #f4efe5, #ece2d3);
        }

        .video-thumb-play {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            width: 42px;
            height: 42px;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.88);
            color: var(--dark);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2rem;
            box-shadow: 0 6px 18px rgba(44, 62, 80, 0.18);
            border: none;
            cursor: pointer;
            transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
        }

        .video-thumb-play:hover {
            transform: translate(-50%, -50%) scale(1.04);
            box-shadow: 0 10px 22px rgba(44, 62, 80, 0.2);
            background: rgba(255, 255, 255, 0.96);
        }

        .video-output-wrap {
            position: relative;
        }

        .video-loading-overlay {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(248, 245, 240, 0.84);
            backdrop-filter: blur(16px);
            -webkit-backdrop-filter: blur(16px);
            border-radius: 12px;
            z-index: 2;
        }

        .video-loading-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.75rem;
            font-family: 'Helvetica Neue', sans-serif;
            color: var(--slate);
        }

        .video-item.selected {
            border-color: var(--sage);
            background: rgba(132, 181, 159, 0.12);
        }

        .video-item.selected .video-thumb-button {
            border-color: var(--sage);
            box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.16);
        }

        .video-select {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-height: 20px;
        }

        .video-select input {
            margin: 0;
            width: 16px;
            height: 16px;
            accent-color: var(--sage);
            cursor: pointer;
        }

        .video-label {
            font-family: 'Helvetica Neue', sans-serif;
            font-weight: 600;
            color: var(--dark);
            text-align: center;
            font-size: 0.82rem;
        }

        .video-empty {
            text-align: center;
            padding: 2rem;
            color: var(--slate);
            font-family: 'Helvetica Neue', sans-serif;
        }

        .timeline-wrap {
            margin: 1rem 0 1.5rem;
            padding: 1rem;
            border: 2px solid var(--border);
            border-radius: 12px;
            background: var(--cream);
        }

        .timeline-header {
            display: flex;
            justify-content: space-between;
            align-items: baseline;
            gap: 1rem;
            margin-bottom: 0.75rem;
            font-family: 'Helvetica Neue', sans-serif;
        }

        .timeline-total {
            font-weight: 700;
            color: var(--dark);
        }

        .timeline-progress {
            display: flex;
            height: 12px;
            border-radius: 999px;
            overflow: hidden;
            background: rgba(0, 0, 0, 0.08);
            align-items: stretch;
        }

        .timeline-segment {
            height: 100%;
            background: linear-gradient(135deg, var(--sage), var(--eucalyptus));
            border-right: 2px solid var(--white);
        }

        .timeline-segment-fixed {
            flex: 0 0 20px;
        }

        .timeline-segment-intro,
        .timeline-segment-outro {
            opacity: 0.75;
        }

        .timeline-segment:last-child {
            border-right: none;
        }

        /* Export Section */
        .export-section {
            background: var(--cream);
            padding: 2rem;
            border-radius: 12px;
            margin-top: 2rem;
        }

        .music-controls {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            flex-wrap: nowrap;
            justify-content: flex-start;
        }

        .music-select-wrap {
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            flex: 0 0 auto;
            white-space: nowrap;
            margin-bottom: 0;
        }

        .music-select {
            width: 312px;
            min-width: 312px;
            padding: 0.45rem 0.6rem;
            border: 1px solid var(--border);
            border-radius: 6px;
            background: var(--surface);
            color: var(--text);
            font-size: 0.9rem;
            vertical-align: middle;
        }

        @media (max-width: 768px) {
            .music-controls {
                flex-wrap: wrap;
            }

            .music-select {
                width: min(312px, calc(100vw - 8rem));
                min-width: 0;
            }
        }

        .thumbnail-grid {
            display: flex;
            gap: 1rem;
            flex-wrap: wrap;
            margin: 1.5rem 0;
            padding: 1.5rem;
            background: var(--white);
            border-radius: 8px;
            min-height: 150px;
        }

        .video-thumbnail {
            width: 120px;
            height: 90px;
            background: var(--dark);
            border-radius: 8px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: var(--white);
            cursor: move;
            position: relative;
            transition: all 0.2s;
            overflow: hidden;
        }

        .video-thumbnail:hover {
            transform: scale(1.05);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        }

        .video-thumbnail.dragging {
            opacity: 0.5;
        }

        .thumbnail-number {
            font-size: 0.75rem;
            font-family: 'Helvetica Neue', sans-serif;
            position: absolute;
            bottom: 4px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.6);
            padding: 1px 6px;
            border-radius: 4px;
            text-align: center;
            white-space: nowrap;
        }

        .export-format {
            display: flex;
            gap: 1rem;
            margin-top: 1rem;
        }

        .format-option {
            flex: 1;
            padding: 1rem;
            border: 2px solid var(--border);
            background: var(--white);
            border-radius: 8px;
            text-align: center;
            cursor: pointer;
            font-family: 'Helvetica Neue', sans-serif;
            transition: all 0.2s;
        }

        .format-option:hover,
        .format-option.selected {
            border-color: var(--sage);
            background: linear-gradient(135deg, #F0F9F6, #E8F4F8);
        }

        .export-history-row {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.6rem 0.75rem;
            background: var(--white);
            border-radius: 6px;
            margin-bottom: 0.5rem;
            font-family: 'Helvetica Neue', sans-serif;
            font-size: 0.85rem;
        }

        .export-history-row .export-date {
            color: var(--slate);
            flex: 1;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .export-history-row .export-format-badge {
            background: var(--sage);
            color: var(--white);
            padding: 0.15rem 0.5rem;
            border-radius: 4px;
            font-size: 0.75rem;
            font-weight: 600;
            text-transform: uppercase;
        }

        .export-history-row button {
            background: none;
            border: none;
            cursor: pointer;
            color: var(--slate);
            font-size: 1rem;
            padding: 0.2rem 0.4rem;
            border-radius: 4px;
            transition: background 0.15s;
        }

        .export-history-row button:hover {
            background: rgba(0, 0, 0, 0.06);
            color: var(--dark);
        }

.char-count {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted, #999);
    margin-top: 0.25rem;
}
.char-count--full {
    color: #e53e3e;
    font-weight: 600;
}

.intro-character-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.intro-character-combobox {
    position: relative;
}

.intro-character-combobox input {
    padding-right: 2.4rem;
}

.intro-character-trigger {
    position: absolute;
    right: 0.45rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--slate);
    cursor: pointer;
    padding: 0.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.intro-character-menu {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    max-height: 220px;
    overflow-y: auto;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 12px 26px rgba(44, 62, 80, 0.12);
    z-index: 20;
}

.intro-character-menu.is-open {
    display: flex;
}

#introCharacter1Menu,
#introCharacter2Menu,
#introCharacter3Menu {
    max-height: 420px;
}

#introHobby1Menu,
#introHobby2Menu,
#introHobby3Menu {
    max-height: 420px;
}

.intro-character-option {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    font-family: 'Helvetica Neue', sans-serif;
    font-size: 0.88rem;
    color: var(--text);
    cursor: pointer;
}

.intro-character-option:hover {
    background: rgba(201, 168, 76, 0.12);
}

.intro-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.intro-layout-top,
.intro-layout-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    align-items: start;
}

.intro-layout-top {
    align-items: stretch;
}

@media (max-width: 900px) {
    .intro-layout-top,
    .intro-layout-fields,
    .intro-character-grid {
        grid-template-columns: 1fr;
    }
}

.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.wallpaper-option {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    aspect-ratio: 16/9;
    background: var(--border, #eee);
    transition: border-color 0.15s;
}
.wallpaper-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.wallpaper-option:hover {
    border-color: var(--primary, #888);
}
.wallpaper-option--selected {
    border-color: var(--primary, #4a90d9);
    box-shadow: 0 0 0 2px var(--primary, #4a90d9);
}

/* Video Overlay */
.video-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.video-overlay.active {
    display: flex;
}

.video-player {
    max-width: 90%;
    max-height: 90%;
    background: var(--dark);
    border-radius: 12px;
    padding: 2rem;
    position: relative;
}

.close-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 0.85rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    pointer-events: auto;
    touch-action: manipulation;
    z-index: 10;
}

.close-overlay span {
    pointer-events: none;
}

.video-display {
    width: 800px;
    height: 450px;
    background: #000;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 4rem;
}
